[gnome-commander] Use G_DEFINE_TYPE for GnomeCmdRemoteDialog



commit b096c495741d94427a1036060a626439e42a0850
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sun Jan 30 17:57:08 2011 +0100

    Use G_DEFINE_TYPE for GnomeCmdRemoteDialog

 src/gnome-cmd-remote-dialog.cc |   61 ++++++----------------------------------
 src/gnome-cmd-remote-dialog.h  |    2 +-
 2 files changed, 10 insertions(+), 53 deletions(-)
---
diff --git a/src/gnome-cmd-remote-dialog.cc b/src/gnome-cmd-remote-dialog.cc
index ce64d79..40949ce 100644
--- a/src/gnome-cmd-remote-dialog.cc
+++ b/src/gnome-cmd-remote-dialog.cc
@@ -35,9 +35,6 @@
 using namespace std;
 
 
-static GnomeCmdDialogClass *parent_class = NULL;
-
-
 struct GnomeCmdRemoteDialogPrivate
 {
     GtkWidget         *connection_list;
@@ -46,6 +43,8 @@ struct GnomeCmdRemoteDialogPrivate
 };
 
 
+G_DEFINE_TYPE (GnomeCmdRemoteDialog, gnome_cmd_remote_dialog, GNOME_CMD_TYPE_DIALOG)
+
 
 /******************************************************
     The main ftp dialog
@@ -404,41 +403,25 @@ inline GtkWidget *create_view_and_model (GList *list)
  * Gtk class implementation
  *******************************/
 
-static void destroy (GtkObject *object)
+static void gnome_cmd_remote_dialog_finalize (GObject *object)
 {
     GnomeCmdRemoteDialog *dialog = GNOME_CMD_REMOTE_DIALOG (object);
 
-    if (!dialog->priv)
-        g_warning ("GnomeCmdRemoteDialog: dialog->priv != NULL test failed");
-
     g_free (dialog->priv);
 
-    if (GTK_OBJECT_CLASS (parent_class)->destroy)
-        (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-
-static void map (GtkWidget *widget)
-{
-    if (GTK_WIDGET_CLASS (parent_class)->map != NULL)
-        GTK_WIDGET_CLASS (parent_class)->map (widget);
+    G_OBJECT_CLASS (gnome_cmd_remote_dialog_parent_class)->finalize (object);
 }
 
 
-static void class_init (GnomeCmdRemoteDialogClass *klass)
+static void gnome_cmd_remote_dialog_class_init (GnomeCmdRemoteDialogClass *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;
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-    widget_class->map = ::map;
+    object_class->finalize = gnome_cmd_remote_dialog_finalize;
 }
 
 
-static void init (GnomeCmdRemoteDialog *ftp_dialog)
+static void gnome_cmd_remote_dialog_init (GnomeCmdRemoteDialog *ftp_dialog)
 {
     GtkWidget *cat_box, *table, *cat, *sw, *label, *button, *bbox;
 
@@ -512,35 +495,9 @@ static void init (GnomeCmdRemoteDialog *ftp_dialog)
  * Public functions
  ***********************************/
 
-GtkType gnome_cmd_remote_dialog_get_type ()
-{
-    static GtkType dlg_type = 0;
-
-    if (dlg_type == 0)
-    {
-        GtkTypeInfo dlg_info =
-        {
-            "GnomeCmdRemoteDialog",
-            sizeof (GnomeCmdRemoteDialog),
-            sizeof (GnomeCmdRemoteDialogClass),
-            (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;
-}
-
-
 GtkWidget *gnome_cmd_remote_dialog_new ()
 {
-    GnomeCmdRemoteDialog *dialog = (GnomeCmdRemoteDialog *) gtk_type_new (gnome_cmd_remote_dialog_get_type ());
-
-    return GTK_WIDGET (dialog);
+    return GTK_WIDGET (g_object_new (GNOME_CMD_TYPE_REMOTE_DIALOG, NULL));
 }
 
 
diff --git a/src/gnome-cmd-remote-dialog.h b/src/gnome-cmd-remote-dialog.h
index c12b287..d61931f 100644
--- a/src/gnome-cmd-remote-dialog.h
+++ b/src/gnome-cmd-remote-dialog.h
@@ -45,7 +45,7 @@ struct GnomeCmdRemoteDialogClass
 };
 
 
-GtkType gnome_cmd_remote_dialog_get_type ();
+GType gnome_cmd_remote_dialog_get_type ();
 
 GtkWidget *gnome_cmd_remote_dialog_new ();
 



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