aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-09-11 23:25:56 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-09-11 23:25:56 -0500
commit00d05564fe963f53d8f56601f0b2dad2834b9b00 (patch)
treeec56a4f7aec66aac5f7ed70ca3c2079d0f74be88
parentee19af5cf98a77eb3e5df03769265193be1384f5 (diff)
downloadlibayatana-indicator-00d05564fe963f53d8f56601f0b2dad2834b9b00.tar.gz
libayatana-indicator-00d05564fe963f53d8f56601f0b2dad2834b9b00.tar.bz2
libayatana-indicator-00d05564fe963f53d8f56601f0b2dad2834b9b00.zip
In tests/test-loader and tests/dummy-indicator-visible.c, support hiding & re-showing IndicatorObjectEntries by caching their parent widgetry instead of using gtk_widget_destroy()
-rw-r--r--tests/dummy-indicator-visible.c12
-rw-r--r--tests/test-loader.c24
2 files changed, 23 insertions, 13 deletions
diff --git a/tests/dummy-indicator-visible.c b/tests/dummy-indicator-visible.c
index 0bb9e89..42cb59c 100644
--- a/tests/dummy-indicator-visible.c
+++ b/tests/dummy-indicator-visible.c
@@ -88,17 +88,25 @@ G_DEFINE_TYPE (DummyIndicatorVisible, dummy_indicator_visible, INDICATOR_OBJECT_
static void
dummy_indicator_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry * entry)
{
+ IndicatorObjectClass * indicator_object_class = INDICATOR_OBJECT_CLASS (dummy_indicator_visible_parent_class);
+
g_object_set_data(G_OBJECT(entry->label), "is-hidden", GINT_TO_POINTER(1));
- INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_being_removed (io, entry);
+ if (indicator_object_class->entry_being_removed != NULL) {
+ indicator_object_class->entry_being_removed (io, entry);
+ }
}
static void
dummy_indicator_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * entry)
{
+ IndicatorObjectClass * indicator_object_class = INDICATOR_OBJECT_CLASS (dummy_indicator_visible_parent_class);
+
g_object_steal_data(G_OBJECT(entry->label), "is-hidden");
- INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_was_added (io, entry);
+ if (indicator_object_class->entry_was_added != NULL) {
+ indicator_object_class->entry_was_added (io, entry);
+ }
}
static void
diff --git a/tests/test-loader.c b/tests/test-loader.c
index 28c56aa..45901cb 100644
--- a/tests/test-loader.c
+++ b/tests/test-loader.c
@@ -156,22 +156,24 @@ test_loader_filename_dummy_signaler (void)
static void
visible_entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer box)
{
- // make a frame for the entry, and add the frame to the box
- GtkWidget * frame = gtk_frame_new (NULL);
- GtkWidget * child = GTK_WIDGET(entry->label);
+ GtkWidget * child = GTK_WIDGET (entry->label);
g_assert (child != NULL);
- gtk_container_add (GTK_CONTAINER(frame), child);
- gtk_box_pack_start (GTK_BOX(box), frame, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT(child), "frame-parent", frame);
+
+ if (g_object_get_data (G_OBJECT(child), "frame-parent") == NULL)
+ {
+ GtkWidget * frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER(frame), child);
+ gtk_box_pack_start (GTK_BOX(box), frame, FALSE, FALSE, 0);
+ g_object_set_data (G_OBJECT(child), "frame-parent", frame);
+ }
}
static void
visible_entry_removed (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer box)
{
- // destroy this entry's frame
- gpointer parent = g_object_steal_data (G_OBJECT(entry->label), "frame-parent");
- if (GTK_IS_WIDGET(parent))
- gtk_widget_destroy(GTK_WIDGET(parent));
+ GtkWidget * child = GTK_WIDGET (entry->label);
+ g_assert (child != NULL);
+ g_assert (g_object_get_data (G_OBJECT(child), "frame-parent") != NULL);
}
void
@@ -218,7 +220,7 @@ test_loader_filename_dummy_visible (void)
g_assert(GTK_IS_LABEL(label));
g_assert(g_object_get_qdata(G_OBJECT(label), is_hidden_quark) != NULL);
list = gtk_container_get_children (GTK_CONTAINER(box));
- g_assert(g_list_length(list) == 0);
+ g_assert(g_list_length(list) == 1);
g_list_free(list);
// restore the entries and confirm that the label survived