Binary files empathy/.bzr/checkout/dirstate and empathy.new/.bzr/checkout/dirstate differ diff -Nur -x '*.orig' -x '*~' empathy/libempathy/empathy-dispatch-operation.c empathy.new/libempathy/empathy-dispatch-operation.c --- empathy/libempathy/empathy-dispatch-operation.c 2010-03-05 00:48:01.558062000 -0500 +++ empathy.new/libempathy/empathy-dispatch-operation.c 2010-03-05 01:48:42.076821809 -0500 @@ -88,6 +88,7 @@ gboolean approved; gulong invalidated_handler; gulong ready_handler; + guint32 user_action_time; }; #define GET_PRIV(o) \ @@ -692,3 +693,28 @@ return priv->incoming; } + +guint32 +empathy_dispatch_operation_get_user_action_time (EmpathyDispatchOperation *self) +{ + EmpathyDispatchOperationPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_DISPATCH_OPERATION (self), 0); + + priv = GET_PRIV (self); + + return priv->user_action_time; +} + +void +empathy_dispatch_operation_set_user_action_time (EmpathyDispatchOperation *self, + guint32 user_action_time) +{ + EmpathyDispatchOperationPriv *priv; + + g_return_if_fail (EMPATHY_IS_DISPATCH_OPERATION (self)); + + priv = GET_PRIV (self); + + priv->user_action_time = user_action_time; +} diff -Nur -x '*.orig' -x '*~' empathy/libempathy/empathy-dispatch-operation.h empathy.new/libempathy/empathy-dispatch-operation.h --- empathy/libempathy/empathy-dispatch-operation.h 2010-03-05 00:48:01.558062000 -0500 +++ empathy.new/libempathy/empathy-dispatch-operation.h 2010-03-05 01:48:42.076821809 -0500 @@ -115,6 +115,13 @@ gboolean empathy_dispatch_operation_is_incoming ( EmpathyDispatchOperation *operation); +guint32 empathy_dispatch_operation_get_user_action_time ( + EmpathyDispatchOperation *operation); + +void empathy_dispatch_operation_set_user_action_time ( + EmpathyDispatchOperation *operation, + guint32 user_action_time); + G_END_DECLS #endif /* #ifndef __EMPATHY_DISPATCH_OPERATION_H__*/ diff -Nur -x '*.orig' -x '*~' empathy/libempathy-gtk/empathy-ui-utils.c empathy.new/libempathy-gtk/empathy-ui-utils.c --- empathy/libempathy-gtk/empathy-ui-utils.c 2010-03-05 01:48:41.505564989 -0500 +++ empathy.new/libempathy-gtk/empathy-ui-utils.c 2010-03-05 01:48:42.076821809 -0500 @@ -1480,7 +1480,10 @@ } timestamp = gtk_get_current_event_time (); - gtk_window_present_with_time (window, timestamp); + if (timestamp != 0) + gtk_window_present_with_time (window, timestamp); + else + gtk_window_present (window); gtk_window_set_skip_taskbar_hint (window, FALSE); gtk_window_deiconify (window); really_activate_window (window); diff -Nur -x '*.orig' -x '*~' empathy/src/empathy.c empathy.new/src/empathy.c --- empathy/src/empathy.c 2010-03-05 00:48:01.558062000 -0500 +++ empathy.new/src/empathy.c 2010-03-05 01:48:42.076821809 -0500 @@ -105,6 +105,7 @@ EmpathyTpChat *tp_chat; EmpathyChat *chat = NULL; const gchar *id; + guint32 action_time; tp_chat = EMPATHY_TP_CHAT (empathy_dispatch_operation_get_channel_wrapper (operation)); @@ -132,7 +133,21 @@ * (a GtkNotebook) when we'll call empathy_chat_window_present_chat */ } - empathy_chat_window_present_chat (chat); + action_time = empathy_dispatch_operation_get_user_action_time (operation); + if (action_time != 0 || !empathy_dispatch_operation_is_incoming (operation)) + { + /* channel has been approved by a user action. We can present the + * chat */ + g_print ("action time: present\n"); + empathy_chat_window_present_chat (chat); + } + else + { + EmpathyChatWindow *window; + /* no user action involved; we just add the chat to a window */ + g_print ("no action time: just create window\n"); + window = empathy_chat_window_ensure_window_for_chat (chat); + } empathy_dispatch_operation_claim (operation); } diff -Nur -x '*.orig' -x '*~' empathy/src/empathy-chat-window.c empathy.new/src/empathy-chat-window.c --- empathy/src/empathy-chat-window.c 2010-03-05 01:48:41.485565101 -0500 +++ empathy.new/src/empathy-chat-window.c 2010-03-05 02:00:08.145564970 -0500 @@ -2074,7 +2074,7 @@ * be added. */ EmpathyChatWindow * -empathy_chat_window_get_default (gboolean room) +empathy_chat_window_get_default (void) { GList *l; gboolean separate_windows = TRUE; @@ -2089,26 +2089,13 @@ } for (l = chat_windows; l; l = l->next) { - EmpathyChatWindowPriv *priv; EmpathyChatWindow *chat_window; GtkWidget *dialog; chat_window = l->data; - priv = GET_PRIV (chat_window); dialog = empathy_chat_window_get_dialog (chat_window); if (empathy_window_get_is_visible (GTK_WINDOW (dialog))) { - guint nb_rooms, nb_private; - empathy_chat_window_get_nb_chats (chat_window, &nb_rooms, &nb_private); - - /* Skip the window if there aren't any rooms in it */ - if (room && nb_rooms == 0) - continue; - - /* Skip the window if there aren't any 1-1 chats in it */ - if (!room && nb_private == 0) - continue; - /* Found a visible window on this desktop */ return chat_window; } @@ -2322,6 +2309,29 @@ return NULL; } +EmpathyChatWindow * +empathy_chat_window_ensure_window_for_chat (EmpathyChat *chat) +{ + EmpathyChatWindow *window; + g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); + + window = chat_window_find_chat (chat); + if (window != NULL) + return window; + + window = empathy_chat_window_get_default (); + if (window == NULL) { + EmpathyChatWindowPriv *priv; + + window = empathy_chat_window_new (); + priv = GET_PRIV (window); + gtk_widget_show (GTK_WIDGET (priv->dialog)); + } + + empathy_chat_window_add_chat (window, chat); + return window; +} + void empathy_chat_window_present_chat (EmpathyChat *chat) { @@ -2330,17 +2340,8 @@ g_return_if_fail (EMPATHY_IS_CHAT (chat)); - window = chat_window_find_chat (chat); - - /* If the chat has no window, create one */ - if (window == NULL) { - window = empathy_chat_window_get_default (empathy_chat_is_room (chat)); - if (!window) { - window = empathy_chat_window_new (); - } - - empathy_chat_window_add_chat (window, chat); - } + /* Create a window for the chat if needed */ + window = empathy_chat_window_ensure_window_for_chat (chat); priv = GET_PRIV (window); empathy_chat_window_switch_to_chat (window, chat); diff -Nur -x '*.orig' -x '*~' empathy/src/empathy-chat-window.h empathy.new/src/empathy-chat-window.h --- empathy/src/empathy-chat-window.h 2010-03-05 00:48:01.558062000 -0500 +++ empathy.new/src/empathy-chat-window.h 2010-03-05 02:01:06.035593943 -0500 @@ -56,27 +56,28 @@ GObjectClass parent_class; }; -GType empathy_chat_window_get_type (void); -EmpathyChatWindow *empathy_chat_window_get_default (gboolean room); -EmpathyChatWindow *empathy_chat_window_new (void); -GtkWidget * empathy_chat_window_get_dialog (EmpathyChatWindow *window); -void empathy_chat_window_add_chat (EmpathyChatWindow *window, - EmpathyChat *chat); -void empathy_chat_window_remove_chat (EmpathyChatWindow *window, - EmpathyChat *chat); -void empathy_chat_window_move_chat (EmpathyChatWindow *old_window, - EmpathyChatWindow *new_window, - EmpathyChat *chat); -void empathy_chat_window_switch_to_chat (EmpathyChatWindow *window, - EmpathyChat *chat); -gboolean empathy_chat_window_has_focus (EmpathyChatWindow *window); -EmpathyChat * empathy_chat_window_find_chat (TpAccount *account, - const gchar *id); -void empathy_chat_window_present_chat (EmpathyChat *chat); +GType empathy_chat_window_get_type (void); +EmpathyChatWindow *empathy_chat_window_get_default (void); +EmpathyChatWindow *empathy_chat_window_new (void); +EmpathyChatWindow *empathy_chat_window_ensure_window_for_chat (EmpathyChat *chat); +GtkWidget * empathy_chat_window_get_dialog (EmpathyChatWindow *window); +void empathy_chat_window_add_chat (EmpathyChatWindow *window, + EmpathyChat *chat); +void empathy_chat_window_remove_chat (EmpathyChatWindow *window, + EmpathyChat *chat); +void empathy_chat_window_move_chat (EmpathyChatWindow *old_window, + EmpathyChatWindow *new_window, + EmpathyChat *chat); +void empathy_chat_window_switch_to_chat (EmpathyChatWindow *window, + EmpathyChat *chat); +gboolean empathy_chat_window_has_focus (EmpathyChatWindow *window); +EmpathyChat * empathy_chat_window_find_chat (TpAccount *account, + const gchar *id); +void empathy_chat_window_present_chat (EmpathyChat *chat); -void empathy_chat_window_get_nb_chats (EmpathyChatWindow *window, - guint *nb_rooms, - guint *nb_private); +void empathy_chat_window_get_nb_chats (EmpathyChatWindow *window, + guint *nb_rooms, + guint *nb_private); G_END_DECLS diff -Nur -x '*.orig' -x '*~' empathy/src/empathy-event-manager.c empathy.new/src/empathy-event-manager.c --- empathy/src/empathy-event-manager.c 2010-03-05 01:48:41.505564989 -0500 +++ empathy.new/src/empathy-event-manager.c 2010-03-05 01:48:42.076821809 -0500 @@ -403,13 +403,18 @@ channel = empathy_tp_chat_get_channel (tp_chat); + // TODO: Edit this so that if session status is set to busy/away + // if (session->available) + empathy_dispatch_operation_approve (approval->operation); + + /* if (event != NULL) event_update (approval->manager, event, EMPATHY_IMAGE_NEW_MESSAGE, header, msg); else event_manager_add (approval->manager, sender, EMPATHY_EVENT_TYPE_CHAT, EMPATHY_IMAGE_NEW_MESSAGE, header, msg, approval, event_text_channel_process_func, NULL); - + */ empathy_sound_play (empathy_main_window_get (), EMPATHY_SOUND_CONVERSATION_NEW); } @@ -1022,6 +1027,14 @@ g_return_if_fail (event_public != NULL); + if (event->approval->operation != NULL) + { + /* Set the time of the event which activated the EmpathyEvent as user + * action time */ + empathy_dispatch_operation_set_user_action_time ( + event->approval->operation, gtk_get_current_event_time ()); + } + if (event->func) event->func (event); else