aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/menu-dbus.c56
-rw-r--r--src/menu-dbus.h17
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__ */