aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2009-01-07 00:48:49 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2009-01-07 00:48:49 +0800
commit08bf3e70e647718f9768f0566aa8e950378ea005 (patch)
tree98290f786ba1bbfbf183e663051b5c4002163f87
parent6dac1f16245c458edb2eea4ff986b457b930f3dd (diff)
downloadgsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar.gz
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar.bz2
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar.lz
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar.xz
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.tar.zst
gsoc2013-empathy-08bf3e70e647718f9768f0566aa8e950378ea005.zip
Turn empathy_sound_pref_is_enabled into empathy_sound_play that
automatically plays the sound if the pref is enabled. git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@2078 4ee84921-47dd-4033-b63a-18d7a039a3e4
-rw-r--r--libempathy-gtk/empathy-ui-utils.c17
-rw-r--r--libempathy-gtk/empathy-ui-utils.h6
-rw-r--r--python/pyempathygtk/pyempathygtk.defs9
-rw-r--r--src/empathy-chat-window.c20
-rw-r--r--src/empathy-main-window.c47
5 files changed, 50 insertions, 49 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index da658dac6..f937ce110 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -38,6 +38,7 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glade/glade.h>
+#include <canberra-gtk.h>
#include <libmissioncontrol/mc-profile.h>
@@ -1492,7 +1493,7 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact)
gtk_widget_show (widget);
}
-gboolean
+static gboolean
empathy_sound_pref_is_enabled (const char *key)
{
EmpathyConf *conf;
@@ -1526,3 +1527,17 @@ empathy_sound_pref_is_enabled (const char *key)
return res;
}
+
+void
+empathy_sound_play (GtkWidget *widget,
+ const char *key,
+ const char *event_id,
+ const char *description)
+{
+ if (empathy_sound_pref_is_enabled (key)) {
+ ca_gtk_play_for_widget (widget, 0,
+ CA_PROP_EVENT_ID, event_id,
+ CA_PROP_EVENT_DESCRIPTION, description,
+ NULL);
+ }
+} \ No newline at end of file
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 7c97f0943..285b66452 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -114,7 +114,11 @@ GtkWidget * empathy_link_button_new (const gchar *url,
void empathy_send_file_with_file_chooser (EmpathyContact *contact);
-gboolean empathy_sound_pref_is_enabled (const char *key);
+/* Sounds */
+void empathy_sound_play (GtkWidget *widget,
+ const char *key,
+ const char *event_id,
+ const char *description);
G_END_DECLS
diff --git a/python/pyempathygtk/pyempathygtk.defs b/python/pyempathygtk/pyempathygtk.defs
index 90bfa0c2f..3c83a28ec 100644
--- a/python/pyempathygtk/pyempathygtk.defs
+++ b/python/pyempathygtk/pyempathygtk.defs
@@ -1732,11 +1732,14 @@
)
)
-(define-function sound_pref_is_enabled
- (c-name "empathy_sound_pref_is_enabled")
- (return-type "gboolean")
+(define-function sound_play
+ (c-name "empathy_sound_play")
+ (return-type "none")
(parameters
+ '("GtkWidget*" "widget")
'("const-char*" "key")
+ '("const-char*" "event_id")
+ '("const-char*" "description")
)
)
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index e1bd9075e..2c97301a5 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -33,7 +33,6 @@
#include <gdk/gdkkeysyms.h>
#include <glade/glade.h>
#include <glib/gi18n.h>
-#include <canberra-gtk.h>
#include <telepathy-glib/util.h>
#include <libmissioncontrol/mission-control.h>
@@ -858,19 +857,14 @@ chat_window_new_message_cb (EmpathyChat *chat,
sender = empathy_message_get_sender (message);
if (empathy_contact_is_user (sender) != FALSE) {
- if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE)) {
- ca_gtk_play_for_widget (GTK_WIDGET (priv->dialog), 0,
- CA_PROP_EVENT_ID, "message-sent-instant",
- CA_PROP_EVENT_DESCRIPTION, _("Sent an instant message"),
- NULL);
- }
+ empathy_sound_play (GTK_WIDGET (priv->dialog),
+ EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE,
+ "message-sent-instant", _("Sent an instant message"));
} else {
- if ((!has_focus || priv->current_chat != chat) &&
- empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE)) {
- ca_gtk_play_for_widget (GTK_WIDGET (priv->dialog), 0,
- CA_PROP_EVENT_ID, "message-new-instant",
- CA_PROP_EVENT_DESCRIPTION, _("Received an instant message"),
- NULL);
+ if ((!has_focus || priv->current_chat != chat)) {
+ empathy_sound_play (GTK_WIDGET (priv->dialog),
+ EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE,
+ "message-new-instant", _("Received an instant message"));
}
}
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 8a377d794..b95783f3a 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <glib/gi18n.h>
-#include <canberra-gtk.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-utils.h>
@@ -284,12 +283,9 @@ main_window_flash_cb (EmpathyMainWindow *window)
static void
main_window_flash_start (EmpathyMainWindow *window)
{
- if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION)) {
- ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0,
- CA_PROP_EVENT_ID, "message-new-instant",
- CA_PROP_EVENT_DESCRIPTION, _("Incoming chat request"),
- NULL);
- }
+ empathy_sound_play (GTK_WIDGET (window->window),
+ EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION,
+ "message-new-instant", _("Incoming chat request"));
if (window->flash_timeout_id != 0) {
return;
@@ -433,23 +429,18 @@ main_window_connection_changed_cb (EmpathyAccountManager *manager,
main_window_error_display (window, account, message);
}
- if (current == TP_CONNECTION_STATUS_DISCONNECTED &&
- empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT)) {
- ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0,
- CA_PROP_EVENT_ID, "service-logout",
- CA_PROP_EVENT_DESCRIPTION, _("Disconnected from server"),
- NULL);
+ if (current == TP_CONNECTION_STATUS_DISCONNECTED) {
+ empathy_sound_play (GTK_WIDGET (window->window),
+ EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT,
+ "service-logout", _("Disconnected from server"));
}
if (current == TP_CONNECTION_STATUS_CONNECTED) {
GtkWidget *error_widget;
- if (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);
- }
+ empathy_sound_play (GTK_WIDGET (window->window),
+ EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN,
+ "service-login", _("Connected to server"));
/* Account connected without error, remove error message if any */
error_widget = g_hash_table_lookup (window->errors, account);
@@ -479,23 +470,17 @@ main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
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);
- }
+ empathy_sound_play (GTK_WIDGET (window->window),
+ EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN,
+ "service-login", _("Contact logged in"));
return;
}
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);
- }
+ empathy_sound_play (GTK_WIDGET (window->window),
+ EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT,
+ "service-logout", _("Contact logged out"));
}
}