[nautilus/gnome-2-32: 62/283] Make NautilusBookmarkList a singleton.
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-2-32: 62/283] Make NautilusBookmarkList a singleton.
- Date: Thu, 12 Aug 2010 11:09:14 +0000 (UTC)
commit 3cb10c00bce04d99e329afd9e0d777a8c4dcbe9b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu May 6 18:04:24 2010 +0200
Make NautilusBookmarkList a singleton.
src/nautilus-bookmark-list.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index f7e1b7c..0507a66 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -46,6 +46,7 @@ enum {
static guint signals[LAST_SIGNAL];
static char *window_geometry;
+static NautilusBookmarkList *singleton = NULL;
/* forward declarations */
@@ -174,12 +175,34 @@ do_finalize (GObject *object)
G_OBJECT_CLASS (nautilus_bookmark_list_parent_class)->finalize (object);
}
+static GObject *
+do_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *retval;
+
+ if (singleton != NULL) {
+ return g_object_ref (singleton);
+ }
+
+ retval = G_OBJECT_CLASS (nautilus_bookmark_list_parent_class)->constructor
+ (type, n_construct_params, construct_params);
+
+ singleton = NAUTILUS_BOOKMARK_LIST (retval);
+ g_object_add_weak_pointer (retval, (gpointer) &singleton);
+
+ return retval;
+}
+
+
static void
nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = do_finalize;
+ object_class->constructor = do_constructor;
signals[CONTENTS_CHANGED] =
g_signal_new ("contents_changed",
@@ -683,7 +706,7 @@ nautilus_bookmark_list_new (void)
list = NAUTILUS_BOOKMARK_LIST (g_object_new (NAUTILUS_TYPE_BOOKMARK_LIST, NULL));
- return g_object_ref_sink (list);
+ return list;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]