From 0373d6fcb3f7b62028db4978ba215c403b43fed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 25 Jan 2012 11:55:37 +0100 Subject: IndicatorObject: correctly initialize the parent object. --- libindicator/indicator-object.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libindicator/indicator-object.c') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 849fb9f..6e25387 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -348,6 +348,7 @@ indicator_object_dispose (GObject *object) if (entry_get_private(io, entry)->visibility == ENTRY_INVISIBLE) { g_signal_emit(io, signals[ENTRY_ADDED], detail, entry); } + entry->parent_object = NULL; } g_list_free (entries); @@ -507,6 +508,8 @@ get_entries_default (IndicatorObject * io) if (!priv->gotten_entries) { IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); + priv->entry.parent_object = io; + if (class->get_label) { priv->entry.label = class->get_label(io); } @@ -551,7 +554,7 @@ get_entries_default (IndicatorObject * io) static GList* get_all_entries (IndicatorObject * io) { - GList * all_entries = NULL; + GList * all_entries = NULL, *l; g_return_val_if_fail(INDICATOR_IS_OBJECT(io), NULL); IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); @@ -559,8 +562,16 @@ get_all_entries (IndicatorObject * io) if (class->get_entries == NULL) g_error("No get_entries function on object. It must have been deleted?!?!"); else + { all_entries = class->get_entries(io); + for (l = all_entries; l; l = l->next) + { + IndicatorObjectEntry *entry = l->data; + entry->parent_object = io; + } + } + return all_entries; } @@ -757,6 +768,7 @@ indicator_object_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); entry_get_private (io, entry)->visibility = ENTRY_INVISIBLE; + entry->parent_object = NULL; if (class->entry_being_removed != NULL) class->entry_being_removed (io, entry); @@ -769,6 +781,7 @@ indicator_object_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * e IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); entry_get_private (io, entry)->visibility = ENTRY_VISIBLE; + entry->parent_object = io; if (class->entry_was_added != NULL) class->entry_was_added (io, entry); -- cgit v1.2.3 From c9df18becfc38ab3e3a833d0095c26f5140800e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 25 Jan 2012 12:21:51 +0100 Subject: Indicator-Object: update the parent_object value only if the entry is valid. --- libindicator/indicator-object.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'libindicator/indicator-object.c') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 6e25387..91f45ff 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -348,7 +348,9 @@ indicator_object_dispose (GObject *object) if (entry_get_private(io, entry)->visibility == ENTRY_INVISIBLE) { g_signal_emit(io, signals[ENTRY_ADDED], detail, entry); } - entry->parent_object = NULL; + + if (entry) + entry->parent_object = NULL; } g_list_free (entries); @@ -568,7 +570,9 @@ get_all_entries (IndicatorObject * io) for (l = all_entries; l; l = l->next) { IndicatorObjectEntry *entry = l->data; - entry->parent_object = io; + + if (entry) + entry->parent_object = io; } } @@ -768,10 +772,14 @@ indicator_object_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); entry_get_private (io, entry)->visibility = ENTRY_INVISIBLE; - entry->parent_object = NULL; if (class->entry_being_removed != NULL) + { + if (entry) + entry->parent_object = NULL; + class->entry_being_removed (io, entry); + } } static void @@ -781,10 +789,14 @@ indicator_object_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * e IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); entry_get_private (io, entry)->visibility = ENTRY_VISIBLE; - entry->parent_object = io; if (class->entry_was_added != NULL) + { + if (entry) + entry->parent_object = io; + class->entry_was_added (io, entry); + } } /** -- cgit v1.2.3 From 1baaf2880f44fea4519f323e3da425318af6c688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 25 Jan 2012 18:10:29 +0100 Subject: IndicatorObject: update object parent in any case. --- libindicator/indicator-object.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libindicator/indicator-object.c') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 91f45ff..d0b3ecf 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -773,11 +773,11 @@ indicator_object_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry entry_get_private (io, entry)->visibility = ENTRY_INVISIBLE; + if (entry) + entry->parent_object = NULL; + if (class->entry_being_removed != NULL) { - if (entry) - entry->parent_object = NULL; - class->entry_being_removed (io, entry); } } @@ -790,11 +790,11 @@ indicator_object_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * e entry_get_private (io, entry)->visibility = ENTRY_VISIBLE; + if (entry) + entry->parent_object = io; + if (class->entry_was_added != NULL) { - if (entry) - entry->parent_object = io; - class->entry_was_added (io, entry); } } -- cgit v1.2.3 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(-) (limited to 'libindicator/indicator-object.c') 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(-) (limited to 'libindicator/indicator-object.c') 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(-) (limited to 'libindicator/indicator-object.c') 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(-) (limited to 'libindicator/indicator-object.c') 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