diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-12-27 06:12:53 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-12-27 06:12:53 +0000 |
commit | 264e9c0ce11839b41859de1ef720b68374b6f850 (patch) | |
tree | 1561d3db72162e63f4eed1b608608c92203b5821 /gtk/gtkcombobox.c | |
parent | 0b0746e44d176ed6eb839257cc3cb9b6065a9978 (diff) | |
download | gdk-pixbuf-264e9c0ce11839b41859de1ef720b68374b6f850.tar.gz |
Fix a few problems with nested menus in comboboxes (#386694, Yevgen
2006-12-17 Matthias Clasen <mclasen@redhat.com>
Fix a few problems with nested menus in comboboxes
(#386694, Yevgen Muntyan)
* gtk/gtkcombobox.c (gtk_combo_box_menu_fill_level): Always
connect the activate callback.
(gtk_combo_box_menu_item_activate): Do nothing if called on
an item with a submenu.
(gtk_combo_box_menu_row_deleted): Remove a submenu when it
is empty.
Diffstat (limited to 'gtk/gtkcombobox.c')
-rw-r--r-- | gtk/gtkcombobox.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index dfa61facd..c9ab32293 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -2749,10 +2749,9 @@ gtk_combo_box_menu_fill_level (GtkComboBox *combo_box, gtk_combo_box_menu_fill_level (combo_box, submenu, &iter); } - else - g_signal_connect (item, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); + g_signal_connect (item, "activate", + G_CALLBACK (gtk_combo_box_menu_item_activate), + combo_box); } gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -2946,7 +2945,10 @@ gtk_combo_box_menu_item_activate (GtkWidget *item, path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (cell_view)); if (gtk_tree_model_get_iter (combo_box->priv->model, &iter, path)) - gtk_combo_box_set_active_iter (combo_box, &iter); + { + if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)) == NULL) + gtk_combo_box_set_active_iter (combo_box, &iter); + } gtk_tree_path_free (path); @@ -3269,6 +3271,24 @@ gtk_combo_box_menu_row_deleted (GtkTreeModel *model, item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE); menu = gtk_widget_get_parent (item); gtk_container_remove (GTK_CONTAINER (menu), item); + + if (gtk_tree_path_get_depth (path) > 1) + { + GtkTreePath *parent_path; + GtkTreeIter iter; + GtkWidget *parent; + + parent_path = gtk_tree_path_copy (path); + gtk_tree_path_up (parent_path); + gtk_tree_model_get_iter (model, &iter, parent_path); + + if (!gtk_tree_model_iter_has_child (model, &iter)) + { + parent = find_menu_by_path (combo_box->priv->popup_widget, + parent_path, FALSE); + gtk_menu_item_remove_submenu (GTK_MENU_ITEM (parent)); + } + } } static void |