aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-04-25 14:51:03 -0500
committerTed Gould <ted@gould.cx>2011-04-25 14:51:03 -0500
commita35975270bc24b0f7d26f431c14be2ec054cdce7 (patch)
tree46722ef17258261914a60599491ef4854159f108
parent2c9d70b972291a0502b3e827f13b120e20565989 (diff)
parent565603d992afa03da6a8f485fcdbe8b71677f7db (diff)
downloadlibdbusmenu-a35975270bc24b0f7d26f431c14be2ec054cdce7.tar.gz
libdbusmenu-a35975270bc24b0f7d26f431c14be2ec054cdce7.tar.bz2
libdbusmenu-a35975270bc24b0f7d26f431c14be2ec054cdce7.zip
Merging U. Desktop
-rw-r--r--debian/changelog22
-rw-r--r--libdbusmenu-glib/client.c2
-rw-r--r--libdbusmenu-glib/server.c5
-rw-r--r--libdbusmenu-gtk/parser.c87
4 files changed, 80 insertions, 36 deletions
diff --git a/debian/changelog b/debian/changelog
index c44f3b0..b4feae4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,24 @@
-libdbusmenu (0.4.3-0ubuntu1~ppa1) natty; urgency=low
+libdbusmenu (0.4.3-0ubuntu3) natty; urgency=low
+
+ * Backport bug fixes from trunk:
+ - Fix a typo in the signal name to make it match the XML
+ files (LP: #641209)
+ - Ref'ing the server for the entire time we're getting the
+ bus (LP: #738568)
+
+ -- Ken VanDine <ken.vandine@canonical.com> Tue, 19 Apr 2011 15:14:23 -0400
+
+libdbusmenu (0.4.3-0ubuntu2) natty; urgency=low
+
+ * Backport bug fixes from trunk:
+ - Watch additions/removals from submenus that get added
+ - Activate new toplevel menu items as they get added
+ - Make sure we don't activate toplevel children that aren't
+ menu items or don't have submenus (LP: #761112)
+
+ -- Michael Terry <mterry@ubuntu.com> Fri, 15 Apr 2011 15:55:37 -0400
+
+libdbusmenu (0.4.3-0ubuntu1) natty; urgency=low
[ Ken VanDine ]
* debian/rules
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 2e6b09a..588c940 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -1239,7 +1239,7 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian
} else if (priv->root == NULL) {
/* Drop out here, all the rest of these really need to have a root
node so we can just ignore them if there isn't one. */
- } else if (g_strcmp0(signal, "ItemPropertiesUpdated") == 0) {
+ } else if (g_strcmp0(signal, "ItemsPropertiesUpdated") == 0) {
/* Remove before adding just incase there is a duplicate, against the
rules, but we can handle it so let's do it. */
GVariantIter ritems;
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index a41e6ce..be99421 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -455,6 +455,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
g_return_if_fail(priv->bus_lookup != NULL);
}
+ g_object_ref(obj);
g_bus_get(G_BUS_TYPE_SESSION, priv->bus_lookup, bus_got_cb, obj);
} else {
register_object(DBUSMENU_SERVER(obj));
@@ -694,6 +695,7 @@ bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data)
if (error != NULL) {
g_warning("Unable to get session bus: %s", error->message);
g_error_free(error);
+ g_object_unref(G_OBJECT(user_data));
return;
}
@@ -706,6 +708,7 @@ bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data)
register_object(DBUSMENU_SERVER(user_data));
+ g_object_unref(G_OBJECT(user_data));
return;
}
@@ -983,7 +986,7 @@ menuitem_property_idle (gpointer user_data)
NULL,
priv->dbusobject,
DBUSMENU_INTERFACE,
- "ItemPropertiesUpdated",
+ "ItemsPropertiesUpdated",
g_variant_new_tuple(megadata, 2),
NULL);
} else {
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index 4972856..4708a64 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -271,6 +271,50 @@ new_menuitem (GtkWidget * widget)
}
static void
+watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu)
+{
+ ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA);
+
+ pdata->shell = menu;
+ g_signal_connect (G_OBJECT (menu),
+ "child-added",
+ G_CALLBACK (child_added_cb),
+ mi);
+ g_signal_connect (G_OBJECT (menu),
+ "child-removed",
+ G_CALLBACK (child_removed_cb),
+ mi);
+ g_object_add_weak_pointer(G_OBJECT (menu), (gpointer*)&pdata->shell);
+}
+
+static void
+activate_toplevel_item (GtkWidget * item)
+{
+ /* Make sure that we have a menu item before we start calling
+ functions that depend on it. This should almost always be
+ the case. */
+ if (!GTK_IS_MENU_ITEM(item)) {
+ return;
+ }
+
+ /* If the item is not opening a submenu we don't want to activate
+ it as that'd cause an action. Like opening a preferences dialog
+ to the user. That's not a good idea. */
+ if (gtk_menu_item_get_submenu(GTK_MENU_ITEM(item)) == NULL) {
+ return;
+ }
+
+ GtkWidget * shell = gtk_widget_get_parent (item);
+ if (!GTK_IS_MENU_BAR (shell)) {
+ return;
+ }
+
+ gtk_menu_shell_activate_item (GTK_MENU_SHELL (shell),
+ item,
+ TRUE);
+}
+
+static void
parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse)
{
/* If this is a shell, then let's handle the items in it. */
@@ -286,33 +330,14 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse)
* Note that this will not force menuitems in submenus to be updated as well.
*/
if (recurse->parent == NULL && GTK_IS_MENU_BAR(widget)) {
- GList *children = gtk_container_get_children (GTK_CONTAINER (widget));
- GList *iter;
-
- for (iter = children; iter != NULL; iter = iter->next) {
- gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget),
- iter->data,
- TRUE);
- }
-
- g_list_free (children);
+ gtk_container_foreach (GTK_CONTAINER (widget),
+ (GtkCallback)activate_toplevel_item,
+ NULL);
}
if (recurse->parent == NULL) {
recurse->parent = new_menuitem(widget);
-
- ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(recurse->parent), PARSER_DATA);
-
- pdata->shell = widget;
- g_signal_connect (G_OBJECT (widget),
- "child-added",
- G_CALLBACK (child_added_cb),
- recurse->parent);
- g_signal_connect (G_OBJECT (widget),
- "child-removed",
- G_CALLBACK (child_removed_cb),
- recurse->parent);
- g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->shell);
+ watch_submenu(recurse->parent, widget);
}
gtk_container_foreach (GTK_CONTAINER (widget),
@@ -561,16 +586,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
GtkWidget *submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
if (submenu)
{
- pdata->shell = submenu;
- g_signal_connect (G_OBJECT (submenu),
- "child-added",
- G_CALLBACK (child_added_cb),
- mi);
- g_signal_connect (G_OBJECT (submenu),
- "child-removed",
- G_CALLBACK (child_removed_cb),
- mi);
- g_object_add_weak_pointer(G_OBJECT(submenu), (gpointer*)&pdata->shell);
+ watch_submenu(mi, submenu);
}
if (!g_object_get_data (G_OBJECT (widget), "gtk-empty-menu-item") && !GTK_IS_TEAROFF_MENU_ITEM (widget))
@@ -1077,6 +1093,7 @@ widget_notify_cb (GtkWidget *widget,
if (item != NULL) {
GtkWidget * menu = GTK_WIDGET (g_value_get_object (&prop_value));
parse_menu_structure_helper(menu, &recurse);
+ watch_submenu(item, menu);
} else {
/* Note: it would be really odd that we wouldn't have a cached
item, but we should handle that appropriately. */
@@ -1106,6 +1123,10 @@ child_added_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)
recurse.toplevel = gtk_widget_get_toplevel(GTK_WIDGET(menu));
recurse.parent = menuitem;
+ if (GTK_IS_MENU_BAR(menu)) {
+ activate_toplevel_item (widget);
+ }
+
parse_menu_structure_helper(widget, &recurse);
}