aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-14 21:01:24 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-14 21:01:24 +0800
commit150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3 (patch)
tree9989ee7c38720b16bc050eacc70584ae07adcc68
parent68703c3fc1665588318d717539c8cf965e67b57c (diff)
downloadgsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar.gz
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar.bz2
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar.lz
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar.xz
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.tar.zst
gsoc2013-empathy-150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3.zip
Various fixes for chats
svn path=/trunk/; revision=938
-rw-r--r--libempathy-gtk/empathy-chat.c59
-rw-r--r--libempathy-gtk/empathy-chat.h1
-rw-r--r--libempathy/empathy-tp-chat.c7
-rw-r--r--src/empathy-chat-window.c98
4 files changed, 81 insertions, 84 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index fce7856c4..3dbda9aea 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -66,6 +66,7 @@ struct _EmpathyChatPriv {
gchar *id;
gchar *name;
gchar *subject;
+ EmpathyContact *remote_contact;
EmpathyLogManager *log_manager;
MissionControl *mc;
@@ -116,6 +117,7 @@ enum {
PROP_ID,
PROP_NAME,
PROP_SUBJECT,
+ PROP_REMOTE_CONTACT,
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -146,6 +148,9 @@ chat_get_property (GObject *object,
case PROP_SUBJECT:
g_value_set_string (value, priv->subject);
break;
+ case PROP_REMOTE_CONTACT:
+ g_value_set_object (value, priv->remote_contact);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -587,7 +592,12 @@ chat_property_changed_cb (EmpathyTpChat *tp_chat,
priv->subject = g_value_dup_string (value);
g_object_notify (G_OBJECT (chat), "subject");
- gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->subject);
+ if (G_STR_EMPTY (priv->subject)) {
+ gtk_widget_hide (priv->hbox_topic);
+ } else {
+ gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->subject);
+ gtk_widget_show (priv->hbox_topic);
+ }
if (priv->block_events_timeout_id == 0) {
gchar *str;
@@ -1246,6 +1256,24 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat,
}
static void
+chat_remote_contact_changed_cb (EmpathyChat *chat)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ if (priv->remote_contact) {
+ g_object_unref (priv->remote_contact);
+ priv->remote_contact = NULL;
+ }
+
+ priv->remote_contact = empathy_tp_chat_get_remote_contact (priv->tp_chat);
+ if (priv->remote_contact) {
+ g_object_ref (priv->remote_contact);
+ }
+
+ g_object_notify (G_OBJECT (chat), "remote-contact");
+}
+
+static void
chat_create_ui (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
@@ -1325,6 +1353,9 @@ chat_create_ui (EmpathyChat *chat)
GTK_WIDGET (priv->view));
gtk_widget_show (GTK_WIDGET (priv->view));
+ /* Initialy hide the topic, will be shown if not empty */
+ gtk_widget_hide (priv->hbox_topic);
+
/* Set widget focus order */
list = g_list_append (NULL, priv->scrolled_window_input);
gtk_container_set_focus_chain (GTK_CONTAINER (priv->vbox_left), list);
@@ -1414,10 +1445,12 @@ chat_finalize (GObject *object)
if (priv->tp_chat) {
g_object_unref (priv->tp_chat);
}
-
if (priv->account) {
g_object_unref (priv->account);
}
+ if (priv->remote_contact) {
+ g_object_unref (priv->remote_contact);
+ }
if (priv->block_events_timeout_id) {
g_source_remove (priv->block_events_timeout_id);
@@ -1489,6 +1522,13 @@ empathy_chat_class_init (EmpathyChatClass *klass)
"The subject or topic of the chat",
NULL,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_REMOTE_CONTACT,
+ g_param_spec_object ("remote-contact",
+ "The remote contact",
+ "The remote contact is any",
+ EMPATHY_TYPE_CONTACT,
+ G_PARAM_READABLE));
signals[COMPOSING] =
g_signal_new ("composing",
@@ -1609,10 +1649,15 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
g_signal_connect (tp_chat, "members-changed",
G_CALLBACK (chat_members_changed_cb),
chat);
+ g_signal_connect_swapped (tp_chat, "notify::remote-contact",
+ G_CALLBACK (chat_remote_contact_changed_cb),
+ chat);
g_signal_connect (tp_chat, "destroy",
G_CALLBACK (chat_destroy_cb),
chat);
+ chat_remote_contact_changed_cb (chat);
+
if (chat->input_text_view) {
gtk_widget_set_sensitive (chat->input_text_view, TRUE);
if (priv->block_events_timeout_id == 0) {
@@ -1665,6 +1710,16 @@ empathy_chat_get_subject (EmpathyChat *chat)
return priv->subject;
}
+EmpathyContact *
+empathy_chat_get_remote_contact (EmpathyChat *chat)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL);
+
+ return priv->remote_contact;
+}
+
void
empathy_chat_clear (EmpathyChat *chat)
{
diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h
index 8a700762b..e40b5c8c8 100644
--- a/libempathy-gtk/empathy-chat.h
+++ b/libempathy-gtk/empathy-chat.h
@@ -70,6 +70,7 @@ McAccount * empathy_chat_get_account (EmpathyChat *chat);
const gchar * empathy_chat_get_id (EmpathyChat *chat);
const gchar * empathy_chat_get_name (EmpathyChat *chat);
const gchar * empathy_chat_get_subject (EmpathyChat *chat);
+EmpathyContact * empathy_chat_get_remote_contact (EmpathyChat *chat);
void empathy_chat_clear (EmpathyChat *chat);
void empathy_chat_scroll_down (EmpathyChat *chat);
void empathy_chat_cut (EmpathyChat *chat);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 8265339ac..43c760579 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -752,9 +752,6 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
priv->id = *names;
g_free (names);
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (chat), "ready");
-
if (tp_proxy_has_interface_by_id (priv->channel,
TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) {
priv->group = empathy_tp_group_new (priv->channel);
@@ -768,6 +765,7 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
g_signal_connect (priv->group, "local-pending",
G_CALLBACK (tp_chat_local_pending_cb),
chat);
+ empathy_run_until_ready (priv->group);
} else {
priv->remote_contact = empathy_contact_factory_get_from_handle (priv->factory,
priv->account,
@@ -817,6 +815,9 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat)
tp_chat_state_changed_cb,
NULL, NULL,
G_OBJECT (chat), NULL);
+
+ priv->ready = TRUE;
+ g_object_notify (G_OBJECT (chat), "ready");
}
static void
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 7b0c27db9..9df7a8211 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -293,16 +293,12 @@ chat_window_update_menu (EmpathyChatWindow *window)
static const gchar *
chat_window_get_chat_name (EmpathyChat *chat)
{
- EmpathyTpChat *tp_chat;
EmpathyContact *remote_contact = NULL;
const gchar *name = NULL;
name = empathy_chat_get_name (chat);
if (!name) {
- tp_chat = empathy_chat_get_tp_chat (chat);
- if (tp_chat) {
- remote_contact = empathy_tp_chat_get_remote_contact (tp_chat);
- }
+ remote_contact = empathy_chat_get_remote_contact (chat);
if (remote_contact) {
name = empathy_contact_get_name (remote_contact);
} else {
@@ -344,8 +340,7 @@ chat_window_update_chat (EmpathyChat *chat)
{
EmpathyChatWindow *window;
EmpathyChatWindowPriv *priv;
- EmpathyTpChat *tp_chat;
- EmpathyContact *remote_contact = NULL;
+ EmpathyContact *remote_contact;
const gchar *name;
const gchar *subject;
GtkWidget *widget;
@@ -362,10 +357,10 @@ chat_window_update_chat (EmpathyChat *chat)
/* Get information */
name = chat_window_get_chat_name (chat);
subject = empathy_chat_get_subject (chat);
- tp_chat = empathy_chat_get_tp_chat (chat);
- if (tp_chat) {
- remote_contact = empathy_tp_chat_get_remote_contact (tp_chat);
- }
+ remote_contact = empathy_chat_get_remote_contact (chat);
+
+ empathy_debug (DEBUG_DOMAIN, "Updating chat window, name=%s, subject=%s, "
+ "remote_contact=%p", name, subject, remote_contact);
/* Update tab image */
if (g_list_find (priv->chats_new_msg, chat)) {
@@ -414,17 +409,13 @@ chat_window_update_chat (EmpathyChat *chat)
}
static void
-chat_window_remote_contact_notify_cb (EmpathyChat *chat)
+chat_window_chat_notify_cb (EmpathyChat *chat)
{
- EmpathyTpChat *tp_chat;
EmpathyContact *old_remote_contact;
EmpathyContact *remote_contact = NULL;
old_remote_contact = g_object_get_data (G_OBJECT (chat), "chat-window-remote-contact");
- tp_chat = empathy_chat_get_tp_chat (chat);
- if (tp_chat) {
- remote_contact = empathy_tp_chat_get_remote_contact (tp_chat);
- }
+ remote_contact = empathy_chat_get_remote_contact (chat);
if (old_remote_contact != remote_contact) {
/* The remote-contact associated with the chat changed, we need
@@ -443,65 +434,6 @@ chat_window_remote_contact_notify_cb (EmpathyChat *chat)
g_object_set_data (G_OBJECT (chat), "chat-window-remote-contact",
remote_contact);
-
- chat_window_update_chat (chat);
- }
-}
-
-static void
-chat_window_weak_ref_cb (gpointer data,
- GObject *chat)
-{
- EmpathyTpChat *tp_chat;
- EmpathyContact *remote_contact;
-
- tp_chat = g_object_get_data (chat, "chat-window-tp-chat");
- if (tp_chat) {
- g_signal_handlers_disconnect_by_func (tp_chat,
- chat_window_remote_contact_notify_cb,
- chat);
- }
-
- remote_contact = g_object_get_data (chat, "chat-window-remote-contact");
- if (remote_contact) {
- g_signal_handlers_disconnect_by_func (remote_contact,
- chat_window_update_chat,
- chat);
- }
-}
-
-static void
-chat_window_chat_notify_cb (EmpathyChat *chat)
-{
- EmpathyTpChat *tp_chat;
- EmpathyTpChat *old_tp_chat;
-
- old_tp_chat = g_object_get_data (G_OBJECT (chat), "chat-window-tp-chat");
- tp_chat = empathy_chat_get_tp_chat (chat);
-
- if (old_tp_chat != tp_chat) {
- /* The TpChat associated with the chat has changed, we need to
- * keep track of it's remote-contact if there is one. */
- if (tp_chat) {
- g_signal_connect_swapped (tp_chat, "notify::remote-contact",
- G_CALLBACK (chat_window_remote_contact_notify_cb),
- chat);
- g_object_weak_ref (G_OBJECT (chat),
- chat_window_weak_ref_cb,
- NULL);
- }
- if (old_tp_chat) {
- g_signal_handlers_disconnect_by_func (old_tp_chat,
- chat_window_remote_contact_notify_cb,
- chat);
- }
- g_object_set_data (G_OBJECT (chat), "chat-window-tp-chat", tp_chat);
-
- /* This will call chat_window_update_chat() if the remote-contact
- * changed, so we don't have to call it again. That's why we
- * return here. */
- chat_window_remote_contact_notify_cb (chat);
- return;
}
chat_window_update_chat (chat);
@@ -1000,7 +932,7 @@ chat_window_page_removed_cb (GtkNotebook *notebook,
if (priv->chats == NULL) {
g_object_unref (window);
} else {
- chat_window_update_chat (chat);
+ chat_window_update_title (window);
}
}
@@ -1410,7 +1342,7 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
g_signal_connect (chat, "notify::subject",
G_CALLBACK (chat_window_chat_notify_cb),
NULL);
- g_signal_connect (chat, "notify::tp-chat",
+ g_signal_connect (chat, "notify::remote-contact",
G_CALLBACK (chat_window_chat_notify_cb),
NULL);
chat_window_chat_notify_cb (chat);
@@ -1431,7 +1363,8 @@ empathy_chat_window_remove_chat (EmpathyChatWindow *window,
EmpathyChat *chat)
{
EmpathyChatWindowPriv *priv;
- gint position;
+ gint position;
+ EmpathyContact *remote_contact;
g_return_if_fail (window != NULL);
g_return_if_fail (EMPATHY_IS_CHAT (chat));
@@ -1441,6 +1374,13 @@ empathy_chat_window_remove_chat (EmpathyChatWindow *window,
g_signal_handlers_disconnect_by_func (chat,
chat_window_chat_notify_cb,
NULL);
+ remote_contact = g_object_get_data (G_OBJECT (chat),
+ "chat-window-remote-contact");
+ if (remote_contact) {
+ g_signal_handlers_disconnect_by_func (remote_contact,
+ chat_window_update_chat,
+ chat);
+ }
position = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
GTK_WIDGET (chat));