summaryrefslogtreecommitdiff
path: root/tests/testgtk.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-04-10 16:16:41 +0200
committerBenjamin Otte <otte@redhat.com>2014-04-10 16:16:41 +0200
commit4f7a972aacbfc04f231a970c6be8ce86608be57c (patch)
tree5e425b1d01eb0e5b11db1ad0327fcc397bb6f12e /tests/testgtk.c
parent38149c472e820e81ac7eed89d6f496adb8857a5e (diff)
downloadgtk+-4f7a972aacbfc04f231a970c6be8ce86608be57c.tar.gz
testgtk: Make dialogs example work without static variable
Makes it a bit more complicated, but meh.
Diffstat (limited to 'tests/testgtk.c')
-rw-r--r--tests/testgtk.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c
index a6232f94e5..5827bb5a04 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -5416,21 +5416,34 @@ static GtkWidget *dialog_window = NULL;
static void
label_toggle (GtkWidget *widget)
{
- static GtkWidget *label = NULL;
+ GtkWidget *content_area;
+ GList *l, *children;
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog_window));
+ children = gtk_container_get_children (GTK_CONTAINER (content_area));
+
+ for (l = children; l; l = l->next)
+ {
+ if (GTK_IS_LABEL (l->data))
+ {
+ gtk_container_remove (GTK_CONTAINER (content_area), l->data);
+ break;
+ }
+ }
- if (label == NULL)
+ /* no label removed, so add one */
+ if (l == NULL)
{
+ GtkWidget *label;
+
label = gtk_label_new ("Dialog Test");
g_object_set (label, "margin", 10, NULL);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog_window))),
+ gtk_box_pack_start (GTK_BOX (content_area),
label, TRUE, TRUE, 0);
gtk_widget_show (label);
}
- else
- {
- gtk_widget_destroy (label);
- label = NULL;
- }
+
+ g_list_free (children);
}
static void