aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-gtk/menu.c')
-rw-r--r--libdbusmenu-gtk/menu.c114
1 files changed, 6 insertions, 108 deletions
diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c
index 4074947..4b88f67 100644
--- a/libdbusmenu-gtk/menu.c
+++ b/libdbusmenu-gtk/menu.c
@@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "menu.h"
#include "libdbusmenu-glib/client.h"
+#include "client.h"
/* Properties */
enum {
@@ -45,7 +46,7 @@ enum {
/* Private */
typedef struct _DbusmenuGtkMenuPrivate DbusmenuGtkMenuPrivate;
struct _DbusmenuGtkMenuPrivate {
- DbusmenuClient * client;
+ DbusmenuGtkClient * client;
gchar * dbus_object;
gchar * dbus_name;
@@ -183,114 +184,11 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
/* Internal Functions */
-static const gchar * data_menuitem = "dbusmenugtk-data-gtkmenuitem";
-static const gchar * data_menu = "dbusmenugtk-data-gtkmenu";
-
-static gboolean
-menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi)
-{
- dbusmenu_menuitem_activate(mi);
- return TRUE;
-}
-
-static void
-menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi)
-{
- if (!g_strcmp0(prop, "label")) {
- gtk_menu_item_set_label(gmi, value);
- gtk_widget_show(GTK_WIDGET(gmi));
- }
-
- return;
-}
-
-static void
-destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem)
-{
- /* g_debug("DbusmenuMenuitem was destroyed"); */
- gtk_widget_destroy(GTK_WIDGET(udata));
- return;
-}
-
-static void
-connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi)
-{
- g_object_set_data(G_OBJECT(mi), data_menuitem, gmi);
-
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi);
- g_signal_connect(G_OBJECT(gmi), "activate", G_CALLBACK(menu_pressed_cb), mi);
-
- g_object_weak_ref(G_OBJECT(mi), destoryed_dbusmenuitem_cb, gmi);
-
- return;
-}
-
static void
-process_dbusmenu_menuitem (DbusmenuMenuitem * mi, GtkMenu * parentmenu)
-{
- gpointer unknown_menuitem = g_object_get_data(G_OBJECT(mi), data_menuitem);
- if (unknown_menuitem == NULL) {
- /* Oh, a virgin DbusmenuMenuitem, let's fix that. */
- GtkWidget * menuitem = gtk_menu_item_new();
- connect_menuitem(mi, GTK_MENU_ITEM(menuitem));
- unknown_menuitem = menuitem;
- gtk_menu_shell_append(GTK_MENU_SHELL(parentmenu), menuitem);
- }
-
- GList * children = dbusmenu_menuitem_get_children(mi);
- if (children == NULL) {
- /* If there are no children to process we are
- done and we can move along */
- return;
- }
-
- /* Phase 0: Make a submenu if we don't have one */
- gpointer unknown_menu = g_object_get_data(G_OBJECT(mi), data_menu);
- if (unknown_menu == NULL) {
- GtkWidget * gtkmenu = gtk_menu_new();
- g_object_ref(gtkmenu);
- g_object_set_data_full(G_OBJECT(mi), data_menu, gtkmenu, g_object_unref);
- unknown_menu = gtkmenu;
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(unknown_menuitem), gtkmenu);
- gtk_widget_show(gtkmenu);
- }
-
- /* Phase 1: Add missing children */
- GList * child = NULL;
- for (child = children; child != NULL; child = g_list_next(child)) {
- process_dbusmenu_menuitem(DBUSMENU_MENUITEM(child->data), GTK_MENU(unknown_menu));
- }
-
- /* Phase 2: Delete removed children */
- /* Actually, we don't need to do this because of the weak
- reference that we've added above. When the DbusmenuMenuitem
- gets destroyed it takes its GtkMenuItem with it. Bye bye. */
-
- /* Phase 3: Profit! */
- return;
+root_changed (void) {
+ /* stub */
}
-/* Processing the layout being updated and handling
- that and making it into a menu */
-static void
-process_layout_change (DbusmenuClient * client, DbusmenuGtkMenu * gtkmenu)
-{
- DbusmenuMenuitem * root = dbusmenu_client_get_root(client);
-
- GList * children = dbusmenu_menuitem_get_children(root);
- if (children == NULL) {
- return;
- }
-
- GList * child = NULL;
- for (child = children; child != NULL; child = g_list_next(child)) {
- process_dbusmenu_menuitem(DBUSMENU_MENUITEM(child->data), GTK_MENU(gtkmenu));
- }
-
- return;
-}
-
-
/* Builds the client and connects all of the signals
up for it so that it's happy-happy */
static void
@@ -299,11 +197,11 @@ build_client (DbusmenuGtkMenu * self)
DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(self);
if (priv->client == NULL) {
- priv->client = dbusmenu_client_new(priv->dbus_name, priv->dbus_object);
+ priv->client = dbusmenu_gtkclient_new(priv->dbus_name, priv->dbus_object);
/* Register for layout changes, this should come after the
creation of the client pulls it from DBus */
- g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(process_layout_change), self);
+ g_signal_connect(G_OBJECT(priv->client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), self);
}
return;