From 57f13d815ddbdb0d001fa92c823d44744b3577e4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 Sep 2003 20:55:24 +0000 Subject: Test handling of empty menus. 2003-09-30 Matthias Clasen * tests/merge-*.ui: * tests/testmerge.c: Test handling of empty menus. * gtk/gtkuimanager.c (_gtk_menu_is_empty): New function to determine whether a menu is empty. Used in gtkaction.c. (update_smart_separators): Also update the visibility of empty menus. (update_node): When creating a new menu proxy, insert an "Empty" menu item which only gets shown if the menu is empty. * gtk/gtkaction.c (gtk_action_class_init): Document the meaning of "is_important" for menu proxies. (_gtk_action_sync_menu_visible): New function to sync the visibility of menu proxies. Used in gtkuimanager.c. (gtk_action_sync_visible): New function to sync the visibility of proxies. --- tests/merge-1.ui | 7 ++++++- tests/merge-2.ui | 8 ++++++++ tests/testmerge.c | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/merge-1.ui b/tests/merge-1.ui index a7fb9779d4..b2cb72218c 100644 --- a/tests/merge-1.ui +++ b/tests/merge-1.ui @@ -3,15 +3,20 @@ + + + + + - + diff --git a/tests/merge-2.ui b/tests/merge-2.ui index a073f917dc..05a641fe96 100644 --- a/tests/merge-2.ui +++ b/tests/merge-2.ui @@ -8,6 +8,14 @@ + + + + + + + + diff --git a/tests/testmerge.c b/tests/testmerge.c index d74ed6fd7f..5c9a59b736 100644 --- a/tests/testmerge.c +++ b/tests/testmerge.c @@ -123,6 +123,8 @@ static GtkActionEntry entries[] = { { "EditMenuAction", NULL, "_Edit" }, { "HelpMenuAction", NULL, "_Help" }, { "JustifyMenuAction", NULL, "_Justify" }, + { "EmptyMenu1Action", NULL, "Empty 1" }, + { "EmptyMenu2Action", NULL, "Empty 2" }, { "Test", NULL, "Test" }, { "QuitAction", GTK_STOCK_QUIT, NULL, "q", "Quit", G_CALLBACK (gtk_main_quit) }, @@ -541,6 +543,10 @@ main (int argc, char **argv) gtk_action_group_add_actions (action_group, entries, n_entries, NULL); + action = gtk_action_group_get_action (action_group, "EmptyMenu1Action"); + g_object_set (G_OBJECT (action), "is_important", TRUE, NULL); + action = gtk_action_group_get_action (action_group, "EmptyMenu2Action"); + g_object_set (G_OBJECT (action), "is_important", FALSE, NULL); gtk_action_group_add_toggle_actions (action_group, toggle_entries, n_toggle_entries, NULL); -- cgit v1.2.1