summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2012-10-21 03:03:38 +0200
committerBerke Viktor <bviktor@hexchat.org>2012-10-21 03:03:38 +0200
commit0c04cfed7f8c4bfe8839374171236e684a9df437 (patch)
treec85f26f84e0c75552e302eadffc35abaa9140f5f /src/fe-gtk
parentef18ded8279cc484194cac897cea5ab634ead07a (diff)
Make modifier buttons truly abstract
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/fkeys.c11
-rw-r--r--src/fe-gtk/fkeys.h5
-rw-r--r--src/fe-gtk/maingui.c2
-rw-r--r--src/fe-gtk/menu.c14
-rw-r--r--src/fe-gtk/servlistgui.c5
-rw-r--r--src/fe-gtk/userlistgui.c3
-rw-r--r--src/fe-gtk/xtext.c5
7 files changed, 22 insertions, 23 deletions
diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c
index dcab0946..bca87dd3 100644
--- a/src/fe-gtk/fkeys.c
+++ b/src/fe-gtk/fkeys.c
@@ -87,10 +87,6 @@ void key_action_tab_clean (void);
 
 /* Remember that the *number* of actions is this *plus* 1 --AGL */
 #define KEY_MAX_ACTIONS 14
-/* These are cp'ed from history.c --AGL */
-#define STATE_SHIFT     GDK_SHIFT_MASK
-#define	STATE_ALT	GDK_MOD1_MASK
-#define STATE_CTRL	GDK_CONTROL_MASK
 
 struct key_binding
 {
@@ -325,7 +321,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
 	/* gtktextview has no 'activate' event, so we trap ENTER here */
 	case GDK_Return:
 	case GDK_KP_Enter:
-		if (!(evt->state & GDK_CONTROL_MASK))
+		if (!(evt->state & STATE_CTRL))
 		{
 			g_signal_stop_emission_by_name (G_OBJECT (wid), "key_press_event");
 			mg_inputbox_cb (wid, sess->gui);
@@ -1738,11 +1734,6 @@ key_action_put_history (GtkWidget * wid, GdkEventKey * ent, char *d1,
 
 /* -------- */
 
-
-#define STATE_SHIFT	GDK_SHIFT_MASK
-#define STATE_ALT		GDK_MOD1_MASK
-#define STATE_CTRL	GDK_CONTROL_MASK
-
 static void
 replace_handle (GtkWidget *t)
 {
diff --git a/src/fe-gtk/fkeys.h b/src/fe-gtk/fkeys.h
index 20cd4c73..70bf100f 100644
--- a/src/fe-gtk/fkeys.h
+++ b/src/fe-gtk/fkeys.h
@@ -1,3 +1,8 @@
+/* These are cp'ed from history.c --AGL */
+#define STATE_SHIFT		GDK_SHIFT_MASK
+#define	STATE_ALT		GDK_MOD1_MASK
+#define STATE_CTRL		GDK_CONTROL_MASK
+
 void key_init (void);
 void key_dialog_show (void);
 int key_handle_key_press (GtkWidget * wid, GdkEventKey * evt, session *sess);
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index 3dbac7af..68795b9b 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -1652,7 +1652,7 @@ static gboolean
 mg_tab_contextmenu_cb (chanview *cv, chan *ch, int tag, gpointer ud, GdkEventButton *event)
 {
 	/* shift-click to close a tab */
-	if ((event->state & GDK_SHIFT_MASK) && event->type == GDK_BUTTON_PRESS)
+	if ((event->state & STATE_SHIFT) && event->type == GDK_BUTTON_PRESS)
 	{
 		mg_xbutton_cb (cv, ch, tag, ud);
 		return FALSE;
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index 243b8192..fcbc810f 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -2097,8 +2097,8 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
 	GtkWidget *menu_bar;
 	GtkWidget *usermenu = 0;
 	GtkWidget *submenu = 0;
-	int close_mask = GDK_CONTROL_MASK;
-	int away_mask = GDK_MOD1_MASK;
+	int close_mask = STATE_CTRL;
+	int away_mask = STATE_ALT;
 	char *key_theme = NULL;
 	GtkSettings *settings;
 	GSList *group = NULL;
@@ -2162,7 +2162,7 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
 		{
 			if (!g_ascii_strcasecmp (key_theme, "Emacs"))
 			{
-				close_mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK;
+				close_mask = STATE_SHIFT | STATE_CTRL;
 				mymenu[SEARCH_OFFSET].key = 0;
 			}
 			g_free (key_theme);
@@ -2174,7 +2174,7 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
 		char *help = _("_Help");
 		char *under = strchr (help, '_');
 		if (under && (under[1] == 'a' || under[1] == 'A'))
-			away_mask = GDK_MOD1_MASK | GDK_CONTROL_MASK;
+			away_mask = STATE_ALT | STATE_CTRL;
 	}
 
 	if (!toplevel)
@@ -2229,8 +2229,8 @@ normalitem:
 										mymenu[i].key == GDK_F1 ? 0 :
 										mymenu[i].key == GDK_w ? close_mask :
 										(g_ascii_isupper (mymenu[i].key)) ?
-											GDK_SHIFT_MASK | GDK_CONTROL_MASK :
-											GDK_CONTROL_MASK,
+											STATE_SHIFT | STATE_CTRL :
+											STATE_CTRL,
 										GTK_ACCEL_VISIBLE);
 			if (mymenu[i].callback)
 				g_signal_connect (G_OBJECT (item), "activate",
@@ -2252,7 +2252,7 @@ togitem:
 			if (mymenu[i].key != 0)
 				gtk_widget_add_accelerator (item, "activate", accel_group,
 									mymenu[i].key, mymenu[i].id == MENU_ID_AWAY ?
-									away_mask : GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+									away_mask : STATE_CTRL, GTK_ACCEL_VISIBLE);
 			if (mymenu[i].callback)
 				g_signal_connect (G_OBJECT (item), "toggled",
 										G_CALLBACK (mymenu[i].callback), 0);
diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c
index 8de93e8d..aba42188 100644
--- a/src/fe-gtk/servlistgui.c
+++ b/src/fe-gtk/servlistgui.c
@@ -43,6 +43,7 @@
 #include "gtkutil.h"
 #include "menu.h"
 #include "pixmaps.h"
+#include "fkeys.h"
 
 
 /* servlistgui.c globals */
@@ -366,7 +367,7 @@ servlist_net_keypress_cb (GtkWidget *wid, GdkEventKey *evt, gpointer tree)
 	if (!selected_net)
 		return FALSE;
 
-	if (evt->state & GDK_SHIFT_MASK)
+	if (evt->state & STATE_SHIFT)
 	{
 		if (evt->keyval == GDK_Up)
 		{
@@ -387,7 +388,7 @@ servlist_serv_keypress_cb (GtkWidget *wid, GdkEventKey *evt, gpointer userdata)
 	if (!selected_net || !selected_serv)
 		return FALSE;
 
-	if (evt->state & GDK_SHIFT_MASK)
+	if (evt->state & STATE_SHIFT)
 	{
 		if (evt->keyval == GDK_Up)
 		{
diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c
index 5edee739..63e71c5a 100644
--- a/src/fe-gtk/userlistgui.c
+++ b/src/fe-gtk/userlistgui.c
@@ -47,6 +47,7 @@
 #include "menu.h"
 #include "pixmaps.h"
 #include "userlistgui.h"
+#include "fkeys.h"
 
 #ifdef USE_GTKSPELL
 #include <gtk/gtktextview.h>
@@ -518,7 +519,7 @@ userlist_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
 	if (!event)
 		return FALSE;
 
-	if (!(event->state & GDK_CONTROL_MASK) &&
+	if (!(event->state & STATE_CTRL) &&
 		event->type == GDK_2BUTTON_PRESS && prefs.doubleclickuser[0])
 	{
 		nicks = userlist_selection_list (widget, &i);
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index 23fb0dff..63abcaca 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -71,6 +71,7 @@
 #include "../common/xchatc.h"
 #include "fe-gtk.h"
 #include "xtext.h"
+#include "fkeys.h"
 
 #define charlen(str) g_utf8_skip[*(guchar *)(str)]
 
@@ -2005,7 +2006,7 @@ gtk_xtext_check_mark_stamp (GtkXText *xtext, GdkModifierType mask)
 {
 	gboolean redraw = FALSE;
 
-	if (mask & GDK_SHIFT_MASK || prefs.autocopy_stamp)
+	if (mask & STATE_SHIFT || prefs.autocopy_stamp)
 	{
 		if (!xtext->mark_stamp)
 		{
@@ -2255,7 +2256,7 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
 		if (xtext->buffer->last_ent_start)
 		{
 			xtext->color_paste = FALSE;
-			if (event->state & GDK_CONTROL_MASK || prefs.autocopy_color)
+			if (event->state & STATE_CTRL || prefs.autocopy_color)
 				xtext->color_paste = TRUE;
 			if (prefs.autocopy_text)
 			{