aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libindicator/indicator-object.c27
-rw-r--r--tests/dummy-indicator-signaler.c21
-rw-r--r--tests/test-loader.c35
3 files changed, 67 insertions, 16 deletions
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index 849fb9f..d0b3ecf 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -348,6 +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);
}
+
+ if (entry)
+ entry->parent_object = NULL;
}
g_list_free (entries);
@@ -507,6 +510,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 +556,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 +564,18 @@ 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;
+
+ if (entry)
+ entry->parent_object = io;
+ }
+ }
+
return all_entries;
}
@@ -758,8 +773,13 @@ 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)
+ {
class->entry_being_removed (io, entry);
+ }
}
static void
@@ -770,8 +790,13 @@ 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)
+ {
class->entry_was_added (io, entry);
+ }
}
/**
diff --git a/tests/dummy-indicator-signaler.c b/tests/dummy-indicator-signaler.c
index c7a5c1f..a4206d0 100644
--- a/tests/dummy-indicator-signaler.c
+++ b/tests/dummy-indicator-signaler.c
@@ -42,6 +42,7 @@ struct _DummyIndicatorSignalerClass {
struct _DummyIndicatorSignaler {
IndicatorObject parent;
+ IndicatorObjectEntry *entries;
};
GType dummy_indicator_signaler_get_type (void);
@@ -110,9 +111,19 @@ idle_signal (gpointer data)
{
DummyIndicatorSignaler * self = DUMMY_INDICATOR_SIGNALER(data);
- g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);
- g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);
- g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, GUINT_TO_POINTER(5), 0, 1, TRUE);
+ IndicatorObjectEntry *added_entry, *removed_entry, *moved_entry;
+
+ added_entry = &self->entries[0];
+ moved_entry = &self->entries[1];
+ removed_entry = &self->entries[2];
+
+ added_entry->name_hint = "added";
+ moved_entry->name_hint = "moved";
+ removed_entry->name_hint = "removed";
+
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, added_entry);
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, moved_entry, 0, 1);
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, removed_entry);
return FALSE; /* Don't queue again */
}
@@ -120,6 +131,7 @@ idle_signal (gpointer data)
static void
dummy_indicator_signaler_init (DummyIndicatorSignaler *self)
{
+ self->entries = g_new0(IndicatorObjectEntry, 3);
g_idle_add(idle_signal, self);
return;
}
@@ -135,7 +147,8 @@ dummy_indicator_signaler_dispose (GObject *object)
static void
dummy_indicator_signaler_finalize (GObject *object)
{
-
+ DummyIndicatorSignaler * self = DUMMY_INDICATOR_SIGNALER(object);
+ g_free (self->entries);
G_OBJECT_CLASS (dummy_indicator_signaler_parent_class)->finalize (object);
return;
}
diff --git a/tests/test-loader.c b/tests/test-loader.c
index 6f9d25b..28c56aa 100644
--- a/tests/test-loader.c
+++ b/tests/test-loader.c
@@ -100,8 +100,9 @@ void destroy_cb (gpointer data, GObject * object);
void
entry_change_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer data)
{
- gpointer * valuestore = (gpointer *)data;
- *valuestore = entry;
+ IndicatorObjectEntry *other_entry = data;
+ other_entry->name_hint = entry->name_hint;
+ other_entry->parent_object = entry->parent_object;
return;
}
@@ -117,11 +118,16 @@ test_loader_filename_dummy_signaler (void)
IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");
g_assert(object != NULL);
- gpointer added_value = NULL, removed_value = NULL, moved_value = NULL;
+ IndicatorObjectEntry *added_entry, *moved_entry, *removed_entry;
+ IndicatorObjectEntry entries[3];
- g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);
- g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);
- g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), &moved_value);
+ added_entry = &entries[0];
+ moved_entry = &entries[1];
+ removed_entry = &entries[2];
+
+ g_signal_connect_after(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), added_entry);
+ g_signal_connect_after(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), moved_entry);
+ g_signal_connect_after(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), removed_entry);
GList * list = indicator_object_get_entries(object);
g_assert(list != NULL);
@@ -131,9 +137,12 @@ test_loader_filename_dummy_signaler (void)
g_main_context_iteration(NULL, TRUE);
}
- g_assert(GPOINTER_TO_UINT(added_value) == 5);
- g_assert(GPOINTER_TO_UINT(removed_value) == 5);
- g_assert(GPOINTER_TO_UINT(moved_value) == 5);
+ g_assert(g_strcmp0(added_entry->name_hint, "added") == 0);
+ g_assert(g_strcmp0(removed_entry->name_hint, "removed") == 0);
+ g_assert(g_strcmp0(moved_entry->name_hint, "moved") == 0);
+
+ g_assert(added_entry->parent_object == object);
+ g_assert(removed_entry->parent_object == NULL);
g_object_unref(object);
@@ -190,6 +199,8 @@ test_loader_filename_dummy_visible (void)
g_assert(entry != NULL);
g_list_free(list);
g_assert(GTK_IS_LABEL(entry->label));
+ g_assert(entry->parent_object == object);
+ g_assert(INDICATOR_IS_OBJECT(entry->parent_object));
GtkWidget * label = GTK_WIDGET(entry->label);
g_assert(g_object_get_qdata(G_OBJECT(label), is_hidden_quark) == NULL);
@@ -239,9 +250,11 @@ test_loader_filename_dummy_simple_location (void)
g_assert(entries != NULL);
g_assert(g_list_length(entries) == 1);
- g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0);
+ IndicatorObjectEntry *entry = entries->data;
+
+ g_assert(indicator_object_get_location(object, entry) == 0);
g_assert(indicator_object_get_location(object, NULL) == 0);
- g_assert(((IndicatorObjectEntry *)entries->data)->parent_object != NULL);
+ g_assert(entry->parent_object == object);
g_object_unref(object);