diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-09-18 06:39:59 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-09-18 06:39:59 +0800 |
commit | afe6f502c326350cc31d34646d5000a964321525 (patch) | |
tree | 9d9469a0ce33428e24e602fdbf87bc496864bc57 /e-util | |
parent | b79bf3d187cabd11df74d2e6e414e41ae637f307 (diff) | |
download | gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar.gz gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar.bz2 gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar.lz gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar.xz gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.tar.zst gsoc2013-evolution-afe6f502c326350cc31d34646d5000a964321525.zip |
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 macors to gtk-compat.h, which can be
dumped as soon as we require GTK+ >= 2.22.0.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-text-event-processor-emacs-like.c | 103 | ||||
-rw-r--r-- | e-util/e-unicode.c | 5 | ||||
-rw-r--r-- | e-util/gtk-compat.h | 162 |
3 files changed, 216 insertions, 54 deletions
diff --git a/e-util/e-text-event-processor-emacs-like.c b/e-util/e-text-event-processor-emacs-like.c index b5febfa89d..3851590f0f 100644 --- a/e-util/e-text-event-processor-emacs-like.c +++ b/e-util/e-text-event-processor-emacs-like.c @@ -29,6 +29,9 @@ #include "e-text-event-processor-emacs-like.h" #include "e-util.h" +/* backward-compatibility cruft */ +#include "e-util/gtk-compat.h" + static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event); @@ -200,60 +203,60 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, else command.action = E_TEP_MOVE; switch (key.keyval) { - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: if (key.state & GDK_CONTROL_MASK) command.position = E_TEP_START_OF_BUFFER; else command.position = E_TEP_START_OF_LINE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: if (key.state & GDK_CONTROL_MASK) command.position = E_TEP_END_OF_BUFFER; else command.position = E_TEP_END_OF_LINE; break; - case GDK_Page_Up: - case GDK_KP_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break; + case GDK_KEY_Page_Up: + case GDK_KEY_KP_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break; - case GDK_Page_Down: - case GDK_KP_Page_Down: command.position = E_TEP_FORWARD_PAGE; break; + case GDK_KEY_Page_Down: + case GDK_KEY_KP_Page_Down: command.position = E_TEP_FORWARD_PAGE; break; /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */ - case GDK_Up: - case GDK_KP_Up: command.position = E_TEP_BACKWARD_LINE; break; + case GDK_KEY_Up: + case GDK_KEY_KP_Up: command.position = E_TEP_BACKWARD_LINE; break; - case GDK_Down: - case GDK_KP_Down: command.position = E_TEP_FORWARD_LINE; break; + case GDK_KEY_Down: + case GDK_KEY_KP_Down: command.position = E_TEP_FORWARD_LINE; break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: if (key.state & GDK_CONTROL_MASK) command.position = E_TEP_BACKWARD_WORD; else command.position = E_TEP_BACKWARD_CHARACTER; break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: if (key.state & GDK_CONTROL_MASK) command.position = E_TEP_FORWARD_WORD; else command.position = E_TEP_FORWARD_CHARACTER; break; - case GDK_BackSpace: + case GDK_KEY_BackSpace: command.action = E_TEP_DELETE; if (key.state & GDK_CONTROL_MASK) command.position = E_TEP_BACKWARD_WORD; else command.position = E_TEP_BACKWARD_CHARACTER; break; - case GDK_Clear: + case GDK_KEY_Clear: command.action = E_TEP_DELETE; command.position = E_TEP_END_OF_LINE; break; - case GDK_Insert: - case GDK_KP_Insert: + case GDK_KEY_Insert: + case GDK_KEY_KP_Insert: if (key.state & GDK_SHIFT_MASK) { command.action = E_TEP_PASTE; command.position = E_TEP_SELECTION; @@ -264,15 +267,15 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, /* gtk_toggle_insert(text) -- IMPLEMENT -- FIXME */ } break; - case GDK_F16: + case GDK_KEY_F16: command.action = E_TEP_COPY; command.position = E_TEP_SELECTION; break; - case GDK_F18: + case GDK_KEY_F18: command.action = E_TEP_PASTE; command.position = E_TEP_SELECTION; break; - case GDK_F20: + case GDK_KEY_F20: command.action = E_TEP_COPY; command.position = E_TEP_SELECTION; g_signal_emit_by_name (tep, "command", &command); @@ -280,8 +283,8 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, command.action = E_TEP_DELETE; command.position = E_TEP_SELECTION; break; - case GDK_Delete: - case GDK_KP_Delete: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: if (key.state & GDK_CONTROL_MASK) { command.action = E_TEP_DELETE; command.position = E_TEP_FORWARD_WORD; @@ -297,16 +300,16 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, command.position = E_TEP_FORWARD_CHARACTER; } break; - case GDK_Tab: - case GDK_KP_Tab: - case GDK_ISO_Left_Tab: - case GDK_3270_BackTab: + case GDK_KEY_Tab: + case GDK_KEY_KP_Tab: + case GDK_KEY_ISO_Left_Tab: + case GDK_KEY_3270_BackTab: /* Don't insert literally */ command.action = E_TEP_NOP; command.position = E_TEP_SELECTION; break; - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: if (tep->allow_newlines) { if (key.state & GDK_CONTROL_MASK) { command.action = E_TEP_ACTIVATE; @@ -327,109 +330,109 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, } } break; - case GDK_Escape: + case GDK_KEY_Escape: /* Don't insert literally */ command.action = E_TEP_NOP; command.position = E_TEP_SELECTION; break; - case GDK_KP_Space: + case GDK_KEY_KP_Space: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = " "; break; - case GDK_KP_Equal: + case GDK_KEY_KP_Equal: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "="; break; - case GDK_KP_Multiply: + case GDK_KEY_KP_Multiply: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "*"; break; - case GDK_KP_Add: + case GDK_KEY_KP_Add: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "+"; break; - case GDK_KP_Subtract: + case GDK_KEY_KP_Subtract: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "-"; break; - case GDK_KP_Decimal: + case GDK_KEY_KP_Decimal: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "."; break; - case GDK_KP_Divide: + case GDK_KEY_KP_Divide: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "/"; break; - case GDK_KP_0: + case GDK_KEY_KP_0: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "0"; break; - case GDK_KP_1: + case GDK_KEY_KP_1: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "1"; break; - case GDK_KP_2: + case GDK_KEY_KP_2: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "2"; break; - case GDK_KP_3: + case GDK_KEY_KP_3: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "3"; break; - case GDK_KP_4: + case GDK_KEY_KP_4: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "4"; break; - case GDK_KP_5: + case GDK_KEY_KP_5: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "5"; break; - case GDK_KP_6: + case GDK_KEY_KP_6: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "6"; break; - case GDK_KP_7: + case GDK_KEY_KP_7: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "7"; break; - case GDK_KP_8: + case GDK_KEY_KP_8: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; command.string = "8"; break; - case GDK_KP_9: + case GDK_KEY_KP_9: command.action = E_TEP_INSERT; command.position = E_TEP_SELECTION; command.value = 1; @@ -477,7 +480,7 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, } else if (!(key.state & GDK_MOD1_MASK) && !(key.state & GDK_CONTROL_MASK) && key.length > 0) { - if (key.keyval >= GDK_KP_0 && key.keyval <= GDK_KP_9) { + if (key.keyval >= GDK_KEY_KP_0 && key.keyval <= GDK_KEY_KP_9) { key.keyval = '0'; key.string = "0"; } diff --git a/e-util/e-unicode.c b/e-util/e-unicode.c index 9d610bc5d8..59e94aa25e 100644 --- a/e-util/e-unicode.c +++ b/e-util/e-unicode.c @@ -39,6 +39,9 @@ #include <glib/gi18n.h> #include "e-unicode.h" +/* backward-compatibility cruft */ +#include "e-util/gtk-compat.h" + #define d(x) #define FONT_TESTING @@ -53,7 +56,7 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string) gchar *utf; gint unilen; - if (keyval == GDK_VoidSymbol) { + if (keyval == GDK_KEY_VoidSymbol) { utf = e_utf8_from_locale_string_sized (string, strlen (string)); } else { unival = gdk_keyval_to_unicode (keyval); diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h index 0bad301e69..0635fd5246 100644 --- a/e-util/gtk-compat.h +++ b/e-util/gtk-compat.h @@ -3,9 +3,165 @@ #include <gtk/gtk.h> -/* Provide a compatibility layer for accessor functions introduced - * in GTK+ 2.21.1 which we need to build with sealed GDK. That way it - * is still possible to build with GTK+ 2.20. */ +/* 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_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \ || (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1) |