[gnome-video-arcade] Use G_DEFINE_TYPE macros.



commit 2f07386b6ed163a643cdaf18cffac81cc7e95d44
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Mar 26 19:04:06 2011 -0400

    Use G_DEFINE_TYPE macros.

 src/gva-cell-renderer-pixbuf.c |   44 ++++++++-------------------------------
 src/gva-column-manager.c       |   45 ++++++++-------------------------------
 src/gva-game-store.c           |   41 ++++++------------------------------
 src/gva-input-file.c           |   40 ++++++-----------------------------
 src/gva-mame-process.c         |   42 +++++++++---------------------------
 src/gva-music-button.c         |   43 ++++++++------------------------------
 src/gva-mute-button.c          |   40 ++++++-----------------------------
 src/gva-process.c              |   43 ++++++++------------------------------
 8 files changed, 69 insertions(+), 269 deletions(-)
---
diff --git a/src/gva-cell-renderer-pixbuf.c b/src/gva-cell-renderer-pixbuf.c
index a6221f3..ce417f1 100644
--- a/src/gva-cell-renderer-pixbuf.c
+++ b/src/gva-cell-renderer-pixbuf.c
@@ -39,9 +39,13 @@ enum
         LAST_SIGNAL
 };
 
-static gpointer parent_class = NULL;
 static guint signals[LAST_SIGNAL] = { 0 };
 
+G_DEFINE_TYPE (
+        GvaCellRendererPixbuf,
+        gva_cell_renderer_pixbuf,
+        GTK_TYPE_CELL_RENDERER_PIXBUF)
+
 static void
 cell_renderer_pixbuf_set_property (GObject *object,
                                    guint property_id,
@@ -114,19 +118,18 @@ cell_renderer_pixbuf_render (GtkCellRenderer *cell,
         gtk_cell_renderer_set_sensitive (cell, priv->active);
 
         /* Chain up to parent's render() method. */
-        GTK_CELL_RENDERER_CLASS (parent_class)->render (
-                cell, cr, widget, background_area, cell_area, flags);
+        GTK_CELL_RENDERER_CLASS (gva_cell_renderer_pixbuf_parent_class)->
+                render (cell, cr, widget, background_area, cell_area, flags);
 
         gtk_cell_renderer_set_sensitive (cell, sensitive);
 }
 
 static void
-cell_renderer_pixbuf_class_init (GvaCellRendererPixbufClass *class)
+gva_cell_renderer_pixbuf_class_init (GvaCellRendererPixbufClass *class)
 {
         GObjectClass *object_class;
         GtkCellRendererClass *cell_renderer_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaCellRendererPixbufPrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -172,42 +175,13 @@ cell_renderer_pixbuf_class_init (GvaCellRendererPixbufClass *class)
 }
 
 static void
-cell_renderer_pixbuf_init (GvaCellRendererPixbuf *cell)
+gva_cell_renderer_pixbuf_init (GvaCellRendererPixbuf *cell)
 {
         cell->priv = GVA_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
 
         g_object_set (cell, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
 }
 
-GType
-gva_cell_renderer_pixbuf_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaCellRendererPixbufClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) cell_renderer_pixbuf_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaCellRendererPixbuf),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) cell_renderer_pixbuf_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GTK_TYPE_CELL_RENDERER_PIXBUF,
-                        "GvaCellRendererPixbuf", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_cell_renderer_pixbuf_new:
  *
diff --git a/src/gva-column-manager.c b/src/gva-column-manager.c
index 775fa02..f7200de 100644
--- a/src/gva-column-manager.c
+++ b/src/gva-column-manager.c
@@ -41,7 +41,10 @@ struct _GvaColumnManagerPrivate
         GtkWidget *hide_button;
 };
 
-static gpointer parent_class = NULL;
+G_DEFINE_TYPE (
+        GvaColumnManager,
+        gva_column_manager,
+        GTK_TYPE_HBOX)
 
 static void
 column_manager_move_selected_up (GvaColumnManager *manager)
@@ -402,7 +405,8 @@ column_manager_constructor (GType type,
         GObject *object;
 
         /* Chain up to parent's constructor() method. */
-        object = G_OBJECT_CLASS (parent_class)->constructor (
+        object = G_OBJECT_CLASS (
+                gva_column_manager_parent_class)->constructor (
                 type, n_construct_properties, construct_properties);
 
         priv = GVA_COLUMN_MANAGER_GET_PRIVATE (object);
@@ -515,7 +519,7 @@ column_manager_dispose (GObject *object)
         }
 
         /* Chain up to parent's dispose() method. */
-        G_OBJECT_CLASS (parent_class)->dispose (object);
+        G_OBJECT_CLASS (gva_column_manager_parent_class)->dispose (object);
 }
 
 static void
