gchar *id;
gchar *name;
gchar *subject;
+ EmpathyContact *remote_contact;
EmpathyLogManager *log_manager;
MissionControl *mc;
PROP_ID,
PROP_NAME,
PROP_SUBJECT,
+ PROP_REMOTE_CONTACT,
};
static guint signals[LAST_SIGNAL] = { 0 };
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;
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;
}
}
+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)
{
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);
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);
"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",
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) {
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)
{
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 {
{
EmpathyChatWindow *window;
EmpathyChatWindowPriv *priv;
- EmpathyTpChat *tp_chat;
- EmpathyContact *remote_contact = NULL;
+ EmpathyContact *remote_contact;
const gchar *name;
const gchar *subject;
GtkWidget *widget;
/* 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)) {
}
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
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);
if (priv->chats == NULL) {
g_object_unref (window);
} else {
- chat_window_update_chat (chat);
+ chat_window_update_title (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);
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));
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));