diff options
author | Cody Russell <crussell@canonical.com> | 2010-07-07 08:48:37 -0500 |
---|---|---|
committer | Cody Russell <crussell@canonical.com> | 2010-07-07 08:48:37 -0500 |
commit | 440588987f43f3a3cce6bd05bd031ecf89ef817b (patch) | |
tree | ee64854e435236e42ff459d6f970ccdbb163c28b /src | |
parent | fab639ce854c1585fc22af5f2ade5c89de7b2c4f (diff) | |
download | ayatana-ido-440588987f43f3a3cce6bd05bd031ecf89ef817b.tar.gz ayatana-ido-440588987f43f3a3cce6bd05bd031ecf89ef817b.tar.bz2 ayatana-ido-440588987f43f3a3cce6bd05bd031ecf89ef817b.zip |
Send button-press and button-release events to the entry. Also grab focus at the first key-press.
Diffstat (limited to 'src')
-rw-r--r-- | src/idoentrymenuitem.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/src/idoentrymenuitem.c b/src/idoentrymenuitem.c index 8e7ab5c..7227201 100644 --- a/src/idoentrymenuitem.c +++ b/src/idoentrymenuitem.c @@ -35,8 +35,8 @@ static gboolean ido_entry_menu_item_key_press (GtkWidget *widget, gpointer data); static gboolean ido_entry_menu_item_button_press (GtkWidget *widget, GdkEventButton *event); -static void ido_entry_menu_item_send_focus_change (GtkWidget *widget, - gboolean in); +static void ido_entry_menu_item_send_focus_change (GtkWidget *widget, + gboolean in); static void entry_realized_cb (GtkWidget *widget, IdoEntryMenuItem *item); static void entry_move_focus_cb (GtkWidget *widget, @@ -113,13 +113,6 @@ ido_entry_menu_item_init (IdoEntryMenuItem *item) } static gboolean -ido_entry_menu_item_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - return TRUE; -} - -static gboolean is_key_press_valid (IdoEntryMenuItem *item, gint key) { @@ -147,9 +140,21 @@ ido_entry_menu_item_key_press (GtkWidget *widget, if (menuitem->priv->selected && is_key_press_valid (menuitem, event->keyval)) { - gtk_widget_event (menuitem->priv->entry, + GtkWidget *entry = menuitem->priv->entry; + + 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 still want to forward the event up to the menu shell * to ensure that the menuitem receives the activate signal. @@ -193,12 +198,10 @@ static gboolean ido_entry_menu_item_button_press (GtkWidget *widget, GdkEventButton *event) { - if (event->button == GDK_BUTTON_PRESS) - { - GtkWidget *entry; - - entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + if (event->button == 1) + { if (entry->window != NULL) { gdk_window_raise (entry->window); @@ -209,12 +212,27 @@ ido_entry_menu_item_button_press (GtkWidget *widget, gtk_widget_grab_focus (entry); } + gtk_widget_event (entry, + ((GdkEvent *)(void*)(event))); + return TRUE; } return FALSE; } +static gboolean +ido_entry_menu_item_button_release (GtkWidget *widget, + GdkEventButton *event) +{ + GtkWidget *entry = IDO_ENTRY_MENU_ITEM (widget)->priv->entry; + + gtk_widget_event (entry, + ((GdkEvent *)(void*)(event))); + + return TRUE; +} + static void ido_entry_menu_item_select (GtkItem *item) { |