From 78b5f5625d130d53e74bf89492e20e75583e5ce9 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 31 Oct 2012 05:18:20 +0100 Subject: Make rawlog text copy behaviour consistent with the main text box And make it close upon pressing Escape --- src/fe-gtk/rawlog.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index 051dd54c..c2c18fe2 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "../common/hexchat.h" #include "../common/hexchatc.h" @@ -44,7 +45,7 @@ #include "maingui.h" #include "rawlog.h" #include "xtext.h" - +#include "fkeys.h" static void close_rawlog (GtkWidget *wid, server *serv) @@ -85,6 +86,28 @@ rawlog_savebutton (GtkWidget * wid, server *serv) return FALSE; } +static void +rawlog_key_cb (GtkWidget * wid, GdkEventKey * key, gpointer userdata) +{ + /* Copy rawlog selection to clipboard when Ctrl+Shift+C is pressed, + * but make sure not to copy twice, i.e. when auto-copy is enabled. + */ + if (!prefs.hex_text_autocopy_text && + (key->keyval == GDK_c || key->keyval == GDK_C) && + key->state & STATE_SHIFT && + key->state & STATE_CTRL) + { + 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); + } +} + void open_rawlog (struct server *serv) { @@ -132,6 +155,9 @@ open_rawlog (struct server *serv) gtkutil_button (hbox, GTK_STOCK_SAVE_AS, NULL, rawlog_savebutton, serv, _("Save As...")); + /* Copy selection to clipboard when Ctrl+Shift+C is pressed AND text auto-copy is disabled */ + g_signal_connect (G_OBJECT (serv->gui->rawlog_window), "key_press_event", G_CALLBACK (rawlog_key_cb), serv->gui->rawlog_textlist); + gtk_widget_show (serv->gui->rawlog_window); } -- cgit 1.4.1