meta/plugin: Use G_DECLARE_DERIVABLE_TYPE

It cuts out some of the GObject boilerplate, and gives us g_autoptr()
support for free.

Since this changes the ABI, we also need to bump the libmutter API
version.
This commit is contained in:
Niels De Graef 2018-10-30 11:19:36 +01:00 committed by Niels De Graef
parent e11ee44236
commit ca7c5c1223
4 changed files with 12 additions and 31 deletions

View File

@ -9,7 +9,7 @@ m4_define([mutter_version],
m4_define([mutter_plugin_api_version], [3]) m4_define([mutter_plugin_api_version], [3])
m4_define([libmutter_api_version], [3]) m4_define([libmutter_api_version], [4])
AC_INIT([mutter], [mutter_version], AC_INIT([mutter], [mutter_version],
[http://bugzilla.gnome.org/enter_bug.cgi?product=mutter]) [http://bugzilla.gnome.org/enter_bug.cgi?product=mutter])

View File

@ -6,7 +6,7 @@ project('mutter', 'c',
mutter_plugin_api_version = '3' mutter_plugin_api_version = '3'
libmutter_api_version = '3' libmutter_api_version = '4'
# generic version requirements # generic version requirements
glib_req = '>= 2.53.2' glib_req = '>= 2.53.2'

View File

@ -43,16 +43,14 @@
#include "meta/display.h" #include "meta/display.h"
#include "meta/util.h" #include "meta/util.h"
struct _MetaPluginPrivate
typedef struct _MetaPluginPrivate
{ {
MetaCompositor *compositor; MetaCompositor *compositor;
}; } MetaPluginPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaPlugin, meta_plugin, G_TYPE_OBJECT); G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaPlugin, meta_plugin, G_TYPE_OBJECT);
#define META_PLUGIN_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), META_TYPE_PLUGIN, MetaPluginPrivate))
static void static void
meta_plugin_class_init (MetaPluginClass *klass) meta_plugin_class_init (MetaPluginClass *klass)
{ {
@ -61,7 +59,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
static void static void
meta_plugin_init (MetaPlugin *self) meta_plugin_init (MetaPlugin *self)
{ {
self->priv = META_PLUGIN_GET_PRIVATE (self);
} }
const MetaPluginInfo * const MetaPluginInfo *
@ -90,7 +87,7 @@ _meta_plugin_xevent_filter (MetaPlugin *plugin,
void void
meta_plugin_switch_workspace_completed (MetaPlugin *plugin) meta_plugin_switch_workspace_completed (MetaPlugin *plugin)
{ {
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv; MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
meta_switch_workspace_completed (priv->compositor); meta_switch_workspace_completed (priv->compositor);
} }
@ -164,7 +161,7 @@ meta_plugin_begin_modal (MetaPlugin *plugin,
MetaModalOptions options, MetaModalOptions options,
guint32 timestamp) guint32 timestamp)
{ {
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv; MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
return meta_begin_modal_for_plugin (priv->compositor, plugin, return meta_begin_modal_for_plugin (priv->compositor, plugin,
options, timestamp); options, timestamp);
@ -185,7 +182,7 @@ void
meta_plugin_end_modal (MetaPlugin *plugin, meta_plugin_end_modal (MetaPlugin *plugin,
guint32 timestamp) guint32 timestamp)
{ {
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv; MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
meta_end_modal_for_plugin (priv->compositor, plugin, timestamp); meta_end_modal_for_plugin (priv->compositor, plugin, timestamp);
} }
@ -201,7 +198,7 @@ meta_plugin_end_modal (MetaPlugin *plugin,
MetaDisplay * MetaDisplay *
meta_plugin_get_display (MetaPlugin *plugin) meta_plugin_get_display (MetaPlugin *plugin)
{ {
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv; MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
return priv->compositor->display; return priv->compositor->display;
} }
@ -209,7 +206,7 @@ meta_plugin_get_display (MetaPlugin *plugin)
void void
_meta_plugin_set_compositor (MetaPlugin *plugin, MetaCompositor *compositor) _meta_plugin_set_compositor (MetaPlugin *plugin, MetaCompositor *compositor)
{ {
MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv; MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
priv->compositor = compositor; priv->compositor = compositor;
} }

View File

@ -34,24 +34,10 @@
#include "meta/types.h" #include "meta/types.h"
#define META_TYPE_PLUGIN (meta_plugin_get_type ()) #define META_TYPE_PLUGIN (meta_plugin_get_type ())
#define META_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_PLUGIN, MetaPlugin)) G_DECLARE_DERIVABLE_TYPE (MetaPlugin, meta_plugin, META, PLUGIN, GObject)
#define META_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_PLUGIN, MetaPluginClass))
#define META_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_PLUGIN))
#define META_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_PLUGIN))
#define META_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_PLUGIN, MetaPluginClass))
typedef struct _MetaPlugin MetaPlugin;
typedef struct _MetaPluginClass MetaPluginClass;
typedef struct _MetaPluginVersion MetaPluginVersion; typedef struct _MetaPluginVersion MetaPluginVersion;
typedef struct _MetaPluginInfo MetaPluginInfo; typedef struct _MetaPluginInfo MetaPluginInfo;
typedef struct _MetaPluginPrivate MetaPluginPrivate;
struct _MetaPlugin
{
GObject parent;
MetaPluginPrivate *priv;
};
/** /**
* MetaPluginClass: * MetaPluginClass:
@ -270,8 +256,6 @@ struct _MetaPluginInfo
const gchar *description; const gchar *description;
}; };
GType meta_plugin_get_type (void);
const MetaPluginInfo * meta_plugin_get_info (MetaPlugin *plugin); const MetaPluginInfo * meta_plugin_get_info (MetaPlugin *plugin);
/** /**