[mutter/wip/nielsdg/meta-plugin-derivable: 38/38] meta/plugin: Use G_DECLARE_DERIVABLE_TYPE
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/nielsdg/meta-plugin-derivable: 38/38] meta/plugin: Use G_DECLARE_DERIVABLE_TYPE
- Date: Fri, 23 Nov 2018 13:53:09 +0000 (UTC)
commit 36872506e6bbe0321968f6067484dcc30f4c3ba4
Author: Niels De Graef <Niels DeGraef barco com>
Date: Tue Oct 30 11:19:36 2018 +0100
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.
configure.ac | 2 +-
meson.build | 2 +-
src/compositor/meta-plugin.c | 19 ++++++++-----------
src/meta/meta-plugin.h | 22 +++-------------------
4 files changed, 13 insertions(+), 32 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fef188045..e27e1aeab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ m4_define([mutter_version],
m4_define([mutter_plugin_api_version], [3])
-m4_define([libmutter_api_version], [3])
+m4_define([libmutter_api_version], [4])
AC_INIT([mutter], [mutter_version],
[http://bugzilla.gnome.org/enter_bug.cgi?product=mutter])
diff --git a/meson.build b/meson.build
index 0f4f0d04a..af156d189 100644
--- a/meson.build
+++ b/meson.build
@@ -6,7 +6,7 @@ project('mutter', 'c',
mutter_plugin_api_version = '3'
-libmutter_api_version = '3'
+libmutter_api_version = '4'
# generic version requirements
glib_req = '>= 2.53.2'
diff --git a/src/compositor/meta-plugin.c b/src/compositor/meta-plugin.c
index b787652bc..ce1d6bed3 100644
--- a/src/compositor/meta-plugin.c
+++ b/src/compositor/meta-plugin.c
@@ -43,16 +43,14 @@
#include "meta/display.h"
#include "meta/util.h"
-struct _MetaPluginPrivate
+
+typedef struct _MetaPluginPrivate
{
MetaCompositor *compositor;
-};
+} MetaPluginPrivate;
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
meta_plugin_class_init (MetaPluginClass *klass)
{
@@ -61,7 +59,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
static void
meta_plugin_init (MetaPlugin *self)
{
- self->priv = META_PLUGIN_GET_PRIVATE (self);
}
const MetaPluginInfo *
@@ -90,7 +87,7 @@ _meta_plugin_xevent_filter (MetaPlugin *plugin,
void
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);
}
@@ -164,7 +161,7 @@ meta_plugin_begin_modal (MetaPlugin *plugin,
MetaModalOptions options,
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,
options, timestamp);
@@ -185,7 +182,7 @@ void
meta_plugin_end_modal (MetaPlugin *plugin,
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);
}
@@ -201,7 +198,7 @@ meta_plugin_end_modal (MetaPlugin *plugin,
MetaDisplay *
meta_plugin_get_display (MetaPlugin *plugin)
{
- MetaPluginPrivate *priv = META_PLUGIN (plugin)->priv;
+ MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
return priv->compositor->display;
}
@@ -209,7 +206,7 @@ meta_plugin_get_display (MetaPlugin *plugin)
void
_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;
}
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index c9399cf53..597e53eef 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -33,25 +33,11 @@
#include "meta/meta-version.h"
#include "meta/types.h"
-#define META_TYPE_PLUGIN (meta_plugin_get_type ())
-#define META_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_PLUGIN, MetaPlugin))
-#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;
+#define META_TYPE_PLUGIN (meta_plugin_get_type ())
+G_DECLARE_DERIVABLE_TYPE (MetaPlugin, meta_plugin, META, PLUGIN, GObject)
+
typedef struct _MetaPluginVersion MetaPluginVersion;
typedef struct _MetaPluginInfo MetaPluginInfo;
-typedef struct _MetaPluginPrivate MetaPluginPrivate;
-
-struct _MetaPlugin
-{
- GObject parent;
-
- MetaPluginPrivate *priv;
-};
/**
* MetaPluginClass:
@@ -270,8 +256,6 @@ struct _MetaPluginInfo
const gchar *description;
};
-GType meta_plugin_get_type (void);
-
const MetaPluginInfo * meta_plugin_get_info (MetaPlugin *plugin);
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]