cookbook/examples: Modernize the code

Use new and non-deprecated methods.
This commit is contained in:
Emmanuele Bassi 2012-02-24 15:42:11 +00:00
parent aadbc6df3e
commit 618e04e9cc
4 changed files with 18 additions and 17 deletions

View File

@ -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);
}
/**

View File

@ -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);

View File

@ -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);

View File

@ -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);