[gnome-commander] Use G_DEFINE_TYPE for GnomeCmdChmodDialog



commit 3d59550deec45afc7b477fe152f28dc0b5b4c856
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sun Jan 23 14:30:51 2011 +0100

    Use G_DEFINE_TYPE for GnomeCmdChmodDialog

 src/gnome-cmd-chmod-dialog.cc |   55 ++++++-----------------------------------
 src/gnome-cmd-chmod-dialog.h  |   12 ++++----
 2 files changed, 14 insertions(+), 53 deletions(-)
---
diff --git a/src/gnome-cmd-chmod-dialog.cc b/src/gnome-cmd-chmod-dialog.cc
index d69fa5a..fa8ce3e 100644
--- a/src/gnome-cmd-chmod-dialog.cc
+++ b/src/gnome-cmd-chmod-dialog.cc
@@ -58,7 +58,7 @@ struct GnomeCmdChmodDialogPrivate
 };
 
 
-static GnomeCmdDialogClass *parent_class = NULL;
+G_DEFINE_TYPE (GnomeCmdChmodDialog, gnome_cmd_chmod_dialog, GNOME_CMD_TYPE_DIALOG)
 
 
 static void do_chmod (GnomeCmdFile *in, GnomeVFSFilePermissions perm, gboolean recursive, ChmodRecursiveMode mode)
@@ -150,40 +150,25 @@ static void on_perms_changed (GnomeCmdChmodComponent *component, GnomeCmdChmodDi
 }
 
 
-/*******************************
- * Gtk class implementation
- *******************************/
-
-static void destroy (GtkObject *object)
+static void gnome_cmd_chmod_dialog_finalize (GObject *object)
 {
     GnomeCmdChmodDialog *dialog = GNOME_CMD_CHMOD_DIALOG (object);
 
     g_free (dialog->priv);
 
-    if (GTK_OBJECT_CLASS (parent_class)->destroy)
-        (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+    G_OBJECT_CLASS (gnome_cmd_chmod_dialog_parent_class)->finalize (object);
 }
 
 
-static void map (GtkWidget *widget)
+static void gnome_cmd_chmod_dialog_class_init (GnomeCmdChmodDialogClass *klass)
 {
-    if (GTK_WIDGET_CLASS (parent_class)->map != NULL)
-        GTK_WIDGET_CLASS (parent_class)->map (widget);
-}
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-
-static void class_init (GnomeCmdChmodDialogClass *klass)
-{
-    GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
-    parent_class = (GnomeCmdDialogClass *) gtk_type_class (GNOME_CMD_TYPE_DIALOG);
-    object_class->destroy = destroy;
-    widget_class->map = ::map;
+    object_class->finalize = gnome_cmd_chmod_dialog_finalize;
 }
 
 
-static void init (GnomeCmdChmodDialog *dialog)
+static void gnome_cmd_chmod_dialog_init (GnomeCmdChmodDialog *dialog)
 {
     GtkWidget *chmod_dialog = GTK_WIDGET (dialog);
     GtkWidget *vbox;
@@ -235,7 +220,7 @@ GtkWidget *gnome_cmd_chmod_dialog_new (GList *files)
 {
     g_return_val_if_fail (files != NULL, NULL);
 
-    GnomeCmdChmodDialog *dialog = (GnomeCmdChmodDialog *) gtk_type_new (gnome_cmd_chmod_dialog_get_type ());
+    GnomeCmdChmodDialog *dialog = (GnomeCmdChmodDialog *) g_object_new (GNOME_CMD_TYPE_CHMOD_DIALOG, NULL);
     dialog->priv->files = gnome_cmd_file_list_copy (files);
 
     dialog->priv->f = (GnomeCmdFile *) dialog->priv->files->data;
@@ -254,27 +239,3 @@ GtkWidget *gnome_cmd_chmod_dialog_new (GList *files)
 
     return GTK_WIDGET (dialog);
 }
-
-
-GtkType gnome_cmd_chmod_dialog_get_type ()
-{
-    static GtkType dlg_type = 0;
-
-    if (dlg_type == 0)
-    {
-        GtkTypeInfo dlg_info =
-        {
-            "GnomeCmdChmodDialog",
-            sizeof (GnomeCmdChmodDialog),
-            sizeof (GnomeCmdChmodDialogClass),
-            (GtkClassInitFunc) class_init,
-            (GtkObjectInitFunc) init,
-            /* reserved_1 */ NULL,
-            /* reserved_2 */ NULL,
-            (GtkClassInitFunc) NULL
-        };
-
-        dlg_type = gtk_type_unique (GNOME_CMD_TYPE_DIALOG, &dlg_info);
-    }
-    return dlg_type;
-}
diff --git a/src/gnome-cmd-chmod-dialog.h b/src/gnome-cmd-chmod-dialog.h
index c9cc453..f58e890 100644
--- a/src/gnome-cmd-chmod-dialog.h
+++ b/src/gnome-cmd-chmod-dialog.h
@@ -20,12 +20,12 @@
 #ifndef __GNOME_CMD_CHMOD_DIALOG_H__
 #define __GNOME_CMD_CHMOD_DIALOG_H__
 
-#define GNOME_CMD_CHMOD_DIALOG(obj) \
-    GTK_CHECK_CAST (obj, gnome_cmd_chmod_dialog_get_type (), GnomeCmdChmodDialog)
-#define GNOME_CMD_CHMOD_DIALOG_CLASS(klass) \
-    GTK_CHECK_CLASS_CAST (klass, gnome_cmd_chmod_dialog_get_type (), GnomeCmdChmodDialogClass)
-#define GNOME_CMD_IS_CHMOD_DIALOG(obj) \
-    GTK_CHECK_TYPE (obj, gnome_cmd_chmod_dialog_get_type ())
+#define GNOME_CMD_TYPE_CHMOD_DIALOG         (gnome_cmd_chmod_dialog_get_type ())
+#define GNOME_CMD_CHMOD_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_CMD_TYPE_CHMOD_DIALOG, GnomeCmdChmodDialog))
+#define GNOME_CMD_IS_CHMOD_DIALOG(obj)      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_CMD_TYPE_CHMOD_DIALOG))
+
+
+GType gnome_cmd_chmod_dialog_get_type ();
 
 
 struct GnomeCmdChmodDialogPrivate;



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