diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-02-13 20:07:33 +0100 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-02-13 20:07:33 +0100 |
commit | 2a6c388d5f5dc2d298322e46fec71839bf41ab58 (patch) | |
tree | d37bb254ba29ca7b59c016b353e7b04ce4b17b62 | |
parent | 233fdd70cdb48ae8818baf416399989841333fcf (diff) | |
parent | b2ca0dbe7704098144b6ccd103dd760ad7dd3636 (diff) | |
download | libayatana-indicator-2a6c388d5f5dc2d298322e46fec71839bf41ab58.tar.gz libayatana-indicator-2a6c388d5f5dc2d298322e46fec71839bf41ab58.tar.bz2 libayatana-indicator-2a6c388d5f5dc2d298322e46fec71839bf41ab58.zip |
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.
This patch also makes indicator_object_dispose use indicator_object_set_visible
(it was already doing something similar).
-rw-r--r-- | libindicator/indicator-object.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index d0b3ecf..a348d9a 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -336,23 +336,9 @@ indicator_object_init (IndicatorObject *self) static void indicator_object_dispose (GObject *object) { - IndicatorObject * io = INDICATOR_OBJECT(object); - /* 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; - } - g_list_free (entries); + indicator_object_set_visible (INDICATOR_OBJECT (object), TRUE); G_OBJECT_CLASS (indicator_object_parent_class)->dispose (object); } @@ -886,9 +872,14 @@ 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); + + for (l=entries; l!=NULL; l=l->next) { + IndicatorObjectEntry *entry = l->data; + if (entry_get_private (io, entry)->visibility != visibility) + g_signal_emit(io, signal_id, detail, entry); + } g_list_free (entries); } |