diff options
author | Ted Gould <ted@gould.cx> | 2010-07-20 13:21:14 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-07-20 13:21:14 -0500 |
commit | 871df0f10c49d538d80a405c1420bddf8baff79b (patch) | |
tree | 7316d1226140a975c4837cb723b5174dd2f388e9 | |
parent | 377d286c9b6e4f43c95cb4e615a476b54c869743 (diff) | |
download | libdbusmenu-871df0f10c49d538d80a405c1420bddf8baff79b.tar.gz libdbusmenu-871df0f10c49d538d80a405c1420bddf8baff79b.tar.bz2 libdbusmenu-871df0f10c49d538d80a405c1420bddf8baff79b.zip |
Pulling out the new item code into a function
-rw-r--r-- | libdbusmenu-glib/client.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b59aecd..baa3e93 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1038,6 +1038,36 @@ dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)( return; } +/* Builds a new child with property requests and everything + else to clean up the code a bit */ +static DbusmenuMenuitem * +parse_layout_new_child (gint id, DbusmenuClient * client, DbusmenuMenuitem * parent) +{ + DbusmenuMenuitem * item = NULL; + + /* Build a new item */ + item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client)); + if (parent == NULL) { + dbusmenu_menuitem_set_root(item, TRUE); + } + + /* Get the properties queued up for this item */ + /* Not happy allocating about this, but I need these :( */ + newItemPropData * propdata = g_new0(newItemPropData, 1); + if (propdata != NULL) { + propdata->client = client; + propdata->item = item; + propdata->parent = parent; + + g_object_ref(item); + get_properties_globber(client, id, NULL, menuitem_get_properties_new_cb, propdata); + } else { + g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); + } + + return item; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * @@ -1060,25 +1090,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } /* Build a new item */ - item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client)); - if (parent == NULL) { - dbusmenu_menuitem_set_root(item, TRUE); - } - - /* Get the properties queued up for this item */ - /* Not happy about this, but I need these :( */ - newItemPropData * propdata = g_new0(newItemPropData, 1); - if (propdata != NULL) { - propdata->client = client; - propdata->item = item; - propdata->parent = parent; - - gchar * properties[1] = {NULL}; /* This gets them all */ - g_object_ref(item); - get_properties_globber(client, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); - } else { - g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); - } + item = parse_layout_new_child(id, client, parent); } else { /* Refresh the properties */ /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ |