[gtkhtml] Use new GDK keysym names if available.



commit b956b89617a1a39c66edd736b81dcba1b31c5a1b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Sep 17 14:01:01 2010 -0400

    Use new GDK keysym names if available.
    
    In GTK+ 2.21.8, the keysym names were renamed from GDK_* to GDK_KEY_*.
    
    I've added backward-compatibility macros to gtk-compat.h, which can be
    dumped as soon as we require GTK+ >= 2.22.0.

 components/editor/gtkhtml-color-combo.c      |   13 ++-
 components/editor/gtkhtml-face-tool-button.c |   13 ++-
 gtkhtml/gtk-compat.h                         |  158 ++++++++++++++++++++++++++
 gtkhtml/gtkhtml-search.c                     |    9 +-
 gtkhtml/gtkhtml.c                            |   22 ++--
 gtkhtml/htmlengine.c                         |    4 +-
 gtkhtml/htmltextinput.c                      |    5 +-
 7 files changed, 200 insertions(+), 24 deletions(-)
---
diff --git a/components/editor/gtkhtml-color-combo.c b/components/editor/gtkhtml-color-combo.c
index 9c074b2..59d1ef3 100644
--- a/components/editor/gtkhtml-color-combo.c
+++ b/components/editor/gtkhtml-color-combo.c
@@ -28,6 +28,9 @@
 #include <gdk/gdkkeysyms.h>
 #include "gtkhtml-color-swatch.h"
 
+/* backward-compatibility cruft */
+#include "gtkhtml/gtk-compat.h"
+
 #define NUM_CUSTOM_COLORS	8
 
 #define GTKHTML_COLOR_COMBO_GET_PRIVATE(obj) \
@@ -815,20 +818,20 @@ color_combo_class_init (GtkhtmlColorComboClass *class)
 
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Down, GDK_MOD1_MASK, "popup", 0);
+		GDK_KEY_Down, GDK_MOD1_MASK, "popup", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_KP_Down, GDK_MOD1_MASK, "popup", 0);
+		GDK_KEY_KP_Down, GDK_MOD1_MASK, "popup", 0);
 
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Up, GDK_MOD1_MASK, "popdown", 0);
+		GDK_KEY_Up, GDK_MOD1_MASK, "popdown", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_KP_Up, GDK_MOD1_MASK, "popdown", 0);
+		GDK_KEY_KP_Up, GDK_MOD1_MASK, "popdown", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Escape, 0, "popdown", 0);
+		GDK_KEY_Escape, 0, "popdown", 0);
 }
 
 static void
diff --git a/components/editor/gtkhtml-face-tool-button.c b/components/editor/gtkhtml-face-tool-button.c
index bd2d2fe..e3eef0f 100644
--- a/components/editor/gtkhtml-face-tool-button.c
+++ b/components/editor/gtkhtml-face-tool-button.c
@@ -30,6 +30,9 @@
 
 #include "gtkhtml-face-chooser.h"
 
+/* backward-compatibility cruft */
+#include "gtkhtml/gtk-compat.h"
+
 #define GTKHTML_FACE_TOOL_BUTTON_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), GTKHTML_TYPE_FACE_TOOL_BUTTON, GtkhtmlFaceToolButtonPrivate))
@@ -486,20 +489,20 @@ face_tool_button_class_init (GtkhtmlFaceToolButtonClass *class)
 
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Down, GDK_MOD1_MASK, "popup", 0);
+		GDK_KEY_Down, GDK_MOD1_MASK, "popup", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_KP_Down, GDK_MOD1_MASK, "popup", 0);
+		GDK_KEY_KP_Down, GDK_MOD1_MASK, "popup", 0);
 
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Up, GDK_MOD1_MASK, "popdown", 0);
+		GDK_KEY_Up, GDK_MOD1_MASK, "popdown", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_KP_Up, GDK_MOD1_MASK, "popdown", 0);
+		GDK_KEY_KP_Up, GDK_MOD1_MASK, "popdown", 0);
 	gtk_binding_entry_add_signal (
 		gtk_binding_set_by_class (class),
-		GDK_Escape, 0, "popdown", 0);
+		GDK_KEY_Escape, 0, "popdown", 0);
 }
 
 static void
