empathy r2118 - trunk/src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2118 - trunk/src
- Date: Fri, 9 Jan 2009 10:06:19 +0000 (UTC)
Author: xclaesse
Date: Fri Jan 9 10:06:19 2009
New Revision: 2118
URL: http://svn.gnome.org/viewvc/empathy?rev=2118&view=rev
Log:
Port EmpathyFTManager to the new singleton policy.
Modified:
trunk/src/empathy-ft-manager.c
trunk/src/empathy-ft-manager.h
trunk/src/empathy.c
Modified: trunk/src/empathy-ft-manager.c
==============================================================================
--- trunk/src/empathy-ft-manager.c (original)
+++ trunk/src/empathy-ft-manager.c Fri Jan 9 10:06:19 2009
@@ -94,6 +94,8 @@
G_DEFINE_TYPE (EmpathyFTManager, empathy_ft_manager, G_TYPE_OBJECT);
+static EmpathyFTManager *manager_singleton = NULL;
+
static gchar *
ft_manager_format_interval (gint interval)
{
@@ -768,36 +770,51 @@
ft_manager_build_ui (ft_manager);
}
+static GObject *
+empathy_ft_manager_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (manager_singleton)
+ {
+ retval = g_object_ref (manager_singleton);
+ }
+ else
+ {
+ retval = G_OBJECT_CLASS (empathy_ft_manager_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ manager_singleton = EMPATHY_FT_MANAGER (retval);
+ }
+
+ return retval;
+}
+
static void
empathy_ft_manager_class_init (EmpathyFTManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = empathy_ft_manager_finalize;
+ object_class->constructor = empathy_ft_manager_constructor;
g_type_class_add_private (object_class, sizeof (EmpathyFTManagerPriv));
}
/**
- * empathy_ft_manager_get_default:
+ * empathy_ft_manager_dup_singleton:
*
- * Returns a new #EmpathyFTManager if there is not already one, or the existing
- * one if it exists.
+ * Returns a reference to the #EmpathyFTManager singleton object.
*
* Returns: a #EmpathyFTManager
*/
EmpathyFTManager *
-empathy_ft_manager_get_default (void)
+empathy_ft_manager_dup_singleton (void)
{
- static EmpathyFTManager *manager_p = NULL;
-
- if (!manager_p)
- {
- manager_p = g_object_new (EMPATHY_TYPE_FT_MANAGER, NULL);
- g_object_add_weak_pointer (G_OBJECT (manager_p), (gpointer) &manager_p);
- }
-
- return manager_p;
+ return g_object_new (EMPATHY_TYPE_FT_MANAGER, NULL);
}
/**
Modified: trunk/src/empathy-ft-manager.h
==============================================================================
--- trunk/src/empathy-ft-manager.h (original)
+++ trunk/src/empathy-ft-manager.h Fri Jan 9 10:06:19 2009
@@ -58,7 +58,7 @@
GType empathy_ft_manager_get_type (void);
-EmpathyFTManager *empathy_ft_manager_get_default (void);
+EmpathyFTManager *empathy_ft_manager_dup_singleton (void);
void empathy_ft_manager_add_tp_file (EmpathyFTManager *ft_manager, EmpathyTpFile *tp_file);
GtkWidget *empathy_ft_manager_get_dialog (EmpathyFTManager *ft_manager);
Modified: trunk/src/empathy.c
==============================================================================
--- trunk/src/empathy.c (original)
+++ trunk/src/empathy.c Fri Jan 9 10:06:19 2009
@@ -110,7 +110,7 @@
EmpathyFTManager *ft_manager;
EmpathyTpFile *tp_file;
- ft_manager = empathy_ft_manager_get_default ();
+ ft_manager = empathy_ft_manager_dup_singleton ();
tp_file = empathy_tp_file_new (channel);
empathy_ft_manager_add_tp_file (ft_manager, tp_file);
g_object_unref (tp_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]