aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/parser.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-25 16:51:31 -0600
committerTed Gould <ted@gould.cx>2011-01-25 16:51:31 -0600
commit275bd0eec2e28b708ff6cda14531f63a8aa16e8e (patch)
tree555f90312c856e83b6ec2ec98f1e1c2d0a6d8444 /libdbusmenu-gtk/parser.c
parentc8190bb47d41524c0a22acf4131cf8254824f24b (diff)
downloadlibdbusmenu-275bd0eec2e28b708ff6cda14531f63a8aa16e8e.tar.gz
libdbusmenu-275bd0eec2e28b708ff6cda14531f63a8aa16e8e.tar.bz2
libdbusmenu-275bd0eec2e28b708ff6cda14531f63a8aa16e8e.zip
Looking for the serializable menu item and using it's build function if it is one.
Diffstat (limited to 'libdbusmenu-gtk/parser.c')
-rw-r--r--libdbusmenu-gtk/parser.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index d26f8fb..6d95f10 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -28,6 +28,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "parser.h"
#include "menuitem.h"
+#include "serializablemenuitem.h"
#define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item"
@@ -240,13 +241,23 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse)
}
}
+/* Turn a widget into a dbusmenu item depending on the type of GTK
+ object that it is. */
static DbusmenuMenuitem *
construct_dbusmenu_for_widget (GtkWidget * widget)
{
- DbusmenuMenuitem *mi = dbusmenu_menuitem_new ();
-
+ /* If it's a subclass of our serializable menu item then we can
+ use its own build function */
+ if (DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(widget)) {
+ DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(widget);
+ return dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem(smi);
+ }
+
+ /* If it's a standard GTK Menu Item we need to do some of our own work */
if (GTK_IS_MENU_ITEM (widget))
{
+ DbusmenuMenuitem *mi = dbusmenu_menuitem_new ();
+
gboolean visible = FALSE;
gboolean sensitive = FALSE;
if (GTK_IS_SEPARATOR_MENU_ITEM (widget))
@@ -379,11 +390,12 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
"notify",
G_CALLBACK (widget_notify_cb),
mi);
+ return mi;
}
- return mi;
-
- return NULL;
+ /* If it's none of those we're going to just create a
+ generic menuitem as a place holder for it. */
+ return dbusmenu_menuitem_new();
}
static void