[gnome-control-center] common: Replace GObject boilerplace with G_DECLARE_TYPE
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] common: Replace GObject boilerplace with G_DECLARE_TYPE
- Date: Fri, 1 Jun 2018 21:46:15 +0000 (UTC)
commit 42ea814d721177602879c2192984df28d28c9cbd
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jun 1 12:13:10 2018 +1200
common: Replace GObject boilerplace with G_DECLARE_TYPE
panels/common/gsd-device-manager-udev.c | 5 -----
panels/common/gsd-device-manager-udev.h | 13 ++-----------
panels/common/gsd-device-manager-x11.c | 5 -----
panels/common/gsd-device-manager-x11.h | 13 ++-----------
panels/common/gsd-device-manager.c | 10 ++++------
panels/common/gsd-device-manager.h | 34 +++++----------------------------
6 files changed, 13 insertions(+), 67 deletions(-)
---
diff --git a/panels/common/gsd-device-manager-udev.c b/panels/common/gsd-device-manager-udev.c
index aa9304232..3b001649a 100644
--- a/panels/common/gsd-device-manager-udev.c
+++ b/panels/common/gsd-device-manager-udev.c
@@ -34,11 +34,6 @@ struct _GsdUdevDeviceManager
GUdevClient *udev_client;
};
-struct _GsdUdevDeviceManagerClass
-{
- GsdDeviceManagerClass parent_class;
-};
-
G_DEFINE_TYPE (GsdUdevDeviceManager, gsd_udev_device_manager, GSD_TYPE_DEVICE_MANAGER)
/* Index matches GsdDeviceType */
diff --git a/panels/common/gsd-device-manager-udev.h b/panels/common/gsd-device-manager-udev.h
index 2004e976f..eec0e5dfa 100644
--- a/panels/common/gsd-device-manager-udev.h
+++ b/panels/common/gsd-device-manager-udev.h
@@ -26,17 +26,8 @@
G_BEGIN_DECLS
-#define GSD_TYPE_UDEV_DEVICE_MANAGER (gsd_udev_device_manager_get_type ())
-#define GSD_UDEV_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_UDEV_DEVICE_MANAGER,
GsdUdevDeviceManager))
-#define GSD_UDEV_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_UDEV_DEVICE_MANAGER,
GsdUdevDeviceManagerClass))
-#define GSD_IS_UDEV_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_UDEV_DEVICE_MANAGER))
-#define GSD_IS_UDEV_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_UDEV_DEVICE_MANAGER))
-#define GSD_UDEV_DEVICE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_UDEV_DEVICE_MANAGER,
GsdUdevDeviceManagerClass))
-
-typedef struct _GsdUdevDeviceManager GsdUdevDeviceManager;
-typedef struct _GsdUdevDeviceManagerClass GsdUdevDeviceManagerClass;
-
-GType gsd_udev_device_manager_get_type (void) G_GNUC_CONST;
+#define GSD_TYPE_UDEV_DEVICE_MANAGER (gsd_udev_device_manager_get_type ())
+G_DECLARE_FINAL_TYPE (GsdUdevDeviceManager, gsd_udev_device_manager, GSD, UDEV_DEVICE_MANAGER,
GsdDeviceManager)
G_END_DECLS
diff --git a/panels/common/gsd-device-manager-x11.c b/panels/common/gsd-device-manager-x11.c
index a77d6faeb..e39725134 100644
--- a/panels/common/gsd-device-manager-x11.c
+++ b/panels/common/gsd-device-manager-x11.c
@@ -36,11 +36,6 @@ struct _GsdX11DeviceManager
GHashTable *gdk_devices;
};
-struct _GsdX11DeviceManagerClass
-{
- GsdDeviceManagerClass parent_class;
-};
-
GsdDevice * gsd_x11_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
GdkDevice *gdk_device);
diff --git a/panels/common/gsd-device-manager-x11.h b/panels/common/gsd-device-manager-x11.h
index a5ea724e8..a21e711b9 100644
--- a/panels/common/gsd-device-manager-x11.h
+++ b/panels/common/gsd-device-manager-x11.h
@@ -27,17 +27,8 @@
G_BEGIN_DECLS
-#define GSD_TYPE_X11_DEVICE_MANAGER (gsd_x11_device_manager_get_type ())
-#define GSD_X11_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_X11_DEVICE_MANAGER,
GsdX11DeviceManager))
-#define GSD_X11_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_X11_DEVICE_MANAGER,
GsdX11DeviceManagerClass))
-#define GSD_IS_X11_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_X11_DEVICE_MANAGER))
-#define GSD_IS_X11_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_X11_DEVICE_MANAGER))
-#define GSD_X11_DEVICE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_X11_DEVICE_MANAGER,
GsdX11DeviceManagerClass))
-
-typedef struct _GsdX11DeviceManager GsdX11DeviceManager;
-typedef struct _GsdX11DeviceManagerClass GsdX11DeviceManagerClass;
-
-GType gsd_x11_device_manager_get_type (void) G_GNUC_CONST;
+#define GSD_TYPE_X11_DEVICE_MANAGER (gsd_x11_device_manager_get_type ())
+G_DECLARE_FINAL_TYPE (GsdX11DeviceManager, gsd_x11_device_manager, GSD, X11_DEVICE_MANAGER, GsdDeviceManager)
G_END_DECLS
diff --git a/panels/common/gsd-device-manager.c b/panels/common/gsd-device-manager.c
index 541f29487..2593b4e2d 100644
--- a/panels/common/gsd-device-manager.c
+++ b/panels/common/gsd-device-manager.c
@@ -28,10 +28,7 @@
#include "gsd-common-enums.h"
#include "gnome-settings-bus.h"
-typedef struct _GsdDevicePrivate GsdDevicePrivate;
-typedef struct _GsdDeviceManagerPrivate GsdDeviceManagerPrivate;
-
-struct _GsdDevicePrivate
+typedef struct
{
gchar *name;
gchar *device_file;
@@ -40,7 +37,9 @@ struct _GsdDevicePrivate
GsdDeviceType type;
guint width;
guint height;
-};
+} GsdDevicePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsdDevice, gsd_device, G_TYPE_OBJECT)
enum {
PROP_NAME = 1,
@@ -61,7 +60,6 @@ enum {
static guint signals[N_SIGNALS] = { 0 };
-G_DEFINE_TYPE_WITH_PRIVATE (GsdDevice, gsd_device, G_TYPE_OBJECT)
G_DEFINE_TYPE (GsdDeviceManager, gsd_device_manager, G_TYPE_OBJECT)
static void
diff --git a/panels/common/gsd-device-manager.h b/panels/common/gsd-device-manager.h
index 1eb5c1356..68ebfc1f9 100644
--- a/panels/common/gsd-device-manager.h
+++ b/panels/common/gsd-device-manager.h
@@ -26,24 +26,11 @@
G_BEGIN_DECLS
-#define GSD_TYPE_DEVICE (gsd_device_get_type ())
-#define GSD_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_DEVICE, GsdDevice))
-#define GSD_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_DEVICE, GsdDeviceClass))
-#define GSD_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_DEVICE))
-#define GSD_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_DEVICE))
-#define GSD_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_DEVICE, GsdDeviceClass))
-
-#define GSD_TYPE_DEVICE_MANAGER (gsd_device_manager_get_type ())
-#define GSD_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManager))
-#define GSD_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManagerClass))
-#define GSD_IS_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_DEVICE_MANAGER))
-#define GSD_IS_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_DEVICE_MANAGER))
-#define GSD_DEVICE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManagerClass))
-
-typedef struct _GsdDevice GsdDevice;
-typedef struct _GsdDeviceClass GsdDeviceClass;
-typedef struct _GsdDeviceManager GsdDeviceManager;
-typedef struct _GsdDeviceManagerClass GsdDeviceManagerClass;
+#define GSD_TYPE_DEVICE (gsd_device_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsdDevice, gsd_device, GSD, DEVICE, GObject)
+
+#define GSD_TYPE_DEVICE_MANAGER (gsd_device_manager_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsdDeviceManager, gsd_device_manager, GSD, DEVICE_MANAGER, GObject)
typedef enum {
GSD_DEVICE_TYPE_MOUSE = 1 << 0,
@@ -54,19 +41,10 @@ typedef enum {
GSD_DEVICE_TYPE_PAD = 1 << 5
} GsdDeviceType;
-struct _GsdDevice {
- GObject parent_instance;
-};
-
struct _GsdDeviceClass {
GObjectClass parent_class;
};
-struct _GsdDeviceManager
-{
- GObject parent_instance;
-};
-
struct _GsdDeviceManagerClass
{
GObjectClass parent_class;
@@ -85,8 +63,6 @@ struct _GsdDeviceManagerClass
GdkDevice *gdk_device);
};
-GType gsd_device_get_type (void) G_GNUC_CONST;
-GType gsd_device_manager_get_type (void) G_GNUC_CONST;
GsdDeviceManager * gsd_device_manager_get (void);
GList * gsd_device_manager_list_devices (GsdDeviceManager *manager,
GsdDeviceType type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]