summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
authorRichardHitt <rbh00@netcom.com>2013-03-17 15:11:23 -0700
committerRichardHitt <rbh00@netcom.com>2013-03-17 15:11:23 -0700
commitecdcc99280d29994791b8bc3273bf03a670d0b7b (patch)
tree947e2145e5cf149f0ccfc4d86d77dd2f2b278943 /src/fe-gtk
parente8a78b9aa1398deb69d20d599be2a630f721cafa (diff)
ESC key will destroy the windows mentioned at issue 211.
This change implements generic routine gtkutil_destroy_on_esc ()
and adds invocations of it in the requisite window-handling places.
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/ascii.c2
-rw-r--r--src/fe-gtk/dccgui.c2
-rw-r--r--src/fe-gtk/gtkutil.c15
-rw-r--r--src/fe-gtk/gtkutil.h1
-rw-r--r--src/fe-gtk/ignoregui.c1
-rw-r--r--src/fe-gtk/notifygui.c1
-rw-r--r--src/fe-gtk/plugingui.c1
-rw-r--r--src/fe-gtk/rawlog.c11
-rw-r--r--src/fe-gtk/search.c12
-rw-r--r--src/fe-gtk/urlgrab.c1
10 files changed, 28 insertions, 19 deletions
diff --git a/src/fe-gtk/ascii.c b/src/fe-gtk/ascii.c
index 06621cd7..ab6ac0ee 100644
--- a/src/fe-gtk/ascii.c
+++ b/src/fe-gtk/ascii.c
@@ -90,7 +90,6 @@ static const unsigned char table[]=
 0xd1,0x89,0xd1,0x8a,0xd1,0x8b,0xd1,0x8c,0xd1,0x8d,0xd1,0x8e,0xd1,0x8f,0
 };
 
-
 static gboolean
 ascii_enter (GtkWidget * wid, GdkEventCrossing *event, GtkWidget *label)
 {
@@ -133,6 +132,7 @@ ascii_open (void)
 	win = mg_create_generic_tab ("charmap", _("Character Chart"), TRUE, TRUE,
 										  NULL, NULL, 0, 0, &vbox, NULL);
 	gtk_container_set_border_width (GTK_CONTAINER (win), 5);
+	gtkutil_destroy_on_esc (win);
 
 	label = gtk_label_new (NULL);
 
diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c
index 6cfcd8b7..ffb95218 100644
--- a/src/fe-gtk/dccgui.c
+++ b/src/fe-gtk/dccgui.c
@@ -745,6 +745,7 @@ fe_dcc_open_recv_win (int passive)
 	dccfwin.window = mg_create_generic_tab ("Transfers", _(DISPLAY_NAME": Uploads and Downloads"),
 														 FALSE, TRUE, close_dcc_file_window, NULL,
 														 win_width, win_height, &vbox, 0);
+	gtkutil_destroy_on_esc (dccfwin.window);
 	gtk_container_set_border_width (GTK_CONTAINER (dccfwin.window), 3);
 	gtk_box_set_spacing (GTK_BOX (vbox), 3);
 
@@ -989,6 +990,7 @@ fe_dcc_open_chat_win (int passive)
 	dcccwin.window =
 			  mg_create_generic_tab ("DCCChat", _(DISPLAY_NAME": DCC Chat List"),
 						FALSE, TRUE, dcc_chat_close_cb, NULL, 550, 180, &vbox, 0);
+	gtkutil_destroy_on_esc (dcccwin.window);
 	gtk_container_set_border_width (GTK_CONTAINER (dcccwin.window), 3);
 	gtk_box_set_spacing (GTK_BOX (vbox), 3);
 
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index d032cf48..3743b5e3 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -45,6 +45,7 @@
 #include <gtk/gtkcellrenderertoggle.h>
 #include <gtk/gtkversion.h>
 #include <gtk/gtkfilechooserdialog.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -338,6 +339,20 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 	gtk_widget_show (dialog);
 }
 
+static gboolean
+gtkutil_esc_destroy (GtkWidget * win, GdkEventKey * key, gpointer userdata)
+{
+	if (key->keyval == GDK_Escape)
+		gtk_widget_destroy (win);
+	return FALSE;
+}
+
+void
+gtkutil_destroy_on_esc (GtkWidget *win)
+{
+	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (gtkutil_esc_destroy), win);
+}
+
 void
 gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad)
 {
diff --git a/src/fe-gtk/gtkutil.h b/src/fe-gtk/gtkutil.h
index 65b5c079..ad0c36ba 100644
--- a/src/fe-gtk/gtkutil.h
+++ b/src/fe-gtk/gtkutil.h
@@ -12,6 +12,7 @@ typedef void (*filereqcallback) (void *, char *file);
 
 void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags);
 void gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad);
+void gtkutil_destroy_on_esc (GtkWidget *win);
 GtkWidget *gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
 				 void *userdata, char *labeltext);
 void gtkutil_label_new (char *text, GtkWidget * box);
diff --git a/src/fe-gtk/ignoregui.c b/src/fe-gtk/ignoregui.c
index dca4384b..6e8b4ff3 100644
--- a/src/fe-gtk/ignoregui.c
+++ b/src/fe-gtk/ignoregui.c
@@ -349,6 +349,7 @@ ignore_gui_open ()
 			  mg_create_generic_tab ("IgnoreList", _(DISPLAY_NAME": Ignore list"),
 											FALSE, TRUE, close_ignore_gui_callback,
 											NULL, 600, 256, &vbox, 0);
