diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-02-02 17:52:01 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-02-02 17:52:01 +0000 |
commit | 67ad02989f0b80d3279c9e72299a4bc9478fe752 (patch) | |
tree | d54c819bec345498973aba81e6f8753e466d8b69 /gtk | |
parent | 7bb3d17abe5e58480e7c4378c7a922c6df016725 (diff) | |
download | gtk+-67ad02989f0b80d3279c9e72299a4bc9478fe752.tar.gz |
Remove the "select first item if popped up from keypress" hack -- was
Sat Feb 2 11:37:21 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenu.c (gtk_menu_popup): Remove the
"select first item if popped up from keypress" hack --
was causing more problems than it was worth
(#53191, #68483)
* gtk/gtktextview.c (popup_targets_received):
gtk/gtkentry.c (popup_targets_received): If activated
from keyboard, select first item of popup menu.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkentry.c | 31 | ||||
-rw-r--r-- | gtk/gtkmenu.c | 16 | ||||
-rw-r--r-- | gtk/gtktextview.c | 31 |
3 files changed, 56 insertions, 22 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 1083a37cc9..d9bf421f3d 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3812,6 +3812,28 @@ unichar_chosen_func (const char *text, gtk_entry_enter_text (entry, text); } +static void +menu_select_first_child (GtkMenu *menu) +{ + GList *children = gtk_container_get_children (GTK_CONTAINER (menu)); + + GList *tmp_list = children; + while (tmp_list) + { + GtkWidget *child = tmp_list->data; + + if (GTK_WIDGET_VISIBLE (child)) + { + gtk_menu_shell_select_item (GTK_MENU_SHELL (menu), child); + break; + } + + tmp_list = tmp_list->next; + } + + g_list_free (children); +} + typedef struct { GtkEntry *entry; @@ -3892,9 +3914,12 @@ popup_targets_received (GtkClipboard *clipboard, NULL, NULL, info->button, info->time); else - gtk_menu_popup (GTK_MENU (entry->popup_menu), NULL, NULL, - popup_position_func, entry, - info->button, info->time); + { + gtk_menu_popup (GTK_MENU (entry->popup_menu), NULL, NULL, + popup_position_func, entry, + info->button, info->time); + menu_select_first_child (GTK_MENU (entry->popup_menu)); + } } g_object_unref (entry); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 5d8a4efc94..e0d69a4aae 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -652,22 +652,6 @@ gtk_menu_popup (GtkMenu *menu, gtk_widget_show (GTK_WIDGET (menu)); gtk_widget_show (menu->toplevel); - if (current_event) - { - /* Also, if we're popping up from a key event, select the first - * item in the menu. Bad hack, but no better way to do it - * in current menu framework. - */ - if (current_event->type == GDK_KEY_PRESS && - GTK_MENU_SHELL (menu)->children) - { - gtk_menu_shell_select_item (GTK_MENU_SHELL (menu), - GTK_MENU_SHELL (menu)->children->data); - } - - gdk_event_free (current_event); - } - gtk_menu_scroll_to (menu, menu->scroll_offset); /* Find the last viewable ancestor, and make an X grab on it diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index dc8d04a8e3..d834db973b 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -6274,6 +6274,28 @@ unichar_chosen_func (const char *text, } static void +menu_select_first_child (GtkMenu *menu) +{ + GList *children = gtk_container_get_children (GTK_CONTAINER (menu)); + + GList *tmp_list = children; + while (tmp_list) + { + GtkWidget *child = tmp_list->data; + + if (GTK_WIDGET_VISIBLE (child)) + { + gtk_menu_shell_select_item (GTK_MENU_SHELL (menu), child); + break; + } + + tmp_list = tmp_list->next; + } + + g_list_free (children); +} + +static void popup_targets_received (GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data) @@ -6355,9 +6377,12 @@ popup_targets_received (GtkClipboard *clipboard, NULL, NULL, info->button, info->time); else - gtk_menu_popup (GTK_MENU (text_view->popup_menu), NULL, NULL, - popup_position_func, text_view, - 0, gtk_get_current_event_time ()); + { + gtk_menu_popup (GTK_MENU (text_view->popup_menu), NULL, NULL, + popup_position_func, text_view, + 0, gtk_get_current_event_time ()); + menu_select_first_child (GTK_MENU (text_view->popup_menu)); + } } g_object_unref (text_view); |