mirror of
https://github.com/brl/mutter.git
synced 2025-04-25 03:09:39 +00:00
cookbook/examples: Modernize the code
Use new and non-deprecated methods.
This commit is contained in:
parent
aadbc6df3e
commit
618e04e9cc
@ -323,7 +323,8 @@ cb_button_init (CbButton *self)
|
|||||||
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
|
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
|
||||||
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 */
|
/* set the parent of the ClutterBox to this instance */
|
||||||
clutter_actor_add_child (CLUTTER_ACTOR (self), priv->child);
|
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));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +18,7 @@ toggle_highlight (ClutterActor *actor,
|
|||||||
|
|
||||||
clutter_actor_meta_set_enabled (meta, !effect_enabled);
|
clutter_actor_meta_set_enabled (meta, !effect_enabled);
|
||||||
|
|
||||||
clutter_actor_queue_redraw (actor);
|
return CLUTTER_EVENT_STOP;
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -59,7 +57,8 @@ main (int argc,
|
|||||||
clutter_flow_layout_set_row_spacing (CLUTTER_FLOW_LAYOUT (layout_manager),
|
clutter_flow_layout_set_row_spacing (CLUTTER_FLOW_LAYOUT (layout_manager),
|
||||||
10);
|
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,
|
width_constraint = clutter_bind_constraint_new (stage,
|
||||||
CLUTTER_BIND_WIDTH,
|
CLUTTER_BIND_WIDTH,
|
||||||
0.0);
|
0.0);
|
||||||
|
@ -38,24 +38,25 @@ main (int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
stage = clutter_stage_new ();
|
stage = clutter_stage_new ();
|
||||||
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
||||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "btn");
|
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,
|
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL,
|
||||||
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_position (box, 25, 25);
|
||||||
clutter_actor_set_reactive (box, TRUE);
|
clutter_actor_set_reactive (box, TRUE);
|
||||||
clutter_actor_set_size (box, 100, 30);
|
clutter_actor_set_size (box, 100, 30);
|
||||||
|
|
||||||
/* background for the button */
|
/* background for the button */
|
||||||
rect = clutter_rectangle_new_with_color (&yellow);
|
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 for the button */
|
||||||
text = clutter_text_new_full ("Sans 10pt", "Hover me", &white);
|
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;
|
* 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_HEIGHT, 50.0));
|
||||||
clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_WIDTH, 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);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
|
@ -35,8 +35,9 @@ main (int argc, char *argv[])
|
|||||||
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
|
layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
|
||||||
CLUTTER_BIN_ALIGNMENT_CENTER);
|
CLUTTER_BIN_ALIGNMENT_CENTER);
|
||||||
|
|
||||||
box = clutter_box_new (layout);
|
box = clutter_actor_new ();
|
||||||
clutter_box_set_color (CLUTTER_BOX (box), &box_color);
|
clutter_actor_set_layout_manager (box, layout);
|
||||||
|
clutter_actor_set_background_color (box, &box_color);
|
||||||
|
|
||||||
texture = clutter_texture_new_from_file (filename, &error);
|
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),
|
(gfloat)(width * 0.5) - (STAGE_SIDE * 0.03125),
|
||||||
CLUTTER_GRAVITY_CENTER);
|
CLUTTER_GRAVITY_CENTER);
|
||||||
clutter_actor_set_width (texture_copy, width);
|
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_BOTH, 0.5));
|
||||||
clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
|
clutter_actor_add_child (stage, box);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
|
|
||||||
|
|
||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user