summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-10-04 18:31:15 +0200
committerBastien Nocera <hadess@hadess.net>2014-09-15 14:49:13 +0200
commitffe677dd78c5b1e10df51ff2cc659c70587d67d7 (patch)
tree56417988af13604aa45a36bb1f4aa35a8e9a5152
parenta2a62570dd038a459326e3d56cb593af97e2f6f3 (diff)
downloadclutter-gtk-ffe677dd78c5b1e10df51ff2cc659c70587d67d7.tar.gz
examples: Add a GtkStack to the examples
Clicking on the "clickety" button in the gtk-clutter-test will toggle, in a GtkStack, between a label, and a clutter-gtk stage. It doesn't take very long to see the display artifacts after that. https://bugzilla.gnome.org/show_bug.cgi?id=695737
-rw-r--r--examples/gtk-clutter-test.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/examples/gtk-clutter-test.c b/examples/gtk-clutter-test.c
index d903c76..b9b8736 100644
--- a/examples/gtk-clutter-test.c
+++ b/examples/gtk-clutter-test.c
@@ -88,8 +88,12 @@ frame_cb (ClutterTimeline *timeline,
static void
clickity (GtkButton *button,
- gpointer ud)
+ gpointer stack)
{
+ if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (stack)), "label") == 0)
+ gtk_stack_set_visible_child_name (GTK_STACK (stack), "clutter");
+ else
+ gtk_stack_set_visible_child_name (GTK_STACK (stack), "label");
fade = !fade;
}
@@ -114,7 +118,7 @@ main (int argc, char *argv[])
{
ClutterTimeline *timeline;
ClutterActor *stage;
- GtkWidget *window, *clutter;
+ GtkWidget *window, *stack, *clutter;
GtkWidget *label, *button, *vbox;
GdkPixbuf *pixbuf;
SuperOH *oh;
@@ -157,8 +161,14 @@ main (int argc, char *argv[])
gtk_widget_set_vexpand (vbox, TRUE);
gtk_container_add (GTK_CONTAINER (window), vbox);
+ stack = gtk_stack_new ();
+ gtk_container_add (GTK_CONTAINER (vbox), stack);
+
+ label = gtk_label_new ("This is a label in a stack");
+ gtk_stack_add_named (GTK_STACK (stack), label, "label");
+
clutter = gtk_clutter_embed_new ();
- gtk_container_add (GTK_CONTAINER (vbox), clutter);
+ gtk_stack_add_named (GTK_STACK (stack), clutter, "clutter");
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter));
clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue);
@@ -168,7 +178,7 @@ main (int argc, char *argv[])
gtk_widget_set_hexpand (label, TRUE);
button = gtk_button_new_with_label ("This is a button...clicky");
- g_signal_connect (button, "clicked", G_CALLBACK (clickity), NULL);
+ g_signal_connect (button, "clicked", G_CALLBACK (clickity), stack);
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_set_hexpand (button, TRUE);