aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2007-05-19 05:50:47 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-05-19 05:50:47 +0800
commit20ce0c962a960e39216b06bdf2198dfd83319278 (patch)
tree7c68fd6c1fe32771ae80c60351247ff810c395e1 /libempathy-gtk
parent8af020a730b144f60c61a55be9e1542e588cf150 (diff)
downloadgsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar.gz
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar.bz2
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar.lz
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar.xz
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.tar.zst
gsoc2013-empathy-20ce0c962a960e39216b06bdf2198dfd83319278.zip
EmpathyContactList is now an interface implemented by
* libempathy-gtk/gossip-private-chat.h: * libempathy-gtk/gossip-contact-list.c: * libempathy-gtk/gossip-chat.c: * libempathy-gtk/gossip-chat.h: * libempathy-gtk/gossip-chat-window.c: * libempathy-gtk/Makefile.am: * libempathy-gtk/gossip-chat-view.c: * libempathy-gtk/gossip-private-chat.c: * src/empathy-chat-main.c: * libempathy/gossip-utils.c: * libempathy/gossip-contact.h: * libempathy/empathy-tp-chat.c: * libempathy/gossip-utils.h: * libempathy/empathy-contact-manager.c: * libempathy/empathy-contact-manager.h: * libempathy/empathy-tp-contact-list.c: * libempathy/empathy-tp-contact-list.h: * libempathy/empathy-tp-chatroom.c: * libempathy/empathy-tp-chatroom.h: * libempathy/empathy-contact-list.c: * libempathy/empathy-contact-list.h: * libempathy/Makefile.am: * libempathy/gossip-contact.c: EmpathyContactList is now an interface implemented by EmpathyTpContactList, EmpathyContactManager and EmpathyTpChatroom. GossipContactList use that interface to display a treeview. svn path=/trunk/; revision=72
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/gossip-chat-view.c10
-rw-r--r--libempathy-gtk/gossip-chat-window.c17
-rw-r--r--libempathy-gtk/gossip-chat.c122
-rw-r--r--libempathy-gtk/gossip-chat.h20
-rw-r--r--libempathy-gtk/gossip-contact-list.c41
-rw-r--r--libempathy-gtk/gossip-private-chat.c92
-rw-r--r--libempathy-gtk/gossip-private-chat.h9
8 files changed, 121 insertions, 192 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 057b80ef1..6bc6c65cd 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -22,9 +22,9 @@ libempathy_gtk_la_SOURCES = \
gossip-contact-list.c gossip-contact-list.h \
gossip-preferences.c gossip-preferences.h \
gossip-theme-manager.c gossip-theme-manager.h \
+ gossip-chat-window.c gossip-chat-window.h \
gossip-chat.c gossip-chat.h \
gossip-chat-view.c gossip-chat-view.h \
- gossip-chat-window.c gossip-chat-window.h \
gossip-private-chat.c gossip-private-chat.h \
gossip-geometry.c gossip-geometry.h \
gossip-status-presets.c gossip-status-presets.h \
diff --git a/libempathy-gtk/gossip-chat-view.c b/libempathy-gtk/gossip-chat-view.c
index 046a5507c..5f8c7d49d 100644
--- a/libempathy-gtk/gossip-chat-view.c
+++ b/libempathy-gtk/gossip-chat-view.c
@@ -1065,7 +1065,7 @@ chat_view_maybe_append_fancy_header (GossipChatView *view,
priv = GET_PRIV (view);
sender = gossip_message_get_sender (msg);
- my_contact = gossip_get_own_contact_from_contact (sender);
+ my_contact = gossip_contact_get_user (sender);
name = gossip_contact_get_name (sender);
from_self = gossip_contact_equal (sender, my_contact);
@@ -1189,7 +1189,7 @@ chat_view_append_irc_action (GossipChatView *view,
gossip_debug (DEBUG_DOMAIN, "Add IRC action");
sender = gossip_message_get_sender (msg);
- my_contact = gossip_get_own_contact_from_contact (sender);
+ my_contact = gossip_contact_get_user (sender);
name = gossip_contact_get_name (sender);
/* Skip the "/me ". */
@@ -1239,7 +1239,7 @@ chat_view_append_fancy_action (GossipChatView *view,
gossip_debug (DEBUG_DOMAIN, "Add fancy action");
sender = gossip_message_get_sender (msg);
- my_contact = gossip_get_own_contact_from_contact (sender);
+ my_contact = gossip_contact_get_user (sender);
name = gossip_contact_get_name (sender);
if (gossip_contact_equal (sender, my_contact)) {
@@ -1284,7 +1284,7 @@ chat_view_append_irc_message (GossipChatView *view,
body = gossip_message_get_body (msg);
sender = gossip_message_get_sender (msg);
- my_contact = gossip_get_own_contact_from_contact (sender);
+ my_contact = gossip_contact_get_user (sender);
name = gossip_contact_get_name (sender);
if (gossip_contact_equal (sender, my_contact)) {
@@ -1335,7 +1335,7 @@ chat_view_append_fancy_message (GossipChatView *view,
priv = GET_PRIV (view);
sender = gossip_message_get_sender (msg);
- my_contact = gossip_get_own_contact_from_contact (sender);
+ my_contact = gossip_contact_get_user (sender);
if (gossip_contact_equal (sender, my_contact)) {
tag = "fancy-body-self";
diff --git a/libempathy-gtk/gossip-chat-window.c b/libempathy-gtk/gossip-chat-window.c
index fb112379b..7dfc8e0c5 100644
--- a/libempathy-gtk/gossip-chat-window.c
+++ b/libempathy-gtk/gossip-chat-window.c
@@ -810,13 +810,16 @@ FIXME:
window);
#endif
} else {
+ GossipPrivateChat *chat;
GossipSubscription subscription;
GossipContact *contact;
+ chat = GOSSIP_PRIVATE_CHAT (priv->current_chat);
+
/* Show / Hide widgets */
gtk_widget_hide (priv->menu_room);
- contact = gossip_chat_get_contact (priv->current_chat);
+ contact = gossip_private_chat_get_contact (chat);
subscription = gossip_contact_get_subscription (contact);
if (!(subscription & GOSSIP_SUBSCRIPTION_FROM)) {
gtk_widget_show (priv->menu_conv_add_contact);
@@ -872,11 +875,11 @@ chat_window_add_contact_activate_cb (GtkWidget *menuitem,
GossipChatWindow *window)
{
GossipChatWindowPriv *priv;
- GossipContact *contact;
+ //GossipContact *contact;
priv = GET_PRIV (window);
- contact = gossip_chat_get_contact (priv->current_chat);
+ //contact = gossip_chat_get_contact (priv->current_chat);
// FIXME: gossip_add_contact_dialog_show (NULL, contact);
}
@@ -911,13 +914,13 @@ chat_window_info_activate_cb (GtkWidget *menuitem,
GossipChatWindow *window)
{
GossipChatWindowPriv *priv;
- GossipContact *contact;
+ //GossipContact *contact;
priv = GET_PRIV (window);
-
+/*FIXME:
contact = gossip_chat_get_contact (priv->current_chat);
-/*FIXME: gossip_contact_info_dialog_show (contact,
+ gossip_contact_info_dialog_show (contact,
GTK_WINDOW (priv->dialog));*/
}
@@ -1007,7 +1010,7 @@ chat_window_show_contacts_toggled_cb (GtkWidget *menuitem,
g_return_if_fail (priv->current_chat != NULL);
show = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (priv->menu_room_show_contacts));
- gossip_chat_set_show_contacts (priv->current_chat, show);
+ //gossip_group_chat_set_show_contacts (GOSSIP_GROUP_CHAT (priv->current_chat), show);
}
static void
diff --git a/libempathy-gtk/gossip-chat.c b/libempathy-gtk/gossip-chat.c
index 179f8f409..70d900d9f 100644
--- a/libempathy-gtk/gossip-chat.c
+++ b/libempathy-gtk/gossip-chat.c
@@ -73,6 +73,7 @@ struct _GossipChatPriv {
GSList *sent_messages;
gint sent_messages_index;
GList *compositors;
+ guint scroll_idle_id;
/* Used to automatically shrink a window that has temporarily
* grown due to long input.
*/
@@ -138,6 +139,7 @@ static void chat_state_changed_cb (EmpathyTpChat *tp_c
GossipContact *contact,
TelepathyChannelChatState state,
GossipChat *chat);
+static gboolean chat_scroll_down_idle_func (GossipChat *chat);
enum {
COMPOSING,
@@ -268,6 +270,51 @@ gossip_chat_init (GossipChat *chat)
"misspelled",
"underline", PANGO_UNDERLINE_ERROR,
NULL);
+
+
+
+ /* Turn off scrolling temporarily */
+ gossip_chat_view_scroll (chat->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 (chat->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) chat_scroll_down_idle_func,
+ g_object_ref (chat));
+
}
static void
@@ -295,6 +342,10 @@ chat_finalize (GObject *object)
g_object_unref (priv->tp_chat);
}
+ if (priv->scroll_idle_id) {
+ g_source_remove (priv->scroll_idle_id);
+ }
+
g_free (priv->id);
G_OBJECT_CLASS (gossip_chat_parent_class)->finalize (object);
@@ -343,9 +394,12 @@ chat_send (GossipChat *chat,
return;
}
+ /* FIXME: add here something to let group/privrate chat handle
+ * some special messages */
+
/* FIXME: gossip_app_set_not_away ();*/
- own_contact = gossip_chat_get_own_contact (chat);
+ own_contact = empathy_contact_manager_get_user (priv->manager, chat->account);
message = gossip_message_new (msg);
gossip_message_set_sender (message, own_contact);
@@ -544,7 +598,7 @@ chat_input_key_press_event_cb (GtkWidget *widget,
}
/* Catch enter but not ctrl/shift-enter */
- if (IS_ENTER (event->keyval) && !(event->state & GDK_SHIFT_MASK)) {
+ if (IS_ENTER (event->keyval) && !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))) {
GtkTextView *view;
/* This is to make sure that kinput2 gets the enter. And if
@@ -1067,6 +1121,22 @@ chat_state_changed_cb (EmpathyTpChat *tp_chat,
}
}
+/* Scroll down after the back-log has been received. */
+static gboolean
+chat_scroll_down_idle_func (GossipChat *chat)
+{
+ GossipChatPriv *priv;
+
+ priv = GET_PRIV (chat);
+
+ gossip_chat_scroll_down (chat);
+ g_object_unref (chat);
+
+ priv->scroll_idle_id = 0;
+
+ return FALSE;
+}
+
gboolean
gossip_chat_get_is_command (const gchar *str)
{
@@ -1144,29 +1214,6 @@ gossip_chat_get_status_icon_name (GossipChat *chat)
return NULL;
}
-GossipContact *
-gossip_chat_get_contact (GossipChat *chat)
-{
- g_return_val_if_fail (GOSSIP_IS_CHAT (chat), NULL);
-
- if (GOSSIP_CHAT_GET_CLASS (chat)->get_contact) {
- return GOSSIP_CHAT_GET_CLASS (chat)->get_contact (chat);
- }
-
- return NULL;
-}
-GossipContact *
-gossip_chat_get_own_contact (GossipChat *chat)
-{
- GossipChatPriv *priv;
-
- g_return_val_if_fail (GOSSIP_IS_CHAT (chat), NULL);
-
- priv = GET_PRIV (chat);
-
- return empathy_contact_manager_get_own (priv->manager, chat->account);
-}
-
GtkWidget *
gossip_chat_get_widget (GossipChat *chat)
{
@@ -1203,29 +1250,6 @@ gossip_chat_is_connected (GossipChat *chat)
return (priv->tp_chat != NULL);
}
-gboolean
-gossip_chat_get_show_contacts (GossipChat *chat)
-{
- g_return_val_if_fail (GOSSIP_IS_CHAT (chat), FALSE);
-
- if (GOSSIP_CHAT_GET_CLASS (chat)->get_show_contacts) {
- return GOSSIP_CHAT_GET_CLASS (chat)->get_show_contacts (chat);
- }
-
- return FALSE;
-}
-
-void
-gossip_chat_set_show_contacts (GossipChat *chat,
- gboolean show)
-{
- g_return_if_fail (GOSSIP_IS_CHAT (chat));
-
- if (GOSSIP_CHAT_GET_CLASS (chat)->set_show_contacts) {
- GOSSIP_CHAT_GET_CLASS (chat)->set_show_contacts (chat, show);
- }
-}
-
void
gossip_chat_save_geometry (GossipChat *chat,
gint x,
@@ -1461,7 +1485,7 @@ gossip_chat_should_highlight_nick (GossipMessage *message)
return FALSE;
}
- my_contact = gossip_get_own_contact_from_contact (gossip_message_get_sender (message));
+ my_contact = gossip_contact_get_user (gossip_message_get_sender (message));
to = gossip_contact_get_name (my_contact);
if (!to) {
return FALSE;
diff --git a/libempathy-gtk/gossip-chat.h b/libempathy-gtk/gossip-chat.h
index 8cbcee0b6..5fedfdd01 100644
--- a/libempathy-gtk/gossip-chat.h
+++ b/libempathy-gtk/gossip-chat.h
@@ -69,23 +69,8 @@ struct _GossipChatClass {
const gchar * (*get_name) (GossipChat *chat);
gchar * (*get_tooltip) (GossipChat *chat);
const gchar * (*get_status_icon_name)(GossipChat *chat);
- GossipContact * (*get_contact) (GossipChat *chat);
GtkWidget * (*get_widget) (GossipChat *chat);
-
- gboolean (*get_show_contacts) (GossipChat *chat);
- void (*set_show_contacts) (GossipChat *chat,
- gboolean show);
gboolean (*is_group_chat) (GossipChat *chat);
- void (*save_geometry) (GossipChat *chat,
- gint x,
- gint y,
- gint w,
- gint h);
- void (*load_geometry) (GossipChat *chat,
- gint *x,
- gint *y,
- gint *w,
- gint *h);
};
GType gossip_chat_get_type (void);
@@ -103,12 +88,7 @@ void gossip_chat_paste (GossipChat *chat);
const gchar * gossip_chat_get_name (GossipChat *chat);
gchar * gossip_chat_get_tooltip (GossipChat *chat);
const gchar * gossip_chat_get_status_icon_name (GossipChat *chat);
-GossipContact * gossip_chat_get_contact (GossipChat *chat);
-GossipContact * gossip_chat_get_own_contact (GossipChat *chat);
GtkWidget * gossip_chat_get_widget (GossipChat *chat);
-gboolean gossip_chat_get_show_contacts (GossipChat *chat);
-void gossip_chat_set_show_contacts (GossipChat *chat,
- gboolean show);
gboolean gossip_chat_is_group_chat (GossipChat *chat);
gboolean gossip_chat_is_connected (GossipChat *chat);
diff --git a/libempathy-gtk/gossip-contact-list.c b/libempathy-gtk/gossip-contact-list.c
index e268e419f..e4abccc80 100644
--- a/libempathy-gtk/gossip-contact-list.c
+++ b/libempathy-gtk/gossip-contact-list.c
@@ -32,6 +32,7 @@
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mission-control.h>
+#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/gossip-debug.h>
#include <libempathy/gossip-utils.h>
@@ -66,7 +67,7 @@
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CONTACT_LIST, GossipContactListPriv))
struct _GossipContactListPriv {
- EmpathyContactManager *manager;
+ EmpathyContactList *list;
GHashTable *groups;
@@ -125,7 +126,7 @@ static gboolean contact_list_row_separator_func (GtkTreeModel
gpointer data);
static void contact_list_contact_update (GossipContactList *list,
GossipContact *contact);
-static void contact_list_contact_added_cb (EmpathyContactManager *manager,
+static void contact_list_contact_added_cb (EmpathyContactList *list_iface,
GossipContact *contact,
GossipContactList *list);
static void contact_list_contact_updated_cb (GossipContact *contact,
@@ -134,7 +135,7 @@ static void contact_list_contact_updated_cb (GossipContact
static void contact_list_contact_groups_updated_cb (GossipContact *contact,
GParamSpec *param,
GossipContactList *list);
-static void contact_list_contact_removed_cb (EmpathyContactManager *manager,
+static void contact_list_contact_removed_cb (EmpathyContactList *list_iface,
GossipContact *contact,
GossipContactList *list);
static void contact_list_contact_set_active (GossipContactList *list,
@@ -456,14 +457,14 @@ gossip_contact_list_init (GossipContactList *list)
priv = GET_PRIV (list);
- priv->manager = empathy_contact_manager_new ();
+ priv->list = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
priv->is_compact = FALSE;
priv->show_active = TRUE;
priv->show_avatars = TRUE;
contact_list_create_model (list);
contact_list_setup_view (list);
- empathy_contact_manager_setup (priv->manager);
+ empathy_contact_list_setup (priv->list);
/* Get saved group states. */
gossip_contact_groups_get_all ();
@@ -488,11 +489,11 @@ gossip_contact_list_init (GossipContactList *list)
NULL, NULL);
/* Signal connection. */
- g_signal_connect (priv->manager,
+ g_signal_connect (priv->list,
"contact-added",
G_CALLBACK (contact_list_contact_added_cb),
list);
- g_signal_connect (priv->manager,
+ g_signal_connect (priv->list,
"contact-removed",
G_CALLBACK (contact_list_contact_removed_cb),
list);
@@ -516,13 +517,13 @@ gossip_contact_list_init (GossipContactList *list)
GINT_TO_POINTER (FALSE));
/* Add contacts already created */
- contacts = empathy_contact_manager_get_contacts (priv->manager);
+ contacts = empathy_contact_list_get_contacts (priv->list);
for (l = contacts; l; l = l->next) {
GossipContact *contact;
contact = l->data;
- contact_list_contact_added_cb (priv->manager, contact, list);
+ contact_list_contact_added_cb (priv->list, contact, list);
g_object_unref (contact);
}
@@ -536,9 +537,9 @@ contact_list_finalize (GObject *object)
priv = GET_PRIV (object);
- /* FIXME: disconnect all signals on the manager and contacts */
+ /* FIXME: disconnect all signals on the list and contacts */
- g_object_unref (priv->manager);
+ g_object_unref (priv->list);
g_object_unref (priv->ui);
g_object_unref (priv->store);
g_object_unref (priv->filter);
@@ -780,9 +781,9 @@ contact_list_contact_update (GossipContactList *list,
}
static void
-contact_list_contact_added_cb (EmpathyContactManager *manager,
- GossipContact *contact,
- GossipContactList *list)
+contact_list_contact_added_cb (EmpathyContactList *list_iface,
+ GossipContact *contact,
+ GossipContactList *list)
{
GossipContactListPriv *priv;
@@ -848,9 +849,9 @@ contact_list_contact_updated_cb (GossipContact *contact,
}
static void
-contact_list_contact_removed_cb (EmpathyContactManager *manager,
- GossipContact *contact,
- GossipContactList *list)
+contact_list_contact_removed_cb (EmpathyContactList *list_iface,
+ GossipContact *contact,
+ GossipContactList *list)
{
gossip_debug (DEBUG_DOMAIN, "Contact:'%s' removed",
gossip_contact_get_name (contact));
@@ -1569,7 +1570,7 @@ contact_list_drag_data_received (GtkWidget *widget,
id);
/* FIXME: This is ambigous, an id can come from multiple accounts */
- contact = empathy_contact_manager_find (priv->manager, id);
+ contact = empathy_contact_list_find (priv->list, id);
if (!contact) {
gossip_debug (DEBUG_DOMAIN, "No contact found associated with drag & drop");
return;
@@ -2365,7 +2366,7 @@ contact_list_filter_show_group (GossipContactList *list,
* group should be shown because a contact we want to
* show exists in it.
*/
- contacts = empathy_contact_manager_get_contacts (priv->manager);
+ contacts = empathy_contact_list_get_contacts (priv->list);
for (l = contacts; l && !show_group; l = l->next) {
if (!gossip_contact_is_in_group (l->data, group)) {
continue;
@@ -2702,7 +2703,7 @@ gossip_contact_list_set_show_offline (GossipContactList *list,
/* Disable temporarily. */
priv->show_active = FALSE;
- contacts = empathy_contact_manager_get_contacts (priv->manager);
+ contacts = empathy_contact_list_get_contacts (priv->list);
for (l = contacts; l; l = l->next) {
GossipContact *contact;
diff --git a/libempathy-gtk/gossip-private-chat.c b/libempathy-gtk/gossip-private-chat.c
index 0c27abf26..84cc156e8 100644
--- a/libempathy-gtk/gossip-private-chat.c
+++ b/libempathy-gtk/gossip-private-chat.c
@@ -55,7 +55,6 @@ struct _GossipPrivateChatPriv {
GossipContact *contact;
gchar *name;
- guint scroll_idle_id;
gboolean is_online;
GtkWidget *widget;
@@ -77,7 +76,6 @@ static void private_chat_widget_destroy_cb (GtkWidget
static const gchar * private_chat_get_name (GossipChat *chat);
static gchar * private_chat_get_tooltip (GossipChat *chat);
static const gchar * private_chat_get_status_icon_name (GossipChat *chat);
-static GossipContact *private_chat_get_contact (GossipChat *chat);
static GtkWidget * private_chat_get_widget (GossipChat *chat);
G_DEFINE_TYPE (GossipPrivateChat, gossip_private_chat, GOSSIP_TYPE_CHAT);
@@ -93,11 +91,7 @@ gossip_private_chat_class_init (GossipPrivateChatClass *klass)
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_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;
g_type_class_add_private (object_class, sizeof (GossipPrivateChatPriv));
}
@@ -135,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);
@@ -262,18 +252,16 @@ 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);
}
@@ -281,19 +269,16 @@ 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_icon_name_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;
@@ -314,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);
@@ -361,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);
}
diff --git a/libempathy-gtk/gossip-private-chat.h b/libempathy-gtk/gossip-private-chat.h
index e370231b1..c93b239e5 100644
--- a/libempathy-gtk/gossip-private-chat.h
+++ b/libempathy-gtk/gossip-private-chat.h
@@ -28,6 +28,8 @@
#ifndef __GOSSIP_PRIVATE_CHAT_H__
#define __GOSSIP_PRIVATE_CHAT_H__
+#include <libtelepathy/tp-chan.h>
+
#include <libempathy/gossip-contact.h>
#include <libempathy/gossip-message.h>
@@ -55,9 +57,10 @@ struct _GossipPrivateChatClass {
};
GType gossip_private_chat_get_type (void);
-GossipPrivateChat * gossip_private_chat_new (GossipContact *contact);
-GossipPrivateChat * gossip_private_chat_new_with_channel (GossipContact *contact,
- TpChan *tp_chan);
+GossipPrivateChat * gossip_private_chat_new (GossipContact *contact);
+GossipPrivateChat * gossip_private_chat_new_with_channel (GossipContact *contact,
+ TpChan *tp_chan);
+GossipContact * gossip_private_chat_get_contact (GossipPrivateChat *chat);
G_END_DECLS