mirror of
https://github.com/brl/mutter.git
synced 2025-02-04 15:44:10 +00:00
stage-manager: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
4425636219
commit
4a2f7a51e3
@ -28,13 +28,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
struct _ClutterStageManager
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GSList *stages;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* stage manager */
|
/* stage manager */
|
||||||
void _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
void _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
||||||
ClutterStage *stage);
|
ClutterStage *stage);
|
||||||
|
@ -61,7 +61,14 @@ enum
|
|||||||
static guint manager_signals[LAST_SIGNAL] = { 0, };
|
static guint manager_signals[LAST_SIGNAL] = { 0, };
|
||||||
static ClutterStage *default_stage = NULL;
|
static ClutterStage *default_stage = NULL;
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterStageManager, clutter_stage_manager, G_TYPE_OBJECT);
|
typedef struct _ClutterStageManagerPrivate
|
||||||
|
{
|
||||||
|
GSList *stages;
|
||||||
|
} ClutterStageManagerPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageManager,
|
||||||
|
clutter_stage_manager,
|
||||||
|
G_TYPE_OBJECT);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_manager_get_property (GObject *gobject,
|
clutter_stage_manager_get_property (GObject *gobject,
|
||||||
@ -83,13 +90,13 @@ clutter_stage_manager_get_property (GObject *gobject,
|
|||||||
static void
|
static void
|
||||||
clutter_stage_manager_dispose (GObject *gobject)
|
clutter_stage_manager_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
ClutterStageManager *stage_manager;
|
ClutterStageManager *stage_manager = CLUTTER_STAGE_MANAGER (gobject);
|
||||||
|
ClutterStageManagerPrivate *priv =
|
||||||
|
clutter_stage_manager_get_instance_private (stage_manager);
|
||||||
|
|
||||||
stage_manager = CLUTTER_STAGE_MANAGER (gobject);
|
g_slist_free_full (priv->stages,
|
||||||
|
|
||||||
g_slist_free_full (stage_manager->stages,
|
|
||||||
(GDestroyNotify) clutter_actor_destroy);
|
(GDestroyNotify) clutter_actor_destroy);
|
||||||
stage_manager->stages = NULL;
|
priv->stages = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (clutter_stage_manager_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_stage_manager_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
@ -200,7 +207,10 @@ clutter_stage_manager_get_default_stage (ClutterStageManager *stage_manager)
|
|||||||
GSList *
|
GSList *
|
||||||
clutter_stage_manager_list_stages (ClutterStageManager *stage_manager)
|
clutter_stage_manager_list_stages (ClutterStageManager *stage_manager)
|
||||||
{
|
{
|
||||||
return g_slist_copy (stage_manager->stages);
|
ClutterStageManagerPrivate *priv =
|
||||||
|
clutter_stage_manager_get_instance_private (stage_manager);
|
||||||
|
|
||||||
|
return g_slist_copy (priv->stages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,14 +227,19 @@ clutter_stage_manager_list_stages (ClutterStageManager *stage_manager)
|
|||||||
const GSList *
|
const GSList *
|
||||||
clutter_stage_manager_peek_stages (ClutterStageManager *stage_manager)
|
clutter_stage_manager_peek_stages (ClutterStageManager *stage_manager)
|
||||||
{
|
{
|
||||||
return stage_manager->stages;
|
ClutterStageManagerPrivate *priv =
|
||||||
|
clutter_stage_manager_get_instance_private (stage_manager);
|
||||||
|
|
||||||
|
return priv->stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
_clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
||||||
ClutterStage *stage)
|
ClutterStage *stage)
|
||||||
{
|
{
|
||||||
if (g_slist_find (stage_manager->stages, stage))
|
ClutterStageManagerPrivate *priv =
|
||||||
|
clutter_stage_manager_get_instance_private (stage_manager);
|
||||||
|
if (g_slist_find (priv->stages, stage))
|
||||||
{
|
{
|
||||||
g_warning ("Trying to add a stage to the list of managed stages, "
|
g_warning ("Trying to add a stage to the list of managed stages, "
|
||||||
"but it is already in it, aborting.");
|
"but it is already in it, aborting.");
|
||||||
@ -233,7 +248,7 @@ _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
|||||||
|
|
||||||
g_object_ref_sink (stage);
|
g_object_ref_sink (stage);
|
||||||
|
|
||||||
stage_manager->stages = g_slist_append (stage_manager->stages, stage);
|
priv->stages = g_slist_append (priv->stages, stage);
|
||||||
|
|
||||||
g_signal_emit (stage_manager, manager_signals[STAGE_ADDED], 0, stage);
|
g_signal_emit (stage_manager, manager_signals[STAGE_ADDED], 0, stage);
|
||||||
}
|
}
|
||||||
@ -242,13 +257,15 @@ void
|
|||||||
_clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager,
|
_clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager,
|
||||||
ClutterStage *stage)
|
ClutterStage *stage)
|
||||||
{
|
{
|
||||||
|
ClutterStageManagerPrivate *priv =
|
||||||
|
clutter_stage_manager_get_instance_private (stage_manager);
|
||||||
/* this might be called multiple times from a ::dispose, so it
|
/* this might be called multiple times from a ::dispose, so it
|
||||||
* needs to just return without warning
|
* needs to just return without warning
|
||||||
*/
|
*/
|
||||||
if (!g_slist_find (stage_manager->stages, stage))
|
if (!g_slist_find (priv->stages, stage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stage_manager->stages = g_slist_remove (stage_manager->stages, stage);
|
priv->stages = g_slist_remove (priv->stages, stage);
|
||||||
|
|
||||||
/* if the default stage is being destroyed then we unset the pointer */
|
/* if the default stage is being destroyed then we unset the pointer */
|
||||||
if (default_stage == stage)
|
if (default_stage == stage)
|
||||||
|
@ -32,14 +32,13 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_STAGE_MANAGER (clutter_stage_manager_get_type ())
|
#define CLUTTER_TYPE_STAGE_MANAGER (clutter_stage_manager_get_type ())
|
||||||
#define CLUTTER_STAGE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_MANAGER, ClutterStageManager))
|
|
||||||
#define CLUTTER_IS_STAGE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STAGE_MANAGER))
|
|
||||||
#define CLUTTER_STAGE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STAGE_MANAGER, ClutterStageManagerClass))
|
|
||||||
#define CLUTTER_IS_STAGE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STAGE_MANAGER))
|
|
||||||
#define CLUTTER_STAGE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STAGE_MANAGER, ClutterStageManagerClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterStageManager ClutterStageManager;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterStageManagerClass ClutterStageManagerClass;
|
G_DECLARE_DERIVABLE_TYPE (ClutterStageManager,
|
||||||
|
clutter_stage_manager,
|
||||||
|
CLUTTER,
|
||||||
|
STAGE_MANAGER,
|
||||||
|
GObject)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterStageManagerClass:
|
* ClutterStageManagerClass:
|
||||||
@ -58,9 +57,6 @@ struct _ClutterStageManagerClass
|
|||||||
ClutterStage *stage);
|
ClutterStage *stage);
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_stage_manager_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterStageManager *clutter_stage_manager_get_default (void);
|
ClutterStageManager *clutter_stage_manager_get_default (void);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user