From 761cd05f56dd236e787ce7da56740b7e0c6ae399 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Wed, 3 Mar 2010 12:29:28 +0100 Subject: Started to implement about-to-show support --- libdbusmenu-glib/client-menuitem.c | 10 ++++++++++ libdbusmenu-glib/client.c | 30 ++++++++++++++++++++++++++++++ libdbusmenu-glib/client.h | 2 ++ libdbusmenu-glib/dbus-menu.xml | 5 +++++ libdbusmenu-glib/menuitem.c | 14 ++++++++++++++ libdbusmenu-glib/menuitem.h | 6 +++++- libdbusmenu-glib/server.c | 23 +++++++++++++++++++++++ libdbusmenu-gtk/client.c | 9 +++++++++ 8 files changed, 98 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index 5d16a66..f4dd583 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -46,6 +46,7 @@ static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); static void dbusmenu_client_menuitem_dispose (GObject *object); static void dbusmenu_client_menuitem_finalize (GObject *object); static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +static void send_about_to_show (DbusmenuMenuitem * mi); G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM); @@ -61,6 +62,7 @@ dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass) DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); mclass->handle_event = handle_event; + mclass->send_about_to_show = send_about_to_show; return; } @@ -104,3 +106,11 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp); return; } + +static void +send_about_to_show (DbusmenuMenuitem * mi) +{ + DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); + dbusmenu_client_send_about_to_show(priv->client, dbusmenu_menuitem_get_id(mi)); + return; +} diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 309a11c..7cf5a14 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -668,6 +668,36 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name return; } +static void +about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpointer userdata) +{ + DbusmenuClient * client = DBUSMENU_CLIENT(userdata); + if (error != NULL) { + g_warning("Unable to send about_to_show: %s", error->message); + return; + } + + if (need_update) { + update_layout(client); + } + return; +} + +void +dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, client); + /* + FIXME: We should wait until either + - about_to_show_cb has been called and need_update was false + - about_to_show_cb has been called, need_update was true and menu has been + updated + - about_to_show_cb has not been called and we already waited for 10msecs + */ + return; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 3909578..5f1c8d1 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -109,6 +109,8 @@ void dbusmenu_client_send_event (DbusmenuClient * client, const gchar * name, const GValue * value, guint timestamp); +void dbusmenu_client_send_about_to_show(DbusmenuClient * client, + gint id); /** SECTION:client diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 9af78fa..e4f33df 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -265,6 +265,11 @@ License version 3 and version 2.1 along with this program. If not, see + + + + + diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index a2d2682..75dd9aa 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1203,3 +1203,17 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const } return; } +void +dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi) +{ + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + #ifdef MASSIVEDEBUGGING + g_debug("Submenu for menuitem %d (%s) is about to be shown", ID(mi), LABEL(mi)); + #endif + DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); + + if (class->send_about_to_show != NULL) { + return class->send_about_to_show(mi); + } + return; +} diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 1382335..777c3ca 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -95,6 +95,8 @@ struct _DbusmenuMenuitem @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information. + @send_about_to_show: Virtual function that notifies server that the + client is about to show a menu. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. @@ -116,9 +118,10 @@ struct _DbusmenuMenuitemClass /* Virtual functions */ void (*buildxml) (GPtrArray * stringarray); void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); + void (*send_about_to_show) (DbusmenuMenuitem * mi); void (*reserved1) (void); - void (*reserved2) (void); + /* void (*reserved2) (void); */ /* void (*reserved3) (void); */ /* void (*reserved4) (void); -- realized, realloc when bumping lib version */ }; @@ -159,6 +162,7 @@ gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi); /** SECTION:menuitem diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f6dddf1..dd1238b 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -41,6 +41,7 @@ static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint i static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); +static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error); #include "dbusmenu-server.h" @@ -578,6 +579,28 @@ _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValu return TRUE; } +static gboolean +_dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error) +{ + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); + + if (mi == NULL) { + if (error != NULL) { + g_set_error(error, + error_quark(), + INVALID_MENUITEM_ID, + "The ID supplied %d does not refer to a menu item we have", + id); + } + return FALSE; + } + + /* GTK+ does not support about-to-show concept for now */ + *need_update = FALSE; + return TRUE; +} + /* Public Interface */ /** dbusmenu_server_new: diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 781326e..77d971e 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -116,6 +116,14 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) return TRUE; } +/* This is called when submenu gm of menuitem mi gets shown. */ +static gboolean +menu_shown_cb (GtkMenu * gm, DbusmenuMenuitem * mi) +{ + dbusmenu_menuitem_send_about_to_show(mi); + return TRUE; +} + /* Process the visible property */ static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) @@ -323,6 +331,7 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus /* Oh, we don't have a submenu, build one! */ menu = GTK_MENU(gtk_menu_new()); g_object_set_data(G_OBJECT(mi), data_menu, menu); + g_signal_connect(G_OBJECT(menu), "show", G_CALLBACK(menu_shown_cb), mi); GtkMenuItem * parent = dbusmenu_gtkclient_menuitem_get(gtkclient, mi); gtk_menu_item_set_submenu(parent, GTK_WIDGET(menu)); -- cgit v1.2.3 From 64db63dfe4b4bde036c1e2a454288c280f582827 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Wed, 3 Mar 2010 17:26:18 +0100 Subject: Send about_to_show instead of "clicked" when opening a submenu --- libdbusmenu-gtk/client.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 77d971e..4c82f40 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -109,18 +109,14 @@ static const gchar * data_menu = "dbusmenugtk-data-gtkmenu"; static gboolean menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) { - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time()); - return TRUE; -} - -/* This is called when submenu gm of menuitem mi gets shown. */ -static gboolean -menu_shown_cb (GtkMenu * gm, DbusmenuMenuitem * mi) -{ - dbusmenu_menuitem_send_about_to_show(mi); + if (gtk_menu_item_get_submenu(gmi) == NULL) { + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time()); + } else { + dbusmenu_menuitem_send_about_to_show(mi); + } return TRUE; } @@ -331,7 +327,6 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus /* Oh, we don't have a submenu, build one! */ menu = GTK_MENU(gtk_menu_new()); g_object_set_data(G_OBJECT(mi), data_menu, menu); - g_signal_connect(G_OBJECT(menu), "show", G_CALLBACK(menu_shown_cb), mi); GtkMenuItem * parent = dbusmenu_gtkclient_menuitem_get(gtkclient, mi); gtk_menu_item_set_submenu(parent, GTK_WIDGET(menu)); -- cgit v1.2.3 From f3681a09522d6381eef14525eafdc4c467420879 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Wed, 3 Mar 2010 17:27:05 +0100 Subject: Send about_to_show when showing the first-level menu. --- libdbusmenu-gtk/menu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index d2a8620..cdc2287 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -95,6 +95,17 @@ dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass) return; } +static void +menu_focus_cb(DbusmenuGtkMenu * menu, gpointer userdata) +{ + g_debug(__FUNCTION__); + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); + if (priv->client != NULL) { + dbusmenu_client_send_about_to_show(DBUSMENU_CLIENT(priv->client), 0); + } + return; +} + static void dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) { @@ -105,6 +116,8 @@ dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) priv->dbus_object = NULL; priv->dbus_name = NULL; + g_signal_connect(G_OBJECT(self), "focus", G_CALLBACK(menu_focus_cb), self); + return; } -- cgit v1.2.3 From 388a8e335ad01e46bf934036fad62fb0ccbbabf4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Mar 2010 11:20:37 -0500 Subject: releasing version 0.2.7-0ubuntu2~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3a8086d..336f048 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.7-0ubuntu2~ppa1) UNRELEASED; urgency=low +libdbusmenu (0.2.7-0ubuntu2~ppa1) lucid; urgency=low * Upstream Merge * Adding support for blank icons - -- Ted Gould Wed, 24 Mar 2010 11:15:48 -0500 + -- Ted Gould Wed, 24 Mar 2010 11:20:33 -0500 libdbusmenu (0.2.7-0ubuntu1) lucid; urgency=low -- cgit v1.2.3 From 504bca7412c56173e3e5e9fcaf9f231479e88d8a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Mar 2010 12:42:30 -0500 Subject: releasing version 0.2.7-0ubuntu2~ppa2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index fcf8066..485657f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.7-0ubuntu2~ppa2) UNRELEASED; urgency=low +libdbusmenu (0.2.7-0ubuntu2~ppa2) lucid; urgency=low * Upstream Merge * Crash fix in blank items - -- Ted Gould Wed, 24 Mar 2010 12:34:09 -0500 + -- Ted Gould Wed, 24 Mar 2010 12:42:27 -0500 libdbusmenu (0.2.7-0ubuntu2~ppa1) lucid; urgency=low -- cgit v1.2.3 From cc7a0c520d9a3871a3fd844d6c895ecc6f3260bb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 25 Mar 2010 10:12:30 -0500 Subject: releasing version 0.2.8-0ubuntu1~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index f8a13dd..3979ac0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,11 @@ -libdbusmenu (0.2.8-0ubuntu1~ppa1) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu1~ppa1) lucid; urgency=low * Upstream release 0.2.8 * Adding support for blank icons (LP: #534854) * Remove unneeded warning (LP: #537312) * Fix typo in documentation - -- Ted Gould Thu, 25 Mar 2010 10:07:29 -0500 + -- Ted Gould Thu, 25 Mar 2010 10:12:27 -0500 libdbusmenu (0.2.7-0ubuntu1) lucid; urgency=low -- cgit v1.2.3 From 4f9bfdd91ad1ebd0fb8d778a717c9429a6c258c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 00:47:26 -0500 Subject: When the proxies drop, we need to assume we're starting over with revision numbers too. --- libdbusmenu-glib/client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 309a11c..697420f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -444,6 +444,9 @@ proxy_destroyed (GObject * gobj_proxy, gpointer userdata) priv->layoutcall = NULL; } + priv->current_revision = 0; + priv->my_revision = 0; + build_dbus_proxy(DBUSMENU_CLIENT(userdata)); return; } -- cgit v1.2.3 From 4d34ef26ed23a32ba777d1049a6fa6de88750516 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 01:03:44 -0500 Subject: Removing this error. It's reasonable for this to happen, and the correction is that when we DO get the item, we'll ask for all of it's properties. --- libdbusmenu-glib/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 697420f..ae4b2f9 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -337,7 +337,12 @@ id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, D g_return_if_fail(priv->root != NULL); DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); - g_return_if_fail(menuitem != NULL); + if (menuitem == NULL) { + #ifdef MASSIVEDEBUGGING + g_debug("Property update '%s' on id %d which couldn't be found", property, id); + #endif + return; + } dbusmenu_menuitem_property_set_value(menuitem, property, value); -- cgit v1.2.3 From 2f5faa5dfaef3da5c42b5c7494bf30d98ecba992 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 01:05:51 -0500 Subject: releasing version 0.2.8-0ubuntu1~ppa2~crash1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index fc72d48..787c739 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1) lucid; urgency=low * Upstream Merge * Trying to fix stuff. - -- Ted Gould Wed, 31 Mar 2010 01:04:04 -0500 + -- Ted Gould Wed, 31 Mar 2010 01:05:49 -0500 libdbusmenu (0.2.8-0ubuntu1~ppa1) lucid; urgency=low -- cgit v1.2.3 From 69f2190a6e57920e6086013c87cea5cc1734abcb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 08:59:36 -0500 Subject: Unreffing always when updating. --- libdbusmenu-glib/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ae4b2f9..fb2a2bc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -802,13 +802,17 @@ parse_layout (DbusmenuClient * client, const gchar * layout) clean up that old root */ if (oldroot != NULL) { dbusmenu_menuitem_set_root(oldroot, FALSE); - g_object_unref(oldroot); } /* If the root changed we can signal that */ g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); } + /* We need to unref it in this function no matter */ + if (oldroot != NULL) { + g_object_unref(oldroot); + } + return 1; } -- cgit v1.2.3 From 923222aa364e1ed26a1f69e0f128ee4a6a62ddc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 09:01:50 -0500 Subject: releasing version 0.2.8-0ubuntu1~ppa2~crash1ubuntu1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 455121a..b1c691c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1ubuntu1) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1ubuntu1) lucid; urgency=low * Upstream merge * Making an unref more accessible - -- Ted Gould Wed, 31 Mar 2010 08:59:48 -0500 + -- Ted Gould Wed, 31 Mar 2010 09:01:48 -0500 libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1) lucid; urgency=low -- cgit v1.2.3 From 26bb50e3a77b677e839ff4e2d3611e2e001611d6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 09:02:05 -0500 Subject: releasing version 0.2.8-0ubuntu1~ppa2~crash2 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b1c691c..177c097 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdbusmenu (0.2.8-0ubuntu1~ppa2~crash1ubuntu1) lucid; urgency=low +libdbusmenu (0.2.8-0ubuntu1~ppa2~crash2) lucid; urgency=low * Upstream merge * Making an unref more accessible -- cgit v1.2.3 From 85a76718ac641b83bb3a283d5819a3272fdd134c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 11:12:45 -0500 Subject: releasing version 0.2.8-0ubuntu2~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 142d224..dbf72d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,11 @@ -libdbusmenu (0.2.8-0ubuntu2~ppa1) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu2~ppa1) lucid; urgency=low * Upstream merge * Unrefing on layout updates (LP: #545026) * Resetting sync versions on disconnection * Removing useless warning - -- Ted Gould Wed, 31 Mar 2010 11:07:55 -0500 + -- Ted Gould Wed, 31 Mar 2010 11:12:42 -0500 libdbusmenu (0.2.8-0ubuntu1~ppa1) lucid; urgency=low -- cgit v1.2.3 From 75b0bba462e192a32e4484e52d0751852d03df12 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 12:29:20 -0500 Subject: Adding a bunch of comments --- libdbusmenu-glib/client-menuitem.c | 3 +++ libdbusmenu-glib/client.c | 11 ++++++++++- libdbusmenu-glib/dbus-menu.xml | 16 ++++++++++++++-- libdbusmenu-glib/menuitem.c | 10 ++++++++++ libdbusmenu-glib/server.c | 1 + 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index f4dd583..833b28c 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -90,6 +90,7 @@ dbusmenu_client_menuitem_finalize (GObject *object) return; } +/* Creates the item and associates the client */ DbusmenuClientMenuitem * dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client) { @@ -99,6 +100,7 @@ dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client) return mi; } +/* Passes the event signal on through the client. */ static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) { @@ -107,6 +109,7 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g return; } +/* Passes the about to show signal on through the client. */ static void send_about_to_show (DbusmenuMenuitem * mi) { diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7cf5a14..940adad 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -660,6 +660,8 @@ menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) return; } +/* Sends the event over DBus to the server on the other side + of the bus. */ void dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp) { @@ -668,6 +670,8 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name return; } +/* Reports errors and responds to update request that were a result + of sending the about to show signal. */ static void about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpointer userdata) { @@ -683,17 +687,22 @@ about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpoi return; } +/* Sends the about to show signal for a given id to the + server on the other side of DBus */ void dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, client); /* - FIXME: We should wait until either + TODO: We should ideally restrict the displaying of the menu until: + - about_to_show_cb has been called and need_update was false - about_to_show_cb has been called, need_update was true and menu has been updated - about_to_show_cb has not been called and we already waited for 10msecs + + There's not really support in GTK for doing this easily. */ return; } diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index e4f33df..e5b0efb 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -266,8 +266,20 @@ License version 3 and version 2.1 along with this program. If not, see - - + + This is called by the applet to notify the application that it is about + to show the menu under the specified item. + + + + Which menu item represents the parent of the item about to be shown. + + + + + Whether this AboutToShow event should result in the menu being updated. + + diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 75dd9aa..f33da74 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1203,6 +1203,16 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const } return; } + +/** + dbusmenu_menuitem_send_about_to_show: + @mi: The #DbusmenuMenuitem to send the signal on. + + This function is used to send the even that the submenu + of this item is about to be shown. Callers to this event + should delay showing the menu until their callback is + called if possible. +*/ void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi) { diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index dd1238b..d87c024 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -579,6 +579,7 @@ _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValu return TRUE; } +/* Recieve the About To Show function. Pass it to our menu item. */ static gboolean _dbusmenu_server_about_to_show (DbusmenuServer * server, gint id, gboolean * need_update, GError ** error) { -- cgit v1.2.3 From 2033f92976ad4e34f01ebf14d11f2198e7ec5142 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 12:55:21 -0500 Subject: Removing a debug message --- libdbusmenu-gtk/menu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index cdc2287..8a2b318 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -98,7 +98,6 @@ dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass) static void menu_focus_cb(DbusmenuGtkMenu * menu, gpointer userdata) { - g_debug(__FUNCTION__); DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); if (priv->client != NULL) { dbusmenu_client_send_about_to_show(DBUSMENU_CLIENT(priv->client), 0); -- cgit v1.2.3 From cae176681adb2e32464ec690b319008ae04a4a09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 13:47:27 -0500 Subject: Adding a set of callbacks so that we can respond to the about to show request. --- libdbusmenu-glib/client-menuitem.c | 38 ++++++++++++++++++++++++++++++++--- libdbusmenu-glib/client.c | 41 ++++++++++++++++++++++++++------------ libdbusmenu-glib/client.h | 4 +++- libdbusmenu-glib/menuitem.c | 9 +++++++-- libdbusmenu-glib/menuitem.h | 15 ++++++++++++-- 5 files changed, 86 insertions(+), 21 deletions(-) diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index 833b28c..979cf79 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -46,7 +46,7 @@ static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); static void dbusmenu_client_menuitem_dispose (GObject *object); static void dbusmenu_client_menuitem_finalize (GObject *object); static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); -static void send_about_to_show (DbusmenuMenuitem * mi); +static void send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM); @@ -109,11 +109,43 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g return; } +typedef struct _about_to_show_t about_to_show_t; +struct _about_to_show_t { + DbusmenuMenuitem * mi; + dbusmenu_menuitem_about_to_show_cb cb; + gpointer cb_data; +}; + +/* Handles calling the callback that we were called with */ +static void +about_to_show_cb (gpointer user_data) +{ + about_to_show_t * data = (about_to_show_t *)user_data; + + data->cb(data->mi, data->cb_data); + + g_object_unref(data->mi); + g_free(user_data); + return; +} + /* Passes the about to show signal on through the client. */ static void -send_about_to_show (DbusmenuMenuitem * mi) +send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) { DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); - dbusmenu_client_send_about_to_show(priv->client, dbusmenu_menuitem_get_id(mi)); + if (cb == NULL) { + /* Common enough that we don't want to bother + with the allocation */ + dbusmenu_client_send_about_to_show(priv->client, dbusmenu_menuitem_get_id(mi), NULL, NULL); + } else { + about_to_show_t * data = g_new0(about_to_show_t, 1); + data->mi = mi; + data->cb = cb; + data->cb_data = cb_data; + g_object_ref(mi); + + dbusmenu_client_send_about_to_show(priv->client, dbusmenu_menuitem_get_id(mi), about_to_show_cb, data); + } return; } diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 940adad..ef0205f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -670,40 +670,55 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name return; } +typedef struct _about_to_show_t about_to_show_t; +struct _about_to_show_t { + DbusmenuClient * client; + void (*cb) (gpointer data); + gpointer cb_data; +}; + /* Reports errors and responds to update request that were a result of sending the about to show signal. */ static void about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpointer userdata) { - DbusmenuClient * client = DBUSMENU_CLIENT(userdata); + about_to_show_t * data = (about_to_show_t *)userdata; + if (error != NULL) { g_warning("Unable to send about_to_show: %s", error->message); - return; + /* Note: we're just ensuring only the callback gets called */ + need_update = FALSE; } + /* If we need to update, do that first. */ if (need_update) { - update_layout(client); + update_layout(data->client); } + + if (data->cb != NULL) { + data->cb(data->cb_data); + } + + g_object_unref(data->client); + g_free(data); + return; } /* Sends the about to show signal for a given id to the server on the other side of DBus */ void -dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id) +dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)(gpointer data), gpointer cb_data) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, client); - /* - TODO: We should ideally restrict the displaying of the menu until: - - about_to_show_cb has been called and need_update was false - - about_to_show_cb has been called, need_update was true and menu has been - updated - - about_to_show_cb has not been called and we already waited for 10msecs + about_to_show_t * data = g_new0(about_to_show_t, 1); + data->client = client; + data->cb = cb; + data->cb_data = cb_data; + g_object_ref(client); - There's not really support in GTK for doing this easily. - */ + org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, data); return; } diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 5f1c8d1..2b76f5e 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -110,7 +110,9 @@ void dbusmenu_client_send_event (DbusmenuClient * client, const GValue * value, guint timestamp); void dbusmenu_client_send_about_to_show(DbusmenuClient * client, - gint id); + gint id, + void (*cb) (gpointer user_data), + gpointer cb_data); /** SECTION:client diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index f33da74..0186a20 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1207,6 +1207,8 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const /** dbusmenu_menuitem_send_about_to_show: @mi: The #DbusmenuMenuitem to send the signal on. + @cb: Callback to call when the call has returned. + @cb_data: Data to pass to the callback. This function is used to send the even that the submenu of this item is about to be shown. Callers to this event @@ -1214,7 +1216,7 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const called if possible. */ void -dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi) +dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data) { g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); #ifdef MASSIVEDEBUGGING @@ -1223,7 +1225,10 @@ dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi) DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); if (class->send_about_to_show != NULL) { - return class->send_about_to_show(mi); + return class->send_about_to_show(mi, cb, cb_data); + } else if (cb != NULL) { + cb(mi, cb_data); } + return; } diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 777c3ca..0183254 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -82,6 +82,17 @@ struct _DbusmenuMenuitem GObject parent; }; +/** + dbusmenu_menuitem_about_to_show_cb: + @mi Menu item that should be shown + @user_data Extra user data sent with the function + + Callback prototype for a callback that is called when the + menu should be shown. +*/ +typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpointer user_data); + + /** DbusmenuMenuitemClass: @property_changed: Slot for #DbusmenuMenuitem::property-changed. @@ -118,7 +129,7 @@ struct _DbusmenuMenuitemClass /* Virtual functions */ void (*buildxml) (GPtrArray * stringarray); void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); - void (*send_about_to_show) (DbusmenuMenuitem * mi); + void (*send_about_to_show) (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); void (*reserved1) (void); /* void (*reserved2) (void); */ @@ -162,7 +173,7 @@ gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); -void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi); +void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data); /** SECTION:menuitem -- cgit v1.2.3 From 79f8505edd8fd05373275f2835e2400d7611fcf5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 13:49:32 -0500 Subject: Fixing the calls into the about_to_show stuff so that we can add callbacks. --- libdbusmenu-gtk/client.c | 4 +++- libdbusmenu-gtk/menu.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4c82f40..bef27dd 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -115,7 +115,9 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) g_value_set_int(&value, 0); dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time()); } else { - dbusmenu_menuitem_send_about_to_show(mi); + /* TODO: We need to stop the display of the submenu + until this callback returns. */ + dbusmenu_menuitem_send_about_to_show(mi, NULL, NULL); } return TRUE; } diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 8a2b318..103ecfe 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -100,7 +100,9 @@ menu_focus_cb(DbusmenuGtkMenu * menu, gpointer userdata) { DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); if (priv->client != NULL) { - dbusmenu_client_send_about_to_show(DBUSMENU_CLIENT(priv->client), 0); + /* TODO: We should stop the display of the menu + until the about to show call returns. */ + dbusmenu_client_send_about_to_show(DBUSMENU_CLIENT(priv->client), 0, NULL, NULL); } return; } -- cgit v1.2.3 From 8147c935ceef9cbd0dcefee8647b5be9ffc17de9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 14:17:16 -0500 Subject: releasing version 0.2.8-0ubuntu2~ppa2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index dfb1c4d..e274875 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -libdbusmenu (0.2.8-0ubuntu2~ppa2) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu2~ppa2) lucid; urgency=low * Upstream merge * Supporting AboutToShow in event callbacks to catch up with QT implementation. - -- Ted Gould Wed, 31 Mar 2010 14:12:57 -0500 + -- Ted Gould Wed, 31 Mar 2010 14:17:14 -0500 libdbusmenu (0.2.8-0ubuntu2~ppa1) lucid; urgency=low -- cgit v1.2.3 From e5c8d4376b81df6c5c9d96e8bb0ba8650f047859 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 14:47:29 -0500 Subject: Changing the parse function from using take_children to get_children. --- libdbusmenu-glib/client.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 09a663a..f5546a2 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -779,7 +779,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it xmlNodePtr children; guint position; - GList * oldchildren = dbusmenu_menuitem_take_children(item); + GList * oldchildren = g_list_copy(dbusmenu_menuitem_get_children(item)); /* g_debug("Starting old children: %d", g_list_length(oldchildren)); */ for (children = node->children, position = 0; children != NULL; children = children->next, position++) { @@ -800,8 +800,16 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } } - childmi = parse_layout_xml(client, children, childmi, item, proxy); - dbusmenu_menuitem_child_add_position(item, childmi, position); + DbusmenuMenuitem * newchildmi = parse_layout_xml(client, children, childmi, item, proxy); + + if (newchildmi != childmi) { + if (childmi != NULL) { + dbusmenu_menuitem_child_delete(item, childmi); + } + dbusmenu_menuitem_child_add_position(item, newchildmi, position); + } else { + dbusmenu_menuitem_child_reorder(item, childmi, position); + } } /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ @@ -811,7 +819,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it #ifdef MASSIVEDEBUGGING g_debug("Unref'ing menu item with layout update. ID: %d", dbusmenu_menuitem_get_id(oldmi)); #endif - g_object_unref(G_OBJECT(oldmi)); + dbusmenu_menuitem_child_delete(item, oldmi); } g_list_free(oldchildren); -- cgit v1.2.3 From ff4238af178ca889e52234ae37b027cb4defffc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 14:51:18 -0500 Subject: releasing version 0.2.8-0ubuntu2~ppa3~update1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8ab95ac..169fa23 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -libdbusmenu (0.2.8-0ubuntu2~ppa3~update1) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu2~ppa3~update1) lucid; urgency=low * Upstream Merge * Changing the parse function to get_children instead of taking them. - -- Ted Gould Wed, 31 Mar 2010 14:47:54 -0500 + -- Ted Gould Wed, 31 Mar 2010 14:51:16 -0500 libdbusmenu (0.2.8-0ubuntu2~ppa2) lucid; urgency=low -- cgit v1.2.3 From 65bd97a9dfb54716be7797923773e1ad7a33a67c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 31 Mar 2010 17:39:50 -0500 Subject: releasing version 0.2.8-0ubuntu2~ppa3 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1162e20..fa90e88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -libdbusmenu (0.2.8-0ubuntu2~ppa3) UNRELEASED; urgency=low +libdbusmenu (0.2.8-0ubuntu2~ppa3) lucid; urgency=low * Upstream Merge * Changing the parse function to get_children instead of taking them. (LP: #471044) - -- Ted Gould Wed, 31 Mar 2010 17:37:16 -0500 + -- Ted Gould Wed, 31 Mar 2010 17:39:46 -0500 libdbusmenu (0.2.8-0ubuntu2~ppa2) lucid; urgency=low -- cgit v1.2.3