1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-12-23 08:08:54 -05:00

Merge pull request #455 from RichardHitt/escape

Let the ESC key close certain windows.  Closes #211
This commit is contained in:
TingPing 2013-03-17 16:16:46 -07:00
commit 20e3522177
10 changed files with 27 additions and 19 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)
{
@ -238,7 +229,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;

View File

@ -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)));