From 5f599a8cabbbc451e6c0846598453eb2618d4405 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 12 Feb 2012 13:40:21 +0100 Subject: indicator_object_set_visible: only emit entry-{added,removed} when visibility actually changed Emitting those signals is semantically incorrect. It also confused indicator-loader and the panel, because they are not checking whether an entry is already present in their entry-added handlers. This led to gtk warnings ("widget already has a parent") and strange effects, such as the same menu being added multiple times into the panel. --- libindicator/indicator-object.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index d0b3ecf..1d0db58 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -886,9 +886,16 @@ indicator_object_set_visible (IndicatorObject * io, gboolean visible) GList * l; GList * entries = get_all_entries (io); const guint signal_id = signals[visible ? ENTRY_ADDED : ENTRY_REMOVED]; + EntryVisibility visibility = visible ? ENTRY_VISIBLE : ENTRY_INVISIBLE; const GQuark detail = (GQuark)0; + for (l=entries; l!=NULL; l=l->next) - g_signal_emit(io, signal_id, detail, l->data); + { + IndicatorObjectEntry *entry = l->data; + EntryVisibility v = entry_get_private (io, entry)->visibility; + if (v == ENTRY_INIT || v != visibility) + g_signal_emit(io, signal_id, detail, entry); + } g_list_free (entries); } -- cgit v1.2.3 From e7780ac9f99dda5fea04721be0b2b26050442c8c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 13 Feb 2012 19:08:27 +0100 Subject: indicator_object_set_visible: no need to check for ENTRY_INIT --- libindicator/indicator-object.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 1d0db58..a67b4e4 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -889,11 +889,9 @@ indicator_object_set_visible (IndicatorObject * io, gboolean visible) EntryVisibility visibility = visible ? ENTRY_VISIBLE : ENTRY_INVISIBLE; const GQuark detail = (GQuark)0; - for (l=entries; l!=NULL; l=l->next) - { + for (l=entries; l!=NULL; l=l->next) { IndicatorObjectEntry *entry = l->data; - EntryVisibility v = entry_get_private (io, entry)->visibility; - if (v == ENTRY_INIT || v != visibility) + if (entry_get_private (io, entry)->visibility != visibility) g_signal_emit(io, signal_id, detail, entry); } g_list_free (entries); -- cgit v1.2.3 From 73c0659d30445a2202faf1d0b87c2464f02b51e3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 13 Feb 2012 19:15:03 +0100 Subject: indicator_object_dispose: use _set_visible instead of reimplementing it --- libindicator/indicator-object.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index a67b4e4..2ce40e2 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -337,21 +337,11 @@ static void indicator_object_dispose (GObject *object) { IndicatorObject * io = INDICATOR_OBJECT(object); + GList * entries = get_all_entries (io); /* Ensure that hidden entries are re-added so their widgetry will be cleaned up properly by the client */ - GList * l; - GList * entries = get_all_entries (io); - const GQuark detail = (GQuark)0; - for (l=entries; l!=NULL; l=l->next) { - IndicatorObjectEntry * entry = l->data; - if (entry_get_private(io, entry)->visibility == ENTRY_INVISIBLE) { - g_signal_emit(io, signals[ENTRY_ADDED], detail, entry); - } - - if (entry) - entry->parent_object = NULL; - } + indicator_object_set_visible (io, TRUE); g_list_free (entries); G_OBJECT_CLASS (indicator_object_parent_class)->dispose (object); -- cgit v1.2.3 From b2ca0dbe7704098144b6ccd103dd760ad7dd3636 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 13 Feb 2012 19:38:10 +0100 Subject: indicator_object_dispose: remove unneeded list of entries --- libindicator/indicator-object.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 2ce40e2..a348d9a 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -336,13 +336,9 @@ indicator_object_init (IndicatorObject *self) static void indicator_object_dispose (GObject *object) { - IndicatorObject * io = INDICATOR_OBJECT(object); - GList * entries = get_all_entries (io); - /* Ensure that hidden entries are re-added so their widgetry will be cleaned up properly by the client */ - indicator_object_set_visible (io, TRUE); - g_list_free (entries); + indicator_object_set_visible (INDICATOR_OBJECT (object), TRUE); G_OBJECT_CLASS (indicator_object_parent_class)->dispose (object); } -- cgit v1.2.3