aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Coulson <chrisccoulson@ubuntu.com>2011-03-30 19:58:47 +0100
committerChris Coulson <chrisccoulson@ubuntu.com>2011-03-30 19:58:47 +0100
commit44fb71ec9b70ad3d2dc7bcb6d35e3f6c7e69370e (patch)
tree900c999f07c08b05090dfaad79b337ab53c3e3b7
parent25b78133a2075185fe2d94925f446927c1b85b9a (diff)
downloadlibdbusmenu-44fb71ec9b70ad3d2dc7bcb6d35e3f6c7e69370e.tar.gz
libdbusmenu-44fb71ec9b70ad3d2dc7bcb6d35e3f6c7e69370e.tar.bz2
libdbusmenu-44fb71ec9b70ad3d2dc7bcb6d35e3f6c7e69370e.zip
Remove some code duplication introduced in this branch
-rw-r--r--libdbusmenu-gtk/parser.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index 037c362..e68c286 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -756,15 +756,13 @@ find_menu_label (GtkWidget *widget)
return label;
}
-static gboolean
-recreate_menu_item_in_idle_cb (gpointer data)
+static void
+recreate_menu_item (DbusmenuMenuitem * parent, DbusmenuMenuitem * child)
{
- DbusmenuMenuitem * child = (DbusmenuMenuitem *)data;
- DbusmenuMenuitem * parent = dbusmenu_menuitem_get_parent (child);
- g_object_unref (child);
if (parent == NULL)
{
- return FALSE;
+ /* We need a parent */
+ return;
}
ParserData * pdata = g_object_get_data (G_OBJECT (child), PARSER_DATA);
/* Keep a pointer to the GtkMenuItem, as pdata->widget might be
@@ -779,7 +777,15 @@ recreate_menu_item_in_idle_cb (gpointer data)
recurse.parent = parent;
parse_menu_structure_helper(menuitem, &recurse);
+}
+static gboolean
+recreate_menu_item_in_idle_cb (gpointer data)
+{
+ DbusmenuMenuitem * child = (DbusmenuMenuitem *)data;
+ DbusmenuMenuitem * parent = dbusmenu_menuitem_get_parent (child);
+ g_object_unref (child);
+ recreate_menu_item (parent, child);
return FALSE;
}
@@ -947,14 +953,7 @@ widget_notify_cb (GtkWidget *widget,
* this menuitem for now and then recreate it
*/
DbusmenuMenuitem * parent = dbusmenu_menuitem_get_parent (child);
- dbusmenu_menuitem_child_delete (parent, child);
-
- RecurseContext recurse = {0};
- recurse.toplevel = gtk_widget_get_toplevel(widget);
- recurse.parent = parent;
-
- parse_menu_structure_helper(widget, &recurse);
-
+ recreate_menu_item (parent, child);
return;
}