]> git.0d.be Git - empathy.git/commitdiff
Make notifications for unfocused chat windows work properly.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:07:42 +0000 (17:07 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:07:42 +0000 (17:07 +0000)
svn path=/trunk/; revision=2287

src/empathy-chat-window.c
src/empathy-event-manager.c

index 2f9d5964118f5219df8d28ea7da64ab794621130..1bc9f2056b9d67ac55cd1514ed7da09144317161 100644 (file)
@@ -836,37 +836,30 @@ chat_window_set_urgency_hint (EmpathyChatWindow *window,
 }
 
 static gboolean
 }
 
 static gboolean
-notification_closed_idle_cb (EmpathyChatWindow *window)
+notification_closed_idle_cb (EmpathyChat *chat)
 {
 {
-       EmpathyChatWindowPriv *priv = GET_PRIV (window);
-
-       gtk_widget_grab_focus (priv->dialog);
+       empathy_chat_window_present_chat (chat);
 
        return FALSE;
 }
 
 static void
 chat_window_notification_closed_cb (NotifyNotification *notify,
 
        return FALSE;
 }
 
 static void
 chat_window_notification_closed_cb (NotifyNotification *notify,
-                                   EmpathyChatWindow *window)
+                                   EmpathyChat *chat)
 {
 {
-       EmpathyChatWindowPriv *priv = GET_PRIV (window);
        int reason;
 
        reason = notify_notification_get_closed_reason (notify);
 
        int reason;
 
        reason = notify_notification_get_closed_reason (notify);
 
-       if (priv->notification) {
-               g_object_unref (priv->notification);
-               priv->notification = NULL;
-       }
-
        if (reason == 2) {
        if (reason == 2) {
-               g_idle_add ((GSourceFunc) notification_closed_idle_cb, window);
+               empathy_chat_window_present_chat (chat);
        }
 }
 
 static void
        }
 }
 
 static void
-show_or_update_notification (EmpathyMessage *message,
-                            EmpathyChatWindow *window)
+chat_window_show_or_update_notification (EmpathyMessage *message,
+                                        EmpathyChatWindow *window,
+                                        EmpathyChat *chat)
 {
        EmpathyContact *sender;
        char *header;
 {
        EmpathyContact *sender;
        char *header;
@@ -894,12 +887,12 @@ show_or_update_notification (EmpathyMessage *message,
                                            header, body, NULL);
                notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
        } else {
                                            header, body, NULL);
                notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
        } else {
-               priv->notification = notify_notification_new (header, body, NULL, priv->dialog);
+               priv->notification = notify_notification_new (header, body, NULL, NULL);
                notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT);
                notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
 
                g_signal_connect (priv->notification, "closed",
                notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_DEFAULT);
                notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
 
                g_signal_connect (priv->notification, "closed",
-                                 G_CALLBACK (chat_window_notification_closed_cb), window);
+                                 G_CALLBACK (chat_window_notification_closed_cb), chat);
        }
 
        notify_notification_show (priv->notification, NULL);
        }
 
        notify_notification_show (priv->notification, NULL);
@@ -942,7 +935,7 @@ chat_window_new_message_cb (EmpathyChat       *chat,
        }
 
        if (!has_focus) {
        }
 
        if (!has_focus) {
-               show_or_update_notification (message, window);
+               chat_window_show_or_update_notification (message, window, chat);
        }
 
        if (has_focus && priv->current_chat == chat) {
        }
 
        if (has_focus && priv->current_chat == chat) {
index 2ff88f9486f184ba4613e0bb9c9259cd2039d92d..3d49127fe867ed5b60a6f51f2dc7ec29770ea0f2 100644 (file)
@@ -182,6 +182,23 @@ event_channel_process_func (EventPriv *event)
   empathy_dispatch_operation_approve (event->approval->operation);
 }
 
   empathy_dispatch_operation_approve (event->approval->operation);
 }
 
+static void
+event_text_channel_process_func (EventPriv *event)
+{
+  EmpathyTpChat *tp_chat;
+
+  if (event->approval->handler != 0)
+    {
+      tp_chat = EMPATHY_TP_CHAT
+        (empathy_dispatch_operation_get_channel_wrapper (event->approval->operation));
+  
+      g_signal_handler_disconnect (tp_chat, event->approval->handler);
+      event->approval->handler = 0;
+    }
+
+  empathy_dispatch_operation_approve (event->approval->operation);
+}
+
 static EventPriv *
 event_lookup_by_approval (EmpathyEventManager *manager,
   EventManagerApproval *approval)
 static EventPriv *
 event_lookup_by_approval (EmpathyEventManager *manager,
   EventManagerApproval *approval)
@@ -233,10 +250,10 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
    * queue. */
   event = event_lookup_by_approval (approval->manager, approval);
 
    * queue. */
   event = event_lookup_by_approval (approval->manager, approval);
 
-  if (event != NULL && event->inhibit)
+  if (event != NULL && event->inhibit && approval->handler != 0)
     {
     {
-      g_signal_handlers_disconnect_by_func (tp_chat,
-        event_manager_chat_message_received_cb, approval);
+      g_signal_handler_disconnect (tp_chat, approval->handler);
+      approval->handler = 0;
       return;
     }
 
       return;
     }
 
@@ -251,7 +268,7 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat,
     event_update (approval->manager, event, EMPATHY_IMAGE_NEW_MESSAGE, header, msg);
   else
     event_manager_add (approval->manager, sender, EMPATHY_IMAGE_NEW_MESSAGE, header,
     event_update (approval->manager, event, EMPATHY_IMAGE_NEW_MESSAGE, header, msg);
   else
     event_manager_add (approval->manager, sender, EMPATHY_IMAGE_NEW_MESSAGE, header,
-      msg, approval, event_channel_process_func, NULL);
+      msg, approval, event_text_channel_process_func, NULL);
 
   g_free (header);
 }
 
   g_free (header);
 }
@@ -461,7 +478,7 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
         EMPATHY_TP_CHAT (
           empathy_dispatch_operation_get_channel_wrapper (operation));
 
         EMPATHY_TP_CHAT (
           empathy_dispatch_operation_get_channel_wrapper (operation));
 
-      g_signal_connect (tp_chat, "message-received",
+      approval->handler = g_signal_connect (tp_chat, "message-received",
         G_CALLBACK (event_manager_chat_message_received_cb), approval);
 
     }
         G_CALLBACK (event_manager_chat_message_received_cb), approval);
 
     }