[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.
This commit is contained in:
Emmanuele Bassi 2009-06-09 13:48:03 +01:00
parent ea82346e0d
commit 7c89a0ccfa
6 changed files with 79 additions and 71 deletions

View File

@ -101,7 +101,7 @@ enum
PROP_0, PROP_0,
PROP_COLOR, PROP_COLOR,
PROP_FULLSCREEN, PROP_FULLSCREEN_SET,
PROP_OFFSCREEN, PROP_OFFSCREEN,
PROP_CURSOR_VISIBLE, PROP_CURSOR_VISIBLE,
PROP_PERSPECTIVE, PROP_PERSPECTIVE,
@ -514,13 +514,6 @@ clutter_stage_set_property (GObject *object,
} }
break; break;
case PROP_FULLSCREEN:
if (g_value_get_boolean (value))
clutter_stage_fullscreen (stage);
else
clutter_stage_unfullscreen (stage);
break;
case PROP_CURSOR_VISIBLE: case PROP_CURSOR_VISIBLE:
if (g_value_get_boolean (value)) if (g_value_get_boolean (value))
clutter_stage_show_cursor (stage); clutter_stage_show_cursor (stage);
@ -572,7 +565,7 @@ clutter_stage_get_property (GObject *gobject,
g_value_set_boolean (value, priv->is_offscreen); g_value_set_boolean (value, priv->is_offscreen);
break; break;
case PROP_FULLSCREEN: case PROP_FULLSCREEN_SET:
g_value_set_boolean (value, priv->is_fullscreen); g_value_set_boolean (value, priv->is_fullscreen);
break; break;
@ -672,38 +665,48 @@ clutter_stage_class_init (ClutterStageClass *klass)
* ClutterStage:fullscreen: * ClutterStage:fullscreen:
* *
* Whether the stage should be fullscreen or not. * 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 pspec = g_param_spec_boolean ("fullscreen-set",
(gobject_class, PROP_FULLSCREEN, "Fullscreen Set",
g_param_spec_boolean ("fullscreen",
"Fullscreen",
"Whether the main stage is fullscreen", "Whether the main stage is fullscreen",
FALSE, FALSE,
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READABLE);
g_object_class_install_property (gobject_class,
PROP_FULLSCREEN_SET,
pspec);
/** /**
* ClutterStage:offscreen: * ClutterStage:offscreen:
* *
* Whether the stage should be rendered in an offscreen buffer. * Whether the stage should be rendered in an offscreen buffer.
*/ */
g_object_class_install_property pspec = g_param_spec_boolean ("offscreen",
(gobject_class, PROP_OFFSCREEN,
g_param_spec_boolean ("offscreen",
"Offscreen", "Offscreen",
"Whether the main stage is renderer offscreen", "Whether the main stage should be "
"rendered offscreen",
FALSE, FALSE,
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_OFFSCREEN,
pspec);
/** /**
* ClutterStage:cursor-visible: * ClutterStage:cursor-visible:
* *
* Whether the mouse pointer should be visible * Whether the mouse pointer should be visible
*/ */
g_object_class_install_property pspec = g_param_spec_boolean ("cursor-visible",
(gobject_class, PROP_CURSOR_VISIBLE,
g_param_spec_boolean ("cursor-visible",
"Cursor Visible", "Cursor Visible",
"Whether the mouse pointer is visible on the main stage ", "Whether the mouse pointer is visible "
"on the main stage",
TRUE, TRUE,
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_CURSOR_VISIBLE,
pspec);
/** /**
* ClutterStage:user-resizable: * ClutterStage:user-resizable:
* *
@ -711,14 +714,15 @@ clutter_stage_class_init (ClutterStageClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property pspec = g_param_spec_boolean ("user-resizable",
(gobject_class, PROP_USER_RESIZE,
g_param_spec_boolean ("user-resizable",
"User Resizable", "User Resizable",
"Whether the stage is able to be resized via " "Whether the stage is able to be resized "
"user interaction", "via user interaction",
FALSE, FALSE,
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_USER_RESIZE,
pspec);
/** /**
* ClutterStage:color: * ClutterStage:color:
* *
@ -739,13 +743,14 @@ clutter_stage_class_init (ClutterStageClass *klass)
* *
* Since: 0.8.2 * Since: 0.8.2
*/ */
g_object_class_install_property pspec = g_param_spec_boxed ("perspective",
(gobject_class, PROP_PERSPECTIVE,
g_param_spec_boxed ("perspective",
"Perspective", "Perspective",
"Perspective projection parameters", "Perspective projection parameters",
CLUTTER_TYPE_PERSPECTIVE, CLUTTER_TYPE_PERSPECTIVE,
CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_PERSPECTIVE,
pspec);
/** /**
* ClutterStage:title: * ClutterStage:title:
@ -754,13 +759,13 @@ clutter_stage_class_init (ClutterStageClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property pspec = g_param_spec_string ("title",
(gobject_class, PROP_TITLE,
g_param_spec_string ("title",
"Title", "Title",
"Stage Title", "Stage Title",
NULL, NULL,
CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_TITLE, pspec);
/** /**
* ClutterStage:use-fog: * ClutterStage:use-fog:
* *
@ -770,13 +775,13 @@ clutter_stage_class_init (ClutterStageClass *klass)
* *
* Since: 0.6 * Since: 0.6
*/ */
g_object_class_install_property (gobject_class, pspec = g_param_spec_boolean ("use-fog",
PROP_USE_FOG,
g_param_spec_boolean ("use-fog",
"Use Fog", "Use Fog",
"Whether to enable depth cueing", "Whether to enable depth cueing",
FALSE, FALSE,
CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_USE_FOG, pspec);
/** /**
* ClutterStage:fog: * ClutterStage:fog:
* *
@ -1397,14 +1402,14 @@ clutter_stage_event (ClutterStage *stage,
priv->is_fullscreen = TRUE; priv->is_fullscreen = TRUE;
g_signal_emit (stage, stage_signals[FULLSCREEN], 0); g_signal_emit (stage, stage_signals[FULLSCREEN], 0);
g_object_notify (G_OBJECT (stage), "fullscreen"); g_object_notify (G_OBJECT (stage), "fullscreen-set");
} }
else else
{ {
priv->is_fullscreen = FALSE; priv->is_fullscreen = FALSE;
g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0); g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0);
g_object_notify (G_OBJECT (stage), "fullscreen"); g_object_notify (G_OBJECT (stage), "fullscreen-set");
} }
} }

View File

@ -64,7 +64,7 @@ clutter_stage_sdl_realize (ClutterActor *actor)
is_offscreen = is_fullscreen = FALSE; is_offscreen = is_fullscreen = FALSE;
g_object_get (stage_sdl->wrapper, g_object_get (stage_sdl->wrapper,
"offscreen", &is_offscreen, "offscreen", &is_offscreen,
"fullscreen", &is_fullscreen, "fullscreen-set", &is_fullscreen,
NULL); NULL);
if (G_LIKELY (!is_offscreen)) if (G_LIKELY (!is_offscreen))

View File

@ -164,7 +164,7 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self,
is_fullscreen = FALSE; is_fullscreen = FALSE;
g_object_get (G_OBJECT (stage_x11->wrapper), g_object_get (G_OBJECT (stage_x11->wrapper),
"fullscreen", &is_fullscreen, "fullscreen-set", &is_fullscreen,
NULL); NULL);
if (is_fullscreen || stage_x11->fullscreen_on_map) if (is_fullscreen || stage_x11->fullscreen_on_map)
@ -207,7 +207,7 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self,
is_fullscreen = FALSE; is_fullscreen = FALSE;
g_object_get (G_OBJECT (stage_x11->wrapper), g_object_get (G_OBJECT (stage_x11->wrapper),
"fullscreen", &is_fullscreen, "fullscreen-set", &is_fullscreen,
NULL); NULL);
if (is_fullscreen || stage_x11->fullscreen_on_map) if (is_fullscreen || stage_x11->fullscreen_on_map)

View File

@ -23,11 +23,15 @@ blue_button_cb (ClutterActor *actor,
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
if (IsFullScreen) if (IsFullScreen)
{
IsFullScreen = FALSE; IsFullScreen = FALSE;
clutter_stage_unfullscreen (CLUTTER_STAGE (stage));
}
else else
{
IsFullScreen = TRUE; IsFullScreen = TRUE;
clutter_stage_fullscreen (CLUTTER_STAGE (stage));
g_object_set (stage, "fullscreen", IsFullScreen, NULL); }
g_print ("*** Fullscreen %s ***\n", g_print ("*** Fullscreen %s ***\n",
IsFullScreen ? "enabled" : "disabled"); IsFullScreen ? "enabled" : "disabled");

View File

@ -36,7 +36,7 @@ toggle_fullscreen (gpointer dummy)
ClutterActor *stage = clutter_stage_get_default (); ClutterActor *stage = clutter_stage_get_default ();
gboolean is_fullscreen = FALSE; 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) switch (state)
{ {

View File

@ -11,9 +11,8 @@ test_perspective_main (int argc, char *argv[])
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
g_object_set (stage, "fullscreen", TRUE, NULL);
clutter_stage_set_color (CLUTTER_STAGE (stage), &red); clutter_stage_set_color (CLUTTER_STAGE (stage), &red);
clutter_stage_fullscreen (CLUTTER_STAGE (stage));
rect = clutter_rectangle_new_with_color (&white); rect = clutter_rectangle_new_with_color (&white);
clutter_actor_set_size (rect, clutter_actor_set_size (rect,