diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-10-23 00:45:18 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-10-23 00:45:18 +0000 |
commit | 3d4c27d06ab4a57508c0c7afdd73a846b365e671 (patch) | |
tree | d8dd578d28bb884d6f0b082ff31623f4a9d8bb4d /gtk/gtkcombo.c | |
parent | ecb42dc78969437f18569dfcdc70ddec61ac9121 (diff) | |
download | gdk-pixbuf-3d4c27d06ab4a57508c0c7afdd73a846b365e671.tar.gz |
When popping up the list without any selected items, hack the focus on the
Tue Oct 22 20:02:22 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkcombo.c: When popping up the list without
any selected items, hack the focus on the list to
avoid triggering a bug in GtkList when clicking
on focused-but-not-selected items (#86700,
Zimler Attila, Matthias Clasen) and to keep
GtkWindow from selecting the first item.
* tests/testgtk.c (create_list): Make the initial
setting of the selection mode correspond to the option
menu.
Diffstat (limited to 'gtk/gtkcombo.c')
-rw-r--r-- | gtk/gtkcombo.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c index 06d354b6c..bb9e222d3 100644 --- a/gtk/gtkcombo.c +++ b/gtk/gtkcombo.c @@ -503,6 +503,7 @@ gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * w static void gtk_combo_popup_list (GtkCombo * combo) { + GtkList *list; gint height, width, x, y; gint old_width, old_height; @@ -518,6 +519,26 @@ gtk_combo_popup_list (GtkCombo * combo) gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar); } + gtk_combo_update_list (GTK_ENTRY (combo->entry), combo); + + /* We need to make sure some child of combo->popwin + * is focused to disable GtkWindow's automatic + * "focus-the-first-item" code. If there is no selected + * child, we focus the list itself with some hackery. + */ + list = GTK_LIST (combo->list); + + if (list->selection) + { + gtk_widget_grab_focus (list->selection->data); + } + else + { + GTK_WIDGET_SET_FLAGS (list, GTK_CAN_FOCUS); + gtk_widget_grab_focus (list); + GTK_WIDGET_UNSET_FLAGS (list, GTK_CAN_FOCUS); + } + gtk_window_move (GTK_WINDOW (combo->popwin), x, y); gtk_widget_set_size_request (combo->popwin, width, height); gtk_widget_show (combo->popwin); |