diff options
author | xclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4> | 2009-01-07 00:47:50 +0800 |
---|---|---|
committer | xclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4> | 2009-01-07 00:47:50 +0800 |
commit | 06386eefb32c3fecba36fc0ca41ad6cdf2b23205 (patch) | |
tree | b57f737206e4623074438cdef01aa403f7fdb13b | |
parent | 001433863d6693df6d2b0e0344b0941a072194c3 (diff) | |
download | gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar.gz gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar.bz2 gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar.lz gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar.xz gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.tar.zst gsoc2013-empathy-06386eefb32c3fecba36fc0ca41ad6cdf2b23205.zip |
Implement sound for contact login/logout.
git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@2060 4ee84921-47dd-4033-b63a-18d7a039a3e4
-rw-r--r-- | src/empathy-main-window.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 5c38a3984..bc795dbe0 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -460,11 +460,55 @@ main_window_connection_changed_cb (EmpathyAccountManager *manager, } } +static void +main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor, + EmpathyContact *contact, + McPresence current, + McPresence previous, + EmpathyMainWindow *window) +{ + EmpathyAccountManager *acc_manager; + McAccount *account; + gboolean should_play; + + acc_manager = empathy_account_manager_new (); + account = empathy_contact_get_account (contact); + should_play = !empathy_account_manager_is_account_just_connected (acc_manager, account); + + if (!should_play) { + goto out; + } + + if (previous < MC_PRESENCE_AVAILABLE && current > MC_PRESENCE_OFFLINE) { + /* someone is logging in */ + if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN)) { + ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0, + CA_PROP_EVENT_ID, "service-login", + CA_PROP_EVENT_DESCRIPTION, _("Contact logged in"), + NULL); + } + goto out; + } + + if (previous > MC_PRESENCE_OFFLINE && current < MC_PRESENCE_AVAILABLE) { + /* someone is logging off */ + if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT)) { + ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0, + CA_PROP_EVENT_ID, "service-logout", + CA_PROP_EVENT_DESCRIPTION, _("Contact logged out"), + NULL); + } + } +out: + g_object_unref (acc_manager); +} + GtkWidget * empathy_main_window_show (void) { static EmpathyMainWindow *window = NULL; EmpathyContactList *list_iface; + EmpathyContactMonitor *monitor; GladeXML *glade; EmpathyConf *conf; GtkWidget *sw; @@ -580,10 +624,13 @@ empathy_main_window_show (void) empathy_status_presets_get_all (); list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ()); + monitor = empathy_contact_list_get_monitor (list_iface); window->list_store = empathy_contact_list_store_new (list_iface); window->list_view = empathy_contact_list_view_new (window->list_store, EMPATHY_CONTACT_LIST_FEATURE_ALL, EMPATHY_CONTACT_FEATURE_ALL); + g_signal_connect (monitor, "contact-presence-changed", + G_CALLBACK (main_window_contact_presence_changed_cb), window); g_object_unref (list_iface); gtk_widget_show (GTK_WIDGET (window->list_view)); |