diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2009-09-10 12:48:37 +0300 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2009-09-11 19:59:32 +0300 |
commit | 7089e90e6ba75e15ebf3734ee8887e21cd6d3c39 (patch) | |
tree | ab82bdcc37b8e8af3ea38a0428ba4103aa6c66f5 | |
parent | 26e0010415f12aaf84a6cdcf993a7345596b3c37 (diff) |
Add hildon_app_menu_has_visible_children() private method
* hildon/hildon-app-menu-private.h: Add below private method.
* hildon/hildon-app-menu.c: (hildon_app_menu_has_visible_children):
New method to check the visibility of a HildonAppMenu children.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | hildon/hildon-app-menu-private.h | 3 | ||||
-rw-r--r-- | hildon/hildon-app-menu.c | 46 |
3 files changed, 43 insertions, 14 deletions
@@ -1,3 +1,11 @@ +2009-09-10 Claudio Saavedra <csaavedra@igalia.com> + + Add hildon_app_menu_has_visible_children() private method + + * hildon/hildon-app-menu-private.h: Add below private method. + * hildon/hildon-app-menu.c: (hildon_app_menu_has_visible_children): + New method to check the visibility of a HildonAppMenu children. + 2009-09-09 Claudio Saavedra <csaavedra@igalia.com> Set the window menu flag for application-common menus diff --git a/hildon/hildon-app-menu-private.h b/hildon/hildon-app-menu-private.h index 9ca1a30..0588b50 100644 --- a/hildon/hildon-app-menu-private.h +++ b/hildon/hildon-app-menu-private.h @@ -50,6 +50,9 @@ hildon_app_menu_set_parent_window (HildonAppMenu *self, gpointer G_GNUC_INTERNAL hildon_app_menu_get_parent_window (HildonAppMenu *self); +gboolean G_GNUC_INTERNAL +hildon_app_menu_has_visible_children (HildonAppMenu *menu); + G_END_DECLS #endif /* __HILDON_APP_MENU_PRIVATE_H__ */ diff --git a/hildon/hildon-app-menu.c b/hildon/hildon-app-menu.c index 73ab87d..243c173 100644 --- a/hildon/hildon-app-menu.c +++ b/hildon/hildon-app-menu.c @@ -803,6 +803,37 @@ hildon_app_menu_repack_items (HildonAppMenu *menu, } /** + * hildon_app_menu_has_visible_children: + * @menu: a #HildonAppMenu + * + * Returns whether this menu has any visible items + * and/or filters. If this is %FALSE, the menu will + * not be popped up. + * + * Returns: whether there are visible items or filters + * + * Since: 2.2 + **/ +gboolean +hildon_app_menu_has_visible_children (HildonAppMenu *menu) +{ + HildonAppMenuPrivate *priv; + GList *i; + gboolean show_menu = FALSE; + + priv = HILDON_APP_MENU_GET_PRIVATE (menu); + + /* Don't show menu if it doesn't contain visible items */ + for (i = priv->buttons; i && !show_menu; i = i->next) + show_menu = GTK_WIDGET_VISIBLE (i->data); + + for (i = priv->filters; i && !show_menu; i = i->next) + show_menu = GTK_WIDGET_VISIBLE (i->data); + + return show_menu; +} + +/** * hildon_app_menu_popup: * @menu: a #HildonAppMenu * @parent_window: a #GtkWindow @@ -816,23 +847,10 @@ void hildon_app_menu_popup (HildonAppMenu *menu, GtkWindow *parent_window) { - HildonAppMenuPrivate *priv; - gboolean show_menu = FALSE; - GList *i; - g_return_if_fail (HILDON_IS_APP_MENU (menu)); g_return_if_fail (GTK_IS_WINDOW (parent_window)); - priv = HILDON_APP_MENU_GET_PRIVATE (menu); - - /* Don't show menu if it doesn't contain visible items */ - for (i = priv->buttons; i && !show_menu; i = i->next) - show_menu = GTK_WIDGET_VISIBLE (i->data); - - for (i = priv->filters; i && !show_menu; i = i->next) - show_menu = GTK_WIDGET_VISIBLE (i->data); - - if (show_menu) { + if (hildon_app_menu_has_visible_children (menu)) { hildon_app_menu_set_parent_window (menu, parent_window); gtk_widget_show (GTK_WIDGET (menu)); } |