empathy r938 - in trunk: libempathy libempathy-gtk src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r938 - in trunk: libempathy libempathy-gtk src
- Date: Mon, 14 Apr 2008 14:01:25 +0100 (BST)
Author: xclaesse
Date: Mon Apr 14 14:01:24 2008
New Revision: 938
URL: http://svn.gnome.org/viewvc/empathy?rev=938&view=rev
Log:
Various fixes for chats
Modified:
trunk/libempathy-gtk/empathy-chat.c
trunk/libempathy-gtk/empathy-chat.h
trunk/libempathy/empathy-tp-chat.c
trunk/src/empathy-chat-window.c
Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c (original)
+++ trunk/libempathy-gtk/empathy-chat.c Mon Apr 14 14:01:24 2008
@@ -66,6 +66,7 @@
gchar *id;
gchar *name;
gchar *subject;
+ EmpathyContact *remote_contact;
EmpathyLogManager *log_manager;
MissionControl *mc;
@@ -116,6 +117,7 @@
PROP_ID,
PROP_NAME,
PROP_SUBJECT,
+ PROP_REMOTE_CONTACT,
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -146,6 +148,9 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
"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 @@
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 @@
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)
{
Modified: trunk/libempathy-gtk/empathy-chat.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.h (original)
+++ trunk/libempathy-gtk/empathy-chat.h Mon Apr 14 14:01:24 2008
@@ -70,6 +70,7 @@
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);
Modified: trunk/libempathy/empathy-tp-chat.c
==============================================================================
--- trunk/libempathy/empathy-tp-chat.c (original)
+++ trunk/libempathy/empathy-tp-chat.c Mon Apr 14 14:01:24 2008
@@ -752,9 +752,6 @@
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 @@
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_state_changed_cb,
NULL, NULL,
G_OBJECT (chat), NULL);
+
+ priv->ready = TRUE;
+ g_object_notify (G_OBJECT (chat), "ready");
}
static void
Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c (original)
+++ trunk/src/empathy-chat-window.c Mon Apr 14 14:01:24 2008
@@ -293,16 +293,12 @@
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 @@
{
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 @@
/* 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 @@
}
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 @@
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 @@
if (priv->chats == NULL) {
g_object_unref (window);
} else {
- chat_window_update_chat (chat);
+ chat_window_update_title (window);
}
}
@@ -1410,7 +1342,7 @@
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 @@
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 @@
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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]