From 26e0010415f12aaf84a6cdcf993a7345596b3c37 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Wed, 9 Sep 2009 11:22:53 +0300 Subject: [PATCH] Set the window menu flag for application-common menus * hildon/hildon-program.c: (+hildon_program_window_set_common_menu_flag): Set or remove the menu flag from a window only this doesn't have its own menu. (+hildon_program_set_common_menu_flag): adjust menu flag for all windows in the program. (hildon_program_add_window), (hildon_program_remove_window): add/remove the menu flag when a window is added to the program. Fixes: NB#137814 (Indicator for view menu in app title area) --- ChangeLog | 15 ++++++++++++++ hildon/hildon-program.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6d41b2f..f776eb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-09-09 Claudio Saavedra + + Set the window menu flag for application-common menus + + * hildon/hildon-program.c: + (+hildon_program_window_set_common_menu_flag): Set or remove the + menu flag from a window only this doesn't have its own menu. + (+hildon_program_set_common_menu_flag): adjust menu flag for + all windows in the program. + (hildon_program_add_window), + (hildon_program_remove_window): add/remove the menu flag when + a window is added to the program. + + Fixes: NB#137814 (Indicator for view menu in app title area) + 2009-09-08 Claudio Saavedra Set a special window property for windows with menus diff --git a/hildon/hildon-program.c b/hildon/hildon-program.c index 86e866c..0174e16 100644 --- a/hildon/hildon-program.c +++ b/hildon/hildon-program.c @@ -411,6 +411,32 @@ hildon_program_root_window_event_filter (GdkXEvent *xevent, return GDK_FILTER_CONTINUE; } +static void +hildon_program_window_set_common_menu_flag (HildonWindow *window, + gboolean common_menu) +{ + if (HILDON_IS_WINDOW (window)) + { + gboolean has_menu = hildon_window_get_app_menu (window) || + hildon_window_get_main_menu (window); + + if (!has_menu) { + hildon_window_set_menu_flag (window, common_menu); + } + } +} + +static void +hildon_program_set_common_menu_flag (HildonProgram *self, + gboolean common_menu) +{ + HildonProgramPrivate *priv = HILDON_PROGRAM_GET_PRIVATE (self); + + g_slist_foreach (priv->windows, + (GFunc) hildon_program_window_set_common_menu_flag, + GINT_TO_POINTER (common_menu)); +} + /* * Checks if the window is the topmost window of the program and in * that case forces the window to take the common toolbar. @@ -491,6 +517,9 @@ hildon_program_add_window (HildonProgram *self, hildon_window_set_program (window, G_OBJECT (self)); + if (priv->common_menu || priv->common_app_menu) + hildon_program_window_set_common_menu_flag (window, TRUE); + priv->windows = g_slist_append (priv->windows, window); priv->window_count ++; } @@ -528,6 +557,9 @@ hildon_program_remove_window (HildonProgram *self, gdk_window_remove_filter (gdk_get_default_root_window(), hildon_program_root_window_event_filter, self); + + if (priv->common_menu || priv->common_app_menu) + hildon_program_window_set_common_menu_flag (window, FALSE); } /** @@ -623,6 +655,15 @@ hildon_program_set_common_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_menu && menu) { + hildon_program_set_common_menu_flag (self, TRUE); + } else if (priv->common_menu && !menu) { + hildon_program_set_common_menu_flag (self, FALSE); + } + priv->common_menu = menu; if (priv->common_menu) @@ -686,6 +727,15 @@ hildon_program_set_common_app_menu (HildonProgram *self, old_menu = priv->common_app_menu; + /* 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) { + hildon_program_set_common_menu_flag (self, TRUE); + } else if (priv->common_app_menu && !menu) { + hildon_program_set_common_menu_flag (self, FALSE); + } + /* Set new menu */ priv->common_app_menu = menu; if (menu) -- 1.7.9.5