+	gtkutil_destroy_on_esc (ignorewin);
 
 	view = ignore_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (ignorewin), "view", view);
diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c
index 0559734c..4d144258 100644
--- a/src/fe-gtk/notifygui.c
+++ b/src/fe-gtk/notifygui.c
@@ -413,6 +413,7 @@ notify_opengui (void)
 	notify_window =
 		mg_create_generic_tab ("Notify", _(DISPLAY_NAME": Friends List"), FALSE, TRUE,
 		                       notify_closegui, NULL, 400, 250, &vbox, 0);
+	gtkutil_destroy_on_esc (notify_window);
 
 	view = notify_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (notify_window), "view", view);
diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c
index 293535cc..b2cb95d7 100644
--- a/src/fe-gtk/plugingui.c
+++ b/src/fe-gtk/plugingui.c
@@ -219,6 +219,7 @@ plugingui_open (void)
 	plugin_window = mg_create_generic_tab ("Addons", _(DISPLAY_NAME": Plugins and Scripts"),
 														 FALSE, TRUE, plugingui_close, NULL,
 														 500, 250, &vbox, 0);
+	gtkutil_destroy_on_esc (plugin_window);
 
 	view = plugingui_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (plugin_window), "view", view);
diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c
index 6764034f..651ca1ec 100644
--- a/src/fe-gtk/rawlog.c
+++ b/src/fe-gtk/rawlog.c
@@ -86,7 +86,7 @@ rawlog_savebutton (GtkWidget * wid, server *serv)
 	return FALSE;
 }
 
-static void
+static gboolean
 rawlog_key_cb (GtkWidget * wid, GdkEventKey * key, gpointer userdata)
 {
 	/* Copy rawlog selection to clipboard when Ctrl+Shift+C is pressed,
@@ -99,13 +99,7 @@ rawlog_key_cb (GtkWidget * wid, GdkEventKey * key, gpointer userdata)
 	{
 		gtk_xtext_copy_selection (userdata);
 	}
-	/* close_rawlog is given to mg_create_generic_tab as
-	 * close_callback, it should take care of the rest.
-	 */
-	else if (key->keyval == GDK_Escape)
-	{
-		gtk_widget_destroy (wid);
-	}
+	return FALSE;
 }
 
 void
@@ -124,6 +118,7 @@ open_rawlog (struct server *serv)
 	serv->gui->rawlog_window =
 		mg_create_generic_tab ("RawLog", tbuf, FALSE, TRUE, close_rawlog, serv,
 							 640, 320, &vbox, serv);
+	gtkutil_destroy_on_esc (serv->gui->rawlog_window);
 
 	hbox = gtk_hbox_new (FALSE, 2);
 	gtk_container_add (GTK_CONTAINER (vbox), hbox);
diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c
index 41a1a642..a8bcfbe2 100644
--- a/src/fe-gtk/search.c
+++ b/src/fe-gtk/search.c
@@ -32,7 +32,6 @@
 #include <gtk/gtkvseparator.h>
 #include <gtk/gtkradiobutton.h>
 #include <gtk/gtktogglebutton.h>
-#include <gdk/gdkkeysyms.h>
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -119,14 +118,6 @@ search_entry_cb (GtkWidget * entry, session * sess)
 	search_search (sess, gtk_entry_get_text (GTK_ENTRY (entry)));
 }
 
-static gboolean 
-search_key_cb (GtkWidget * window, GdkEventKey * key, gpointer userdata)
-{
-	if (key->keyval == GDK_Escape)
-		gtk_widget_destroy (window);
-	return FALSE;
-}
-
 static void
 search_caseign_cb (GtkToggleButton * but, session * sess)
 {
@@ -152,6 +143,7 @@ search_highlight_cb (GtkToggleButton * but, session * sess)
 	search_search (sess, NULL);
 }
 
+int RBHesc = 0;
 void
 search_open (session * sess)
 {
@@ -238,7 +230,7 @@ search_open (session * sess)
 	add_tip (wid, "Close this box, reset highlighted search items, and stop searching new lines.");
 
 	/* Add recognition of the ESC key to close the box */
-	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (search_key_cb), win);
+	gtkutil_destroy_on_esc (win);
 
 	/* That's all, folks */
 	searchwin = win;
diff --git a/src/fe-gtk/urlgrab.c b/src/fe-gtk/urlgrab.c
index b8a40a35..0e27efdc 100644
--- a/src/fe-gtk/urlgrab.c
+++ b/src/fe-gtk/urlgrab.c
@@ -198,6 +198,7 @@ url_opengui ()
 	urlgrabberwindow =
 		mg_create_generic_tab ("UrlGrabber", _(DISPLAY_NAME": URL Grabber"), FALSE,
 							 TRUE, url_closegui, NULL, 400, 256, &vbox, 0);
+	gtkutil_destroy_on_esc (urlgrabberwindow);
 	view = url_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (urlgrabberwindow), "model",
 	                   gtk_tree_view_get_model (GTK_TREE_VIEW (view)));