cookbook: Fix examples

This commit is contained in:
Emmanuele Bassi 2010-07-01 15:59:15 +01:00
parent b74c722670
commit da06f650df

View File

@ -58,14 +58,14 @@
<informalexample> <informalexample>
<programlisting> <programlisting>
g_signal_connect (actor, "notify::x", g_signal_connect (actor, "notify::x",
G_CALLBACK (on_x_changed), G_CALLBACK (on_x_changed),
NULL); NULL);
g_signal_connect (actor, "notify::height", g_signal_connect (actor, "notify::height",
G_CALLBACK (on_height_changed), G_CALLBACK (on_height_changed),
NULL); NULL);
g_signal_connect (actor, "notify::depth", g_signal_connect (actor, "notify::depth",
G_CALLBACK (on_depth_changed), G_CALLBACK (on_depth_changed),
NULL); NULL);
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -76,8 +76,8 @@ g_signal_connect (actor, "notify::depth",
<informalexample> <informalexample>
<programlisting> <programlisting>
g_signal_connect (actor, "allocation-changed", g_signal_connect (actor, "allocation-changed",
G_CALLBACK (on_allocation_changed), G_CALLBACK (on_allocation_changed),
NULL); NULL);
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -87,8 +87,8 @@ g_signal_connect (actor, "allocation-changed",
<programlisting> <programlisting>
void void
on_notify (GObject *gobject, on_notify (GObject *gobject,
GParamSpec *pspec, GParamSpec *pspec,
gpointer user_data); gpointer user_data);
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -99,9 +99,9 @@ on_notify (GObject *gobject,
<programlisting> <programlisting>
void void
on_allocation_changed (ClutterActor *actor, on_allocation_changed (ClutterActor *actor,
const ClutterActorBox *allocation, const ClutterActorBox *allocation,
ClutterAllocationFlags flags, ClutterAllocationFlags flags,
gpointer user_data); gpointer user_data);
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -122,15 +122,15 @@ on_allocation_changed (ClutterActor *actor,
<programlisting> <programlisting>
void void
on_x_changed (GObject *gobject, on_x_changed (GObject *gobject,
GParamSpec *pspec, GParamSpec *pspec,
gpointer user_data) gpointer user_data)
{ {
gint x_value = 0; gint x_value = 0;
/* Round the X coordinate to the nearest pixel */ /* Round the X coordinate to the nearest pixel */
x_value = floorf (clutter_actor_get_x (CLUTTER_ACTOR (gobject))) + 0.5; x_value = floorf (clutter_actor_get_x (CLUTTER_ACTOR (gobject))) + 0.5;
g_print ("The new X coordinate is '%d' pixels\n", x_value); g_print ("The new X coordinate is '%d' pixels\n", x_value);
} }
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -143,17 +143,15 @@ g_print ("The new X coordinate is '%d' pixels\n", x_value);
<programlisting> <programlisting>
void void
on_allocation_changed (ClutterActor *actor, on_allocation_changed (ClutterActor *actor,
const ClutterActorBox *allocation, const ClutterActorBox *allocation,
ClutterAllocationFlags flags, ClutterAllocationFlags flags,
gpointer user_data) gpointer user_data)
{ {
ClutterActor *actor = CLUTTER_ACTOR (gobject); g_print ("The bounding box is now: (%.2f, %.2f) (%.2f x %.2f)\n",
clutter_actor_box_get_x (allocation),
g_print ("The bounding box is now: (%.2f, %.2f) (%.2f x %.2f)\n", clutter_actor_box_get_y (allocation),
clutter_actor_box_get_x (allocation), clutter_actor_box_get_width (allocation),
clutter_actor_box_get_y (allocation), clutter_actor_box_get_height (allocation));
clutter_actor_box_get_width (allocation),
clutter_actor_box_get_height (allocation));
} }
</programlisting> </programlisting>
</informalexample> </informalexample>
@ -243,9 +241,9 @@ void on_paint (ClutterActor *actor, gpointer user_data);
void void
on_paint (ClutterActor *actor) on_paint (ClutterActor *actor)
{ {
do_my_paint (actor); do_my_paint (actor);
g_signal_stop_emission_by_name (actor, "paint"); g_signal_stop_emission_by_name (actor, "paint");
} }
</programlisting> </programlisting>
</informalexample> </informalexample>