]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/gossip-private-chat.c
EmpathyContactList is now an interface implemented by
[empathy.git] / libempathy-gtk / gossip-private-chat.c
index 17c55b19cba98dbb0b08343f6c233e46cdcfcb60..84cc156e8d0370634cda9356db2d6e2200c2ee7f 100644 (file)
 #include "gossip-chat.h"
 #include "gossip-preferences.h"
 //#include "gossip-sound.h"
-#include "gossip-stock.h"
+#include "empathy-images.h"
 #include "gossip-ui-utils.h"
 
 #define DEBUG_DOMAIN "PrivateChat"
 
-#define COMPOSING_STOP_TIMEOUT 5
-
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_PRIVATE_CHAT, GossipPrivateChatPriv))
 
 struct _GossipPrivateChatPriv {   
        GossipContact *contact;
        gchar         *name;
 
-       guint          scroll_idle_id;
        gboolean       is_online;
 
        GtkWidget     *widget;
@@ -78,13 +75,8 @@ static void           private_chat_widget_destroy_cb            (GtkWidget
                                                                 GossipPrivateChat      *chat);
 static const gchar *  private_chat_get_name                     (GossipChat             *chat);
 static gchar *        private_chat_get_tooltip                  (GossipChat             *chat);
-static GdkPixbuf *    private_chat_get_status_pixbuf            (GossipChat             *chat);
-static GossipContact *private_chat_get_contact                  (GossipChat             *chat);
+static const gchar *  private_chat_get_status_icon_name         (GossipChat             *chat);
 static GtkWidget *    private_chat_get_widget                   (GossipChat             *chat);
-/*static GdkPixbuf *    private_chat_pad_to_size                  (GdkPixbuf              *pixbuf,
-                                                                gint                    width,
-                                                                gint                    height,
-                                                                gint                    extra_padding_right);*/
 
 G_DEFINE_TYPE (GossipPrivateChat, gossip_private_chat, GOSSIP_TYPE_CHAT);
 
@@ -96,14 +88,10 @@ gossip_private_chat_class_init (GossipPrivateChatClass *klass)
 
        object_class->finalize = private_chat_finalize;
 
-       chat_class->get_name          = private_chat_get_name;
-       chat_class->get_tooltip       = private_chat_get_tooltip;
-       chat_class->get_status_pixbuf = private_chat_get_status_pixbuf;
-       chat_class->get_contact       = private_chat_get_contact;
-       chat_class->get_widget        = private_chat_get_widget;
-       chat_class->get_show_contacts = NULL;
-       chat_class->set_show_contacts = NULL;
-       chat_class->is_group_chat     = NULL;
+       chat_class->get_name             = private_chat_get_name;
+       chat_class->get_tooltip          = private_chat_get_tooltip;
+       chat_class->get_status_icon_name = private_chat_get_status_icon_name;
+       chat_class->get_widget           = private_chat_get_widget;
 
        g_type_class_add_private (object_class, sizeof (GossipPrivateChatPriv));
 }
@@ -141,10 +129,6 @@ private_chat_finalize (GObject *object)
                g_object_unref (priv->contact);
        }
 
-       if (priv->scroll_idle_id) {
-               g_source_remove (priv->scroll_idle_id);
-       }
-
        g_free (priv->name);
 
        G_OBJECT_CLASS (gossip_private_chat_parent_class)->finalize (object);
@@ -268,38 +252,33 @@ static gchar *
 private_chat_get_tooltip (GossipChat *chat)
 {
        GossipPrivateChatPriv *priv;
-       GossipContact         *contact;
        const gchar           *status;
 
        g_return_val_if_fail (GOSSIP_IS_PRIVATE_CHAT (chat), NULL);
 
        priv = GET_PRIV (chat);
 
-       contact = gossip_chat_get_contact (chat);
-       status = gossip_contact_get_status (contact);
+       status = gossip_contact_get_status (priv->contact);
 
        return g_strdup_printf ("%s\n%s",
-                               gossip_contact_get_id (contact),
+                               gossip_contact_get_id (priv->contact),
                                status);
 }
 
