diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-14 21:01:24 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-14 21:01:24 +0800 |
commit | 150dc07ffeaefc877a3f8c48ba861a93fcb9e6f3 (patch) | |
tree | 9989ee7c38720b16bc050eacc70584ae07adcc68 /libempathy-gtk | |
parent | 68703c3fc1665588318d717539c8cf965e67b57c (diff) | |
download | gsoc2013-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
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 59 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.h | 1 |
2 files changed, 58 insertions, 2 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); |