diff --git a/gtkhtml/gtk-compat.h b/gtkhtml/gtk-compat.h
index 264d273..0e46947 100644
--- a/gtkhtml/gtk-compat.h
+++ b/gtkhtml/gtk-compat.h
@@ -5,6 +5,164 @@
 
 /* Provide a GTK+ compatibility layer. */
 
+#if !GTK_CHECK_VERSION (2,21,8)
+
+#define GDK_KEY_3270_BackTab	GDK_3270_BackTab
+#define GDK_KEY_3270_Enter	GDK_3270_Enter
+#define GDK_KEY_BackSpace	GDK_BackSpace
+#define GDK_KEY_Caps_Lock	GDK_Caps_Lock
+#define GDK_KEY_Clear		GDK_Clear
+#define GDK_KEY_Delete		GDK_Delete
+#define GDK_KEY_Down		GDK_Down
+#define GDK_KEY_End		GDK_End
+#define GDK_KEY_Escape		GDK_Escape
+#define GDK_KEY_Home		GDK_Home
+#define GDK_KEY_ISO_Enter	GDK_ISO_Enter
+#define GDK_KEY_ISO_Left_Tab	GDK_ISO_Left_Tab
+#define GDK_KEY_ISO_Lock	GDK_ISO_Lock
+#define GDK_KEY_Insert		GDK_Insert
+#define GDK_KEY_Left		GDK_Left
+#define GDK_KEY_Page_Down	GDK_Page_Down
+#define GDK_KEY_Page_Up		GDK_Page_Up
+#define GDK_KEY_Return		GDK_Return
+#define GDK_KEY_Right		GDK_Right
+#define GDK_KEY_Scroll_Lock	GDK_Scroll_Lock
+#define GDK_KEY_Shift_Lock	GDK_Shift_Lock
+#define GDK_KEY_Sys_Req		GDK_Sys_Req
+#define GDK_KEY_Tab		GDK_Tab
+#define GDK_KEY_Up		GDK_Up
+#define GDK_KEY_VoidSymbol	GDK_VoidSymbol
+#define GDK_KEY_backslash	GDK_backslash
+#define GDK_KEY_bracketleft	GDK_bracketleft
+#define GDK_KEY_bracketright	GDK_bracketright
+#define GDK_KEY_comma		GDK_comma
+#define GDK_KEY_equal		GDK_equal
+#define GDK_KEY_exclam		GDK_exclam
+#define GDK_KEY_minus		GDK_minus
+#define GDK_KEY_period		GDK_period
+#define GDK_KEY_plus		GDK_plus
+#define GDK_KEY_space		GDK_space
+#define GDK_KEY_underscore	GDK_underscore
+
+#define GDK_KEY_KP_0		GDK_KP_0
+#define GDK_KEY_KP_1		GDK_KP_1
+#define GDK_KEY_KP_2		GDK_KP_2
+#define GDK_KEY_KP_3		GDK_KP_3
+#define GDK_KEY_KP_4		GDK_KP_4
+#define GDK_KEY_KP_5		GDK_KP_5
+#define GDK_KEY_KP_6		GDK_KP_6
+#define GDK_KEY_KP_7		GDK_KP_7
+#define GDK_KEY_KP_8		GDK_KP_8
+#define GDK_KEY_KP_9		GDK_KP_9
+#define GDK_KEY_KP_Add		GDK_KP_Add
+#define GDK_KEY_KP_Decimal	GDK_KP_Decimal
+#define GDK_KEY_KP_Delete	GDK_KP_Delete
+#define GDK_KEY_KP_Divide	GDK_KP_Divide
+#define GDK_KEY_KP_Down		GDK_KP_Down
+#define GDK_KEY_KP_End		GDK_KP_End
+#define GDK_KEY_KP_Enter	GDK_KP_Enter
+#define GDK_KEY_KP_Equal	GDK_KP_Equal
+#define GDK_KEY_KP_Home		GDK_KP_Home
+#define GDK_KEY_KP_Insert	GDK_KP_Insert
+#define GDK_KEY_KP_Left		GDK_KP_Left
+#define GDK_KEY_KP_Multiply	GDK_KP_Multiply
+#define GDK_KEY_KP_Page_Down	GDK_KP_Page_Down
+#define GDK_KEY_KP_Page_Up	GDK_KP_Page_Up
+#define GDK_KEY_KP_Right	GDK_KP_Right
+#define GDK_KEY_KP_Space	GDK_KP_Space
+#define GDK_KEY_KP_Subtract	GDK_KP_Subtract
+#define GDK_KEY_KP_Tab		GDK_KP_Tab
+#define GDK_KEY_KP_Up		GDK_KP_Up
+
+#define GDK_KEY_0		GDK_0
+#define GDK_KEY_1		GDK_1
+#define GDK_KEY_2		GDK_2
+#define GDK_KEY_3		GDK_3
+#define GDK_KEY_4		GDK_4
+#define GDK_KEY_5		GDK_5
+#define GDK_KEY_6		GDK_6
+#define GDK_KEY_7		GDK_7
+#define GDK_KEY_8		GDK_8
+#define GDK_KEY_9		GDK_9
+#define GDK_KEY_a		GDK_a
+#define GDK_KEY_b		GDK_b
+#define GDK_KEY_c		GDK_c
+#define GDK_KEY_d		GDK_d
+#define GDK_KEY_e		GDK_e
+#define GDK_KEY_f		GDK_f
+#define GDK_KEY_g		GDK_g
+#define GDK_KEY_h		GDK_h
+#define GDK_KEY_i		GDK_i
+#define GDK_KEY_j		GDK_j
+#define GDK_KEY_k		GDK_k
+#define GDK_KEY_l		GDK_l
+#define GDK_KEY_m		GDK_m
+#define GDK_KEY_n		GDK_n
+#define GDK_KEY_o		GDK_o
+#define GDK_KEY_p		GDK_p
+#define GDK_KEY_q		GDK_q
+#define GDK_KEY_r		GDK_r
+#define GDK_KEY_s		GDK_s
+#define GDK_KEY_t		GDK_t
+#define GDK_KEY_u		GDK_u
+#define GDK_KEY_v		GDK_v
+#define GDK_KEY_w		GDK_w
+#define GDK_KEY_x		GDK_x
+#define GDK_KEY_y		GDK_y
+#define GDK_KEY_z		GDK_z
+#define GDK_KEY_A		GDK_A
+#define GDK_KEY_B		GDK_B
+#define GDK_KEY_C		GDK_C
+#define GDK_KEY_D		GDK_D
+#define GDK_KEY_E		GDK_E
+#define GDK_KEY_F		GDK_F
+#define GDK_KEY_G		GDK_G
+#define GDK_KEY_H		GDK_H
+#define GDK_KEY_I		GDK_I
+#define GDK_KEY_J		GDK_J
+#define GDK_KEY_K		GDK_K
+#define GDK_KEY_L		GDK_L
+#define GDK_KEY_M		GDK_M
+#define GDK_KEY_N		GDK_N
+#define GDK_KEY_O		GDK_O
+#define GDK_KEY_P		GDK_P
+#define GDK_KEY_Q		GDK_Q
+#define GDK_KEY_R		GDK_R
+#define GDK_KEY_S		GDK_S
+#define GDK_KEY_T		GDK_T
+#define GDK_KEY_U		GDK_U
+#define GDK_KEY_V		GDK_V
+#define GDK_KEY_W		GDK_W
+#define GDK_KEY_X		GDK_X
+#define GDK_KEY_Y		GDK_Y
+#define GDK_KEY_Z		GDK_Z
+
+#define GDK_KEY_F10		GDK_F10
+#define GDK_KEY_F14		GDK_F14
+#define GDK_KEY_F16		GDK_F16
+#define GDK_KEY_F18		GDK_F18
+#define GDK_KEY_F20		GDK_F20
+
+#define GDK_KEY_Alt_L		GDK_Alt_L
+#define GDK_KEY_Alt_R		GDK_Alt_R
+
+#define GDK_KEY_Control_L	GDK_Control_L
+#define GDK_KEY_Control_R	GDK_Control_R
+
+#define GDK_KEY_Hyper_L		GDK_Hyper_L
+#define GDK_KEY_Hyper_R		GDK_Hyper_R
+
+#define GDK_KEY_Meta_L		GDK_Meta_L
+#define GDK_KEY_Meta_R		GDK_Meta_R
+
+#define GDK_KEY_Shift_L		GDK_Shift_L
+#define GDK_KEY_Shift_R		GDK_Shift_R
+
+#define GDK_KEY_Super_L		GDK_Super_L
+#define GDK_KEY_Super_R		GDK_Super_R
+
+#endif
+
 #if GTK_CHECK_VERSION (2,90,5)
 
 /* Recreate GdkRegion until we drop GTK2 compatibility. */
