]> git.0d.be Git - empathy.git/commitdiff
chat-window: cache the 'chat' gsettings
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 17 Nov 2010 08:39:43 +0000 (09:39 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 17 Nov 2010 08:39:43 +0000 (09:39 +0100)
We use it each time the window is focused so best to reduce the D-Bus traffic
(#635022).

src/empathy-chat-window.c

index 43c4fabf6f5b265e81c19de484559fa48e5965ec..4aba2af2d2a9dfc47a9db69ccd9dc86cae207c06 100644 (file)
@@ -111,6 +111,8 @@ typedef struct {
 
        /* Last user action time we acted upon to show a tab */
        guint32    x_user_action_time;
+
+       GSettings *gsettings_chat;
 } EmpathyChatWindowPriv;
 
 static GList *chat_windows = NULL;
@@ -533,9 +535,7 @@ chat_window_icon_update (EmpathyChatWindowPriv *priv)
                gtk_window_set_icon_name (GTK_WINDOW (priv->dialog),
                                          EMPATHY_IMAGE_MESSAGE);
        } else {
-               GSettings *gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
-
-               avatar_in_icon = g_settings_get_boolean (gsettings,
+               avatar_in_icon = g_settings_get_boolean (priv->gsettings_chat,
                                EMPATHY_PREFS_CHAT_AVATAR_IN_ICON);
 
                if (n_chats == 1 && avatar_in_icon) {
@@ -549,8 +549,6 @@ chat_window_icon_update (EmpathyChatWindowPriv *priv)
                } else {
                        gtk_window_set_icon_name (GTK_WINDOW (priv->dialog), NULL);
                }
-
-               g_object_unref (gsettings);
        }
 }
 
@@ -1875,6 +1873,7 @@ chat_window_finalize (GObject *object)
        g_object_unref (priv->ui_manager);
        g_object_unref (priv->chatroom_manager);
        g_object_unref (priv->notify_mgr);
+       g_object_unref (priv->gsettings_chat);
 
        if (priv->notification != NULL) {
                notify_notification_close (priv->notification, NULL);
@@ -1985,6 +1984,7 @@ empathy_chat_window_init (EmpathyChatWindow *window)
        g_object_ref (priv->ui_manager);
        g_object_unref (gui);
 
+       priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
        priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
 
        priv->notebook = gtk_notebook_new ();