qulogic/libgnt

Use G_DEFINE_TYPE for GntMenuItem*.

2019-04-03, Elliott Sales de Andrade
b955bf6b3f13
Parents c9bfee35581f
Children 746987e29e4d
Use G_DEFINE_TYPE for GntMenuItem*.
--- a/gntmenuitem.c Wed Apr 03 18:32:15 2019 -0400
+++ b/gntmenuitem.c Wed Apr 03 19:04:31 2019 -0400
@@ -31,7 +31,11 @@
};
static guint signals[SIGS] = { 0 };
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE(GntMenuItem, gnt_menuitem, G_TYPE_OBJECT)
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
static void
gnt_menuitem_destroy(GObject *obj)
@@ -42,14 +46,13 @@
if (item->submenu)
gnt_widget_destroy(GNT_WIDGET(item->submenu));
g_free(item->priv.id);
- parent_class->dispose(obj);
+ G_OBJECT_CLASS(gnt_menuitem_parent_class)->dispose(obj);
}
static void
gnt_menuitem_class_init(GntMenuItemClass *klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
obj_class->dispose = gnt_menuitem_destroy;
@@ -62,44 +65,14 @@
}
static void
-gnt_menuitem_init(GTypeInstance *instance, gpointer klass)
+gnt_menuitem_init(GntMenuItem *item)
{
- GntMenuItem *item = GNT_MENU_ITEM(instance);
-
item->visible = TRUE;
}
/******************************************************************************
* GntMenuItem API
*****************************************************************************/
-GType
-gnt_menuitem_get_type(void)
-{
- static GType type = 0;
-
- if(type == 0)
- {
- static const GTypeInfo info = {
- sizeof(GntMenuItemClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)gnt_menuitem_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(GntMenuItem),
- 0, /* n_preallocs */
- gnt_menuitem_init, /* instance_init */
- NULL /* value_table */
- };
-
- type = g_type_register_static(G_TYPE_OBJECT,
- "GntMenuItem",
- &info, 0);
- }
-
- return type;
-}
-
GntMenuItem *gnt_menuitem_new(const char *text)
{
GObject *item = g_object_new(GNT_TYPE_MENU_ITEM, NULL);
--- a/gntmenuitemcheck.c Wed Apr 03 18:32:15 2019 -0400
+++ b/gntmenuitemcheck.c Wed Apr 03 19:04:31 2019 -0400
@@ -23,53 +23,25 @@
#include "gntinternal.h"
#include "gntmenuitemcheck.h"
-static GntMenuItemClass *parent_class = NULL;
+G_DEFINE_TYPE(GntMenuItemCheck, gnt_menuitem_check, GNT_TYPE_MENU_ITEM)
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
static void
-gnt_menuitem_check_class_init(GntMenuItemCheckClass *klass)
+gnt_menuitem_check_class_init(G_GNUC_UNUSED GntMenuItemCheckClass *klass)
{
- parent_class = GNT_MENU_ITEM_CLASS(klass);
-
- GNTDEBUG;
}
static void
-gnt_menuitem_check_init(GTypeInstance *instance, gpointer class)
+gnt_menuitem_check_init(G_GNUC_UNUSED GntMenuItemCheck *item)
{
- GNTDEBUG;
}
/******************************************************************************
* GntMenuItemCheck API
*****************************************************************************/
-GType
-gnt_menuitem_check_get_type(void)
-{
- static GType type = 0;
-
- if(type == 0)
- {
- static const GTypeInfo info = {
- sizeof(GntMenuItemCheckClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)gnt_menuitem_check_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(GntMenuItemCheck),
- 0, /* n_preallocs */
- gnt_menuitem_check_init, /* instance_init */
- NULL /* value_table */
- };
-
- type = g_type_register_static(GNT_TYPE_MENU_ITEM,
- "GntMenuItemCheck",
- &info, 0);
- }
-
- return type;
-}
-
GntMenuItem *gnt_menuitem_check_new(const char *text)
{
GntMenuItem *item = g_object_new(GNT_TYPE_MENU_ITEM_CHECK, NULL);