[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_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");
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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,