diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-11-30 18:24:20 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-11-30 18:24:20 +0800 |
commit | 81068bbf3ebd6c251f308d6d45e4dadf07432ea7 (patch) | |
tree | d17b2afe895a95156d753b6ccbb4b66196cb01b9 | |
parent | 8172bca03c6f85d7dcc0ff39f1a81ccfd719b08b (diff) | |
download | gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar.gz gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar.bz2 gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar.lz gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar.xz gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.tar.zst gsoc2013-empathy-81068bbf3ebd6c251f308d6d45e4dadf07432ea7.zip |
move sound functions to EmpathySoundManager methods
-rw-r--r-- | libempathy-gtk/empathy-sound-manager.c | 34 | ||||
-rw-r--r-- | libempathy-gtk/empathy-sound-manager.h | 19 | ||||
-rw-r--r-- | src/empathy-call-window.c | 15 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 9 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 30 | ||||
-rw-r--r-- | src/empathy-main-window.c | 10 |
6 files changed, 85 insertions, 32 deletions
diff --git a/libempathy-gtk/empathy-sound-manager.c b/libempathy-gtk/empathy-sound-manager.c index 8d51f7391..d0da9e54c 100644 --- a/libempathy-gtk/empathy-sound-manager.c +++ b/libempathy-gtk/empathy-sound-manager.c @@ -148,14 +148,16 @@ finally: } /** - * empathy_sound_stop: + * empathy_sound_manager_stop: + * @self: a #EmpathySoundManager * @sound_id: The #EmpathySound to stop playing. * * Stop playing a sound. If it has been stated in loop with * empathy_sound_start_playing(), it will also stop replaying. */ void -empathy_sound_stop (EmpathySound sound_id) +empathy_sound_manager_stop (EmpathySoundManager *self, + EmpathySound sound_id) { EmpathySoundEntry *entry; @@ -232,7 +234,8 @@ failed: } /** - * empathy_sound_play_full: + * empathy_sound_manager_play_full: + * @self: a #EmpathySoundManager * @widget: The #GtkWidget from which the sound is originating. * @sound_id: The #EmpathySound to play. * @callback: The #ca_finish_callback_t function that will be called when the @@ -253,8 +256,11 @@ failed: * otherwise. */ gboolean -empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, - ca_finish_callback_t callback, gpointer user_data) +empathy_sound_manager_play_full (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id, + ca_finish_callback_t callback, + gpointer user_data) { g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); @@ -272,22 +278,25 @@ empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, } /** - * empathy_sound_play: + * empathy_sound_manager_play: + * @self: a #EmpathySoundManager * @widget: The #GtkWidget from which the sound is originating. * @sound_id: The #EmpathySound to play. * - * Plays a sound. See %empathy_sound_play_full for details.' + * Plays a sound. See %empathy_sound_manager_play_full for details.' * * Return value: %TRUE if the sound has successfully started playing, %FALSE * otherwise. */ gboolean -empathy_sound_play (GtkWidget *widget, EmpathySound sound_id) +empathy_sound_manager_play (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id) { g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); - return empathy_sound_play_full (widget, sound_id, NULL, NULL); + return empathy_sound_manager_play_full (self, widget, sound_id, NULL, NULL); } static void playing_finished_cb (ca_context *c, guint id, int error_code, @@ -362,7 +371,8 @@ repeating_sounds_item_delete (gpointer data) } /** - * empathy_sound_start_playing: + * empathy_sound_manager_start_playing: + * @self: a #EmpathySoundManager * @widget: The #GtkWidget from which the sound is originating. * @sound_id: The #EmpathySound to play. * @timeout_before_replay: The amount of time, in milliseconds, between two @@ -376,7 +386,9 @@ repeating_sounds_item_delete (gpointer data) * Return value: %TRUE if the sound has successfully started playing. */ gboolean -empathy_sound_start_playing (GtkWidget *widget, EmpathySound sound_id, +empathy_sound_manager_start_playing (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id, guint timeout_before_replay) { EmpathyRepeatableSound *repeatable_sound; diff --git a/libempathy-gtk/empathy-sound-manager.h b/libempathy-gtk/empathy-sound-manager.h index ca112e2d9..99e96c571 100644 --- a/libempathy-gtk/empathy-sound-manager.h +++ b/libempathy-gtk/empathy-sound-manager.h @@ -68,14 +68,23 @@ GType empathy_sound_manager_get_type (void) G_GNUC_CONST; EmpathySoundManager * empathy_sound_manager_dup_singleton (void); -gboolean empathy_sound_play (GtkWidget *widget, EmpathySound sound_id); -void empathy_sound_stop (EmpathySound sound_id); +gboolean empathy_sound_manager_play (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id); -gboolean empathy_sound_start_playing (GtkWidget *widget, EmpathySound sound_id, +void empathy_sound_manager_stop (EmpathySoundManager *self, + EmpathySound sound_id); + +gboolean empathy_sound_manager_start_playing (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id, guint timeout_before_replay); -gboolean empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, - ca_finish_callback_t callback, gpointer user_data); +gboolean empathy_sound_manager_play_full (EmpathySoundManager *self, + GtkWidget *widget, + EmpathySound sound_id, + ca_finish_callback_t callback, + gpointer user_data); G_END_DECLS diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 4d2d99c27..6a0c24aad 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -221,6 +221,8 @@ struct _EmpathyCallWindowPriv gboolean start_call_when_playing; /* TRUE if we requested to set the pipeline in the playing state */ gboolean pipeline_playing; + + EmpathySoundManager *sound_mgr; }; #define GET_PRIV(o) \ @@ -810,7 +812,7 @@ empathy_call_window_set_state_connecting (EmpathyCallWindow *window) priv->call_state = CONNECTING; if (priv->outgoing) - empathy_sound_start_playing (GTK_WIDGET (window), + empathy_sound_manager_start_playing (priv->sound_mgr, GTK_WIDGET (window), EMPATHY_SOUND_PHONE_OUTGOING, MS_BETWEEN_RING); } @@ -1225,6 +1227,8 @@ empathy_call_window_init (EmpathyCallWindow *self) g_object_ref (priv->ui_manager); g_object_unref (gui); + priv->sound_mgr = empathy_sound_manager_dup_singleton (); + empathy_geometry_bind (GTK_WINDOW (self), "call-window"); } @@ -1761,6 +1765,8 @@ empathy_call_window_dispose (GObject *object) priv->contact = NULL; } + tp_clear_object (&priv->sound_mgr); + /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose) G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object); @@ -1913,7 +1919,8 @@ empathy_call_window_disconnected (EmpathyCallWindow *self, could_reset_pipeline = empathy_call_window_reset_pipeline (self); if (priv->call_state == CONNECTING) - empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING); + empathy_sound_manager_stop (priv->sound_mgr, + EMPATHY_SOUND_PHONE_OUTGOING); if (priv->call_state != REDIALING) priv->call_state = DISCONNECTED; @@ -2456,7 +2463,7 @@ empathy_call_window_connected (gpointer user_data) EmpathyTpCall *call; gboolean can_send_video; - empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING); + empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING); can_send_video = priv->video_input != NULL && priv->contact != NULL && empathy_contact_can_voip_video (priv->contact); @@ -2884,7 +2891,7 @@ empathy_call_window_delete_cb (GtkWidget *widget, GdkEvent*event, } if (priv->call_state == CONNECTING) - empathy_sound_stop (EMPATHY_SOUND_PHONE_OUTGOING); + empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_OUTGOING); return FALSE; } diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 97514e63d..457be5b2d 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -115,6 +115,8 @@ typedef struct { GSettings *gsettings_chat; GSettings *gsettings_notif; GSettings *gsettings_ui; + + EmpathySoundManager *sound_mgr; } EmpathyChatWindowPriv; static GList *chat_windows = NULL; @@ -1402,7 +1404,7 @@ chat_window_new_message_cb (EmpathyChat *chat, sender = empathy_message_get_sender (message); if (empathy_contact_is_user (sender)) { - empathy_sound_play (GTK_WIDGET (priv->dialog), + empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (priv->dialog), EMPATHY_SOUND_MESSAGE_OUTGOING); } @@ -1453,7 +1455,7 @@ chat_window_new_message_cb (EmpathyChat *chat, chat_window_set_highlight_room_tab_label (chat); } - empathy_sound_play (GTK_WIDGET (priv->dialog), + empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (priv->dialog), EMPATHY_SOUND_MESSAGE_INCOMING); chat_window_show_or_update_notification (window, message, chat); } @@ -1873,6 +1875,7 @@ chat_window_finalize (GObject *object) g_object_unref (priv->gsettings_chat); g_object_unref (priv->gsettings_notif); g_object_unref (priv->gsettings_ui); + g_object_unref (priv->sound_mgr); if (priv->notification != NULL) { notify_notification_close (priv->notification, NULL); @@ -1988,6 +1991,8 @@ empathy_chat_window_init (EmpathyChatWindow *window) priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA); priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); + priv->sound_mgr = empathy_sound_manager_dup_singleton (); + priv->notebook = gtk_notebook_new (); g_signal_connect (priv->notebook, "create-window", diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 0877c2699..5516328cc 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -85,6 +85,8 @@ typedef struct { GSettings *gsettings_notif; GSettings *gsettings_ui; + + EmpathySoundManager *sound_mgr; } EmpathyEventManagerPriv; typedef struct _EventPriv EventPriv; @@ -531,6 +533,7 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat, const gchar *msg; TpChannel *channel; EventPriv *event; + EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager); /* try to update the event if it's referring to a chat which is already in the * queue. */ @@ -550,7 +553,8 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat, EMPATHY_IMAGE_NEW_MESSAGE, header, msg, approval, event_text_channel_process_func, NULL); - empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW); + empathy_sound_manager_play (priv->sound_mgr, window, + EMPATHY_SOUND_CONVERSATION_NEW); g_object_unref (window); } @@ -571,7 +575,8 @@ event_manager_approval_done (EventManagerApproval *approval) { priv->ringing--; if (priv->ringing == 0) - empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING); + empathy_sound_manager_stop (priv->sound_mgr, + EMPATHY_SOUND_PHONE_INCOMING); } } @@ -630,7 +635,7 @@ event_manager_media_channel_got_contact (EventManagerApproval *approval) priv->ringing++; if (priv->ringing == 1) - empathy_sound_start_playing (window, + empathy_sound_manager_start_playing (priv->sound_mgr, window, EMPATHY_SOUND_PHONE_INCOMING, MS_BETWEEN_RING); g_object_unref (window); @@ -735,6 +740,7 @@ display_invite_room_dialog (EventManagerApproval *approval) const gchar *invite_msg; gchar *msg; TpHandle self_handle; + EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager); self_handle = tp_channel_group_get_self_handle (approval->main_channel); tp_channel_group_get_local_pending_info (approval->main_channel, self_handle, @@ -756,7 +762,8 @@ display_invite_room_dialog (EventManagerApproval *approval) EMPATHY_EVENT_TYPE_INVITATION, EMPATHY_IMAGE_GROUP_MESSAGE, msg, invite_msg, approval, event_room_channel_process_func, NULL); - empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW); + empathy_sound_manager_play (priv->sound_mgr, window, + EMPATHY_SOUND_CONVERSATION_NEW); g_free (msg); g_object_unref (window); @@ -793,6 +800,7 @@ event_manager_ft_got_contact_cb (TpConnection *connection, EventManagerApproval *approval = (EventManagerApproval *) user_data; GtkWidget *window = empathy_main_window_dup (); char *header; + EmpathyEventManagerPriv *priv = GET_PRIV (approval->manager); approval->contact = g_object_ref (contact); @@ -804,7 +812,8 @@ event_manager_ft_got_contact_cb (TpConnection *connection, approval, event_channel_process_func, NULL); /* FIXME better sound for incoming file transfers ?*/ - empathy_sound_play (window, EMPATHY_SOUND_CONVERSATION_NEW); + empathy_sound_manager_play (priv->sound_mgr, window, + EMPATHY_SOUND_CONVERSATION_NEW); g_free (header); g_object_unref (window); @@ -1048,7 +1057,8 @@ event_manager_presence_changed_cb (EmpathyContact *contact, TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) { /* someone is logging off */ - empathy_sound_play (window, EMPATHY_SOUND_CONTACT_DISCONNECTED); + empathy_sound_manager_play (priv->sound_mgr, window, + EMPATHY_SOUND_CONTACT_DISCONNECTED); if (g_settings_get_boolean (priv->gsettings_notif, EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT)) @@ -1068,7 +1078,8 @@ event_manager_presence_changed_cb (EmpathyContact *contact, TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) { /* someone is logging in */ - empathy_sound_play (window, EMPATHY_SOUND_CONTACT_CONNECTED); + empathy_sound_manager_play (priv->sound_mgr, window, + EMPATHY_SOUND_CONTACT_CONNECTED); if (g_settings_get_boolean (priv->gsettings_notif, EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN)) @@ -1131,7 +1142,7 @@ event_manager_finalize (GObject *object) EmpathyEventManagerPriv *priv = GET_PRIV (object); if (priv->ringing > 0) - empathy_sound_stop (EMPATHY_SOUND_PHONE_INCOMING); + empathy_sound_manager_stop (priv->sound_mgr, EMPATHY_SOUND_PHONE_INCOMING); g_slist_foreach (priv->events, (GFunc) event_free, NULL); g_slist_free (priv->events); @@ -1141,6 +1152,7 @@ event_manager_finalize (GObject *object) g_object_unref (priv->approver); g_object_unref (priv->gsettings_notif); g_object_unref (priv->gsettings_ui); + g_object_unref (priv->sound_mgr); } static void @@ -1196,6 +1208,8 @@ empathy_event_manager_init (EmpathyEventManager *manager) priv->gsettings_notif = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA); priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA); + priv->sound_mgr = empathy_sound_manager_dup_singleton (); + priv->contact_manager = empathy_contact_manager_dup_singleton (); g_signal_connect (priv->contact_manager, "pendings-changed", G_CALLBACK (event_manager_pendings_changed_cb), manager); diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 8b9661838..db5818c0c 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -107,6 +107,7 @@ struct _EmpathyMainWindowPriv { TpAccountManager *account_manager; EmpathyChatroomManager *chatroom_manager; EmpathyEventManager *event_manager; + EmpathySoundManager *sound_mgr;; guint flash_timeout_id; gboolean flash_on; gboolean empty; @@ -639,6 +640,8 @@ main_window_connection_changed_cb (TpAccount *account, GHashTable *details, EmpathyMainWindow *window) { + EmpathyMainWindowPriv *priv = GET_PRIV (window); + main_window_update_status (window); if (current == TP_CONNECTION_STATUS_DISCONNECTED && @@ -647,12 +650,12 @@ main_window_connection_changed_cb (TpAccount *account, } if (current == TP_CONNECTION_STATUS_DISCONNECTED) { - empathy_sound_play (GTK_WIDGET (window), + empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (window), EMPATHY_SOUND_ACCOUNT_DISCONNECTED); } if (current == TP_CONNECTION_STATUS_CONNECTED) { - empathy_sound_play (GTK_WIDGET (window), + empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (window), EMPATHY_SOUND_ACCOUNT_CONNECTED); /* Account connected without error, remove error message if any */ @@ -706,6 +709,7 @@ empathy_main_window_finalize (GObject *window) g_object_unref (priv->account_manager); g_object_unref (priv->individual_store); g_object_unref (priv->contact_manager); + g_object_unref (priv->sound_mgr); g_hash_table_destroy (priv->errors); /* disconnect all handlers of status-changed signal */ @@ -1576,6 +1580,8 @@ empathy_main_window_init (EmpathyMainWindow *window) priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA); priv->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA); + priv->sound_mgr = empathy_sound_manager_dup_singleton (); + gtk_window_set_title (GTK_WINDOW (window), _("Contact List")); gtk_window_set_role (GTK_WINDOW (window), "contact_list"); gtk_window_set_default_size (GTK_WINDOW (window), 225, 325); |