stage: Deprecate the default stage

Deprecate the clutter_stage_get_default() function, as well as the
clutter_stage_is_default() one, and replace its internal usage.
This commit is contained in:
Emmanuele Bassi 2011-11-09 17:12:45 +00:00
parent 2288d708e2
commit 0c18dc6bf9
3 changed files with 31 additions and 15 deletions

View File

@ -276,6 +276,23 @@ queue_full_redraw (ClutterStage *stage)
_clutter_stage_window_add_redraw_clip (stage_window, NULL); _clutter_stage_window_add_redraw_clip (stage_window, NULL);
} }
static gboolean
stage_is_default (ClutterStage *stage)
{
ClutterStageManager *stage_manager;
ClutterStageWindow *impl;
stage_manager = clutter_stage_manager_get_default ();
if (stage != clutter_stage_manager_get_default_stage (stage_manager))
return FALSE;
impl = _clutter_stage_get_window (stage);
if (impl != _clutter_stage_get_default_window ())
return FALSE;
return TRUE;
}
static void static void
clutter_stage_allocate (ClutterActor *self, clutter_stage_allocate (ClutterActor *self,
const ClutterActorBox *box, const ClutterActorBox *box,
@ -1472,7 +1489,7 @@ static gboolean
clutter_stage_real_delete_event (ClutterStage *stage, clutter_stage_real_delete_event (ClutterStage *stage,
ClutterEvent *event) ClutterEvent *event)
{ {
if (clutter_stage_is_default (stage)) if (stage_is_default (stage))
clutter_main_quit (); clutter_main_quit ();
else else
clutter_actor_destroy (CLUTTER_ACTOR (stage)); clutter_actor_destroy (CLUTTER_ACTOR (stage));
@ -2197,6 +2214,8 @@ clutter_stage_init (ClutterStage *self)
* Return value: (transfer none) (type Clutter.Stage): the main * Return value: (transfer none) (type Clutter.Stage): the main
* #ClutterStage. You should never destroy or unref the returned * #ClutterStage. You should never destroy or unref the returned
* actor. * actor.
*
* Deprecated: 1.10: Use clutter_stage_new() instead.
*/ */
ClutterActor * ClutterActor *
clutter_stage_get_default (void) clutter_stage_get_default (void)
@ -3497,24 +3516,17 @@ clutter_stage_queue_redraw (ClutterStage *stage)
* Return value: %TRUE if the passed stage is the default one * Return value: %TRUE if the passed stage is the default one
* *
* Since: 0.8 * Since: 0.8
*
* Deprecated: 1.10: Track the stage pointer inside your application
* code, or use clutter_actor_get_stage() to retrieve the stage for
* a given actor.
*/ */
gboolean gboolean
clutter_stage_is_default (ClutterStage *stage) clutter_stage_is_default (ClutterStage *stage)
{ {
ClutterStageManager *stage_manager;
ClutterStageWindow *impl;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
stage_manager = clutter_stage_manager_get_default (); return stage_is_default (stage);
if (stage != clutter_stage_manager_get_default_stage (stage_manager))
return FALSE;
impl = _clutter_stage_get_window (stage);
if (impl != _clutter_stage_get_default_window ())
return FALSE;
return TRUE;
} }
void void

View File

@ -146,7 +146,6 @@ GType clutter_perspective_get_type (void) G_GNUC_CONST;
GType clutter_fog_get_type (void) G_GNUC_CONST; GType clutter_fog_get_type (void) G_GNUC_CONST;
GType clutter_stage_get_type (void) G_GNUC_CONST; GType clutter_stage_get_type (void) G_GNUC_CONST;
ClutterActor *clutter_stage_get_default (void);
ClutterActor *clutter_stage_new (void); ClutterActor *clutter_stage_new (void);
void clutter_stage_set_color (ClutterStage *stage, void clutter_stage_set_color (ClutterStage *stage,
@ -194,7 +193,6 @@ void clutter_stage_set_key_focus (ClutterStage *stage,
ClutterActor * clutter_stage_get_key_focus (ClutterStage *stage); ClutterActor * clutter_stage_get_key_focus (ClutterStage *stage);
void clutter_stage_ensure_current (ClutterStage *stage); void clutter_stage_ensure_current (ClutterStage *stage);
void clutter_stage_queue_redraw (ClutterStage *stage); void clutter_stage_queue_redraw (ClutterStage *stage);
gboolean clutter_stage_is_default (ClutterStage *stage);
void clutter_stage_ensure_viewport (ClutterStage *stage); void clutter_stage_ensure_viewport (ClutterStage *stage);
void clutter_stage_ensure_redraw (ClutterStage *stage); void clutter_stage_ensure_redraw (ClutterStage *stage);

View File

@ -40,6 +40,12 @@ G_BEGIN_DECLS
#endif /* CLUTTER_DISABLE_DEPRECATED */ #endif /* CLUTTER_DISABLE_DEPRECATED */
CLUTTER_DEPRECATED_FOR(clutter_stage_new)
ClutterActor * clutter_stage_get_default (void);
CLUTTER_DEPRECATED
gboolean clutter_stage_is_default (ClutterStage *stage);
G_END_DECLS G_END_DECLS
#endif /* __CLUTTER_STAGE_DEPRECATED_H__ */ #endif /* __CLUTTER_STAGE_DEPRECATED_H__ */