diff options
Diffstat (limited to 'src/idoentrymenuitem.c')
-rw-r--r-- | src/idoentrymenuitem.c | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c index 251d108..1636da9 100644 --- a/src/idoentrymenuitem.c +++ b/src/idoentrymenuitem.c @@ -26,8 +26,13 @@ #include <gdk/gdkkeysyms.h> #include "idoentrymenuitem.h" +#if GTK_CHECK_VERSION (3, 0, 0) +static void ido_entry_menu_item_select (GtkMenuItem *item); +static void ido_entry_menu_item_deselect (GtkMenuItem *item); +#else static void ido_entry_menu_item_select (GtkItem *item); static void ido_entry_menu_item_deselect (GtkItem *item); +#endif static gboolean ido_entry_menu_item_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean ido_entry_menu_item_key_press (GtkWidget *widget, @@ -60,18 +65,27 @@ ido_entry_menu_item_class_init (IdoEntryMenuItemClass *klass) GObjectClass *gobject_class; GtkWidgetClass *widget_class; GtkMenuItemClass *menu_item_class; +#if ! GTK_CHECK_VERSION (3, 0, 0) GtkItemClass *item_class; +#endif gobject_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); menu_item_class = GTK_MENU_ITEM_CLASS (klass); +#if ! GTK_CHECK_VERSION (3, 0, 0) item_class = GTK_ITEM_CLASS (klass); +#endif widget_class->button_release_event = ido_entry_menu_item_button_release; widget_class->button_press_event = ido_entry_menu_item_button_press; +#if GTK_CHECK_VERSION (3, 0, 0) + menu_item_class->select = ido_entry_menu_item_select; + menu_item_class->deselect = ido_entry_menu_item_deselect; +#else item_class->select = ido_entry_menu_item_select; item_class->deselect = ido_entry_menu_item_deselect; +#endif menu_item_class->hide_on_activate = TRUE; @@ -118,11 +132,11 @@ is_key_press_valid (IdoEntryMenuItem *item, { switch (key) { - case GDK_Escape: - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Escape: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: return FALSE; default: @@ -145,21 +159,11 @@ ido_entry_menu_item_key_press (GtkWidget *widget, gtk_widget_event (entry, ((GdkEvent *)(void*)(event))); - if (entry->window != NULL) - { - gdk_window_raise (entry->window); - } - - if (!gtk_widget_has_focus (entry)) - { - gtk_widget_grab_focus (entry); - } - - /* We've handled the event, but if the key was GDK_Return + /* We've handled the event, but if the key was GDK_KEY_Return * we still want to forward the event up to the menu shell * to ensure that the menuitem receives the activate signal. */ - return event->keyval != GDK_Return; + return event->keyval != GDK_KEY_Return; } return FALSE; @@ -173,11 +177,8 @@ ido_entry_menu_item_send_focus_change (GtkWidget *widget, g_object_ref (widget); - if (in) - gtk_widget_grab_focus (widget); - event->focus_change.type = GDK_FOCUS_CHANGE; - event->focus_change.window = g_object_ref (widget->window); + event->focus_change.window = g_object_ref (gtk_widget_get_window (widget)); event->focus_change.in = in; gtk_widget_event (widget, event); @@ -196,9 +197,9 @@ ido_entry_menu_item_button_press (GtkWidget *widget, if (event->button == 1) { - if (entry->window != NULL) + if (gtk_widget_get_window (entry) != NULL) { - gdk_window_raise (entry->window); + gdk_window_raise (gtk_widget_get_window (entry)); } if (!gtk_widget_has_focus (entry)) @@ -228,7 +229,11 @@ ido_entry_menu_item_button_release (GtkWidget *widget, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_entry_menu_item_select (GtkMenuItem *item) +#else ido_entry_menu_item_select (GtkItem *item) +#endif { IDO_ENTRY_MENU_ITEM (item)->priv->selected = TRUE; @@ -236,7 +241,11 @@ ido_entry_menu_item_select (GtkItem *item) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_entry_menu_item_deselect (GtkMenuItem *item) +#else ido_entry_menu_item_deselect (GtkItem *item) +#endif { IDO_ENTRY_MENU_ITEM (item)->priv->selected = FALSE; @@ -248,12 +257,12 @@ static void entry_realized_cb (GtkWidget *widget, IdoEntryMenuItem *item) { - if (widget->window != NULL) + if (gtk_widget_get_window (widget) != NULL) { - gdk_window_raise (widget->window); + gdk_window_raise (gtk_widget_get_window (widget)); } - g_signal_connect (GTK_WIDGET (item)->parent, + g_signal_connect (gtk_widget_get_parent (GTK_WIDGET (item)), "key-press-event", G_CALLBACK (ido_entry_menu_item_key_press), item); |