]> git.0d.be Git - empathy.git/commitdiff
Don't emit sound when changing state and properly play login sound.
authorXavier Claessens <xclaesse@src.gnome.org>
Tue, 6 Jan 2009 16:46:07 +0000 (16:46 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 6 Jan 2009 16:46:07 +0000 (16:46 +0000)
svn path=/trunk/; revision=2027

libempathy-gtk/empathy-ui-utils.c
src/empathy-main-window.c

index a7a468c3fbe497013efc156108c56f00c3cfb598..83141afbf3bd4f3680299ac8274ba745f061f6d5 100644 (file)
@@ -1509,11 +1509,13 @@ empathy_sound_pref_is_enabled (const char *key)
                return FALSE;
        }
 
-       idle = empathy_idle_new ();     
+       idle = empathy_idle_new ();
        presence = empathy_idle_get_state (idle);
        g_object_unref (idle);
 
-       if (presence > MC_PRESENCE_AVAILABLE) {
+
+       if (presence != MC_PRESENCE_AVAILABLE &&
+           presence != MC_PRESENCE_UNSET) {
                empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
                                       &res);
                if (res) {
index ced1d68e3bbdb450fcec028889e08d5064ce0d75..58c4a0184b3c2b729c8ea2f21266bfc28b4844d2 100644 (file)
@@ -36,6 +36,7 @@
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-contact-factory.h>
+#include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-status-presets.h>
 
 #include <libempathy-gtk/empathy-contact-dialogs.h>
@@ -1183,14 +1184,24 @@ main_window_status_changed_cb (MissionControl           *mc,
 
        if (status == TP_CONNECTION_STATUS_CONNECTED) {
                GtkWidget *error_widget;
+               EmpathyIdle *idle;
 
-               if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN)) {
+               idle = empathy_idle_new ();
+
+               /* emit the sound only on first connect, i.e. when the saved
+                * idle state is MC_PRESENCE_UNSET.
+                */
+
+               if (empathy_idle_get_state (idle) == MC_PRESENCE_UNSET &&
+                   empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN)) {
                        ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0,
                                                CA_PROP_EVENT_ID, "service-login",
                                                CA_PROP_EVENT_DESCRIPTION, _("Connected to server"),
                                                NULL);
                }
 
+               g_object_unref (idle);
+
                /* Account connected without error, remove error message if any */
                error_widget = g_hash_table_lookup (window->errors, account);
                if (error_widget) {