-static GdkPixbuf *
-private_chat_get_status_pixbuf (GossipChat *chat)
+static const gchar *
+private_chat_get_status_icon_name (GossipChat *chat)
 {
        GossipPrivateChatPriv *priv;
-       GossipContact         *contact;
 
        g_return_val_if_fail (GOSSIP_IS_PRIVATE_CHAT (chat), NULL);
 
        priv = GET_PRIV (chat);
 
-       contact = gossip_chat_get_contact (chat);
-
-       return gossip_pixbuf_for_contact (contact);
+       return gossip_icon_name_for_contact (priv->contact);
 }
 
-static GossipContact *
-private_chat_get_contact (GossipChat *chat)
+GossipContact *
+gossip_private_chat_get_contact (GossipPrivateChat *chat)
 {
        GossipPrivateChatPriv *priv;
 
@@ -320,34 +299,12 @@ private_chat_get_widget (GossipChat *chat)
        return priv->widget;
 }
 
-/* Scroll down after the back-log has been received. */
-static gboolean
-private_chat_scroll_down_idle_func (GossipChat *chat)
-{
-       GossipPrivateChatPriv *priv;
-
-       priv = GET_PRIV (chat);
-
-       gossip_chat_scroll_down (chat);
-       g_object_unref (chat);
-
-       priv->scroll_idle_id = 0;
-
-       return FALSE;
-}
-
 static void
 private_chat_setup (GossipPrivateChat *chat,
                    GossipContact     *contact,
                    EmpathyTpChat     *tp_chat)
 {
        GossipPrivateChatPriv *priv;
-       //GossipLogManager      *log_manager;
-       GossipChatView        *view;
-/*     GossipContact         *sender;
-       GossipMessage         *message;
-       GList                 *messages, *l;
-       gint                   num_messages, i;*/
 
        priv = GET_PRIV (chat);
 
@@ -367,51 +324,6 @@ private_chat_setup (GossipPrivateChat *chat,
                          G_CALLBACK (private_chat_contact_presence_updated_cb),
                          chat);
 
-       view = GOSSIP_CHAT (chat)->view;
-
-       /* Turn off scrolling temporarily */
-       gossip_chat_view_scroll (view, FALSE);
-#if 0
-FIXME:
-       /* Add messages from last conversation */
-       log_manager = gossip_session_get_log_manager (gossip_app_get_session ());
-       messages = gossip_log_get_last_for_contact (log_manager, priv->contact);
-       num_messages  = g_list_length (messages);
-
-       for (l = messages, i = 0; l; l = l->next, i++) {
-               message = l->data;
-
-               if (num_messages - i > 10) {
-                       continue;
-               }
-
-               sender = gossip_message_get_sender (message);
-               if (gossip_contact_equal (priv->own_contact, sender)) {
-                       gossip_chat_view_append_message_from_self (view,
-                                                                  message,
-                                                                  priv->own_contact,
-                                                                  priv->own_avatar);
-               } else {
-                       gossip_chat_view_append_message_from_other (view,
-                                                                   message,
-                                                                   sender,
-                                                                   priv->other_avatar);
-               }
-       }
-
-       g_list_foreach (messages, (GFunc) g_object_unref, NULL);
-       g_list_free (messages);
-#endif
-       /* Turn back on scrolling */
-       gossip_chat_view_scroll (view, TRUE);
-
-       /* Scroll to the most recent messages, we reference the chat
-        * for the duration of the scroll func.
-        */
-       priv->scroll_idle_id = g_idle_add ((GSourceFunc) 
-                                          private_chat_scroll_down_idle_func, 
-                                          g_object_ref (chat));
-
        priv->is_online = gossip_contact_is_online (priv->contact);
 }