From: Claudio Saavedra Date: Thu, 10 Sep 2009 17:24:52 +0000 (+0300) Subject: Update the application menu flag for application-wise windows X-Git-Tag: 2.2.0-rc5~3 X-Git-Url: https://vcs.maemo.org/git/?p=hildon;a=commitdiff_plain;h=a9a9c6c5c73ba1727b907167026559ceb7208b99 Update the application menu flag for application-wise windows * hildon/hildon-program.c: (+hildon_program_on_common_app_menu_changed), (hildon_program_set_common_app_menu): Also take into account the visibility of its items. --- diff --git a/ChangeLog b/ChangeLog index ad9f2f4..72839c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-09-10 Claudio Saavedra + Update the application menu flag for application-wise windows + + * hildon/hildon-program.c: (+hildon_program_on_common_app_menu_changed), + (hildon_program_set_common_app_menu): Also take into account the visibility + of its items. + +2009-09-10 Claudio Saavedra + Emit HildonAppMenu::changed when menu items change visibility * hildon/hildon-app-menu.c: (item_visibility_changed), diff --git a/hildon/hildon-program.c b/hildon/hildon-program.c index 0174e16..f2b1906 100644 --- a/hildon/hildon-program.c +++ b/hildon/hildon-program.c @@ -696,6 +696,14 @@ hildon_program_get_common_menu (HildonProgram *self) return priv->common_menu; } +static void +hildon_program_on_common_app_menu_changed (HildonAppMenu *menu, + HildonProgram *program) +{ + hildon_program_set_common_menu_flag (program, + hildon_app_menu_has_visible_children (menu)); +} + /** * hildon_program_set_common_app_menu: * @self: The #HildonProgram in which the common menu should be used @@ -730,20 +738,28 @@ hildon_program_set_common_app_menu (HildonProgram *self, /* Only set the menu flag if there was no common menu and we are setting one. If we are unsetting the current common menu, remove the commmon menu flag. Otherwise, nothing to do. */ - if (!priv->common_app_menu && menu) { + if (!priv->common_app_menu + && menu && hildon_app_menu_has_visible_children (menu)) { hildon_program_set_common_menu_flag (self, TRUE); - } else if (priv->common_app_menu && !menu) { + } else if (priv->common_app_menu && + (!menu || !hildon_app_menu_has_visible_children (menu))) { hildon_program_set_common_menu_flag (self, FALSE); } /* Set new menu */ priv->common_app_menu = menu; - if (menu) + if (menu) { + g_signal_connect (menu, "changed", + G_CALLBACK (hildon_program_on_common_app_menu_changed), self); g_object_ref_sink (menu); + } /* Hide and unref old menu */ if (old_menu) { hildon_app_menu_set_parent_window (old_menu, NULL); + g_signal_handlers_disconnect_by_func (old_menu, + hildon_program_on_common_app_menu_changed, + self); g_object_unref (old_menu); } }