2 * Copyright © 2011 Canonical Ltd.
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * licence, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * Author: Ryan Lortie <desrt@desrt.ca>
22 #include "gdbusmenumodel.h"
24 #include "gmenumodel.h"
29 * SECTION:gdbusmenumodel
30 * @title: GDBusMenuModel
31 * @short_description: A D-Bus GMenuModel implementation
32 * @see_also: <link linkend="gio-GMenuModel-exporter">GMenuModel Exporter</link>
34 * #GDBusMenuModel is an implementation of #GMenuModel that can be used
35 * as a proxy for a menu model that is exported over D-Bus with
36 * g_dbus_connection_export_menu_model().
40 * There are 3 main (quasi-)classes involved here:
46 * Each of these classes exists as a parameterised singleton keyed to a
49 * - GDBusMenuPath represents a D-Bus object path on a particular
50 * unique bus name on a particular GDBusConnection and in a
51 * particular GMainContext.
53 * - GDBusMenuGroup represents a particular group on a particular
56 * - GDBusMenuModel represents a particular menu within a particular
59 * There are also two (and a half) utility structs:
61 * - PathIdentifier and ConstPathIdentifier
62 * - GDBusMenuModelItem
64 * PathIdentifier is the 4-tuple of (GMainContext, GDBusConnection,
65 * unique name, object path) that uniquely identifies a particular
66 * GDBusMenuPath. It holds ownership on each of these things, so we
67 * have a ConstPathIdentifier variant that does not.
69 * We have a 3-level hierarchy of hashtables:
71 * - a global hashtable (g_dbus_menu_paths) maps from PathIdentifier
74 * - each GDBusMenuPath has a hashtable mapping from guint (group
75 * number) to GDBusMenuGroup
77 * - each GDBusMenuGroup has a hashtable mapping from guint (menu
78 * number) to GDBusMenuModel.
80 * In this way, each quintuplet of (connection, bus name, object path,
81 * group id, menu id) maps to a single GDBusMenuModel instance that can be
82 * located via 3 hashtable lookups.
84 * All of the 3 classes are refcounted (GDBusMenuPath and
85 * GDBusMenuGroup manually, and GDBusMenuModel by virtue of being a
86 * GObject). The hashtables do not hold references -- rather, when the
87 * last reference is dropped, the object is removed from the hashtable.
89 * The hard references go in the other direction: GDBusMenuModel is created
90 * as the user requests it and only exists as long as the user holds a
91 * reference on it. GDBusMenuModel holds a reference on the GDBusMenuGroup
92 * from which it came. GDBusMenuGroup holds a reference on
95 * In addition to refcounts, each object has an 'active' variable (ints
96 * for GDBusMenuPath and GDBusMenuGroup, boolean for GDBusMenuModel).
98 * - GDBusMenuModel is inactive when created and becomes active only when
99 * first queried for information. This prevents extra work from
100 * happening just by someone acquiring a GDBusMenuModel (and not
101 * actually trying to display it yet).
103 * - The active count on GDBusMenuGroup is equal to the number of
104 * GDBusMenuModel instances in that group that are active. When the
105 * active count transitions from 0 to 1, the group calls the 'Start'
106 * method on the service to begin monitoring that group. When it
107 * drops from 1 to 0, the group calls the 'End' method to stop
110 * - The active count on GDBusMenuPath is equal to the number of
111 * GDBusMenuGroup instances on that path with a non-zero active
112 * count. When the active count transitions from 0 to 1, the path
113 * sets up a signal subscription to monitor any changes. The signal
114 * subscription is taken down when the active count transitions from
117 * When active, GDBusMenuPath gets incoming signals when changes occur.
118 * If the change signal mentions a group for which we currently have an
119 * active GDBusMenuGroup, the change signal is passed along to that
120 * group. If the group is inactive, the change signal is ignored.
122 * Most of the "work" occurs in GDBusMenuGroup. In addition to the
123 * hashtable of GDBusMenuModel instances, it keeps a hashtable of the actual
124 * menu contents, each encoded as GSequence of GDBusMenuModelItem. It
125 * initially populates this table with the results of the "Start" method
126 * call and then updates it according to incoming change signals. If
127 * the change signal mentions a menu for which we current have an active
128 * GDBusMenuModel, the change signal is passed along to that model. If the
129 * model is inactive, the change signal is ignored.
131 * GDBusMenuModelItem is just a pair of hashtables, one for the attributes
132 * and one for the links of the item. Both map strings to GVariant
133 * instances. In the case of links, the GVariant has type '(uu)' and is
134 * turned into a GDBusMenuModel at the point that the user pulls it through
137 * Following the "empty is the same as non-existent" rule, the hashtable
138 * of GSequence of GDBusMenuModelItem holds NULL for empty menus.
140 * GDBusMenuModel contains very little functionality of its own. It holds a
141 * (weak) reference to the GSequence of GDBusMenuModelItem contained in the
142 * GDBusMenuGroup. It uses this GSequence to implement the GMenuModel
143 * interface. It also emits the "items-changed" signal if it is active
144 * and it was told that the contents of the GSequence changed.
147 typedef struct _GDBusMenuGroup GDBusMenuGroup;
148 typedef struct _GDBusMenuPath GDBusMenuPath;
150 static void g_dbus_menu_group_changed (GDBusMenuGroup *group,
155 static void g_dbus_menu_model_changed (GDBusMenuModel *proxy,
160 static GDBusMenuGroup * g_dbus_menu_group_get_from_path (GDBusMenuPath *path,
162 static GDBusMenuModel * g_dbus_menu_model_get_from_group (GDBusMenuGroup *group,
165 /* PathIdentifier {{{1 */
168 GMainContext *context;
169 GDBusConnection *connection;
176 GMainContext *context;
177 GDBusConnection *connection;
178 const gchar *bus_name;
179 const gchar *object_path;
180 } ConstPathIdentifier;
183 path_identifier_hash (gconstpointer data)
185 ConstPathIdentifier *id = data;
187 return g_str_hash (id->object_path);
191 path_identifier_equal (gconstpointer a,
194 ConstPathIdentifier *id_a = a;
195 ConstPathIdentifier *id_b = b;
197 return id_a->connection == id_b->connection &&
198 g_str_equal (id_a->bus_name, id_b->bus_name) &&
199 g_str_equal (id_a->object_path, id_b->object_path);
203 path_identifier_free (PathIdentifier *id)
205 g_main_context_unref (id->context);
206 g_object_unref (id->connection);
207 g_free (id->bus_name);
208 g_free (id->object_path);
210 g_slice_free (PathIdentifier, id);
213 static PathIdentifier *
214 path_identifier_new (ConstPathIdentifier *cid)
218 id = g_slice_new (PathIdentifier);
219 id->context = g_main_context_ref (cid->context);
220 id->connection = g_object_ref (cid->connection);
221 id->bus_name = g_strdup (cid->bus_name);
222 id->object_path = g_strdup (cid->object_path);
227 /* GDBusMenuPath {{{1 */
229 struct _GDBusMenuPath
239 static GHashTable *g_dbus_menu_paths;
241 static GDBusMenuPath *
242 g_dbus_menu_path_ref (GDBusMenuPath *path)
250 g_dbus_menu_path_unref (GDBusMenuPath *path)
252 if (--path->ref_count == 0)
254 g_hash_table_remove (g_dbus_menu_paths, path->id);
255 g_hash_table_unref (path->groups);
256 path_identifier_free (path->id);
258 g_slice_free (GDBusMenuPath, path);
263 g_dbus_menu_path_signal (GDBusConnection *connection,
264 const gchar *sender_name,
265 const gchar *object_path,
266 const gchar *interface_name,
267 const gchar *signal_name,
268 GVariant *parameters,
271 GDBusMenuPath *path = user_data;
279 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a(uuuuaa{sv}))")))
282 g_variant_get (parameters, "(a(uuuuaa{sv}))", &iter);
283 while (g_variant_iter_loop (iter, "(uuuu@aa{sv})", &group_id, &menu_id, &position, &removes, &adds))
285 GDBusMenuGroup *group;
287 group = g_hash_table_lookup (path->groups, GINT_TO_POINTER (group_id));
290 g_dbus_menu_group_changed (group, menu_id, position, removes, adds);
292 g_variant_iter_free (iter);
296 g_dbus_menu_path_activate (GDBusMenuPath *path)
298 if (path->active++ == 0)
299 path->watch_id = g_dbus_connection_signal_subscribe (path->id->connection, path->id->bus_name,
300 "org.gtk.Menus", "Changed", path->id->object_path,
301 NULL, G_DBUS_SIGNAL_FLAGS_NONE,
302 g_dbus_menu_path_signal, path, NULL);
306 g_dbus_menu_path_deactivate (GDBusMenuPath *path)
308 if (--path->active == 0)
309 g_dbus_connection_signal_unsubscribe (path->id->connection, path->watch_id);
312 static GDBusMenuPath *
313 g_dbus_menu_path_get (GMainContext *context,
314 GDBusConnection *connection,
315 const gchar *bus_name,
316 const gchar *object_path)
318 ConstPathIdentifier cid = { context, connection, bus_name, object_path };
321 if (g_dbus_menu_paths == NULL)
322 g_dbus_menu_paths = g_hash_table_new (path_identifier_hash, path_identifier_equal);
324 path = g_hash_table_lookup (g_dbus_menu_paths, &cid);
328 path = g_slice_new (GDBusMenuPath);
329 path->id = path_identifier_new (&cid);
330 path->groups = g_hash_table_new (NULL, NULL);
334 g_hash_table_insert (g_dbus_menu_paths, path->id, path);
337 return g_dbus_menu_path_ref (path);
340 /* GDBusMenuGroup, GDBusMenuModelItem {{{1 */
348 struct _GDBusMenuGroup
353 GHashTable *proxies; /* uint -> unowned GDBusMenuModel */
354 GHashTable *menus; /* uint -> owned GSequence */
362 GHashTable *attributes;
364 } GDBusMenuModelItem;
366 static GDBusMenuGroup *
367 g_dbus_menu_group_ref (GDBusMenuGroup *group)
375 g_dbus_menu_group_unref (GDBusMenuGroup *group)
377 if (--group->ref_count == 0)
379 g_assert (group->state == GROUP_OFFLINE);
380 g_assert (group->active == 0);
382 g_hash_table_remove (group->path->groups, GINT_TO_POINTER (group->id));
383 g_hash_table_unref (group->proxies);
384 g_hash_table_unref (group->menus);
386 g_dbus_menu_path_unref (group->path);
388 g_slice_free (GDBusMenuGroup, group);
393 g_dbus_menu_model_item_free (gpointer data)
395 GDBusMenuModelItem *item = data;
397 g_hash_table_unref (item->attributes);
398 g_hash_table_unref (item->links);
400 g_slice_free (GDBusMenuModelItem, item);
403 static GDBusMenuModelItem *
404 g_dbus_menu_group_create_item (GVariant *description)
406 GDBusMenuModelItem *item;
411 item = g_slice_new (GDBusMenuModelItem);
412 item->attributes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
413 item->links = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
415 g_variant_iter_init (&iter, description);
416 while (g_variant_iter_loop (&iter, "{&sv}", &key, &value))
418 /* key + 1 to skip the ':' */
419 g_hash_table_insert (item->links, g_strdup (key + 1), g_variant_ref (value));
421 g_hash_table_insert (item->attributes, g_strdup (key), g_variant_ref (value));
427 * GDBusMenuGroup can be in three states:
429 * OFFLINE: not subscribed to this group
430 * PENDING: we made the call to subscribe to this group, but the result
431 * has not come back yet
432 * ONLINE: we are fully subscribed
434 * We can get into some nasty situations where we make a call due to an
435 * activation request but receive a deactivation request before the call
436 * returns. If another activation request occurs then we could risk
437 * sending a Start request even though one is already in progress. For
438 * this reason, we have to carefully consider what to do in each of the
439 * three states for each of the following situations:
441 * - activation requested
442 * - deactivation requested
443 * - Start call finishes
445 * To simplify things a bit, we do not have a callback for the Stop
446 * call. We just send it and assume that it takes effect immediately.
448 * Activation requested:
449 * OFFLINE: make the Start call and transition to PENDING
450 * PENDING: do nothing -- call is already in progress.
451 * ONLINE: this should not be possible
453 * Deactivation requested:
454 * OFFLINE: this should not be possible
455 * PENDING: do nothing -- handle it when the Start call finishes
456 * ONLINE: send the Stop call and move to OFFLINE immediately
458 * Start call finishes:
459 * OFFLINE: this should not be possible
461 * If we should be active (ie: active count > 0): move to ONLINE
462 * If not: send Stop call and move to OFFLINE immediately
463 * ONLINE: this should not be possible
465 * We have to take care with regards to signal subscriptions (ie:
466 * activation of the GDBusMenuPath). The signal subscription is always
467 * established when transitioning from OFFLINE to PENDING and taken down
468 * when transitioning to OFFLINE (from either PENDING or ONLINE).
470 * Since there are two places where we transition to OFFLINE, we split
471 * that code out into a separate function.
474 g_dbus_menu_group_go_offline (GDBusMenuGroup *group)
476 g_dbus_menu_path_deactivate (group->path);
477 g_dbus_connection_call (group->path->id->connection,
478 group->path->id->bus_name,
479 group->path->id->object_path,
480 "org.gtk.Menus", "End",
481 g_variant_new_parsed ("([ %u ],)", group->id),
482 NULL, G_DBUS_CALL_FLAGS_NONE, -1,
484 group->state = GROUP_OFFLINE;
489 g_dbus_menu_group_start_ready (GObject *source_object,
490 GAsyncResult *result,
493 GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
494 GDBusMenuGroup *group = user_data;
497 g_assert (group->state == GROUP_PENDING);
499 reply = g_dbus_connection_call_finish (connection, result, NULL);
503 group->state = GROUP_ONLINE;
505 /* If we receive no reply, just act like we got an empty reply. */
513 g_variant_get (reply, "(a(uuaa{sv}))", &iter);
514 while (g_variant_iter_loop (iter, "(uu@aa{sv})", &group_id, &menu_id, &items))
515 if (group_id == group->id)
516 g_dbus_menu_group_changed (group, menu_id, 0, 0, items);
517 g_variant_iter_free (iter);
521 g_dbus_menu_group_go_offline (group);
524 g_variant_unref (reply);
526 g_dbus_menu_group_unref (group);
530 g_dbus_menu_group_activate (GDBusMenuGroup *group)
532 if (group->active++ == 0)
534 g_assert (group->state != GROUP_ONLINE);
536 if (group->state == GROUP_OFFLINE)
538 g_dbus_menu_path_activate (group->path);
540 g_dbus_connection_call (group->path->id->connection,
541 group->path->id->bus_name,
542 group->path->id->object_path,
543 "org.gtk.Menus", "Start",
544 g_variant_new_parsed ("([ %u ],)", group->id),
545 G_VARIANT_TYPE ("(a(uuaa{sv}))"),
546 G_DBUS_CALL_FLAGS_NONE, -1, NULL,
547 g_dbus_menu_group_start_ready,
548 g_dbus_menu_group_ref (group));
549 group->state = GROUP_PENDING;
555 g_dbus_menu_group_deactivate (GDBusMenuGroup *group)
557 if (--group->active == 0)
559 g_assert (group->state != GROUP_OFFLINE);
561 if (group->state == GROUP_ONLINE)
563 /* We are here because nobody is watching, so just free
564 * everything and don't bother with the notifications.
566 g_hash_table_remove_all (group->menus);
568 g_dbus_menu_group_go_offline (group);
574 g_dbus_menu_group_changed (GDBusMenuGroup *group,
580 GSequenceIter *point;
582 GDBusMenuModel *proxy;
587 /* We could have signals coming to us when we're not active (due to
588 * some other process having subscribed to this group) or when we're
589 * pending. In both of those cases, we want to ignore the signal
590 * since we'll get our own information when we call "Start" for
593 if (group->state != GROUP_ONLINE)
596 items = g_hash_table_lookup (group->menus, GINT_TO_POINTER (menu_id));
600 items = g_sequence_new (g_dbus_menu_model_item_free);
601 g_hash_table_insert (group->menus, GINT_TO_POINTER (menu_id), items);
604 point = g_sequence_get_iter_at_pos (items, position + removed);
606 g_return_if_fail (point != NULL);
610 GSequenceIter *start;
612 start = g_sequence_get_iter_at_pos (items, position);
613 g_sequence_remove_range (start, point);
616 n_added = g_variant_iter_init (&iter, added);
617 while (g_variant_iter_loop (&iter, "@a{sv}", &item))
618 g_sequence_insert_before (point, g_dbus_menu_group_create_item (item));
620 if (g_sequence_get_length (items) == 0)
622 g_hash_table_remove (group->menus, GINT_TO_POINTER (menu_id));
626 if ((proxy = g_hash_table_lookup (group->proxies, GINT_TO_POINTER (menu_id))))
627 g_dbus_menu_model_changed (proxy, items, position, removed, n_added);
630 static GDBusMenuGroup *
631 g_dbus_menu_group_get_from_path (GDBusMenuPath *path,
634 GDBusMenuGroup *group;
636 group = g_hash_table_lookup (path->groups, GINT_TO_POINTER (group_id));
640 group = g_slice_new (GDBusMenuGroup);
641 group->path = g_dbus_menu_path_ref (path);
642 group->id = group_id;
643 group->proxies = g_hash_table_new (NULL, NULL);
644 group->menus = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_sequence_free);
645 group->state = GROUP_OFFLINE;
647 group->ref_count = 0;
649 g_hash_table_insert (path->groups, GINT_TO_POINTER (group->id), group);
652 return g_dbus_menu_group_ref (group);
655 static GDBusMenuGroup *
656 g_dbus_menu_group_get (GMainContext *context,
657 GDBusConnection *connection,
658 const gchar *bus_name,
659 const gchar *object_path,
662 GDBusMenuGroup *group;
665 path = g_dbus_menu_path_get (context, connection, bus_name, object_path);
666 group = g_dbus_menu_group_get_from_path (path, group_id);
667 g_dbus_menu_path_unref (path);
672 /* GDBusMenuModel {{{1 */
674 typedef GMenuModelClass GDBusMenuModelClass;
675 struct _GDBusMenuModel
679 GDBusMenuGroup *group;
682 GSequence *items; /* unowned */
686 G_DEFINE_TYPE (GDBusMenuModel, g_dbus_menu_model, G_TYPE_MENU_MODEL)
689 g_dbus_menu_model_is_mutable (GMenuModel *model)
695 g_dbus_menu_model_get_n_items (GMenuModel *model)
697 GDBusMenuModel *proxy = G_DBUS_MENU_MODEL (model);
701 g_dbus_menu_group_activate (proxy->group);
702 proxy->active = TRUE;
705 return proxy->items ? g_sequence_get_length (proxy->items) : 0;
709 g_dbus_menu_model_get_item_attributes (GMenuModel *model,
713 GDBusMenuModel *proxy = G_DBUS_MENU_MODEL (model);
714 GDBusMenuModelItem *item;
717 g_return_if_fail (proxy->active);
718 g_return_if_fail (proxy->items);
720 iter = g_sequence_get_iter_at_pos (proxy->items, item_index);
721 g_return_if_fail (iter);
723 item = g_sequence_get (iter);
724 g_return_if_fail (item);
726 *table = g_hash_table_ref (item->attributes);
730 g_dbus_menu_model_get_item_links (GMenuModel *model,
734 GDBusMenuModel *proxy = G_DBUS_MENU_MODEL (model);
735 GDBusMenuModelItem *item;
738 g_return_if_fail (proxy->active);
739 g_return_if_fail (proxy->items);
741 iter = g_sequence_get_iter_at_pos (proxy->items, item_index);
742 g_return_if_fail (iter);
744 item = g_sequence_get (iter);
745 g_return_if_fail (item);
747 *table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
754 g_hash_table_iter_init (&tmp, item->links);
755 while (g_hash_table_iter_next (&tmp, &key, &value))
757 if (g_variant_is_of_type (value, G_VARIANT_TYPE ("(uu)")))
759 guint group_id, menu_id;
760 GDBusMenuGroup *group;
761 GDBusMenuModel *link;
763 g_variant_get (value, "(uu)", &group_id, &menu_id);
765 /* save the hash lookup in a relatively common case */
766 if (proxy->group->id != group_id)
767 group = g_dbus_menu_group_get_from_path (proxy->group->path, group_id);
769 group = g_dbus_menu_group_ref (proxy->group);
771 link = g_dbus_menu_model_get_from_group (group, menu_id);
773 g_hash_table_insert (*table, g_strdup (key), link);
775 g_dbus_menu_group_unref (group);
782 g_dbus_menu_model_finalize (GObject *object)
784 GDBusMenuModel *proxy = G_DBUS_MENU_MODEL (object);
787 g_dbus_menu_group_deactivate (proxy->group);
789 g_hash_table_remove (proxy->group->proxies, GINT_TO_POINTER (proxy->id));
790 g_dbus_menu_group_unref (proxy->group);
792 G_OBJECT_CLASS (g_dbus_menu_model_parent_class)
797 g_dbus_menu_model_init (GDBusMenuModel *proxy)
802 g_dbus_menu_model_class_init (GDBusMenuModelClass *class)
804 GObjectClass *object_class = G_OBJECT_CLASS (class);
806 class->is_mutable = g_dbus_menu_model_is_mutable;
807 class->get_n_items = g_dbus_menu_model_get_n_items;
808 class->get_item_attributes = g_dbus_menu_model_get_item_attributes;
809 class->get_item_links = g_dbus_menu_model_get_item_links;
811 object_class->finalize = g_dbus_menu_model_finalize;
815 g_dbus_menu_model_changed (GDBusMenuModel *proxy,
821 proxy->items = items;
823 if (proxy->active && (removed || added))
824 g_menu_model_items_changed (G_MENU_MODEL (proxy), position, removed, added);
827 static GDBusMenuModel *
828 g_dbus_menu_model_get_from_group (GDBusMenuGroup *group,
831 GDBusMenuModel *proxy;
833 proxy = g_hash_table_lookup (group->proxies, GINT_TO_POINTER (menu_id));
835 g_object_ref (proxy);
839 proxy = g_object_new (G_TYPE_DBUS_MENU_MODEL, NULL);
840 proxy->items = g_hash_table_lookup (group->menus, GINT_TO_POINTER (menu_id));
841 g_hash_table_insert (group->proxies, GINT_TO_POINTER (menu_id), proxy);
842 proxy->group = g_dbus_menu_group_ref (group);
850 * g_dbus_menu_model_get:
851 * @connection: a #GDBusConnection
852 * @bus_name: the bus name which exports the menu model
853 * @object_path: the object path at which the menu model is exported
855 * Obtains a #GDBusMenuModel for the menu model which is exported
856 * at the given @bus_name and @object_path.
858 * The thread default main context is taken at the time of this call.
859 * All signals on the menu model (and any linked models) are reported
860 * with respect to this context. All calls on the returned menu model
861 * (and linked models) must also originate from this same context, with
862 * the thread default main context unchanged.
864 * Returns: (transfer full): a #GDBusMenuModel object. Free with
870 g_dbus_menu_model_get (GDBusConnection *connection,
871 const gchar *bus_name,
872 const gchar *object_path)
874 GDBusMenuGroup *group;
875 GDBusMenuModel *proxy;
876 GMainContext *context;
878 context = g_main_context_get_thread_default ();
880 context = g_main_context_default ();
882 group = g_dbus_menu_group_get (context, connection, bus_name, object_path, 0);
883 proxy = g_dbus_menu_model_get_from_group (group, 0);
884 g_dbus_menu_group_unref (group);
891 dump_proxy (gpointer key, gpointer value, gpointer data)
893 GDBusMenuModel *proxy = value;
895 g_print (" menu %d refcount %d active %d\n",
896 proxy->id, G_OBJECT (proxy)->ref_count, proxy->active);
900 dump_group (gpointer key, gpointer value, gpointer data)
902 GDBusMenuGroup *group = value;
904 g_print (" group %d refcount %d state %d active %d\n",
905 group->id, group->ref_count, group->state, group->active);
907 g_hash_table_foreach (group->proxies, dump_proxy, NULL);
911 dump_path (gpointer key, gpointer value, gpointer data)
913 PathIdentifier *pid = key;
914 GDBusMenuPath *path = value;
916 g_print ("%s active %d\n", pid->object_path, path->active);
917 g_hash_table_foreach (path->groups, dump_group, NULL);
921 g_dbus_menu_model_dump (void)
923 g_hash_table_foreach (g_dbus_menu_paths, dump_path, NULL);
929 /* vim:set foldmethod=marker: */