[clutter] cookbook/examples: Modernize the code
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] cookbook/examples: Modernize the code
- Date: Mon, 27 Feb 2012 11:06:51 +0000 (UTC)
commit 618e04e9ccb14c5a920b0d0974b539267d64a2b7
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Feb 24 15:42:11 2012 +0000
cookbook/examples: Modernize the code
Use new and non-deprecated methods.
doc/cookbook/examples/cb-button.c | 5 +++--
doc/cookbook/examples/effects-basic.c | 7 +++----
.../examples/events-pointer-motion-crossing.c | 11 ++++++-----
doc/cookbook/examples/layouts-stacking.c | 12 ++++++------
4 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/doc/cookbook/examples/cb-button.c b/doc/cookbook/examples/cb-button.c
index 6f1f0b9..2abbf7f 100644
--- a/doc/cookbook/examples/cb-button.c
+++ b/doc/cookbook/examples/cb-button.c
@@ -323,7 +323,8 @@ cb_button_init (CbButton *self)
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
CLUTTER_BIN_ALIGNMENT_CENTER);
- priv->child = clutter_box_new (layout);
+ priv->child = clutter_actor_new ();
+ clutter_actor_set_layout_manager (priv->child, layout);
/* set the parent of the ClutterBox to this instance */
clutter_actor_add_child (CLUTTER_ACTOR (self), priv->child);
@@ -400,7 +401,7 @@ cb_button_set_background_color (CbButton *self,
{
g_return_if_fail (CB_IS_BUTTON (self));
- clutter_box_set_color (CLUTTER_BOX (self->priv->child), color);
+ clutter_actor_set_background_color (self->priv->child, color);
}
/**
diff --git a/doc/cookbook/examples/effects-basic.c b/doc/cookbook/examples/effects-basic.c
index 875e4c8..151a244 100644
--- a/doc/cookbook/examples/effects-basic.c
+++ b/doc/cookbook/examples/effects-basic.c
@@ -18,9 +18,7 @@ toggle_highlight (ClutterActor *actor,
clutter_actor_meta_set_enabled (meta, !effect_enabled);
- clutter_actor_queue_redraw (actor);
-
- return TRUE;
+ return CLUTTER_EVENT_STOP;
}
int
@@ -59,7 +57,8 @@ main (int argc,
clutter_flow_layout_set_row_spacing (CLUTTER_FLOW_LAYOUT (layout_manager),
10);
- box = clutter_box_new (layout_manager);
+ box = clutter_actor_new ();
+ clutter_actor_set_layout_manager (box, layout_manager);
width_constraint = clutter_bind_constraint_new (stage,
CLUTTER_BIND_WIDTH,
0.0);
diff --git a/doc/cookbook/examples/events-pointer-motion-crossing.c b/doc/cookbook/examples/events-pointer-motion-crossing.c
index 03852bb..946ff2b 100644
--- a/doc/cookbook/examples/events-pointer-motion-crossing.c
+++ b/doc/cookbook/examples/events-pointer-motion-crossing.c
@@ -38,24 +38,25 @@ main (int argc, char *argv[])
return 1;
stage = clutter_stage_new ();
- clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
clutter_stage_set_title (CLUTTER_STAGE (stage), "btn");
+ clutter_actor_set_background_color (stage, &stage_color);
+ g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL,
CLUTTER_BIN_ALIGNMENT_FILL);
- box = clutter_box_new (layout);
+ box = clutter_actor_new ();
+ clutter_actor_set_layout_manager (box, layout);
clutter_actor_set_position (box, 25, 25);
clutter_actor_set_reactive (box, TRUE);
clutter_actor_set_size (box, 100, 30);
/* background for the button */
rect = clutter_rectangle_new_with_color (&yellow);
- clutter_container_add_actor (CLUTTER_CONTAINER (box), rect);
+ clutter_actor_add_child (box, rect);
/* text for the button */
text = clutter_text_new_full ("Sans 10pt", "Hover me", &white);
- clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER);
/*
* NB don't set the height, so the actor assumes the height of the text;
@@ -102,7 +103,7 @@ main (int argc, char *argv[])
clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_HEIGHT, 50.0));
clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_WIDTH, 50.0));
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
+ clutter_actor_add_child (stage, box);
clutter_actor_show (stage);
diff --git a/doc/cookbook/examples/layouts-stacking.c b/doc/cookbook/examples/layouts-stacking.c
index 4fda817..9ee340b 100644
--- a/doc/cookbook/examples/layouts-stacking.c
+++ b/doc/cookbook/examples/layouts-stacking.c
@@ -35,8 +35,9 @@ main (int argc, char *argv[])
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
CLUTTER_BIN_ALIGNMENT_CENTER);
- box = clutter_box_new (layout);
- clutter_box_set_color (CLUTTER_BOX (box), &box_color);
+ box = clutter_actor_new ();
+ clutter_actor_set_layout_manager (box, layout);
+ clutter_actor_set_background_color (box, &box_color);
texture = clutter_texture_new_from_file (filename, &error);
@@ -67,12 +68,11 @@ main (int argc, char *argv[])
(gfloat)(width * 0.5) - (STAGE_SIDE * 0.03125),
CLUTTER_GRAVITY_CENTER);
clutter_actor_set_width (texture_copy, width);
- clutter_container_add_actor (CLUTTER_CONTAINER (box), texture_copy);
+ clutter_actor_add_child (box, texture_copy);
}
- clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
- clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
+ clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
+ clutter_actor_add_child (stage, box);
clutter_actor_show (stage);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]