From 7c89a0ccfab2d597b306f8189c623cec3ee76580 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 9 Jun 2009 13:48:03 +0100 Subject: [PATCH] [stage] Rename :fullscreen to :fullscreen-set The :fullscreen property is very much confusing as it is implemented. It can be written to a value, but the whole process might fail. If we set: g_object_set (stage, "fullscreen", TRUE, NULL); and the fullscreen process fails or it is not implemented, the value will be reset to FALSE (if we're lucky) or left TRUE (most of the times). The writability is just a shorthand for invoking clutter_stage_fullscreen() or clutter_stage_unfullscreen() depending on a boolean value without using an if. The :fullscreen property also greatly confuses high level languages, since the same symbol is used: - for a method name (Clutter.Stage.fullscreen()) - for a property name (Clutter.Stage.fullscreen) - for a signal (Clutter.Stage::fullscreen) For these reasons, the :fullscreen should be renamed to :fullscreen-set and be read-only. Implementations of the Stage should only emit the StageState event to change from normal to fullscreen, and the Stage will automatically update the value of the property and emit a notify signal for it. --- clutter/clutter-stage.c | 127 ++++++++++++++------------- clutter/sdl/clutter-stage-sdl.c | 2 +- clutter/x11/clutter-stage-x11.c | 4 +- tests/interactive/test-events.c | 12 ++- tests/interactive/test-fullscreen.c | 2 +- tests/interactive/test-perspective.c | 3 +- 6 files changed, 79 insertions(+), 71 deletions(-) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index d9cf7a67b..93a0cb32c 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -101,7 +101,7 @@ enum PROP_0, PROP_COLOR, - PROP_FULLSCREEN, + PROP_FULLSCREEN_SET, PROP_OFFSCREEN, PROP_CURSOR_VISIBLE, PROP_PERSPECTIVE, @@ -514,13 +514,6 @@ clutter_stage_set_property (GObject *object, } break; - case PROP_FULLSCREEN: - if (g_value_get_boolean (value)) - clutter_stage_fullscreen (stage); - else - clutter_stage_unfullscreen (stage); - break; - case PROP_CURSOR_VISIBLE: if (g_value_get_boolean (value)) clutter_stage_show_cursor (stage); @@ -572,7 +565,7 @@ clutter_stage_get_property (GObject *gobject, g_value_set_boolean (value, priv->is_offscreen); break; - case PROP_FULLSCREEN: + case PROP_FULLSCREEN_SET: g_value_set_boolean (value, priv->is_fullscreen); break; @@ -672,38 +665,48 @@ clutter_stage_class_init (ClutterStageClass *klass) * ClutterStage:fullscreen: * * Whether the stage should be fullscreen or not. + * + * This property is set by calling clutter_stage_fullscreen() + * and clutter_stage_unfullscreen() + * + * Since: 1.0 */ - g_object_class_install_property - (gobject_class, PROP_FULLSCREEN, - g_param_spec_boolean ("fullscreen", - "Fullscreen", - "Whether the main stage is fullscreen", - FALSE, - G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("fullscreen-set", + "Fullscreen Set", + "Whether the main stage is fullscreen", + FALSE, + CLUTTER_PARAM_READABLE); + g_object_class_install_property (gobject_class, + PROP_FULLSCREEN_SET, + pspec); /** * ClutterStage:offscreen: * * Whether the stage should be rendered in an offscreen buffer. */ - g_object_class_install_property - (gobject_class, PROP_OFFSCREEN, - g_param_spec_boolean ("offscreen", - "Offscreen", - "Whether the main stage is renderer offscreen", - FALSE, - G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("offscreen", + "Offscreen", + "Whether the main stage should be " + "rendered offscreen", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_OFFSCREEN, + pspec); /** * ClutterStage:cursor-visible: * * Whether the mouse pointer should be visible */ - g_object_class_install_property - (gobject_class, PROP_CURSOR_VISIBLE, - g_param_spec_boolean ("cursor-visible", - "Cursor Visible", - "Whether the mouse pointer is visible on the main stage ", - TRUE, - G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("cursor-visible", + "Cursor Visible", + "Whether the mouse pointer is visible " + "on the main stage", + TRUE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_CURSOR_VISIBLE, + pspec); /** * ClutterStage:user-resizable: * @@ -711,14 +714,15 @@ clutter_stage_class_init (ClutterStageClass *klass) * * Since: 0.4 */ - g_object_class_install_property - (gobject_class, PROP_USER_RESIZE, - g_param_spec_boolean ("user-resizable", - "User Resizable", - "Whether the stage is able to be resized via " - "user interaction", - FALSE, - G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("user-resizable", + "User Resizable", + "Whether the stage is able to be resized " + "via user interaction", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_USER_RESIZE, + pspec); /** * ClutterStage:color: * @@ -739,13 +743,14 @@ clutter_stage_class_init (ClutterStageClass *klass) * * Since: 0.8.2 */ - g_object_class_install_property - (gobject_class, PROP_PERSPECTIVE, - g_param_spec_boxed ("perspective", - "Perspective", - "Perspective projection parameters", - CLUTTER_TYPE_PERSPECTIVE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boxed ("perspective", + "Perspective", + "Perspective projection parameters", + CLUTTER_TYPE_PERSPECTIVE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + PROP_PERSPECTIVE, + pspec); /** * ClutterStage:title: @@ -754,13 +759,13 @@ clutter_stage_class_init (ClutterStageClass *klass) * * Since: 0.4 */ - g_object_class_install_property - (gobject_class, PROP_TITLE, - g_param_spec_string ("title", - "Title", - "Stage Title", - NULL, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_string ("title", + "Title", + "Stage Title", + NULL, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_TITLE, pspec); + /** * ClutterStage:use-fog: * @@ -770,13 +775,13 @@ clutter_stage_class_init (ClutterStageClass *klass) * * Since: 0.6 */ - g_object_class_install_property (gobject_class, - PROP_USE_FOG, - g_param_spec_boolean ("use-fog", - "Use Fog", - "Whether to enable depth cueing", - FALSE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("use-fog", + "Use Fog", + "Whether to enable depth cueing", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_USE_FOG, pspec); + /** * ClutterStage:fog: * @@ -1397,14 +1402,14 @@ clutter_stage_event (ClutterStage *stage, priv->is_fullscreen = TRUE; g_signal_emit (stage, stage_signals[FULLSCREEN], 0); - g_object_notify (G_OBJECT (stage), "fullscreen"); + g_object_notify (G_OBJECT (stage), "fullscreen-set"); } else { priv->is_fullscreen = FALSE; g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0); - g_object_notify (G_OBJECT (stage), "fullscreen"); + g_object_notify (G_OBJECT (stage), "fullscreen-set"); } } diff --git a/clutter/sdl/clutter-stage-sdl.c b/clutter/sdl/clutter-stage-sdl.c index fbb7a865f..efbec7b9c 100644 --- a/clutter/sdl/clutter-stage-sdl.c +++ b/clutter/sdl/clutter-stage-sdl.c @@ -64,7 +64,7 @@ clutter_stage_sdl_realize (ClutterActor *actor) is_offscreen = is_fullscreen = FALSE; g_object_get (stage_sdl->wrapper, "offscreen", &is_offscreen, - "fullscreen", &is_fullscreen, + "fullscreen-set", &is_fullscreen, NULL); if (G_LIKELY (!is_offscreen)) diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index ee9161776..5d7812582 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -164,7 +164,7 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self, is_fullscreen = FALSE; g_object_get (G_OBJECT (stage_x11->wrapper), - "fullscreen", &is_fullscreen, + "fullscreen-set", &is_fullscreen, NULL); if (is_fullscreen || stage_x11->fullscreen_on_map) @@ -207,7 +207,7 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self, is_fullscreen = FALSE; g_object_get (G_OBJECT (stage_x11->wrapper), - "fullscreen", &is_fullscreen, + "fullscreen-set", &is_fullscreen, NULL); if (is_fullscreen || stage_x11->fullscreen_on_map) diff --git a/tests/interactive/test-events.c b/tests/interactive/test-events.c index 1112e703c..a7d9571ed 100644 --- a/tests/interactive/test-events.c +++ b/tests/interactive/test-events.c @@ -23,11 +23,15 @@ blue_button_cb (ClutterActor *actor, stage = clutter_stage_get_default (); if (IsFullScreen) - IsFullScreen = FALSE; + { + IsFullScreen = FALSE; + clutter_stage_unfullscreen (CLUTTER_STAGE (stage)); + } else - IsFullScreen = TRUE; - - g_object_set (stage, "fullscreen", IsFullScreen, NULL); + { + IsFullScreen = TRUE; + clutter_stage_fullscreen (CLUTTER_STAGE (stage)); + } g_print ("*** Fullscreen %s ***\n", IsFullScreen ? "enabled" : "disabled"); diff --git a/tests/interactive/test-fullscreen.c b/tests/interactive/test-fullscreen.c index 2952a8eb4..a2dc41295 100644 --- a/tests/interactive/test-fullscreen.c +++ b/tests/interactive/test-fullscreen.c @@ -36,7 +36,7 @@ toggle_fullscreen (gpointer dummy) ClutterActor *stage = clutter_stage_get_default (); gboolean is_fullscreen = FALSE; - g_object_get (G_OBJECT (stage), "fullscreen", &is_fullscreen, NULL); + g_object_get (G_OBJECT (stage), "fullscreen-set", &is_fullscreen, NULL); switch (state) { diff --git a/tests/interactive/test-perspective.c b/tests/interactive/test-perspective.c index 5f467e591..7872ca6a8 100644 --- a/tests/interactive/test-perspective.c +++ b/tests/interactive/test-perspective.c @@ -11,9 +11,8 @@ test_perspective_main (int argc, char *argv[]) clutter_init (&argc, &argv); stage = clutter_stage_get_default (); - g_object_set (stage, "fullscreen", TRUE, NULL); - clutter_stage_set_color (CLUTTER_STAGE (stage), &red); + clutter_stage_fullscreen (CLUTTER_STAGE (stage)); rect = clutter_rectangle_new_with_color (&white); clutter_actor_set_size (rect,