diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2007-06-03 23:43:02 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-06-03 23:43:02 +0800 |
commit | 23230ae320a27d2c66bf8e338a2cc197eafd6b3c (patch) | |
tree | 363e05eb7df53e1381d97826e5cb21bdca4eff2f /libempathy-gtk | |
parent | 835cd9e9ed1327cf0bf98ae15c7a6761823c8f18 (diff) | |
download | gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar.gz gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar.bz2 gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar.lz gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar.xz gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.tar.zst gsoc2013-empathy-23230ae320a27d2c66bf8e338a2cc197eafd6b3c.zip |
Add all properties described by TP spec for the Text channel on
2007-06-03 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/gossip-group-chat.c:
* libempathy-gtk/gossip-private-chat.c:
* libempathy-gtk/gossip-chat.c:
* libempathy-gtk/gossip-chat.h:
* libempathy/empathy-tp-chat.c: Add all properties described by TP spec
for the Text channel on EmpathyTpChat. Make use of "name" and "subject"
properties in GossipGroupChat.
svn path=/trunk/; revision=118
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/gossip-chat.c | 18 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat.h | 13 | ||||
-rw-r--r-- | libempathy-gtk/gossip-group-chat.c | 166 | ||||
-rw-r--r-- | libempathy-gtk/gossip-private-chat.c | 1 |
4 files changed, 141 insertions, 57 deletions
diff --git a/libempathy-gtk/gossip-chat.c b/libempathy-gtk/gossip-chat.c index 37da0853c..5492edfbf 100644 --- a/libempathy-gtk/gossip-chat.c +++ b/libempathy-gtk/gossip-chat.c @@ -319,7 +319,6 @@ chat_destroy_cb (EmpathyTpChat *tp_chat, GossipChat *chat) { GossipChatPriv *priv; - GtkWidget *widget; priv = GET_PRIV (chat); @@ -327,12 +326,14 @@ chat_destroy_cb (EmpathyTpChat *tp_chat, g_object_unref (priv->tp_chat); priv->tp_chat = NULL; } + priv->sensitive = FALSE; gossip_chat_view_append_event (chat->view, _("Disconnected")); + gtk_widget_set_sensitive (chat->input_text_view, FALSE); - widget = gossip_chat_get_widget (chat); - gtk_widget_set_sensitive (widget, FALSE); - priv->sensitive = FALSE; + if (GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat) { + GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat (chat, NULL); + } } static void @@ -1284,7 +1285,6 @@ gossip_chat_set_tp_chat (GossipChat *chat, EmpathyTpChat *tp_chat) { GossipChatPriv *priv; - GtkWidget *widget; g_return_if_fail (GOSSIP_IS_CHAT (chat)); g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat)); @@ -1327,11 +1327,15 @@ gossip_chat_set_tp_chat (GossipChat *chat, empathy_tp_chat_request_pending (tp_chat); if (!priv->sensitive) { - widget = gossip_chat_get_widget (chat); - gtk_widget_set_sensitive (widget, TRUE); + gtk_widget_set_sensitive (chat->input_text_view, TRUE); gossip_chat_view_append_event (chat->view, _("Connected")); priv->sensitive = TRUE; } + + if (GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat) { + GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat (chat, tp_chat); + } + } const gchar * diff --git a/libempathy-gtk/gossip-chat.h b/libempathy-gtk/gossip-chat.h index 5fedfdd01..85bfc66b9 100644 --- a/libempathy-gtk/gossip-chat.h +++ b/libempathy-gtk/gossip-chat.h @@ -57,6 +57,7 @@ struct _GossipChat { /* Protected */ GossipChatView *view; + EmpathyTpChat *tp_chat; GtkWidget *input_text_view; gboolean is_first_char; McAccount *account; @@ -66,11 +67,13 @@ struct _GossipChatClass { GObjectClass parent; /* VTable */ - const gchar * (*get_name) (GossipChat *chat); - gchar * (*get_tooltip) (GossipChat *chat); - const gchar * (*get_status_icon_name)(GossipChat *chat); - GtkWidget * (*get_widget) (GossipChat *chat); - gboolean (*is_group_chat) (GossipChat *chat); + const gchar * (*get_name) (GossipChat *chat); + gchar * (*get_tooltip) (GossipChat *chat); + const gchar * (*get_status_icon_name)(GossipChat *chat); + GtkWidget * (*get_widget) (GossipChat *chat); + gboolean (*is_group_chat) (GossipChat *chat); + void (*set_tp_chat) (GossipChat *chat, + EmpathyTpChat *tp_chat); }; GType gossip_chat_get_type (void); diff --git a/libempathy-gtk/gossip-group-chat.c b/libempathy-gtk/gossip-group-chat.c index 8e8aa1967..9f3a0f79f 100644 --- a/libempathy-gtk/gossip-group-chat.c +++ b/libempathy-gtk/gossip-group-chat.c @@ -97,6 +97,14 @@ static gchar * group_chat_get_tooltip (GossipChat *cha static const gchar * group_chat_get_status_icon_name (GossipChat *chat); static GtkWidget * group_chat_get_widget (GossipChat *chat); static gboolean group_chat_is_group_chat (GossipChat *chat); +static void group_chat_set_tp_chat (GossipChat *chat, + EmpathyTpChat *tp_chat); +static void group_chat_subject_notify_cb (EmpathyTpChat *tp_chat, + GParamSpec *param, + GossipGroupChat *chat); +static void group_chat_name_notify_cb (EmpathyTpChat *tp_chat, + GParamSpec *param, + GossipGroupChat *chat); /*static gboolean group_chat_key_press_event (GtkWidget *widget, GdkEventKey *event, GossipGroupChat *chat);*/ @@ -122,6 +130,7 @@ gossip_group_chat_class_init (GossipGroupChatClass *klass) chat_class->get_status_icon_name = group_chat_get_status_icon_name; chat_class->get_widget = group_chat_get_widget; chat_class->is_group_chat = group_chat_is_group_chat; + chat_class->set_tp_chat = group_chat_set_tp_chat; g_type_class_add_private (object_class, sizeof (GossipGroupChatPriv)); } @@ -180,29 +189,6 @@ gossip_group_chat_new (McAccount *account, priv->tp_chat = empathy_tp_chatroom_new (account, tp_chan); gossip_chat_set_tp_chat (GOSSIP_CHAT (chat), EMPATHY_TP_CHAT (priv->tp_chat)); - /* FIXME: Ask the user before accepting */ - empathy_tp_chatroom_accept_invitation (priv->tp_chat); - - /* Create contact list */ - priv->store = gossip_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat)); - priv->view = gossip_contact_list_view_new (priv->store); - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts), - GTK_WIDGET (priv->view)); - gtk_widget_show (GTK_WIDGET (priv->view)); - - g_signal_connect (priv->tp_chat, "contact-added", - G_CALLBACK (group_chat_contact_added_cb), - chat); - g_signal_connect (priv->tp_chat, "contact-removed", - G_CALLBACK (group_chat_contact_removed_cb), - chat); -/* g_signal_connect (priv->tp_chat, "chatroom-topic-changed", - G_CALLBACK (group_chat_topic_changed_cb), - chat); - g_signal_connect (priv->tp_chat, "contact-info-changed", - G_CALLBACK (group_chat_contact_info_changed_cb), - chat);*/ - return chat; } @@ -395,29 +381,7 @@ group_chat_contact_removed_cb (EmpathyTpChatroom *tp_chat, gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str); g_free (str); } -/* -static void -group_chat_topic_changed_cb (EmpathyTpChatroom *tp_chat, - const gchar *new_topic, - GossipGroupChat *chat) -{ - GossipGroupChatPriv *priv; - gchar *str; - priv = GET_PRIV (chat); - - gossip_debug (DEBUG_DOMAIN, "Topic changed by to:'%s'", new_topic); - - g_free (priv->topic); - priv->topic = g_strdup (new_topic); - - gtk_label_set_text (GTK_LABEL (priv->label_topic), new_topic); - - str = g_strdup_printf (_("Topic set to: %s"), new_topic); - gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str); - g_free (str); -} -*/ static void group_chat_topic_entry_activate_cb (GtkWidget *entry, GtkDialog *dialog) @@ -460,6 +424,20 @@ group_chat_get_name (GossipChat *chat) group_chat = GOSSIP_GROUP_CHAT (chat); priv = GET_PRIV (group_chat); + if (!priv->name) { + const gchar *id; + const gchar *server; + + id = gossip_chat_get_id (chat); + server = strstr (id, "@"); + + if (server) { + priv->name = g_strndup (id, server - id); + } else { + priv->name = g_strdup (id); + } + } + return priv->name; } @@ -514,6 +492,104 @@ group_chat_is_group_chat (GossipChat *chat) return TRUE; } + +static void +group_chat_set_tp_chat (GossipChat *chat, + EmpathyTpChat *tp_chat) +{ + GossipGroupChat *group_chat; + GossipGroupChatPriv *priv; + + g_return_if_fail (GOSSIP_IS_GROUP_CHAT (chat)); + + group_chat = GOSSIP_GROUP_CHAT (chat); + priv = GET_PRIV (group_chat); + + /* Free all resources related to tp_chat */ + if (priv->tp_chat) { + g_object_unref (priv->tp_chat); + priv->tp_chat = NULL; + } + if (priv->view) { + gtk_widget_destroy (GTK_WIDGET (priv->view)); + g_object_unref (priv->store); + } + g_free (priv->name); + g_free (priv->topic); + priv->name = NULL; + priv->topic = NULL; + + if (!tp_chat) { + /* We are no more connected */ + gtk_widget_set_sensitive (priv->hbox_topic, FALSE); + gtk_widget_set_sensitive (priv->scrolled_window_contacts, FALSE); + return; + } + + /* We are connected */ + gtk_widget_set_sensitive (priv->hbox_topic, TRUE); + gtk_widget_set_sensitive (priv->scrolled_window_contacts, TRUE); + + priv->tp_chat = g_object_ref (tp_chat); + + /* FIXME: Ask the user before accepting */ + empathy_tp_chatroom_accept_invitation (priv->tp_chat); + + /* Create contact list */ + priv->store = gossip_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat)); + priv->view = gossip_contact_list_view_new (priv->store); + gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts), + GTK_WIDGET (priv->view)); + gtk_widget_show (GTK_WIDGET (priv->view)); + + /* Connect signals */ + g_signal_connect (priv->tp_chat, "contact-added", + G_CALLBACK (group_chat_contact_added_cb), + chat); + g_signal_connect (priv->tp_chat, "contact-removed", + G_CALLBACK (group_chat_contact_removed_cb), + chat); + g_signal_connect (priv->tp_chat, "notify::subject", + G_CALLBACK (group_chat_subject_notify_cb), + chat); + g_signal_connect (priv->tp_chat, "notify::name", + G_CALLBACK (group_chat_name_notify_cb), + chat); +} + +static void +group_chat_subject_notify_cb (EmpathyTpChat *tp_chat, + GParamSpec *param, + GossipGroupChat *chat) +{ + GossipGroupChatPriv *priv; + gchar *str; + + priv = GET_PRIV (chat); + + g_free (priv->topic); + + g_object_get (priv->tp_chat, "subject", &priv->topic, NULL); + gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic); + + str = g_strdup_printf (_("Topic set to: %s"), priv->topic); + gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str); + g_free (str); +} + +static void +group_chat_name_notify_cb (EmpathyTpChat *tp_chat, + GParamSpec *param, + GossipGroupChat *chat) +{ + GossipGroupChatPriv *priv; + + priv = GET_PRIV (chat); + + g_free (priv->name); + g_object_get (priv->tp_chat, "name", &priv->name, NULL); +} + #if 0 static gboolean group_chat_key_press_event (GtkWidget *widget, diff --git a/libempathy-gtk/gossip-private-chat.c b/libempathy-gtk/gossip-private-chat.c index f047f12e2..a7ef8fb03 100644 --- a/libempathy-gtk/gossip-private-chat.c +++ b/libempathy-gtk/gossip-private-chat.c @@ -92,6 +92,7 @@ gossip_private_chat_class_init (GossipPrivateChatClass *klass) chat_class->get_tooltip = private_chat_get_tooltip; chat_class->get_status_icon_name = private_chat_get_status_icon_name; chat_class->get_widget = private_chat_get_widget; + chat_class->set_tp_chat = NULL; g_type_class_add_private (object_class, sizeof (GossipPrivateChatPriv)); } |