diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-call-window.c | 8 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 80 | ||||
-rw-r--r-- | src/empathy-chat-window.ui | 7 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 83 | ||||
-rw-r--r-- | src/empathy-invite-participant-dialog.c | 2 | ||||
-rw-r--r-- | src/empathy-main-window.c | 73 |
6 files changed, 135 insertions, 118 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 598f483ab..40c461488 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -1257,7 +1257,7 @@ contact_avatar_changed_cb (EmpathyContact *contact, } static void -empathy_call_window_got_self_contact_cb (EmpathyTpContactFactory *factory, +empathy_call_window_got_self_contact_cb (TpConnection *connection, EmpathyContact *contact, const GError *error, gpointer user_data, GObject *weak_object) { @@ -1282,7 +1282,6 @@ empathy_call_window_setup_avatars (EmpathyCallWindow *self, if (priv->contact != NULL) { TpConnection *connection; - EmpathyTpContactFactory *factory; set_window_title (self); @@ -1294,12 +1293,9 @@ empathy_call_window_setup_avatars (EmpathyCallWindow *self, /* Retreiving the self avatar */ connection = empathy_contact_get_connection (priv->contact); - factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_handle (factory, + empathy_tp_contact_factory_get_from_handle (connection, tp_connection_get_self_handle (connection), empathy_call_window_got_self_contact_cb, self, NULL, G_OBJECT (self)); - - g_object_unref (factory); } else { diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index d47e942f5..73c5f9472 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -94,6 +94,7 @@ typedef struct { GtkUIManager *ui_manager; GtkAction *menu_conv_insert_smiley; GtkAction *menu_conv_favorite; + GtkAction *menu_conv_always_urgent; GtkAction *menu_conv_toggle_contacts; GtkAction *menu_edit_cut; @@ -785,6 +786,13 @@ chat_window_conv_activate_cb (GtkAction *action, DEBUG ("This room %s favorite", found ? "is" : "is not"); gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (priv->menu_conv_favorite), found); + + if (chatroom != NULL) + found = empathy_chatroom_is_always_urgent (chatroom); + + gtk_toggle_action_set_active ( + GTK_TOGGLE_ACTION (priv->menu_conv_always_urgent), + found); } gtk_action_set_visible (priv->menu_conv_favorite, is_room); @@ -828,19 +836,38 @@ chat_window_favorite_toggled_cb (GtkToggleAction *toggle_action, account = empathy_chat_get_account (priv->current_chat); room = empathy_chat_get_id (priv->current_chat); - chatroom = empathy_chatroom_manager_find (priv->chatroom_manager, - account, room); + chatroom = empathy_chatroom_manager_ensure_chatroom ( + priv->chatroom_manager, + account, + room, + empathy_chat_get_name (priv->current_chat)); - if (chatroom == NULL) { - const gchar *name; + empathy_chatroom_set_favorite (chatroom, active); + g_object_unref (chatroom); +} - name = empathy_chat_get_name (priv->current_chat); - chatroom = empathy_chatroom_new_full (account, room, name, FALSE); - empathy_chatroom_manager_add (priv->chatroom_manager, chatroom); - g_object_unref (chatroom); - } +static void +chat_window_always_urgent_toggled_cb (GtkToggleAction *toggle_action, + EmpathyChatWindow *window) +{ + EmpathyChatWindowPriv *priv = GET_PRIV (window); + gboolean active; + TpAccount *account; + const gchar *room; + EmpathyChatroom *chatroom; - empathy_chatroom_set_favorite (chatroom, active); + active = gtk_toggle_action_get_active (toggle_action); + account = empathy_chat_get_account (priv->current_chat); + room = empathy_chat_get_id (priv->current_chat); + + chatroom = empathy_chatroom_manager_ensure_chatroom ( + priv->chatroom_manager, + account, + room, + empathy_chat_get_name (priv->current_chat)); + + empathy_chatroom_set_always_urgent (chatroom, active); + g_object_unref (chatroom); } static void @@ -856,7 +883,7 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action, } static void -got_contact_cb (EmpathyTpContactFactory *factory, +got_contact_cb (TpConnection *connection, EmpathyContact *contact, const GError *error, gpointer user_data, @@ -900,7 +927,6 @@ chat_window_invite_participant_activate_cb (GtkAction *action, if (response == GTK_RESPONSE_ACCEPT) { TpConnection *connection; - EmpathyTpContactFactory *factory; const char *id; id = empathy_contact_selector_dialog_get_selected ( @@ -908,12 +934,8 @@ chat_window_invite_participant_activate_cb (GtkAction *action, if (EMP_STR_EMPTY (id)) goto out; connection = tp_channel_borrow_connection (channel); - factory = empathy_tp_contact_factory_dup_singleton (connection); - - empathy_tp_contact_factory_get_from_id (factory, id, + empathy_tp_contact_factory_get_from_id (connection, id, got_contact_cb, tp_chat, NULL, NULL); - - g_object_unref (factory); } out: @@ -1360,11 +1382,27 @@ chat_window_new_message_cb (EmpathyChat *chat, /* If empathy_chat_is_room () returns TRUE, that means it's a named MUC. * If empathy_chat_get_remote_contact () returns NULL, that means it's * an unamed MUC (msn-like). - * In case of a MUC, we set urgency only if the message contains our - * alias. */ + * In case of a MUC, we set urgency if either: + * a) the chatroom's always_urgent property is TRUE + * b) the message contains our alias + */ if (empathy_chat_is_room (chat) || empathy_chat_get_remote_contact (chat) == NULL) { - needs_urgency = empathy_message_should_highlight (message); + TpAccount *account; + const gchar *room; + EmpathyChatroom *chatroom; + + account = empathy_chat_get_account (chat); + room = empathy_chat_get_id (chat); + + chatroom = empathy_chatroom_manager_find (priv->chatroom_manager, + account, room); + + if (empathy_chatroom_is_always_urgent (chatroom)) { + needs_urgency = TRUE; + } else { + needs_urgency = empathy_message_should_highlight (message); + } } else { needs_urgency = TRUE; } @@ -1865,6 +1903,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "ui_manager", &priv->ui_manager, "menu_conv_insert_smiley", &priv->menu_conv_insert_smiley, "menu_conv_favorite", &priv->menu_conv_favorite, + "menu_conv_always_urgent", &priv->menu_conv_always_urgent, "menu_conv_toggle_contacts", &priv->menu_conv_toggle_contacts, "menu_edit_cut", &priv->menu_edit_cut, "menu_edit_copy", &priv->menu_edit_copy, @@ -1883,6 +1922,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "menu_conv", "activate", chat_window_conv_activate_cb, "menu_conv_clear", "activate", chat_window_clear_activate_cb, "menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb, + "menu_conv_always_urgent", "toggled", chat_window_always_urgent_toggled_cb, "menu_conv_toggle_contacts", "toggled", chat_window_contacts_toggled_cb, "menu_conv_invite_participant", "activate", chat_window_invite_participant_activate_cb, "menu_conv_close", "activate", chat_window_close_activate_cb, diff --git a/src/empathy-chat-window.ui b/src/empathy-chat-window.ui index 362286a09..a4285bc96 100644 --- a/src/empathy-chat-window.ui +++ b/src/empathy-chat-window.ui @@ -32,6 +32,12 @@ </object> </child> <child> + <object class="GtkToggleAction" id="menu_conv_always_urgent"> + <property name="name">menu_conv_always_urgent</property> + <property name="label" translatable="yes">Important Room</property> + </object> + </child> + <child> <object class="GtkToggleAction" id="menu_conv_toggle_contacts"> <property name="name">menu_conv_toggle_contacts</property> <property name="active">TRUE</property> @@ -166,6 +172,7 @@ <menuitem action="menu_conv_clear"/> <menuitem action="menu_conv_insert_smiley"/> <menuitem action="menu_conv_favorite"/> + <menuitem action="menu_conv_always_urgent"/> <menuitem action="menu_conv_toggle_contacts"/> <menuitem action="menu_conv_invite_participant"/> <separator/> diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index a7283594f..08f490966 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -624,7 +624,7 @@ event_room_channel_process_func (EventPriv *event) } static void -event_manager_muc_invite_got_contact_cb (EmpathyTpContactFactory *factory, +event_manager_muc_invite_got_contact_cb (TpConnection *connection, EmpathyContact *contact, const GError *error, gpointer user_data, @@ -665,7 +665,7 @@ event_manager_muc_invite_got_contact_cb (EmpathyTpContactFactory *factory, } static void -event_manager_ft_got_contact_cb (EmpathyTpContactFactory *factory, +event_manager_ft_got_contact_cb (TpConnection *connection, EmpathyContact *contact, const GError *error, gpointer user_data, @@ -730,20 +730,16 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher, channel, self_handle, &inviter, NULL, NULL)) { /* We are invited to a room */ - EmpathyTpContactFactory *factory; TpConnection *connection; DEBUG ("Have been invited to %s. Ask user if he wants to accept", tp_channel_get_identifier (channel)); connection = empathy_tp_chat_get_connection (tp_chat); - factory = empathy_tp_contact_factory_dup_singleton (connection); - - empathy_tp_contact_factory_get_from_handle (factory, + empathy_tp_contact_factory_get_from_handle (connection, inviter, event_manager_muc_invite_got_contact_cb, approval, NULL, G_OBJECT (manager)); - g_object_unref (factory); return; } @@ -781,17 +777,13 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher, TpChannel *channel; TpConnection *connection; TpHandle handle; - EmpathyTpContactFactory *factory; channel = empathy_dispatch_operation_get_channel (operation); handle = tp_channel_get_handle (channel, NULL); connection = tp_channel_borrow_connection (channel); - factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_handle (factory, handle, + empathy_tp_contact_factory_get_from_handle (connection, handle, event_manager_ft_got_contact_cb, approval, NULL, G_OBJECT (manager)); - - g_object_unref (factory); } else { @@ -851,8 +843,7 @@ event_manager_pendings_changed_cb (EmpathyContactList *list, } static void -event_manager_presence_changed_cb (EmpathyContactMonitor *monitor, - EmpathyContact *contact, +event_manager_presence_changed_cb (EmpathyContact *contact, TpConnectionPresenceType current, TpConnectionPresenceType previous, EmpathyEventManager *manager) @@ -872,33 +863,45 @@ event_manager_presence_changed_cb (EmpathyContactMonitor *monitor, TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) { /* contact was online */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT, &preference); - if (preference && tp_connection_presence_type_cmp_availability (current, + if (tp_connection_presence_type_cmp_availability (current, TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) { /* someone is logging off */ - header = g_strdup_printf (_("%s is now offline."), - empathy_contact_get_name (contact)); + empathy_sound_play (empathy_main_window_get (), + EMPATHY_SOUND_CONTACT_DISCONNECTED); - event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, - EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT, &preference); + if (preference) + { + header = g_strdup_printf (_("%s is now offline."), + empathy_contact_get_name (contact)); + + event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, + EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); + } } } else { /* contact was offline */ - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN, &preference); if (preference && tp_connection_presence_type_cmp_availability (current, TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) { /* someone is logging in */ - header = g_strdup_printf (_("%s is now online."), - empathy_contact_get_name (contact)); + empathy_sound_play (empathy_main_window_get (), + EMPATHY_SOUND_CONTACT_CONNECTED); + + empathy_conf_get_bool (empathy_conf_get (), + EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN, &preference); + if (preference) + { + header = g_strdup_printf (_("%s is now online."), + empathy_contact_get_name (contact)); - event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, - EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); + event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, + EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); + } } } g_free (header); @@ -907,6 +910,22 @@ out: g_object_unref (idle); } +static void +event_manager_members_changed_cb (EmpathyContactList *list, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, + EmpathyEventManager *manager) +{ + if (is_member) + g_signal_connect (contact, "presence-changed", + G_CALLBACK (event_manager_presence_changed_cb), manager); + else + g_signal_handlers_disconnect_by_func (contact, + event_manager_presence_changed_cb, manager); +} static GObject * event_manager_constructor (GType type, @@ -989,12 +1008,6 @@ empathy_event_manager_init (EmpathyEventManager *manager) { EmpathyEventManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, EMPATHY_TYPE_EVENT_MANAGER, EmpathyEventManagerPriv); - EmpathyContactMonitor *monitor; - EmpathyContactList *list_iface; - - list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ()); - monitor = empathy_contact_list_get_monitor (list_iface); - g_object_unref (list_iface); manager->priv = priv; @@ -1004,8 +1017,8 @@ empathy_event_manager_init (EmpathyEventManager *manager) G_CALLBACK (event_manager_approve_channel_cb), manager); g_signal_connect (priv->contact_manager, "pendings-changed", G_CALLBACK (event_manager_pendings_changed_cb), manager); - g_signal_connect (monitor, "contact-presence-changed", - G_CALLBACK (event_manager_presence_changed_cb), manager); + g_signal_connect (priv->contact_manager, "members-changed", + G_CALLBACK (event_manager_members_changed_cb), manager); } EmpathyEventManager * diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c index 77fb93738..da75e72cd 100644 --- a/src/empathy-invite-participant-dialog.c +++ b/src/empathy-invite-participant-dialog.c @@ -42,7 +42,7 @@ empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self) gtk_widget_show (label); parent->button_action = gtk_dialog_add_button (GTK_DIALOG (self), - "Invite", GTK_RESPONSE_ACCEPT); + _("Invite"), GTK_RESPONSE_ACCEPT); gtk_widget_set_sensitive (parent->button_action, FALSE); gtk_window_set_title (GTK_WINDOW (self), _("Invite Participant")); diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index b526a4c0b..ae1667622 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -124,7 +124,7 @@ typedef struct { GList *actions_connected; /* The idle event source to migrate butterfly's logs */ - guint butterfly_log_migration_contact_added_id; + guint butterfly_log_migration_members_changed_id; } EmpathyMainWindow; static EmpathyMainWindow *main_window = NULL; @@ -556,49 +556,6 @@ main_window_connection_changed_cb (TpAccount *account, } static void -main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor, - EmpathyContact *contact, - TpConnectionPresenceType current, - TpConnectionPresenceType previous, - EmpathyMainWindow *window) -{ - TpAccount *account; - gboolean should_play = FALSE; - EmpathyIdle *idle; - - account = empathy_contact_get_account (contact); - idle = empathy_idle_dup_singleton (); - - should_play = !empathy_idle_account_is_just_connected (idle, account); - - if (!should_play) - goto out; - - if (tp_connection_presence_type_cmp_availability (previous, - TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) - { - /* contact was online */ - if (tp_connection_presence_type_cmp_availability (current, - TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) - /* someone is logging off */ - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_CONTACT_DISCONNECTED); - } - else - { - /* contact was offline */ - if (tp_connection_presence_type_cmp_availability (current, - TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) - /* someone is logging in */ - empathy_sound_play (GTK_WIDGET (window->window), - EMPATHY_SOUND_CONTACT_CONNECTED); - } - -out: - g_object_unref (idle); -} - -static void main_window_accels_load (void) { gchar *filename; @@ -1302,14 +1259,21 @@ account_manager_prepared_cb (GObject *source_object, } static void -main_window_contact_added_cb (EmpathyContactMonitor *monitor, - EmpathyContact *contact, - EmpathyMainWindow *window) +main_window_members_changed_cb (EmpathyContactList *list, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, + EmpathyMainWindow *window) { + if (!is_member) + return; + if (!empathy_migrate_butterfly_logs (contact)) { - g_signal_handler_disconnect (monitor, - window->butterfly_log_migration_contact_added_id); - window->butterfly_log_migration_contact_added_id = 0; + g_signal_handler_disconnect (list, + window->butterfly_log_migration_members_changed_id); + window->butterfly_log_migration_members_changed_id = 0; } } @@ -1318,7 +1282,6 @@ empathy_main_window_show (void) { EmpathyMainWindow *window; EmpathyContactList *list_iface; - EmpathyContactMonitor *monitor; GtkBuilder *gui; EmpathyConf *conf; GtkWidget *sw; @@ -1451,15 +1414,13 @@ empathy_main_window_show (void) window->throbber_tool_item = GTK_WIDGET (item); list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ()); - 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); - window->butterfly_log_migration_contact_added_id = g_signal_connect (monitor, "contact-added", - G_CALLBACK (main_window_contact_added_cb), window); + window->butterfly_log_migration_members_changed_id = g_signal_connect ( + list_iface, "members-changed", + G_CALLBACK (main_window_members_changed_cb), window); g_object_unref (list_iface); gtk_widget_show (GTK_WIDGET (window->list_view)); |