summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2011-04-05 11:57:23 +0100
committerEmmanuele Bassi <ebassi@linux.intel.com>2011-04-05 12:02:22 +0100
commite52250a7b81d7ea31107dfc413cf17dd75d88b24 (patch)
treef4f4f4c623dec388666556df28c905c957305265 /examples
parentc9fb6db8ce510ef033d73a0384dbfa57881c931e (diff)
downloadclutter-gtk-e52250a7b81d7ea31107dfc413cf17dd75d88b24.tar.gz
Fix C99-isms in example code
Diffstat (limited to 'examples')
-rw-r--r--examples/gtk-clutter-window-test.c20
-rw-r--r--examples/gtk-clutter-window-test2.c93
2 files changed, 62 insertions, 51 deletions
diff --git a/examples/gtk-clutter-window-test.c b/examples/gtk-clutter-window-test.c
index cc786d4..dfa86af 100644
--- a/examples/gtk-clutter-window-test.c
+++ b/examples/gtk-clutter-window-test.c
@@ -93,14 +93,17 @@ on_toolbar_leave (ClutterActor *actor,
int
main (int argc, char **argv)
{
+ GtkWidget *window, *iconview, *sw, *toolbar;
+ GtkListStore *store;
+ ClutterActor *stage, *actor;
+
gtk_clutter_init (&argc, &argv);
- GtkWidget *window = gtk_clutter_window_new ();
+ window = gtk_clutter_window_new ();
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- GtkListStore *store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING, GDK_TYPE_PIXBUF);
+ store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF);
add_liststore_rows (store,
"devhelp",
"empathy",
@@ -111,20 +114,19 @@ main (int argc, char **argv)
"totem",
NULL);
- GtkWidget *iconview = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
+ iconview = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
gtk_icon_view_set_text_column (GTK_ICON_VIEW (iconview), NAME_COLUMN);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (iconview), PIXBUF_COLUMN);
- GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
-
+ sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (window), sw);
gtk_container_add (GTK_CONTAINER (sw), iconview);
gtk_widget_show_all (sw);
/* Widget 2 is a toolbar */
- ClutterActor *stage = gtk_clutter_window_get_stage (GTK_CLUTTER_WINDOW (window));
+ stage = gtk_clutter_window_get_stage (GTK_CLUTTER_WINDOW (window));
- GtkWidget *toolbar = gtk_toolbar_new ();
+ toolbar = gtk_toolbar_new ();
add_toolbar_items (GTK_TOOLBAR (toolbar),
GTK_STOCK_ADD,
GTK_STOCK_BOLD,
@@ -135,7 +137,7 @@ main (int argc, char **argv)
NULL);
gtk_widget_show_all (toolbar);
- ClutterActor *actor = gtk_clutter_actor_new_with_contents (toolbar);
+ actor = gtk_clutter_actor_new_with_contents (toolbar);
clutter_actor_add_constraint (actor, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, 0.0));
g_signal_connect (actor, "enter-event", G_CALLBACK (on_toolbar_enter), NULL);
g_signal_connect (actor, "leave-event", G_CALLBACK (on_toolbar_leave), NULL);
diff --git a/examples/gtk-clutter-window-test2.c b/examples/gtk-clutter-window-test2.c
index 834c5e5..6c8b46a 100644
--- a/examples/gtk-clutter-window-test2.c
+++ b/examples/gtk-clutter-window-test2.c
@@ -28,91 +28,94 @@ animation_stage_1_complete (ClutterTimeline *timeline, ClutterActor *texture)
{
GtkAllocation allocation;
GtkWidget *image;
+ ClutterAnimation *animation;
image = GTK_WIDGET (g_object_get_data (G_OBJECT (texture), "image"));
gtk_widget_get_allocation (image, &allocation);
/* do the second animation, have the icon grow out from the middle of the
* button */
- ClutterAnimation *animation = clutter_actor_animate (texture,
- CLUTTER_EASE_OUT_SINE,
- 100,
- "fixed::x", (float) allocation.x,
- "fixed::y", (float) allocation.y,
- "fixed::scale-x", 0.,
- "fixed::scale-y", 0.,
- "scale-x", 1.,
- "scale-y", 1.,
- "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
- NULL);
+ animation = clutter_actor_animate (texture, CLUTTER_EASE_OUT_SINE, 100,
+ "fixed::x", (float) allocation.x,
+ "fixed::y", (float) allocation.y,
+ "fixed::scale-x", 0.,
+ "fixed::scale-y", 0.,
+ "scale-x", 1.,
+ "scale-y", 1.,
+ "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+ NULL);
g_signal_connect_after (clutter_animation_get_timeline (animation),
- "completed",
- G_CALLBACK (animation_stage_2_complete),
- texture);
+ "completed",
+ G_CALLBACK (animation_stage_2_complete),
+ texture);
}
static void
button_clicked (GtkButton *button, char *stock_id)
{
+ GtkWidget *toplevel;
+
g_print ("button clicked: %s\n", stock_id);
/* this whole function is really, really hacky and should never, ever
* be copied into a real program. It's just a demonstration of what
* is hypothetically possible with GTK+ CSW and Clutter */
- GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
if (GTK_CLUTTER_IS_WINDOW (toplevel))
{
-
+ ClutterActor *texture, *stage;
+ GtkWidget *image;
char *icon_name;
GtkAllocation allocation;
GtkAllocation toplevel_allocation;
GtkIconSize size;
+ GdkPixbuf *blank;
+ ClutterAnimation *animation;
/* create a texture from the button image */
- ClutterActor *texture = gtk_clutter_texture_new ();
- GtkWidget *image = gtk_button_get_image (button);
+ texture = gtk_clutter_texture_new ();
+ image = gtk_button_get_image (button);
gtk_image_get_stock (GTK_IMAGE (image), &icon_name, &size);
gtk_clutter_texture_set_from_stock (GTK_CLUTTER_TEXTURE (texture),
GTK_WIDGET (button),
icon_name, size, NULL);
/* position the texture on top of the existing icon */
- ClutterActor *stage = gtk_clutter_window_get_stage (GTK_CLUTTER_WINDOW (toplevel));
+ stage = gtk_clutter_window_get_stage (GTK_CLUTTER_WINDOW (toplevel));
clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture);
g_object_set_data (G_OBJECT (texture), "image", image);
g_object_set_data_full (G_OBJECT (texture), "stock-id",
- g_strdup (icon_name), (GDestroyNotify) g_free);
+ g_strdup (icon_name),
+ (GDestroyNotify) g_free);
g_object_set_data (G_OBJECT (texture), "icon-size",
- GINT_TO_POINTER (size));
+ GINT_TO_POINTER (size));
gtk_widget_get_allocation (image, &allocation);
/* replace the icon itself */
- GdkPixbuf *blank = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE, 8,
- allocation.width,
- allocation.height);
+ blank = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ allocation.width,
+ allocation.height);
gdk_pixbuf_fill (blank, 0x00000000);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), blank);
g_object_unref (blank);
/* animate a fall due to gravity */
gtk_widget_get_allocation (toplevel, &toplevel_allocation);
- ClutterAnimation *animation = clutter_actor_animate (texture,
- CLUTTER_EASE_IN_QUAD,
- 200,
- "fixed::x", (float) allocation.x,
- "fixed::y", (float) allocation.y,
- "y", (float) toplevel_allocation.height,
- NULL);
+ animation = clutter_actor_animate (texture, CLUTTER_EASE_IN_QUAD, 200,
+ "fixed::x", (float) allocation.x,
+ "fixed::y", (float) allocation.y,
+ "y", (float) toplevel_allocation.height,
+ NULL);
g_signal_connect_after (clutter_animation_get_timeline (animation),
- "completed",
- G_CALLBACK (animation_stage_1_complete),
- texture);
+ "completed",
+ G_CALLBACK (animation_stage_1_complete),
+ texture);
}
}
@@ -121,10 +124,12 @@ add_button (GtkTable *table, char *stock_id, int row)
{
GtkWidget *button = gtk_button_new_from_stock (stock_id);
gtk_table_attach_defaults (GTK_TABLE (table), button,
- row, row + 1, row, row + 1);
+ row, row + 1,
+ row, row + 1);
g_signal_connect (button, "clicked",
- G_CALLBACK (button_clicked), stock_id);
+ G_CALLBACK (button_clicked),
+ stock_id);
return button;
}
@@ -132,10 +137,13 @@ add_button (GtkTable *table, char *stock_id, int row)
int
main (int argc, char **argv)
{
+ GtkWidget *window, *table;
+ GtkSettings *settings;
+
gtk_clutter_init (&argc, &argv);
- GtkWidget *window = gtk_clutter_window_new ();
- GtkWidget *table = gtk_table_new (6, 6, TRUE);
+ window = gtk_clutter_window_new ();
+ table = gtk_table_new (6, 6, TRUE);
add_button (GTK_TABLE (table), GTK_STOCK_OK, 0);
add_button (GTK_TABLE (table), GTK_STOCK_CANCEL, 1);
@@ -151,11 +159,12 @@ main (int argc, char **argv)
* of rely on this to be TRUE to actually show the stock
* icon falling off the button
*/
- GtkSettings *settings = gtk_widget_get_settings (window);
+ settings = gtk_widget_get_settings (window);
g_object_set (settings, "gtk-button-images", TRUE, NULL);
- g_signal_connect_swapped (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (window, "destroy",
+ G_CALLBACK (gtk_main_quit),
+ NULL);
gtk_main ();