From 8a739e176e44cfff995711606c224caa9a1920b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Jan 2012 11:44:37 -0600 Subject: Adding a parent object pointer to the entry --- libindicator/indicator-object.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index bbc215a..b8b9a8b 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -152,6 +152,7 @@ struct _IndicatorObject { /** IndicatorObjectEntry: + @parent_object: The #IndicatorObject that created this entry @label: The label to be shown on the panel @image: The image to be shown on the panel @menu: The menu to be added to the menubar @@ -166,6 +167,7 @@ struct _IndicatorObject { @reserved4: Reserved for future use */ struct _IndicatorObjectEntry { + IndicatorObject * parent_object; GtkLabel * label; GtkImage * image; GtkMenu * menu; -- cgit v1.2.3 From f2f9c5b63cfc8e9c9b8dfb77d2f8f9aed687720e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Jan 2012 11:46:28 -0600 Subject: Set the parent_object on the default entry --- libindicator/indicator-object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 7a3e393..adaa9ed 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -257,6 +257,7 @@ indicator_object_init (IndicatorObject *self) self->priv->module = NULL; + self->priv->entry.parent_object = self; self->priv->entry.menu = NULL; self->priv->entry.label = NULL; self->priv->entry.image = NULL; -- cgit v1.2.3 From e14c0872345cc6761b4b81adedf1aad8d694872a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Jan 2012 11:48:32 -0600 Subject: Adding a warning for entries that do not set their parent_object --- tools/indicator-loader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/indicator-loader.c b/tools/indicator-loader.c index 59e90b1..10952dc 100644 --- a/tools/indicator-loader.c +++ b/tools/indicator-loader.c @@ -45,6 +45,10 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_d { g_debug("Signal: Entry Added"); + if (entry->parent_object == NULL) { + g_warning("Entry '%p' does not have a parent object", entry); + } + GtkWidget * menuitem = gtk_menu_item_new(); #if GTK_CHECK_VERSION(3,0,0) GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); -- cgit v1.2.3 From a1ed503a7513d46ca530dd9e853140f2981e69a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 19 Jan 2012 11:55:47 -0600 Subject: Checking to ensure the parent_object pointer gets set --- tests/test-loader.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-loader.c b/tests/test-loader.c index 2e9cf55..38f2cb1 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -152,6 +152,7 @@ test_loader_filename_dummy_simple_location (void) g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0); g_assert(indicator_object_get_location(object, NULL) == 0); + g_assert(((IndicatorObjectEntry *)entries->data)->parent_object != NULL); g_object_unref(object); -- cgit v1.2.3