[gedit] Simplify app and command-line singletons



commit 6868673dfc1236cf4d711ab7f3f9f38a56585f02
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Apr 8 21:46:54 2011 +0200

    Simplify app and command-line singletons
    
    GeditApp had the wrong parent class in the class struct, but we may as
    well make it a normal gobject instead of an initially-unowned since we
    were ref-sinking it immediately.

 gedit/gedit-app.c          |   19 +++----------------
 gedit/gedit-app.h          |    2 +-
 gedit/gedit-command-line.c |   21 ++++-----------------
 gedit/gedit-command-line.h |    4 ++--
 4 files changed, 10 insertions(+), 36 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index b18de86..78cdb5f 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -87,7 +87,7 @@ struct _GeditAppPrivate
 	PeasExtensionSet  *extensions;
 };
 
-G_DEFINE_ABSTRACT_TYPE(GeditApp, gedit_app, G_TYPE_INITIALLY_UNOWNED)
+G_DEFINE_ABSTRACT_TYPE(GeditApp, gedit_app, G_TYPE_OBJECT)
 
 static void
 gedit_app_finalize (GObject *object)
@@ -165,11 +165,9 @@ gedit_app_constructor (GType                  gtype,
 		                                                            construct_params);
 
 		g_object_add_weak_pointer (app, (gpointer *) &app);
-
-		return app;
 	}
 
-	return g_object_ref (app);
+	return app;
 }
 
 static gboolean
@@ -560,18 +558,7 @@ gedit_app_get_default (void)
 #endif
 #endif
 
-	app = GEDIT_APP (g_object_new (type, NULL));
-
-	if (g_object_is_floating (app))
-	{
-		g_object_ref_sink (app);
-	}
-	else
-	{
-		g_object_unref (app);
-	}
-
-	return app;
+	return GEDIT_APP (g_object_new (type, NULL));
 }
 
 static void
diff --git a/gedit/gedit-app.h b/gedit/gedit-app.h
index 03f0c53..87cad87 100644
--- a/gedit/gedit-app.h
+++ b/gedit/gedit-app.h
@@ -57,7 +57,7 @@ typedef struct _GeditApp GeditApp;
 
 struct _GeditApp 
 {
-	GInitiallyUnowned parent;
+	GObject parent;
 
 	/*< private > */
 	GeditAppPrivate *priv;
diff --git a/gedit/gedit-command-line.c b/gedit/gedit-command-line.c
index 60fdb30..6ecf2f7 100644
--- a/gedit/gedit-command-line.c
+++ b/gedit/gedit-command-line.c
@@ -62,7 +62,7 @@ struct _GeditCommandLinePrivate
 	const GeditEncoding *encoding;
 };
 
-G_DEFINE_TYPE (GeditCommandLine, gedit_command_line, G_TYPE_INITIALLY_UNOWNED)
+G_DEFINE_TYPE (GeditCommandLine, gedit_command_line, G_TYPE_OBJECT)
 
 static void
 gedit_command_line_finalize (GObject *object)
@@ -92,11 +92,11 @@ gedit_command_line_constructor (GType                  gtype,
 		                                                                              construct_params);
 
 		g_object_add_weak_pointer (command_line, (gpointer *) &command_line);
-		return command_line;
 	}
 
-	return g_object_ref (command_line);
+	return command_line;
 }
+
 static void
 gedit_command_line_class_init (GeditCommandLineClass *klass)
 {
@@ -117,20 +117,7 @@ gedit_command_line_init (GeditCommandLine *self)
 GeditCommandLine *
 gedit_command_line_get_default (void)
 {
-	GeditCommandLine *command_line;
-
-	command_line = g_object_new (GEDIT_TYPE_COMMAND_LINE, NULL);
-
-	if (g_object_is_floating (command_line))
-	{
-		g_object_ref_sink (command_line);
-	}
-	else
-	{
-		g_object_unref (command_line);
-	}
-
-	return command_line;
+	return g_object_new (GEDIT_TYPE_COMMAND_LINE, NULL);
 }
 
 static void
diff --git a/gedit/gedit-command-line.h b/gedit/gedit-command-line.h
index a5c3b31..057f804 100644
--- a/gedit/gedit-command-line.h
+++ b/gedit/gedit-command-line.h
@@ -44,14 +44,14 @@ typedef struct _GeditCommandLineGeometry GeditCommandLineGeometry;
 
 struct _GeditCommandLine
 {
-	GInitiallyUnowned parent;
+	GObject parent;
 
 	GeditCommandLinePrivate *priv;
 };
 
 struct _GeditCommandLineClass
 {
-	GInitiallyUnownedClass parent_class;
+	GObjectClass parent_class;
 };
 
 GType			 gedit_command_line_get_type		(void) G_GNUC_CONST;



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