[glib/wip/menus: 34/61] report changes from GMenuExporter
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/menus: 34/61] report changes from GMenuExporter
- Date: Thu, 17 Nov 2011 23:37:34 +0000 (UTC)
commit 0bfca49ce80881bc09d31e9a5d244b5eebd9b5a1
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Oct 21 22:48:47 2011 -0400
report changes from GMenuExporter
gio/gmenuexporter.c | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/gio/gmenuexporter.c b/gio/gmenuexporter.c
index fcd9203..9d63aa4 100644
--- a/gio/gmenuexporter.c
+++ b/gio/gmenuexporter.c
@@ -260,6 +260,8 @@ g_menu_exporter_menu_items_changed (GMenuModel *model,
static void
g_menu_exporter_menu_prepare (GMenuExporterMenu *menu)
{
+ gint n_items;
+
g_assert (menu->item_links == NULL);
if (g_menu_model_is_mutable (menu->model))
@@ -267,7 +269,10 @@ g_menu_exporter_menu_prepare (GMenuExporterMenu *menu)
G_CALLBACK (g_menu_exporter_menu_items_changed), menu);
menu->item_links = g_sequence_new (g_menu_exporter_link_free);
- g_menu_exporter_menu_items_changed (menu->model, 0, 0, g_menu_model_get_n_items (menu->model), menu);
+
+ n_items = g_menu_model_get_n_items (menu->model);
+ if (n_items)
+ g_menu_exporter_menu_items_changed (menu->model, 0, 0, n_items, menu);
}
static GMenuExporterMenu *
@@ -345,11 +350,14 @@ g_menu_exporter_group_subscribe (GMenuExporterGroup *group,
guint id = GPOINTER_TO_INT (key);
GMenuExporterMenu *menu = val;
- g_variant_builder_open (builder, G_VARIANT_TYPE ("(uuaa{sv})"));
- g_variant_builder_add (builder, "u", group->id);
- g_variant_builder_add (builder, "u", id);
- g_variant_builder_add_value (builder, g_menu_exporter_menu_list (menu));
- g_variant_builder_close (builder);
+ if (g_sequence_get_length (menu->item_links))
+ {
+ g_variant_builder_open (builder, G_VARIANT_TYPE ("(uuaa{sv})"));
+ g_variant_builder_add (builder, "u", group->id);
+ g_variant_builder_add (builder, "u", id);
+ g_variant_builder_add_value (builder, g_menu_exporter_menu_list (menu));
+ g_variant_builder_close (builder);
+ }
}
}
@@ -594,6 +602,19 @@ static void
g_menu_exporter_report (GMenuExporter *exporter,
GVariant *report)
{
+ GVariantBuilder builder;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
+ g_variant_builder_open (&builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_add_value (&builder, report);
+ g_variant_builder_close (&builder);
+
+ g_dbus_connection_emit_signal (exporter->connection,
+ NULL,
+ exporter->object_path,
+ "org.gtk.Menus", "Changed",
+ g_variant_builder_end (&builder),
+ NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]