qulogic/libgnt

Use GObject macros for GntClipboard.

2019-04-03, Elliott Sales de Andrade
c9bfee35581f
Parents 4c75f5751615
Children b955bf6b3f13
Use GObject macros for GntClipboard.
--- a/gntclipboard.c Fri Mar 08 03:45:29 2019 +0000
+++ b/gntclipboard.c Wed Apr 03 18:32:15 2019 -0400
@@ -29,6 +29,12 @@
static guint signals[SIGS] = { 0 };
+G_DEFINE_TYPE(GntClipboard, gnt_clipboard, G_TYPE_OBJECT)
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+
static void
gnt_clipboard_class_init(GntClipboardClass *klass)
{
@@ -42,6 +48,12 @@
}
+static void
+gnt_clipboard_init(GntClipboard *clipboard)
+{
+ clipboard->string = g_strdup("");
+}
+
/******************************************************************************
* GntClipboard API
*****************************************************************************/
@@ -59,35 +71,3 @@
{
return g_strdup(clipboard->string);
}
-
-static void gnt_clipboard_init(GTypeInstance *instance, gpointer class) {
- GntClipboard *clipboard = GNT_CLIPBOARD(instance);
- clipboard->string = g_strdup("");
-}
-
-GType
-gnt_clipboard_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(GntClipboardClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)gnt_clipboard_class_init,
- NULL,
- NULL, /* class_data */
- sizeof(GntClipboard),
- 0, /* n_preallocs */
- gnt_clipboard_init, /* instance_init */
- NULL /* value_table */
- };
-
- type = g_type_register_static(G_TYPE_OBJECT,
- "GntClipboard",
- &info, 0);
- }
-
- return type;
-}
--- a/gntclipboard.h Fri Mar 08 03:45:29 2019 +0000
+++ b/gntclipboard.h Wed Apr 03 18:32:15 2019 -0400
@@ -29,19 +29,10 @@
* @title: Clipboard
*/
-#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
-#define GNT_TYPE_CLIPBOARD (gnt_clipboard_get_type())
-#define GNT_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_CLIPBOARD, GntClipboard))
-#define GNT_CLIPBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_CLIPBOARD, GntClipboardClass))
-#define GNT_IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_CLIPBOARD))
-#define GNT_IS_CLIPBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_CLIPBOARD))
-#define GNT_CLIPBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_CLIPBOARD, GntClipboardClass))
-
-typedef struct _GntClipboard GntClipboard;
-typedef struct _GntClipboardClass GntClipboardClass;
+#define GNT_TYPE_CLIPBOARD gnt_clipboard_get_type()
struct _GntClipboard
{
@@ -49,17 +40,6 @@
gchar *string;
};
-struct _GntClipboardClass
-{
- GObjectClass parent;
-
- /*< private >*/
- void (*gnt_reserved1)(void);
- void (*gnt_reserved2)(void);
- void (*gnt_reserved3)(void);
- void (*gnt_reserved4)(void);
-};
-
G_BEGIN_DECLS
/**
@@ -67,7 +47,7 @@
*
* Returns: GType for GntClipboard.
*/
-GType gnt_clipboard_get_type(void);
+G_DECLARE_FINAL_TYPE(GntClipboard, gnt_clipboard, GNT, CLIPBOARD, GObject)
/**
* gnt_clipboard_get_string: