From 09cb60267e5a4773ec5965e7e1a2ff92a690d7f0 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Mon, 13 Dec 2010 16:51:45 +0000 Subject: Add an about-to-show signal to the menu items and hook this up to be emitted when someone calls dbusmenu_menuitem_send_about_to_show --- libdbusmenu-glib/menuitem.c | 19 ++++++++++++++++++- libdbusmenu-glib/menuitem.h | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ad6472b..747cc01 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -70,6 +70,7 @@ enum { CHILD_MOVED, REALIZED, SHOW_TO_USER, + ABOUT_TO_SHOW, LAST_SIGNAL }; @@ -229,6 +230,21 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE); + /** + DbusmenuMenuitem::about-to-show: + @arg0: The #DbusmenuMenuitem object. + + Emitted when the submenu for this item + is about to be shown + */ + signals[ABOUT_TO_SHOW] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuMenuitemClass, about_to_show), + NULL, NULL, + _dbusmenu_menuitem_marshal_VOID__VOID, + G_TYPE_BOOLEAN, 0, G_TYPE_NONE); + g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", "This is a unique indentifier for the menu item.", @@ -398,7 +414,8 @@ send_about_to_show (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gp if (dbusmenu_menuitem_get_children(mi) == NULL) { g_warning("About to Show called on an item wihtout submenus. We're ignoring it."); } else { - g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, 0 /* timestamp */, TRUE); + gboolean dummy; + g_signal_emit(G_OBJECT(mi), signals[ABOUT_TO_SHOW], 0, &dummy); } if (cb != NULL) { diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 9158f3e..0058ded 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_SIGNAL_REALIZED "realized" #define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM)) #define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user" +#define DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW "about-to-show" #define DBUSMENU_MENUITEM_PROP_TYPE "type" #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" @@ -158,6 +159,7 @@ struct _DbusmenuMenuitemClass void (*send_about_to_show) (DbusmenuMenuitem * mi, void (*cb) (DbusmenuMenuitem * mi, gpointer user_data), gpointer cb_data); void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data); + gboolean (*about_to_show) (void); /*< Private >*/ void (*reserved1) (void); @@ -165,7 +167,6 @@ struct _DbusmenuMenuitemClass void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); - void (*reserved6) (void); }; GType dbusmenu_menuitem_get_type (void); -- cgit v1.2.3