aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-10-10 06:28:26 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-01 22:36:45 +0800
commit940f9b60e27fe79d64357c651525cbf50a936567 (patch)
tree92a7ad5aae1285f5b5a1562ddf3df464c1210b11 /libempathy-gtk
parente00d3a20de6603e927f4c977492052701cc0a988 (diff)
downloadgsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar.gz
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar.bz2
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar.lz
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar.xz
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.tar.zst
gsoc2013-empathy-940f9b60e27fe79d64357c651525cbf50a936567.zip
Fix topic not always shown, and add /topic command support.
https://bugzilla.gnome.org/show_bug.cgi?id=573407
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 3931115be..6c712a54e 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -394,6 +394,31 @@ chat_send (EmpathyChat *chat,
if (strcmp (msg, "/clear") == 0) {
empathy_chat_view_clear (chat->view);
return;
+ } else if (g_str_has_prefix (msg, "/topic")) {
+ EmpathyTpChatProperty *property;
+ GValue value = {0, };
+ gchar *topic;
+
+ property = empathy_tp_chat_get_property (priv->tp_chat, "subject");
+ if (property == NULL) {
+ empathy_chat_view_append_event (chat->view,
+ _("This conversation does not have topic"));
+ return;
+ }
+
+ if (!(property->flags & TP_PROPERTY_FLAG_WRITE)) {
+ empathy_chat_view_append_event (chat->view,
+ _("You need to be a channel operator to do that"));
+ return;
+ }
+
+ topic = g_strstrip (g_strdup (msg + strlen ("/topic")));
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, topic);
+ empathy_tp_chat_set_property (priv->tp_chat, "subject", &value);
+ g_value_unset (&value);
+
+ return;
}
message = empathy_message_new_from_entry (msg);
@@ -1449,9 +1474,6 @@ chat_create_ui (EmpathyChat *chat)
chat->input_text_view);
gtk_widget_show (chat->input_text_view);
- /* Create contact list */
- chat_update_contacts_visibility (chat);
-
/* Initialy hide the topic, will be shown if not empty */
gtk_widget_hide (priv->hbox_topic);
@@ -1588,7 +1610,6 @@ chat_constructed (GObject *object)
{
EmpathyChat *chat = EMPATHY_CHAT (object);
- chat_create_ui (chat);
chat_add_logs (chat);
show_pending_messages (chat);
}
@@ -1728,6 +1749,8 @@ empathy_chat_init (EmpathyChat *chat)
/* Add nick name completion */
priv->completion = g_completion_new ((GCompletionFunc) empathy_contact_get_name);
g_completion_set_compare (priv->completion, chat_contacts_completion_func);
+
+ chat_create_ui (chat);
}
EmpathyChat *
@@ -1752,6 +1775,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
{
EmpathyChatPriv *priv = GET_PRIV (chat);
TpConnection *connection;
+ GPtrArray *properties;
g_return_if_fail (EMPATHY_IS_CHAT (chat));
g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
@@ -1794,6 +1818,25 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
G_CALLBACK (chat_remote_contact_changed_cb),
chat);
+ /* Get initial value of properties */
+ properties = empathy_tp_chat_get_properties (priv->tp_chat);
+ if (properties != NULL) {
+ guint i;
+
+ for (i = 0; i < properties->len; i++) {
+ EmpathyTpChatProperty *property;
+
+ property = g_ptr_array_index (properties, i);
+ if (property->value == NULL)
+ continue;
+
+ chat_property_changed_cb (priv->tp_chat,
+ property->name,
+ property->value,
+ chat);
+ }
+ }
+
chat_remote_contact_changed_cb (chat);
if (chat->input_text_view) {