[mutter] backends: Use macros for declaring the backend types



commit f5b2d79f3b8fe1a3c8f6c822ea7c1e119e40f92d
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Nov 30 18:46:20 2016 +0800

    backends: Use macros for declaring the backend types
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777732

 src/backends/meta-backend-private.h       |   13 ++-----------
 src/backends/native/meta-backend-native.c |    5 +++++
 src/backends/native/meta-backend-native.h |   24 +++---------------------
 src/backends/x11/meta-backend-x11.c       |    5 +++++
 src/backends/x11/meta-backend-x11.h       |   24 +++---------------------
 5 files changed, 18 insertions(+), 53 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index 0f617e8..4395b00 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -43,17 +43,8 @@
 #define DEFAULT_XKB_RULES_FILE "evdev"
 #define DEFAULT_XKB_MODEL "pc105+inet"
 
-#define META_TYPE_BACKEND             (meta_backend_get_type ())
-#define META_BACKEND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_BACKEND, MetaBackend))
-#define META_BACKEND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_BACKEND, 
MetaBackendClass))
-#define META_IS_BACKEND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_BACKEND))
-#define META_IS_BACKEND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_BACKEND))
-#define META_BACKEND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_BACKEND, 
MetaBackendClass))
-
-struct _MetaBackend
-{
-  GObject parent;
-};
+#define META_TYPE_BACKEND (meta_backend_get_type ())
+G_DECLARE_DERIVABLE_TYPE (MetaBackend, meta_backend, META, BACKEND, GObject)
 
 struct _MetaBackendClass
 {
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 36ca773..37e8ccf 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -45,6 +45,11 @@
 
 #include <stdlib.h>
 
+struct _MetaBackendNative
+{
+  MetaBackend parent;
+};
+
 struct _MetaBackendNativePrivate
 {
   MetaLauncher *launcher;
diff --git a/src/backends/native/meta-backend-native.h b/src/backends/native/meta-backend-native.h
index 136012b..08e48d7 100644
--- a/src/backends/native/meta-backend-native.h
+++ b/src/backends/native/meta-backend-native.h
@@ -28,27 +28,9 @@
 #include "backends/meta-backend-private.h"
 #include "backends/native/meta-clutter-backend-native.h"
 
-#define META_TYPE_BACKEND_NATIVE             (meta_backend_native_get_type ())
-#define META_BACKEND_NATIVE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_BACKEND_NATIVE, 
MetaBackendNative))
-#define META_BACKEND_NATIVE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_BACKEND_NATIVE, 
MetaBackendNativeClass))
-#define META_IS_BACKEND_NATIVE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_BACKEND_NATIVE))
-#define META_IS_BACKEND_NATIVE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_BACKEND_NATIVE))
-#define META_BACKEND_NATIVE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_BACKEND_NATIVE, 
MetaBackendNativeClass))
-
-typedef struct _MetaBackendNative        MetaBackendNative;
-typedef struct _MetaBackendNativeClass   MetaBackendNativeClass;
-
-struct _MetaBackendNative
-{
-  MetaBackend parent;
-};
-
-struct _MetaBackendNativeClass
-{
-  MetaBackendClass parent_class;
-};
-
-GType meta_backend_native_get_type (void) G_GNUC_CONST;
+#define META_TYPE_BACKEND_NATIVE (meta_backend_native_get_type ())
+G_DECLARE_FINAL_TYPE (MetaBackendNative, meta_backend_native,
+                      META, BACKEND_NATIVE, MetaBackend)
 
 gboolean meta_activate_vt (int vt, GError **error);
 
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 25c0e3c..7c8a5cb 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -54,6 +54,11 @@
 #include "display-private.h"
 #include "compositor/compositor-private.h"
 
+struct _MetaBackendX11
+{
+  MetaBackend parent;
+};
+
 typedef enum {
   /* We're a traditional CM running under the host. */
   META_BACKEND_X11_MODE_COMPOSITOR,
diff --git a/src/backends/x11/meta-backend-x11.h b/src/backends/x11/meta-backend-x11.h
index 439d09f..d3854b2 100644
--- a/src/backends/x11/meta-backend-x11.h
+++ b/src/backends/x11/meta-backend-x11.h
@@ -31,27 +31,9 @@
 
 #include "backends/x11/meta-clutter-backend-x11.h"
 
-#define META_TYPE_BACKEND_X11             (meta_backend_x11_get_type ())
-#define META_BACKEND_X11(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_BACKEND_X11, 
MetaBackendX11))
-#define META_BACKEND_X11_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_BACKEND_X11, 
MetaBackendX11Class))
-#define META_IS_BACKEND_X11(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_BACKEND_X11))
-#define META_IS_BACKEND_X11_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  META_TYPE_BACKEND_X11))
-#define META_BACKEND_X11_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  META_TYPE_BACKEND_X11, 
MetaBackendX11Class))
-
-typedef struct _MetaBackendX11        MetaBackendX11;
-typedef struct _MetaBackendX11Class   MetaBackendX11Class;
-
-struct _MetaBackendX11
-{
-  MetaBackend parent;
-};
-
-struct _MetaBackendX11Class
-{
-  MetaBackendClass parent_class;
-};
-
-GType meta_backend_x11_get_type (void) G_GNUC_CONST;
+#define META_TYPE_BACKEND_X11 (meta_backend_x11_get_type ())
+G_DECLARE_FINAL_TYPE (MetaBackendX11, meta_backend_x11,
+                      META, BACKEND_X11, MetaBackend)
 
 Display * meta_backend_x11_get_xdisplay (MetaBackendX11 *backend);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]