diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-06-22 15:43:03 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-06-22 15:43:03 +0100 |
commit | b8cfcc7d9959c770a6d48adbd39d7b9e70f7a56e (patch) | |
tree | 3f19a2e01f991c6917fc420adc5c5b3952635d35 /examples | |
parent | 063502210a5fa1af4005268b2deb91ed099317ed (diff) | |
download | clutter-gtk-b8cfcc7d9959c770a6d48adbd39d7b9e70f7a56e.tar.gz |
Update the Viewport example
The GtkClutterViewport example shows how to use the newly added
support for the Zoomable interface inside the Viewport actor.
It's a pretty trivial implementation, but it should be enough
to show how it's done.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gtk-clutter-viewport.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/examples/gtk-clutter-viewport.c b/examples/gtk-clutter-viewport.c index 3c67178..09b8912 100644 --- a/examples/gtk-clutter-viewport.c +++ b/examples/gtk-clutter-viewport.c @@ -10,20 +10,31 @@ on_load_finished (ClutterTexture *texture, const GError *error, gpointer user_data) { + if (error) + g_warning ("Unable to load texture: %s", error->message); + if (timer) g_print ("%s: load time: %.3f secs\n", G_STRLOC, g_timer_elapsed (timer, NULL)); } +static void +on_size_change (ClutterTexture *texture, + gint width, + gint height) +{ + g_print ("%s: tex.size = %d, %d\n", G_STRLOC, width, height); +} + int main (int argc, char *argv[]) { ClutterActor *stage, *viewport, *tex; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - GtkWidget *window, *embed; - GtkWidget *table, *scrollbar; - GtkAdjustment *h_adjustment, *v_adjustment; + GtkWidget *window, *embed; + GtkWidget *table, *scrollbar, *slider; + GtkAdjustment *h_adjustment, *v_adjustment, *z_adjustment; g_thread_init (NULL); gdk_threads_init (); @@ -35,7 +46,7 @@ main (int argc, char *argv[]) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - table = gtk_table_new (2, 2, FALSE); + table = gtk_table_new (3, 2, FALSE); gtk_container_add (GTK_CONTAINER (window), table); gtk_widget_show (table); @@ -65,7 +76,10 @@ main (int argc, char *argv[]) GError *error = NULL; tex = clutter_texture_new (); - g_object_set (G_OBJECT (tex), "load-async", TRUE, NULL); + clutter_texture_set_load_async (CLUTTER_TEXTURE (tex), TRUE); + g_signal_connect (tex, + "size-change", G_CALLBACK (on_size_change), + NULL); g_signal_connect (tex, "load-finished", G_CALLBACK (on_load_finished), NULL); @@ -111,6 +125,17 @@ main (int argc, char *argv[]) 0, 0); gtk_widget_show (scrollbar); + z_adjustment = + gtk_clutter_zoomable_get_adjustment (GTK_CLUTTER_ZOOMABLE (viewport)); + + slider = gtk_hscale_new (z_adjustment); + gtk_table_attach (GTK_TABLE (table), slider, + 0, 1, + 2, 3, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + gtk_widget_show (slider); + gtk_widget_show (window); gtk_main(); |