@@ -528,15 +532,14 @@ column_manager_finalize (GObject *object)
         gtk_tree_row_reference_free (priv->move_reference);
 
         /* Chain up to parent's finalize() method. */
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (gva_column_manager_parent_class)->finalize (object);
 }
 
 static void
-column_manager_class_init (GvaColumnManagerClass *class)
+gva_column_manager_class_init (GvaColumnManagerClass *class)
 {
         GObjectClass *object_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaColumnManagerPrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -558,7 +561,7 @@ column_manager_class_init (GvaColumnManagerClass *class)
 }
 
 static void
-column_manager_init (GvaColumnManager *manager)
+gva_column_manager_init (GvaColumnManager *manager)
 {
         GvaColumnManagerPrivate *priv;
         GtkTreeViewColumn *column;
@@ -653,34 +656,6 @@ column_manager_init (GvaColumnManager *manager)
                 G_CALLBACK (column_manager_hide_selected), manager);
 }
 
-GType
-gva_column_manager_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaColumnManagerClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) column_manager_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaColumnManager),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) column_manager_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GTK_TYPE_HBOX, "GvaColumnManager", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_column_manager_new:
  * @managed_view: a #GtkTreeView to manage
diff --git a/src/gva-game-store.c b/src/gva-game-store.c
index b96b796..94b991f 100644
--- a/src/gva-game-store.c
+++ b/src/gva-game-store.c
@@ -29,7 +29,10 @@
 
 #define DEFAULT_SORT_COLUMN     GVA_GAME_STORE_COLUMN_DESCRIPTION
 
-static gpointer parent_class = NULL;
+G_DEFINE_TYPE (
+        GvaGameStore,
+        gva_game_store,
+        GTK_TYPE_TREE_STORE)
 
 static GHashTable *
 game_store_get_index (GvaGameStore *game_store)
@@ -184,7 +187,7 @@ game_store_constructor (GType type,
         g_assert (column == GVA_GAME_STORE_NUM_COLUMNS);
 
         /* Chain up to parent's constructor() method. */
-        object = G_OBJECT_CLASS (parent_class)->constructor (
+        object = G_OBJECT_CLASS (gva_game_store_parent_class)->constructor (
                 type, n_construct_properties, construct_properties);
 
         gtk_tree_store_set_column_types (
@@ -205,18 +208,16 @@ game_store_constructor (GType type,
 }
 
 static void
-game_store_class_init (GvaGameStoreClass *class)
+gva_game_store_class_init (GvaGameStoreClass *class)
 {
         GObjectClass *object_class;
 
-        parent_class = g_type_class_peek_parent (class);
-
         object_class = G_OBJECT_CLASS (class);
         object_class->constructor = game_store_constructor;
 }
 
 static void
-game_store_init (GvaGameStore *game_store)
+gva_game_store_init (GvaGameStore *game_store)
 {
         GHashTable *index;
 
@@ -230,34 +231,6 @@ game_store_init (GvaGameStore *game_store)
                 (GDestroyNotify) g_hash_table_destroy);
 }
 
-GType
-gva_game_store_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaGameStoreClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) game_store_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaGameStore),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) game_store_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GTK_TYPE_TREE_STORE, "GvaGameStore", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_game_store_new:
  *
diff --git a/src/gva-input-file.c b/src/gva-input-file.c
index 68d0219..8a631c3 100644
--- a/src/gva-input-file.c
+++ b/src/gva-input-file.c
@@ -111,7 +111,10 @@ struct _GvaInpHeaderVersioned
         gchar origin[32];       /* MAME version string */
 };
 
-static gpointer parent_class = NULL;
+G_DEFINE_TYPE (
+        GvaInputFile,
+        gva_input_file,
+        G_TYPE_OBJECT)
 
 static void
 input_file_dump_header (GvaInputFile *input_file)
@@ -332,15 +335,14 @@ input_file_finalize (GObject *object)
         g_free (priv->origin);
 
         /* Chain up to parent's finalize() method. */
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (gva_input_file_parent_class)->finalize (object);
 }
 
 static void
-input_file_class_init (GvaInputFileClass *class)
+gva_input_file_class_init (GvaInputFileClass *class)
 {
         GObjectClass *object_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaInputFilePrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -428,39 +430,11 @@ input_file_class_init (GvaInputFileClass *class)
 }
 
 static void
-input_file_init (GvaInputFile *input_file)
+gva_input_file_init (GvaInputFile *input_file)
 {
         input_file->priv = GVA_INPUT_FILE_GET_PRIVATE (input_file);
 }
 
-GType
-gva_input_file_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaInputFileClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) input_file_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaInputFile),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) input_file_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        G_TYPE_OBJECT, "GvaInputFile", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_input_file_new:
  * @filename: path to a MAME INP file
diff --git a/src/gva-mame-process.c b/src/gva-mame-process.c
index 90d30c8..c2729f9 100644
--- a/src/gva-mame-process.c
+++ b/src/gva-mame-process.c
@@ -24,7 +24,10 @@
 #include "gva-error.h"
 #include "gva-util.h"
 
-static gpointer parent_class = NULL;
+G_DEFINE_TYPE (
+        GvaMameProcess,
+        gva_mame_process,
+        GVA_TYPE_PROCESS)
 
 static void
 mame_process_check_for_error (GvaProcess *process, const gchar *line)
@@ -59,7 +62,8 @@ mame_process_stdout_read_line (GvaProcess *process)
         gchar *line;
 
         /* Chain up to parent's stdout_read_line() method. */
-        line = GVA_PROCESS_CLASS (parent_class)->stdout_read_line (process);
+        line = GVA_PROCESS_CLASS (gva_mame_process_parent_class)->
+                stdout_read_line (process);
 
         mame_process_check_for_error (process, line);
 
@@ -72,7 +76,8 @@ mame_process_stderr_read_line (GvaProcess *process)
         gchar *line;
 
         /* Chain up to parent's stderr_read_line() method. */
-        line = GVA_PROCESS_CLASS (parent_class)->stderr_read_line (process);
+        line = GVA_PROCESS_CLASS (gva_mame_process_parent_class)->
+                stderr_read_line (process);
 
         mame_process_check_for_error (process, line);
 
@@ -91,44 +96,19 @@ mame_process_exited (GvaProcess *process, gint status)
 }
 
 static void
-mame_process_class_init (GvaProcessClass *class)
+gva_mame_process_class_init (GvaMameProcessClass *class)
 {
         GvaProcessClass *process_class;
 
-        parent_class = g_type_class_peek_parent (class);
-
         process_class = GVA_PROCESS_CLASS (class);
         process_class->stdout_read_line = mame_process_stdout_read_line;
         process_class->stderr_read_line = mame_process_stderr_read_line;
         process_class->exited = mame_process_exited;
 }
 
-GType
-gva_mame_process_get_type (void)
+static void
+gva_mame_process_init (GvaMameProcess *mame_process)
 {
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaMameProcessClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) mame_process_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaMameProcess),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) NULL,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GVA_TYPE_PROCESS, "GvaMameProcess", &type_info, 0);
-        }
-
-        return type;
 }
 
 /**
diff --git a/src/gva-music-button.c b/src/gva-music-button.c
index 94aa23d..cd09667 100644
--- a/src/gva-music-button.c
+++ b/src/gva-music-button.c
@@ -55,9 +55,13 @@ enum
         LAST_SIGNAL
 };
 
-static gpointer parent_class;
 static gulong signals[LAST_SIGNAL];
 
+G_DEFINE_TYPE (
+        GvaMusicButton,
+        gva_music_button,
+        GTK_TYPE_BUTTON)
+
 #ifdef HAVE_GSTREAMER
 
 static gboolean
@@ -328,7 +332,7 @@ music_button_dispose (GObject *object)
 #endif
 
         /* Chain up to parent's dispose() method. */
-        G_OBJECT_CLASS (parent_class)->dispose (object);
+        G_OBJECT_CLASS (gva_music_button_parent_class)->dispose (object);
 }
 
 static void
@@ -344,7 +348,7 @@ music_button_finalize (GObject *object)
         g_free (priv->status);
 
         /* Chain up to parent's finalize() method. */
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (gva_music_button_parent_class)->finalize (object);
 }
 
 static void
@@ -412,12 +416,11 @@ music_button_play (GvaMusicButton *music_button)
 }
 
 static void
-music_button_class_init (GvaMusicButtonClass *class)
+gva_music_button_class_init (GvaMusicButtonClass *class)
 {
         GObjectClass *object_class;
         GtkButtonClass *button_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaMusicButtonPrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -495,7 +498,7 @@ music_button_class_init (GvaMusicButtonClass *class)
 }
 
 static void
-music_button_init (GvaMusicButton *music_button)
+gva_music_button_init (GvaMusicButton *music_button)
 {
 #ifdef HAVE_GSTREAMER
         GstElement *element;
@@ -513,34 +516,6 @@ music_button_init (GvaMusicButton *music_button)
 #endif
 }
 
-GType
-gva_music_button_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo type_info =
-                {
-                        sizeof (GvaMusicButtonClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) music_button_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaMusicButton),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) music_button_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GTK_TYPE_BUTTON, "GvaMusicButton", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_music_button_new:
  *
