diff options
author | Ted Gould <ted@gould.cx> | 2011-01-27 13:54:18 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-01-27 13:54:18 -0600 |
commit | b41b9f202bcae24d256c1a4a9dd044e9e21b984f (patch) | |
tree | 55a19709b6e24f2540cea02318133d63c939ce0b /libdbusmenu-gtk | |
parent | 4669e1cc14ab1a6709415d0cc61afa9e5d92cff4 (diff) | |
parent | 07666d7543bfce7fe925c15d3350519fd711a8f0 (diff) | |
download | libdbusmenu-b41b9f202bcae24d256c1a4a9dd044e9e21b984f.tar.gz libdbusmenu-b41b9f202bcae24d256c1a4a9dd044e9e21b984f.tar.bz2 libdbusmenu-b41b9f202bcae24d256c1a4a9dd044e9e21b984f.zip |
Making the parser recognize when it hits serializable menu items
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/parser.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index ead653a..5d71585 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" @@ -221,13 +222,23 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) return; } +/* 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_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)) @@ -360,11 +371,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 |