[gnome-commander] Use G_DEFINE_TYPE for GnomeCmdFileInfo



commit 8293257699db78db583accf0fa3ed3234abfd4b3
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Mon Jan 31 22:56:52 2011 +0100

    Use G_DEFINE_TYPE for GnomeCmdFileInfo

 libgcmd/gnome-cmd-file-info.cc |   62 +++++++++------------------------------
 libgcmd/gnome-cmd-file-info.h  |   11 +++----
 src/gnome-cmd-file.cc          |    2 +-
 3 files changed, 21 insertions(+), 54 deletions(-)
---
diff --git a/libgcmd/gnome-cmd-file-info.cc b/libgcmd/gnome-cmd-file-info.cc
index d6c1bca..bf7b7df 100644
--- a/libgcmd/gnome-cmd-file-info.cc
+++ b/libgcmd/gnome-cmd-file-info.cc
@@ -19,70 +19,38 @@
 */
 
 #include <config.h>
+
 #include "libgcmd-deps.h"
 #include "gnome-cmd-file-info.h"
 
-static GtkObjectClass *parent_class = NULL;
-
+using namespace std;
 
-/*******************************
- * Gtk class implementation
- *******************************/
 
-static void destroy (GtkObject *object)
-{
-    GnomeCmdFileInfo *f = GNOME_CMD_FILE_INFO (object);
+G_DEFINE_TYPE (GnomeCmdFileInfo, gnome_cmd_file_info, G_TYPE_OBJECT)
 
-    gnome_vfs_file_info_unref (f->info);
-    if (f->uri)
-        gnome_vfs_uri_unref (f->uri);
 
-    if (GTK_OBJECT_CLASS (parent_class)->destroy)
-        (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+static void gnome_cmd_file_info_init (GnomeCmdFileInfo *self)
+{
 }
 
 
-static void class_init (GnomeCmdFileInfoClass *klass)
+static void gnome_cmd_file_info_finalize (GObject *object)
 {
-    GtkObjectClass *object_class;
+    GnomeCmdFileInfo *self = GNOME_CMD_FILE_INFO (object);
 
-    object_class = GTK_OBJECT_CLASS (klass);
-    parent_class = (GtkObjectClass *) gtk_type_class (gtk_object_get_type ());
+    gnome_vfs_file_info_unref (self->info);
+    if (self->uri)
+        gnome_vfs_uri_unref (self->uri);
 
-    object_class->destroy = destroy;
+    G_OBJECT_CLASS (gnome_cmd_file_info_parent_class)->finalize (object);
 }
 
 
-static void init (GnomeCmdFileInfo *f)
+static void gnome_cmd_file_info_class_init (GnomeCmdFileInfoClass *klass)
 {
-    f->info = NULL;
-    f->uri = NULL;
-}
-
+    gnome_cmd_file_info_parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
 
-/***********************************
- * Public functions
- ***********************************/
+    GObjectClass *object_class = (GObjectClass *) klass;
 
-GtkType gnome_cmd_file_info_get_type ()
-{
-    static GtkType type = 0;
-
-    if (type == 0)
-    {
-        GtkTypeInfo info =
-        {
-            "GnomeCmdFileInfo",
-            sizeof (GnomeCmdFileInfo),
-            sizeof (GnomeCmdFileInfoClass),
-            (GtkClassInitFunc) class_init,
-            (GtkObjectInitFunc) init,
-            /* reserved_1 */ NULL,
-            /* reserved_2 */ NULL,
-            (GtkClassInitFunc) NULL
-        };
-
-        type = gtk_type_unique (gtk_object_get_type (), &info);
-    }
-    return type;
+    object_class->finalize = gnome_cmd_file_info_finalize;
 }
diff --git a/libgcmd/gnome-cmd-file-info.h b/libgcmd/gnome-cmd-file-info.h
index f3f0f18..f492103 100644
--- a/libgcmd/gnome-cmd-file-info.h
+++ b/libgcmd/gnome-cmd-file-info.h
@@ -29,9 +29,12 @@
 #define GNOME_CMD_FILE_INFO_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), GNOME_CMD_TYPE_FILE_INFO, GnomeCmdFileInfoClass))
 
 
+GType gnome_cmd_file_info_get_type ();
+
+
 struct GnomeCmdFileInfo
 {
-    GtkObject parent;
+    GObject parent;
 
     GnomeVFSURI *uri;
     GnomeVFSFileInfo *info;
@@ -41,13 +44,9 @@ struct GnomeCmdFileInfo
 
 struct GnomeCmdFileInfoClass
 {
-    GtkObjectClass parent_class;
+    GObjectClass parent_class;
 };
 
-
-GtkType gnome_cmd_file_info_get_type ();
-
-
 inline void GnomeCmdFileInfo::setup(GnomeVFSURI *uri, GnomeVFSFileInfo *info)
 {
     this->info = info;
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 390d420..b7bd568 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -235,7 +235,7 @@ void GnomeCmdFile::unref()
 
     DEBUG (c, "un-refing: 0x%p %s to %d\n", this, info->name, priv->ref_cnt);
     if (priv->ref_cnt < 1)
-        gtk_object_destroy (GTK_OBJECT (this));
+        g_object_unref (this);
 }
 
 



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