Commit 4f7a972a authored by Benjamin Otte's avatar Benjamin Otte

testgtk: Make dialogs example work without static variable

Makes it a bit more complicated, but meh.
parent 38149c47
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment