diff options
author | Ted Gould <ted@canonical.com> | 2008-11-12 21:49:27 -0600 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2008-11-12 21:49:27 -0600 |
commit | b63286e253aea5a176439efbc69efae18112528b (patch) | |
tree | 9eb30f3f37fb7705af08bd6a9a78edcc42bc00b7 /src | |
parent | b4b7ab38fd5990567da2713638e8edcd055e3eec (diff) | |
download | libayatana-indicator-b63286e253aea5a176439efbc69efae18112528b.tar.gz libayatana-indicator-b63286e253aea5a176439efbc69efae18112528b.tar.bz2 libayatana-indicator-b63286e253aea5a176439efbc69efae18112528b.zip |
Starting to build functions to handle the menu spec over DBus
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/menu-dbus.c | 56 | ||||
-rw-r--r-- | src/menu-dbus.h | 17 |
3 files changed, 76 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7ba96ff..ab1089d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,7 +17,9 @@ indicator_applet_SOURCES = \ indicator-power.c \ indicator-power.h \ indicator-system.c \ - indicator-system.h + indicator-system.h \ + menu-dbus.c \ + menu-dbus.h indicator_applet_LDADD = \ $(APPLET_LIBS) diff --git a/src/menu-dbus.c b/src/menu-dbus.c new file mode 100644 index 0000000..cb4d531 --- /dev/null +++ b/src/menu-dbus.c @@ -0,0 +1,56 @@ + +#include "menu-dbus.h" + +GtkWidget * +_dbus_menu_make_menuitem_val (DBusGProxy * proxy, guint id) +{ + + + +} + +GtkWidget * +_dbus_menu_make_menuitem_recurse (DBusGProxy * proxy, guint id) +{ + GError * error = NULL; + GArray * items = NULL; + gboolean proxyret; + + /* TODO: switch to begin_call */ + proxyret = dbus_g_proxy_call (proxy, "GetSubmenuItems", &error, + G_TYPE_UINT, id, + G_TYPE_INVALID, + DBUS_TYPE_G_UINT_ARRAY, &items, + G_TYPE_INVALID); + + if (!proxyret) { + /* TODO: clear error */ + return NULL; + } + + GtkWidget * menu = gtk_menu_new(); + gint i; + for (i = 0; i < items->len; i++) { + guint id = g_array_index(items, guint, i); + GtkWidget * item = _dbus_menu_make_menuitem_val(proxy, id); + if (item != NULL) { + gtk_menu_append(menu, item); + gtk_widget_show(item); + } + } + + return menu; +} + +GtkWidget * +dbus_menu_make_menuitem (DBusGConnection * bus, const char * name, const char * object, guint menu_id) +{ + DBusGProxy * iface = dbus_g_proxy_new_for_name_owner (bus, name, object, "com.canonical.menu", NULL); + if (iface == NULL) { + return NULL; + } + + return _dbus_menu_make_menuitem_recurse(iface, menu_id); +} + + diff --git a/src/menu-dbus.h b/src/menu-dbus.h new file mode 100644 index 0000000..3b7ed8e --- /dev/null +++ b/src/menu-dbus.h @@ -0,0 +1,17 @@ + +#ifndef MENU_DBUS_H__SEEN__ +#define MENU_DBUS_H__SEEN__ 1 + +#include <gtk/gtk.h> +#include <dbus/dbus-glib.h> + +#define DBUS_MENU_ROOT_ID (0) + +GtkWidget * dbus_menu_make_menuitem (DBusGConnection * bus, + const char * name, + const char * object, + guint menu_id); + + + +#endif /* MENU_DBUS_H__SEEN__ */ |