#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat)
typedef struct {
EmpathyTpChat *tp_chat;
- McAccount *account;
+ EmpathyAccount *account;
gchar *id;
gchar *name;
gchar *subject;
EmpathyContact *remote_contact;
+ gboolean show_contacts;
EmpathyLogManager *log_manager;
EmpathyAccountManager *account_manager;
PROP_NAME,
PROP_SUBJECT,
PROP_REMOTE_CONTACT,
+ PROP_SHOW_CONTACTS,
};
static guint signals[LAST_SIGNAL] = { 0 };
case PROP_REMOTE_CONTACT:
g_value_set_object (value, priv->remote_contact);
break;
+ case PROP_SHOW_CONTACTS:
+ g_value_set_boolean (value, priv->show_contacts);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
case PROP_TP_CHAT:
empathy_chat_set_tp_chat (chat, EMPATHY_TP_CHAT (g_value_get_object (value)));
break;
+ case PROP_SHOW_CONTACTS:
+ empathy_chat_set_show_contacts (chat, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
- McAccount *account;
+ EmpathyAccount *account;
account = empathy_account_manager_get_account (manager, connection);
if (!priv->tp_chat && empathy_account_equal (account, priv->account) &&
priv->handle_type != TP_HANDLE_TYPE_NONE &&
!EMP_STR_EMPTY (priv->id)) {
-
+
DEBUG ("Account reconnected, request a new Text channel");
switch (priv->handle_type) {
/* Save the sent message in our repeat buffer */
list = priv->sent_messages;
-
+
/* Remove any other occurances of this msg */
while ((item = g_slist_find_custom (list, str, (GCompareFunc) strcmp)) != NULL) {
list = g_slist_remove_link (list, item);
{
EmpathyChatPriv *priv;
gint max;
-
+
priv = GET_PRIV (chat);
if (!priv->sent_messages) {
if (priv->sent_messages_index < max) {
priv->sent_messages_index++;
}
-
+
DEBUG ("Returning next message index:%d", priv->sent_messages_index);
return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index);
g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL);
priv = GET_PRIV (chat);
-
+
if (!priv->sent_messages) {
DEBUG ("No sent messages, last message is NULL");
return NULL;
}
static void
-chat_set_show_contacts (EmpathyChat *chat, gboolean show)
+chat_update_contacts_visibility (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
+ gboolean show;
+
+ show = priv->remote_contact == NULL && priv->show_contacts;
if (!priv->scrolled_window_contacts) {
return;
}
- if (show) {
+ if (show && priv->contact_list_view == NULL) {
EmpathyContactListStore *store;
gint min_width;
gtk_widget_show (priv->contact_list_view);
gtk_widget_show (priv->scrolled_window_contacts);
g_object_unref (store);
- } else {
+ } else if (!show) {
priv->contacts_width = gtk_paned_get_position (GTK_PANED (priv->hpaned));
gtk_widget_hide (priv->scrolled_window_contacts);
- if (priv->contact_list_view) {
+ if (priv->contact_list_view != NULL) {
gtk_widget_destroy (priv->contact_list_view);
priv->contact_list_view = NULL;
}
}
}
+void
+empathy_chat_set_show_contacts (EmpathyChat *chat,
+ gboolean show)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ priv->show_contacts = show;
+
+ chat_update_contacts_visibility (chat);
+
+ g_object_notify (G_OBJECT (chat), "show-contacts");
+}
+
static void
chat_remote_contact_changed_cb (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
- if (priv->remote_contact) {
+ if (priv->remote_contact != NULL) {
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) {
+ if (priv->remote_contact != NULL) {
g_object_ref (priv->remote_contact);
priv->handle_type = TP_HANDLE_TYPE_CONTACT;
g_free (priv->id);
priv->id = g_strdup (empathy_contact_get_id (priv->remote_contact));
}
- else if (priv->tp_chat) {
+ else if (priv->tp_chat != NULL) {
TpChannel *channel;
channel = empathy_tp_chat_get_channel (priv->tp_chat);
priv->id = g_strdup (empathy_tp_chat_get_id (priv->tp_chat));
}
- chat_set_show_contacts (chat, priv->remote_contact == NULL);
+ chat_update_contacts_visibility (chat);
g_object_notify (G_OBJECT (chat), "remote-contact");
g_object_notify (G_OBJECT (chat), "id");
empathy_chat_view_append_event (chat->view, _("Disconnected"));
gtk_widget_set_sensitive (chat->input_text_view, FALSE);
- chat_set_show_contacts (chat, FALSE);
+ empathy_chat_set_show_contacts (chat, FALSE);
}
static void
gtk_widget_show (chat->input_text_view);
/* Create contact list */
- chat_set_show_contacts (chat, priv->remote_contact == NULL);
+ chat_update_contacts_visibility (chat);
/* Initialy hide the topic, will be shown if not empty */
gtk_widget_hide (priv->hbox_topic);
"The tp chat object",
EMPATHY_TYPE_TP_CHAT,
G_PARAM_CONSTRUCT |
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_ACCOUNT,
g_param_spec_object ("account",
"Account of the chat",
"The account of the chat",
- MC_TYPE_ACCOUNT,
- G_PARAM_READABLE));
+ EMPATHY_TYPE_ACCOUNT,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_string ("id",
"Chat's id",
"The id of the chat",
NULL,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
"Chat's name",
"The name of the chat",
NULL,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_SUBJECT,
g_param_spec_string ("subject",
"Chat's subject",
"The subject or topic of the chat",
NULL,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
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));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_SHOW_CONTACTS,
+ g_param_spec_boolean ("show-contacts",
+ "Contacts' visibility",
+ "The visibility of the contacts' list",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
signals[COMPOSING] =
g_signal_new ("composing",
G_CALLBACK (chat_new_connection_cb),
chat);
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
+ &priv->show_contacts);
+
/* Block events for some time to avoid having "has come online" or
* "joined" messages. */
priv->block_events_timeout_id =
show_pending_messages (chat);
}
-McAccount *
+EmpathyAccount *
empathy_chat_get_account (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);