aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-window.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2009-09-11 20:17:09 +0300
committerClaudio Saavedra <csaavedra@igalia.com>2009-09-11 20:17:09 +0300
commita9196682cadd78ab37c8a32a45dc9d687e2f9c2f (patch)
tree8143beb61272893192121889343b25f4babb75be /hildon/hildon-window.c
parentecf300748aa59210d2b65a1a1e446fd1b2386dea (diff)
Do not set the menu flag in a window when a menu is empty
* hildon/hildon-window.c: (hildon_window_update_menu_flag), (on_menu_changed), (on_menu_changedhildon_window_set_main_menu), (on_menu_changed), (hildon_window_set_main_menu): Update on menu changes by using the HildonAppMenu::changed signal.
Diffstat (limited to 'hildon/hildon-window.c')
-rw-r--r--hildon/hildon-window.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/hildon/hildon-window.c b/hildon/hildon-window.c
index 990a2bd..bd84c32 100644
--- a/hildon/hildon-window.c
+++ b/hildon/hildon-window.c
@@ -1343,6 +1343,40 @@ hildon_window_is_topmost_notify (HildonWindow *window)
}
}
+static void
+hildon_window_update_menu_flag (HildonWindow *self,
+ gboolean is_app_menu)
+{
+ HildonWindowPrivate *priv;
+
+ priv = HILDON_WINDOW_GET_PRIVATE (self);
+
+ if (is_app_menu)
+ {
+ /* Change the menu flag only if there is no program or common
+ application menu. */
+ if (!priv->program ||
+ !hildon_program_get_common_app_menu (priv->program))
+ {
+ hildon_window_set_menu_flag (self, priv->app_menu != NULL &&
+ hildon_app_menu_has_visible_children (priv->app_menu));
+ }
+ } else {
+ if (!priv->program || !hildon_program_get_common_menu (priv->program))
+ {
+ hildon_window_set_menu_flag (self, priv->menu != NULL
+ && gtk_container_get_children (GTK_CONTAINER (priv->menu)));
+ }
+ }
+}
+
+static void
+on_menu_changed (HildonAppMenu *menu,
+ HildonWindow *window)
+{
+ hildon_window_update_menu_flag (window, TRUE);
+}
+
/*
* Sets the program to which the window belongs. This should only be called
* by hildon_program_add_window
@@ -2003,8 +2037,6 @@ hildon_window_set_main_menu (HildonWindow* self,
priv = HILDON_WINDOW_GET_PRIVATE (self);
- hildon_window_set_menu_flag (self, menu != NULL);
-
if (priv->menu != NULL)
{
accel_group = gtk_menu_get_accel_group (priv->menu);
@@ -2026,6 +2058,8 @@ hildon_window_set_main_menu (HildonWindow* self,
if (accel_group != NULL)
hildon_window_add_accel_group (self, accel_group);
}
+
+ hildon_window_update_menu_flag (self, FALSE);
}
/**
@@ -2110,16 +2144,22 @@ hildon_window_set_app_menu (HildonWindow *self,
old_menu = priv->app_menu;
- hildon_window_set_menu_flag (self, menu != NULL);
-
/* Add new menu */
priv->app_menu = menu;
if (menu)
+ {
g_object_ref_sink (menu);
+ g_signal_connect (menu, "changed", G_CALLBACK (on_menu_changed), self);
+ }
/* Unref old menu */
if (old_menu)
+ {
+ g_signal_handlers_disconnect_by_func (old_menu, on_menu_changed, self);
g_object_unref (old_menu);
+ }
+
+ hildon_window_update_menu_flag (self, TRUE);
}
/**