diff --git a/gtkhtml/gtkhtml-search.c b/gtkhtml/gtkhtml-search.c
index e164026..e16de06 100644
--- a/gtkhtml/gtkhtml-search.c
+++ b/gtkhtml/gtkhtml-search.c
@@ -30,6 +30,9 @@
 #include "htmlsearch.h"
 #include "htmlselection.h"
 
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
 struct _GtkHTMLISearch {
 	GtkHTML  *html;
 	gboolean forward;
@@ -92,11 +95,11 @@ key_press (GtkWidget *widget, GdkEventKey *event, GtkHTMLISearch *data)
 {
 	gint rv = TRUE;
 
-	if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_s) {
+	if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_s) {
 		continue_search (data, TRUE);
-	} else if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_r) {
+	} else if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_r) {
 		continue_search (data, FALSE);
-	} else if (event->keyval == GDK_Escape) {
+	} else if (event->keyval == GDK_KEY_Escape) {
 		hide (data);
 	} else
 		rv = FALSE;
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index dc45e1b..534aa71 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -69,6 +69,9 @@
 #include "gtkhtml-properties.h"
 #include "math.h"
 
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
 enum DndTargetType {
 	DND_TARGET_TYPE_TEXT_URI_LIST,
 	DND_TARGET_TYPE_MOZILLA_URL,
@@ -1044,7 +1047,7 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
 	html->priv->update_styles = FALSE;
 	html->priv->event_time = event->time;
 
-	if ((event->keyval == GDK_Control_L || event->keyval == GDK_Control_R)
+	if ((event->keyval == GDK_KEY_Control_L || event->keyval == GDK_KEY_Control_R)
 	    && html_engine_get_editable (html->engine))
 		url_test_mode = TRUE;
 	else
@@ -1083,8 +1086,8 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
 	/* FIXME: use bindings */
 	if (!html_engine_get_editable (html->engine)) {
 		switch (event->keyval) {
-		case GDK_Return:
-		case GDK_KP_Enter:
+		case GDK_KEY_Return:
+		case GDK_KEY_KP_Enter:
 			/* the toplevel gtkhtml's focus object may be a frame or ifame */
 			focus_object = html_engine_get_focus_object (html->engine, &focus_object_offset);
 
@@ -5670,18 +5673,18 @@ add_bindings (GtkHTMLClass *klass)
 
 	/* layout scrolling */
 #define BSCROLL(m,key,orient,sc) \
-	gtk_binding_entry_add_signal (binding_set, GDK_ ## key, m, \
+	gtk_binding_entry_add_signal (binding_set, GDK_KEY_ ## key, m, \
 				      "scroll", 3, \
 				      GTK_TYPE_ORIENTATION, GTK_ORIENTATION_ ## orient, \
 				      GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_ ## sc, \
-				      G_TYPE_FLOAT, 0.0); \
+				      G_TYPE_FLOAT, 0.0);
 
 #define BSPACESCROLL(m,key,orient,sc) \
-	gtk_binding_entry_add_signal (binding_set, GDK_ ## key, m, \
+	gtk_binding_entry_add_signal (binding_set, GDK_KEY_ ## key, m, \
 				      "scroll", 3, \
 				      GTK_TYPE_ORIENTATION, GTK_ORIENTATION_ ## orient, \
 				      GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_ ## sc, \
-				      G_TYPE_FLOAT, 1.0); \
+				      G_TYPE_FLOAT, 1.0);
 
 	BSCROLL (0, Up, VERTICAL, STEP_BACKWARD);
 	BSCROLL (0, KP_Up, VERTICAL, STEP_BACKWARD);
@@ -5709,7 +5712,7 @@ add_bindings (GtkHTMLClass *klass)
 	/* editing */
 
 #define BMOVE(m,key,dir,sk) \
-	gtk_binding_entry_add_signal (binding_set, GDK_ ## key, m, \
+	gtk_binding_entry_add_signal (binding_set, GDK_KEY_ ## key, m, \
 				      "cursor_move", 2, \
 				      GTK_TYPE_DIRECTION_TYPE, GTK_DIR_ ## dir, \
 				      GTK_TYPE_HTML_CURSOR_SKIP, GTK_HTML_CURSOR_SKIP_ ## sk);
@@ -5750,9 +5753,10 @@ add_bindings (GtkHTMLClass *klass)
 	BMOVE (GDK_CONTROL_MASK, KP_End, DOWN, ALL);
 
 #define BCOM(m,key,com) \
-	gtk_binding_entry_add_signal (binding_set, GDK_ ## key, m, \
+	gtk_binding_entry_add_signal (binding_set, GDK_KEY_ ## key, m, \
 				      "command", 1, \
 				      GTK_TYPE_HTML_COMMAND, GTK_HTML_COMMAND_ ## com);
+
 	BCOM (0, Home, SCROLL_BOD);
 	BCOM (0, KP_Home, SCROLL_BOD);
 	BCOM (0, End, SCROLL_EOD);
diff --git a/gtkhtml/htmlengine.c b/gtkhtml/htmlengine.c
index 4d5949e..5f5feba 100644
--- a/gtkhtml/htmlengine.c
+++ b/gtkhtml/htmlengine.c
@@ -27,7 +27,6 @@
    If `e->flow' is not NULL, it must contain something.  */
 
 #include <config.h>
-#include "gtk-compat.h"
 #include "gtkhtml-compat.h"
 
 #include <stdio.h>
@@ -100,6 +99,9 @@
 #include "htmlmarshal.h"
 #include "htmlstyle.h"
 
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
 /* #define CHECK_CURSOR */
 
 static void      html_engine_class_init       (HTMLEngineClass     *klass);
diff --git a/gtkhtml/htmltextinput.c b/gtkhtml/htmltextinput.c
index 73fb4e8..e2ceb99 100644
--- a/gtkhtml/htmltextinput.c
+++ b/gtkhtml/htmltextinput.c
@@ -27,6 +27,9 @@
 #include "htmltextinput.h"
 #include "htmlform.h"
 
+/* backward-compatibility cruft */
+#include "gtk-compat.h"
+
 
 HTMLTextInputClass html_text_input_class;
 static HTMLEmbeddedClass *parent_class = NULL;
@@ -76,7 +79,7 @@ html_text_input_key_pressed (GtkWidget *w, GdkEventKey *ev, gpointer p)
 	gboolean found = FALSE;
 	GList *node = NULL;
 
-	if (ev->keyval == GDK_Return) {
+	if (ev->keyval == GDK_KEY_Return) {
 		for (node = e->form->elements; node; node = node->next) {
 			current = HTML_EMBEDDED (node->data);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]