diff --git a/src/gva-mute-button.c b/src/gva-mute-button.c
index 7be9f18..5da2abc 100644
--- a/src/gva-mute-button.c
+++ b/src/gva-mute-button.c
@@ -36,7 +36,10 @@ enum
         PROP_MUTED
 };
 
-static gpointer parent_class;
+G_DEFINE_TYPE (
+        GvaMuteButton,
+        gva_mute_button,
+        GTK_TYPE_BUTTON)
 
 static void
 mute_button_set_property (GObject *object,
@@ -88,7 +91,7 @@ mute_button_dispose (GObject *object)
         }
 
         /* Chain up to parent's dispose() method. */
-        G_OBJECT_CLASS (parent_class)->dispose (object);
+        G_OBJECT_CLASS (gva_mute_button_parent_class)->dispose (object);
 }
 
 static void
@@ -102,12 +105,11 @@ mute_button_clicked (GtkButton *button)
 }
 
 static void
-mute_button_class_init (GvaMuteButtonClass *class)
+gva_mute_button_class_init (GvaMuteButtonClass *class)
 {
         GObjectClass *object_class;
         GtkButtonClass *button_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaMuteButtonPrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -131,7 +133,7 @@ mute_button_class_init (GvaMuteButtonClass *class)
 }
 
 static void
-mute_button_init (GvaMuteButton *mute_button)
+gva_mute_button_init (GvaMuteButton *mute_button)
 {
         GtkWidget *widget;
 
@@ -146,34 +148,6 @@ mute_button_init (GvaMuteButton *mute_button)
         gtk_widget_show (widget);
 }
 
-GType
-gva_mute_button_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo type_info =
-                {
-                        sizeof (GvaMuteButtonClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) mute_button_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaMuteButton),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) mute_button_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        GTK_TYPE_BUTTON, "GvaMuteButton", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_mute_button_new:
  *
diff --git a/src/gva-process.c b/src/gva-process.c
index 1bda2b1..415f2fd 100644
--- a/src/gva-process.c
+++ b/src/gva-process.c
@@ -70,10 +70,14 @@ struct _GvaProcessPrivate
         gint status;
 };
 
-static gpointer parent_class = NULL;
 static guint signals[LAST_SIGNAL] = { 0 };
 static GSList *active_list = NULL;
 
+G_DEFINE_TYPE (
+        GvaProcess,
+        gva_process,
+        G_TYPE_OBJECT)
+
 static GIOChannel *
 process_new_channel (gint fd)
 {
@@ -276,7 +280,7 @@ process_constructor (GType type,
         GObject *object;
 
         /* Chain up to parent's constructor() method. */
-        object = G_OBJECT_CLASS (parent_class)->constructor (
+        object = G_OBJECT_CLASS (gva_process_parent_class)->constructor (
                 type, n_construct_properties, construct_properties);
 
         priv = GVA_PROCESS_GET_PRIVATE (object);
@@ -420,7 +424,7 @@ process_finalize (GObject *object)
         g_queue_free (process->priv->stderr_lines);
 
         /* Chain up to parent's finalize() method. */
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (gva_process_parent_class)->finalize (object);
 }
 
 static gchar *
@@ -436,11 +440,10 @@ process_stderr_read_line (GvaProcess *process)
 }
 
 static void
-process_class_init (GvaProcessClass *class)
+gva_process_class_init (GvaProcessClass *class)
 {
         GObjectClass *object_class;
 
-        parent_class = g_type_class_peek_parent (class);
         g_type_class_add_private (class, sizeof (GvaProcessPrivate));
 
         object_class = G_OBJECT_CLASS (class);
@@ -600,7 +603,7 @@ process_class_init (GvaProcessClass *class)
 }
 
 static void
-process_init (GvaProcess *process)
+gva_process_init (GvaProcess *process)
 {
         process->priv = GVA_PROCESS_GET_PRIVATE (process);
 
@@ -611,34 +614,6 @@ process_init (GvaProcess *process)
         active_list = g_slist_prepend (active_list, g_object_ref (process));
 }
 
-GType
-gva_process_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                static const GTypeInfo type_info =
-                {
-                        sizeof (GvaProcessClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) process_class_init,
-                        (GClassFinalizeFunc) NULL,
-                        NULL,  /* class_data */
-                        sizeof (GvaProcess),
-                        0,     /* n_preallocs */
-                        (GInstanceInitFunc) process_init,
-                        NULL   /* value_table */
-                };
-
-                type = g_type_register_static (
-                        G_TYPE_OBJECT, "GvaProcess", &type_info, 0);
-        }
-
-        return type;
-}
-
 /**
  * gva_process_new:
  * @pid: child process ID



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