empathy r2116 - in trunk: libempathy-gtk src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2116 - in trunk: libempathy-gtk src
- Date: Fri, 9 Jan 2009 10:06:10 +0000 (UTC)
Author: xclaesse
Date: Fri Jan 9 10:06:10 2009
New Revision: 2116
URL: http://svn.gnome.org/viewvc/empathy?rev=2116&view=rev
Log:
Port EmpathySmileyManager to the new singleton policy.
Modified:
trunk/libempathy-gtk/empathy-chat-text-view.c
trunk/libempathy-gtk/empathy-chat.c
trunk/libempathy-gtk/empathy-smiley-manager.c
trunk/libempathy-gtk/empathy-smiley-manager.h
trunk/libempathy-gtk/empathy-theme.c
trunk/src/empathy-chat-window.c
Modified: trunk/libempathy-gtk/empathy-chat-text-view.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-text-view.c (original)
+++ trunk/libempathy-gtk/empathy-chat-text-view.c Fri Jan 9 10:06:10 2009
@@ -637,7 +637,7 @@
priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
priv->last_timestamp = 0;
priv->allow_scrolling = TRUE;
- priv->smiley_manager = empathy_smiley_manager_new ();
+ priv->smiley_manager = empathy_smiley_manager_dup_singleton ();
g_object_set (view,
"wrap-mode", GTK_WRAP_WORD_CHAR,
Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c (original)
+++ trunk/libempathy-gtk/empathy-chat.c Fri Jan 9 10:06:10 2009
@@ -968,7 +968,7 @@
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
- smiley_manager = empathy_smiley_manager_new ();
+ smiley_manager = empathy_smiley_manager_dup_singleton ();
smiley_menu = empathy_smiley_menu_new (smiley_manager,
chat_insert_smiley_activate_cb,
chat);
Modified: trunk/libempathy-gtk/empathy-smiley-manager.c
==============================================================================
--- trunk/libempathy-gtk/empathy-smiley-manager.c (original)
+++ trunk/libempathy-gtk/empathy-smiley-manager.c Fri Jan 9 10:06:10 2009
@@ -44,6 +44,8 @@
G_DEFINE_TYPE (EmpathySmileyManager, empathy_smiley_manager, G_TYPE_OBJECT);
+static EmpathySmileyManager *manager_singleton = NULL;
+
static SmileyManagerTree *
smiley_manager_tree_new (gunichar c)
{
@@ -115,12 +117,33 @@
g_slist_free (priv->smileys);
}
+static GObject *
+smiley_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_smiley_manager_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ manager_singleton = EMPATHY_SMILEY_MANAGER (retval);
+ }
+
+ return retval;
+}
+
static void
empathy_smiley_manager_class_init (EmpathySmileyManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = smiley_manager_finalize;
+ object_class->constructor = smiley_manager_constructor;
g_type_class_add_private (object_class, sizeof (EmpathySmileyManagerPriv));
}
@@ -134,22 +157,14 @@
manager->priv = priv;
priv->tree = smiley_manager_tree_new ('\0');
priv->smileys = NULL;
+
+ empathy_smiley_manager_load (manager);
}
EmpathySmileyManager *
-empathy_smiley_manager_new (void)
+empathy_smiley_manager_dup_singleton (void)
{
- static EmpathySmileyManager *manager = NULL;
-
- if (!manager) {
- manager = g_object_new (EMPATHY_TYPE_SMILEY_MANAGER, NULL);
- g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager);
- empathy_smiley_manager_load (manager);
- } else {
- g_object_ref (manager);
- }
-
- return manager;
+ return g_object_new (EMPATHY_TYPE_SMILEY_MANAGER, NULL);
}
static SmileyManagerTree *
Modified: trunk/libempathy-gtk/empathy-smiley-manager.h
==============================================================================
--- trunk/libempathy-gtk/empathy-smiley-manager.h (original)
+++ trunk/libempathy-gtk/empathy-smiley-manager.h Fri Jan 9 10:06:10 2009
@@ -57,7 +57,7 @@
gpointer user_data);
GType empathy_smiley_manager_get_type (void) G_GNUC_CONST;
-EmpathySmileyManager *empathy_smiley_manager_new (void);
+EmpathySmileyManager *empathy_smiley_manager_dup_singleton (void);
void empathy_smiley_manager_load (EmpathySmileyManager *manager);
void empathy_smiley_manager_add (EmpathySmileyManager *manager,
const gchar *icon_name,
Modified: trunk/libempathy-gtk/empathy-theme.c
==============================================================================
--- trunk/libempathy-gtk/empathy-theme.c (original)
+++ trunk/libempathy-gtk/empathy-theme.c Fri Jan 9 10:06:10 2009
@@ -102,7 +102,7 @@
EMPATHY_TYPE_THEME, EmpathyThemePriv);
theme->priv = priv;
- priv->smiley_manager = empathy_smiley_manager_new ();
+ priv->smiley_manager = empathy_smiley_manager_dup_singleton ();
}
static void
Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c (original)
+++ trunk/src/empathy-chat-window.c Fri Jan 9 10:06:10 2009
@@ -1277,7 +1277,7 @@
g_object_unref (accel_group);
/* Set up smiley menu */
- smiley_manager = empathy_smiley_manager_new ();
+ smiley_manager = empathy_smiley_manager_dup_singleton ();
menu = empathy_smiley_menu_new (smiley_manager,
chat_window_insert_smiley_activate_cb,
window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]