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.
This commit is contained in:
Matthias Clasen 2006-12-27 06:12:53 +00:00 committed by Matthias Clasen
parent 0b0746e44d
commit 264e9c0ce1
2 changed files with 37 additions and 5 deletions

View File

@ -1,3 +1,15 @@
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.
2006-12-26 Mariano Suárez-Alvarez <mariano@gnome.org>
* gtk/gtkfilechooserbuuton.[hc]: Add a file-set signal to the

View File

@ -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