diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-02 17:41:31 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-02 17:41:31 +0800 |
commit | 226ca7f42019148efc47bec6b913fef3a9f764da (patch) | |
tree | 140cc8e510a7b89632631e59f0144e1ec4f15e12 /libempathy-gtk | |
parent | 62ba1a881425767bcfec26aabbd09f97ed1df0b4 (diff) | |
download | gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar.gz gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar.bz2 gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar.lz gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar.xz gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.tar.zst gsoc2013-empathy-226ca7f42019148efc47bec6b913fef3a9f764da.zip |
Remove group/private chat, will unify in empathy-chat.ch
svn path=/trunk/; revision=833
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-group-chat.c | 697 | ||||
-rw-r--r-- | libempathy-gtk/empathy-group-chat.glade | 123 | ||||
-rw-r--r-- | libempathy-gtk/empathy-group-chat.h | 67 | ||||
-rw-r--r-- | libempathy-gtk/empathy-private-chat.c | 365 | ||||
-rw-r--r-- | libempathy-gtk/empathy-private-chat.h | 63 |
5 files changed, 0 insertions, 1315 deletions
diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c deleted file mode 100644 index 5d10da68d..000000000 --- a/libempathy-gtk/empathy-group-chat.c +++ /dev/null @@ -1,697 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <glib/gi18n.h> - -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-tp-chat.h> -#include <libempathy/empathy-tp-chatroom.h> -#include <libempathy/empathy-contact.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-debug.h> - -#include "empathy-group-chat.h" -#include "empathy-chat.h" -#include "empathy-chat-view.h" -#include "empathy-contact-list-store.h" -#include "empathy-contact-list-view.h" -//#include "empathy-chat-invite.h" -//#include "empathy-sound.h" -#include "empathy-images.h" -#include "empathy-ui-utils.h" -#include "empathy-conf.h" - -#define DEBUG_DOMAIN "GroupChat" - -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_GROUP_CHAT, EmpathyGroupChatPriv)) - -struct _EmpathyGroupChatPriv { - EmpathyContactListStore *store; - EmpathyContactListView *view; - EmpathyTpChatroom *tp_chat; - - GtkWidget *widget; - GtkWidget *hpaned; - GtkWidget *vbox_left; - GtkWidget *scrolled_window_chat; - GtkWidget *scrolled_window_input; - GtkWidget *scrolled_window_contacts; - GtkWidget *hbox_topic; - GtkWidget *label_topic; - - gchar *topic; - gchar *name; - GCompletion *completion; - - gint contacts_width; - gboolean contacts_visible; -}; - -static void group_chat_finalize (GObject *object); -static void group_chat_create_ui (EmpathyGroupChat *chat); -static void group_chat_widget_destroy_cb (GtkWidget *widget, - EmpathyGroupChat *chat); -static void group_chat_members_changed_cb (EmpathyTpChatroom *tp_chat, - EmpathyContact *contact, - EmpathyContact *actor, - guint reason, - gchar *message, - gboolean is_member, - EmpathyGroupChat *chat); -static const gchar * group_chat_get_name (EmpathyChat *chat); -static gchar * group_chat_get_tooltip (EmpathyChat *chat); -static const gchar * group_chat_get_status_icon_name (EmpathyChat *chat); -static GtkWidget * group_chat_get_widget (EmpathyChat *chat); -static gboolean group_chat_is_group_chat (EmpathyChat *chat); -static void group_chat_set_tp_chat (EmpathyChat *chat, - EmpathyTpChat *tp_chat); -static gboolean group_chat_key_press_event (EmpathyChat *chat, - GdkEventKey *event); -static gint group_chat_contacts_completion_func (const gchar *s1, - const gchar *s2, - gsize n); - -G_DEFINE_TYPE (EmpathyGroupChat, empathy_group_chat, EMPATHY_TYPE_CHAT) - -static void -empathy_group_chat_class_init (EmpathyGroupChatClass *klass) -{ - GObjectClass *object_class; - EmpathyChatClass *chat_class; - - object_class = G_OBJECT_CLASS (klass); - chat_class = EMPATHY_CHAT_CLASS (klass); - - object_class->finalize = group_chat_finalize; - - chat_class->get_name = group_chat_get_name; - chat_class->get_tooltip = group_chat_get_tooltip; - 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; - chat_class->key_press_event = group_chat_key_press_event; - - g_type_class_add_private (object_class, sizeof (EmpathyGroupChatPriv)); -} - -static void -empathy_group_chat_init (EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - EmpathyChatView *chatview; - - priv = GET_PRIV (chat); - - priv->contacts_visible = TRUE; - - chatview = EMPATHY_CHAT_VIEW (EMPATHY_CHAT (chat)->view); - empathy_chat_view_set_is_group_chat (chatview, TRUE); - - group_chat_create_ui (chat); -} - -static void -group_chat_finalize (GObject *object) -{ - EmpathyGroupChat *chat; - EmpathyGroupChatPriv *priv; - - empathy_debug (DEBUG_DOMAIN, "Finalized:%p", object); - - chat = EMPATHY_GROUP_CHAT (object); - priv = GET_PRIV (chat); - - g_free (priv->name); - g_free (priv->topic); - if (priv->store) { - g_object_unref (priv->store); - } - if (priv->tp_chat) { - g_object_unref (priv->tp_chat); - } - g_completion_free (priv->completion); - - G_OBJECT_CLASS (empathy_group_chat_parent_class)->finalize (object); -} - -EmpathyGroupChat * -empathy_group_chat_new (EmpathyTpChatroom *tp_chat) -{ - EmpathyGroupChat *chat; - - g_return_val_if_fail (EMPATHY_IS_TP_CHAT (tp_chat), NULL); - - chat = g_object_new (EMPATHY_TYPE_GROUP_CHAT, - "tp-chat", tp_chat, - NULL); - - return chat; -} - -gboolean -empathy_group_chat_get_show_contacts (EmpathyGroupChat *chat) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_GROUP_CHAT (chat), FALSE); - - group_chat = EMPATHY_GROUP_CHAT (chat); - priv = GET_PRIV (group_chat); - - return priv->contacts_visible; -} - -void -empathy_group_chat_set_show_contacts (EmpathyGroupChat *chat, - gboolean show) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_if_fail (EMPATHY_IS_GROUP_CHAT (chat)); - - group_chat = EMPATHY_GROUP_CHAT (chat); - priv = GET_PRIV (group_chat); - - priv->contacts_visible = show; - - if (show) { - gtk_widget_show (priv->scrolled_window_contacts); - gtk_paned_set_position (GTK_PANED (priv->hpaned), - priv->contacts_width); - } else { - priv->contacts_width = gtk_paned_get_position (GTK_PANED (priv->hpaned)); - gtk_widget_hide (priv->scrolled_window_contacts); - } -} - -static void -group_chat_topic_response_cb (GtkWidget *dialog, - gint response, - EmpathyGroupChat *chat) -{ - if (response == GTK_RESPONSE_OK) { - GtkWidget *entry; - const gchar *topic; - - entry = g_object_get_data (G_OBJECT (dialog), "entry"); - topic = gtk_entry_get_text (GTK_ENTRY (entry)); - - if (!G_STR_EMPTY (topic)) { - EmpathyGroupChatPriv *priv; - GValue value = {0, }; - - priv = GET_PRIV (chat); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, topic); - empathy_tp_chat_set_property (EMPATHY_TP_CHAT (priv->tp_chat), - "subject", &value); - g_value_unset (&value); - } - } - - gtk_widget_destroy (dialog); -} - -static void -group_chat_topic_entry_activate_cb (GtkWidget *entry, - GtkDialog *dialog) -{ - gtk_dialog_response (dialog, GTK_RESPONSE_OK); -} - -void -empathy_group_chat_set_topic (EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - GtkWindow *parent; - GtkWidget *dialog; - GtkWidget *entry; - GtkWidget *hbox; - const gchar *topic; - - priv = GET_PRIV (chat); - - g_return_if_fail (EMPATHY_IS_GROUP_CHAT (chat)); - - parent = empathy_get_toplevel_window (empathy_chat_get_widget (EMPATHY_CHAT (chat))); - dialog = gtk_message_dialog_new (GTK_WINDOW (parent), - 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_OK_CANCEL, - _("Enter the new topic you want to set for this room:")); - - topic = gtk_label_get_text (GTK_LABEL (priv->label_topic)); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - hbox, FALSE, TRUE, 4); - - entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (entry), topic); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 4); - - g_object_set (GTK_MESSAGE_DIALOG (dialog)->label, "use-markup", TRUE, NULL); - g_object_set_data (G_OBJECT (dialog), "entry", entry); - - g_signal_connect (entry, "activate", - G_CALLBACK (group_chat_topic_entry_activate_cb), - dialog); - g_signal_connect (dialog, "response", - G_CALLBACK (group_chat_topic_response_cb), - chat); - - gtk_widget_show_all (dialog); -} - -static void -group_chat_create_ui (EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - GladeXML *glade; - GList *list = NULL; - gchar *filename; - - priv = GET_PRIV (chat); - - filename = empathy_file_lookup ("empathy-group-chat.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "group_chat_widget", - NULL, - "group_chat_widget", &priv->widget, - "hpaned", &priv->hpaned, - "vbox_left", &priv->vbox_left, - "scrolled_window_chat", &priv->scrolled_window_chat, - "scrolled_window_input", &priv->scrolled_window_input, - "hbox_topic", &priv->hbox_topic, - "label_topic", &priv->label_topic, - "scrolled_window_contacts", &priv->scrolled_window_contacts, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - chat, - "group_chat_widget", "destroy", group_chat_widget_destroy_cb, - NULL); - - g_object_unref (glade); - - g_object_set_data (G_OBJECT (priv->widget), "chat", g_object_ref (chat)); - - /* Add room GtkTextView. */ - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_chat), - GTK_WIDGET (EMPATHY_CHAT (chat)->view)); - gtk_widget_show (GTK_WIDGET (EMPATHY_CHAT (chat)->view)); - - /* Add input GtkTextView */ - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_input), - EMPATHY_CHAT (chat)->input_text_view); - gtk_widget_show (EMPATHY_CHAT (chat)->input_text_view); - - /* Add nick name completion */ - priv->completion = g_completion_new ((GCompletionFunc) empathy_contact_get_name); - g_completion_set_compare (priv->completion, - group_chat_contacts_completion_func); - - /* Set widget focus order */ - list = g_list_append (NULL, priv->scrolled_window_input); - gtk_container_set_focus_chain (GTK_CONTAINER (priv->vbox_left), list); - g_list_free (list); - - list = g_list_append (NULL, priv->vbox_left); - list = g_list_append (list, priv->scrolled_window_contacts); - gtk_container_set_focus_chain (GTK_CONTAINER (priv->hpaned), list); - g_list_free (list); - - list = g_list_append (NULL, priv->hpaned); - list = g_list_append (list, priv->hbox_topic); - gtk_container_set_focus_chain (GTK_CONTAINER (priv->widget), list); - g_list_free (list); -} - -static void -group_chat_widget_destroy_cb (GtkWidget *widget, - EmpathyGroupChat *chat) -{ - empathy_debug (DEBUG_DOMAIN, "Destroyed"); - - g_object_unref (chat); -} - -static void -group_chat_members_changed_cb (EmpathyTpChatroom *tp_chat, - EmpathyContact *contact, - EmpathyContact *actor, - guint reason, - gchar *message, - gboolean is_member, - EmpathyGroupChat *chat) -{ - if (!EMPATHY_CHAT (chat)->block_events) { - gchar *str; - if (is_member) { - str = g_strdup_printf (_("%s has joined the room"), - empathy_contact_get_name (contact)); - } else { - str = g_strdup_printf (_("%s has left the room"), - empathy_contact_get_name (contact)); - } - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, str); - g_free (str); - } -} - -static const gchar * -group_chat_get_name (EmpathyChat *chat) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_GROUP_CHAT (chat), NULL); - - group_chat = EMPATHY_GROUP_CHAT (chat); - priv = GET_PRIV (group_chat); - - if (!priv->name) { - const gchar *id; - const gchar *server; - - id = empathy_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; -} - -static gchar * -group_chat_get_tooltip (EmpathyChat *chat) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_GROUP_CHAT (chat), NULL); - - group_chat = EMPATHY_GROUP_CHAT (chat); - priv = GET_PRIV (group_chat); - - if (priv->topic) { - gchar *topic, *tmp; - - topic = g_strdup_printf (_("Topic: %s"), priv->topic); - tmp = g_strdup_printf ("%s\n%s", priv->name, topic); - g_free (topic); - - return tmp; - } - - return g_strdup (priv->name); -} - -static const gchar * -group_chat_get_status_icon_name (EmpathyChat *chat) -{ - return EMPATHY_IMAGE_GROUP_MESSAGE; -} - -static GtkWidget * -group_chat_get_widget (EmpathyChat *chat) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_GROUP_CHAT (chat), NULL); - - group_chat = EMPATHY_GROUP_CHAT (chat); - priv = GET_PRIV (group_chat); - - return priv->widget; -} - -static gboolean -group_chat_is_group_chat (EmpathyChat *chat) -{ - g_return_val_if_fail (EMPATHY_IS_GROUP_CHAT (chat), FALSE); - - return TRUE; -} - -static void -group_chat_property_changed_cb (EmpathyTpChat *tp_chat, - gchar *name, - GValue *value, - EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - const gchar *str = NULL; - - priv = GET_PRIV (chat); - - /* FIXME: this is ugly, should use properties on EmpathyChat obj */ - - if (!tp_strdiff (name, "name")) { - str = g_value_get_string (value); - g_free (priv->name); - priv->name = g_strdup (str); - return; - } - - if (tp_strdiff (name, "subject")) { - return; - } - - str = g_value_get_string (value); - if (!tp_strdiff (priv->topic, str)) { - return; - } - - g_free (priv->topic); - priv->topic = g_strdup (str); - gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic); - - if (!EMPATHY_CHAT (chat)->block_events) { - gchar *string; - - if (!G_STR_EMPTY (priv->topic)) { - string = g_strdup_printf (_("Topic set to: %s"), priv->topic); - } else { - string = g_strdup (_("No topic defined")); - } - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, string); - g_free (string); - } -} - -static void -group_chat_set_tp_chat (EmpathyChat *chat, - EmpathyTpChat *tp_chat) -{ - EmpathyGroupChat *group_chat; - EmpathyGroupChatPriv *priv; - - g_return_if_fail (EMPATHY_IS_GROUP_CHAT (chat)); - - group_chat = EMPATHY_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); - - if (empathy_tp_chatroom_get_invitation (priv->tp_chat, NULL, NULL)) { - empathy_tp_chatroom_accept_invitation (priv->tp_chat); - } - - /* Create contact list */ - priv->store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat)); - priv->view = empathy_contact_list_view_new (priv->store, - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT | - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL | - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG | - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT | - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE | - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO); - - 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, "members-changed", - G_CALLBACK (group_chat_members_changed_cb), - chat); - g_signal_connect (priv->tp_chat, "property-changed", - G_CALLBACK (group_chat_property_changed_cb), - chat); -} - -static gboolean -group_chat_key_press_event (EmpathyChat *chat, - GdkEventKey *event) -{ - EmpathyGroupChatPriv *priv = GET_PRIV (chat); - - if (!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) && - event->keyval == GDK_Tab) { - GtkTextBuffer *buffer; - GtkTextIter start, current; - gchar *nick, *completed; - GList *list, *completed_list; - gboolean is_start_of_buffer; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (EMPATHY_CHAT (chat)->input_text_view)); - gtk_text_buffer_get_iter_at_mark (buffer, ¤t, gtk_text_buffer_get_insert (buffer)); - - /* Get the start of the nick to complete. */ - gtk_text_buffer_get_iter_at_mark (buffer, &start, gtk_text_buffer_get_insert (buffer)); - gtk_text_iter_backward_word_start (&start); - is_start_of_buffer = gtk_text_iter_is_start (&start); - - list = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (priv->tp_chat)); - g_completion_add_items (priv->completion, list); - - nick = gtk_text_buffer_get_text (buffer, &start, ¤t, FALSE); - completed_list = g_completion_complete (priv->completion, - nick, - &completed); - - g_free (nick); - - if (completed) { - guint len; - const gchar *text; - gchar *complete_char = NULL; - - gtk_text_buffer_delete (buffer, &start, ¤t); - - len = g_list_length (completed_list); - - if (len == 1) { - /* If we only have one hit, use that text - * instead of the text in completed since the - * completed text will use the typed string - * which might be cased all wrong. - * Fixes #120876 - * */ - text = empathy_contact_get_name (completed_list->data); - } else { - text = completed; - } - - gtk_text_buffer_insert_at_cursor (buffer, text, strlen (text)); - - if (len == 1 && is_start_of_buffer && - empathy_conf_get_string (empathy_conf_get (), - EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR, - &complete_char) && - complete_char != NULL) { - gtk_text_buffer_insert_at_cursor (buffer, - complete_char, - strlen (complete_char)); - gtk_text_buffer_insert_at_cursor (buffer, " ", 1); - g_free (complete_char); - } - - g_free (completed); - } - - g_completion_clear_items (priv->completion); - - g_list_foreach (list, (GFunc) g_object_unref, NULL); - g_list_free (list); - - return TRUE; - } - - return FALSE; -} - -static gint -group_chat_contacts_completion_func (const gchar *s1, - const gchar *s2, - gsize n) -{ - gchar *tmp, *nick1, *nick2; - gint ret; - - tmp = g_utf8_normalize (s1, -1, G_NORMALIZE_DEFAULT); - nick1 = g_utf8_casefold (tmp, -1); - g_free (tmp); - - tmp = g_utf8_normalize (s2, -1, G_NORMALIZE_DEFAULT); - nick2 = g_utf8_casefold (tmp, -1); - g_free (tmp); - - ret = strncmp (nick1, nick2, n); - - g_free (nick1); - g_free (nick2); - - return ret; -} - diff --git a/libempathy-gtk/empathy-group-chat.glade b/libempathy-gtk/empathy-group-chat.glade deleted file mode 100644 index 5b40dc375..000000000 --- a/libempathy-gtk/empathy-group-chat.glade +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--*- mode: xml -*--> -<glade-interface> - <widget class="GtkWindow" id="group_chat_window"> - <property name="border_width">6</property> - <property name="title" translatable="yes">Group Chat</property> - <property name="default_width">1000</property> - <property name="default_height">800</property> - <property name="icon_name">system-users</property> - <child> - <widget class="GtkVBox" id="group_chat_widget"> - <property name="visible">True</property> - <property name="border_width">4</property> - <property name="spacing">6</property> - <child> - <widget class="GtkHBox" id="hbox_topic"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label80"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes"><b>Topic:</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_topic"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - <property name="selectable">True</property> - <property name="ellipsize">PANGO_ELLIPSIZE_END</property> - <property name="single_line_mode">True</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="padding">2</property> - </packing> - </child> - <child> - <widget class="GtkHPaned" id="hpaned"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkVBox" id="vbox_left"> - <property name="width_request">600</property> - <property name="height_request">500</property> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkScrolledWindow" id="scrolled_window_chat"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <placeholder/> - </child> - </widget> - </child> - <child> - <widget class="GtkScrolledWindow" id="scrolled_window_input"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="resize">True</property> - <property name="shrink">True</property> - </packing> - </child> - <child> - <widget class="GtkScrolledWindow" id="scrolled_window_contacts"> - <property name="width_request">200</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="resize">True</property> - <property name="shrink">True</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/libempathy-gtk/empathy-group-chat.h b/libempathy-gtk/empathy-group-chat.h deleted file mode 100644 index e0ce79462..000000000 --- a/libempathy-gtk/empathy-group-chat.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_GROUP_CHAT_H__ -#define __EMPATHY_GROUP_CHAT_H__ - -G_BEGIN_DECLS - -#include <libempathy/empathy-tp-chatroom.h> -#include <libempathy/empathy-contact.h> - -#define EMPATHY_TYPE_GROUP_CHAT (empathy_group_chat_get_type ()) -#define EMPATHY_GROUP_CHAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_GROUP_CHAT, EmpathyGroupChat)) -#define EMPATHY_GROUP_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_GROUP_CHAT, EmpathyGroupChatClass)) -#define EMPATHY_IS_GROUP_CHAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_GROUP_CHAT)) -#define EMPATHY_IS_GROUP_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_GROUP_CHAT)) -#define EMPATHY_GROUP_CHAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_GROUP_CHAT, EmpathyGroupChatClass)) - -typedef struct _EmpathyGroupChat EmpathyGroupChat; -typedef struct _EmpathyGroupChatClass EmpathyGroupChatClass; -typedef struct _EmpathyGroupChatPriv EmpathyGroupChatPriv; - -#include "empathy-chat.h" - -struct _EmpathyGroupChat { - EmpathyChat parent; - - EmpathyGroupChatPriv *priv; -}; - -struct _EmpathyGroupChatClass { - EmpathyChatClass parent_class; -}; - -GType empathy_group_chat_get_type (void) G_GNUC_CONST; -EmpathyGroupChat *empathy_group_chat_new (EmpathyTpChatroom *tp_chat); -gboolean empathy_group_chat_get_show_contacts (EmpathyGroupChat *chat); -void empathy_group_chat_set_show_contacts (EmpathyGroupChat *chat, - gboolean show); -void empathy_group_chat_set_topic (EmpathyGroupChat *chat); - -G_END_DECLS - -#endif /* __EMPATHY_GROUP_CHAT_H__ */ diff --git a/libempathy-gtk/empathy-private-chat.c b/libempathy-gtk/empathy-private-chat.c deleted file mode 100644 index 950f168a5..000000000 --- a/libempathy-gtk/empathy-private-chat.c +++ /dev/null @@ -1,365 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Geert-Jan Van den Bogaerde <geertjan@gnome.org> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <glib/gi18n.h> - -#include <libmissioncontrol/mission-control.h> -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-debug.h> -#include <libempathy/empathy-tp-chat.h> -#include <libempathy/empathy-tp-contact-list.h> -#include <libempathy/empathy-contact-factory.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-private-chat.h" -#include "empathy-chat-view.h" -#include "empathy-chat.h" -//#include "empathy-sound.h" -#include "empathy-images.h" -#include "empathy-ui-utils.h" - -#define DEBUG_DOMAIN "PrivateChat" - -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_PRIVATE_CHAT, EmpathyPrivateChatPriv)) - -struct _EmpathyPrivateChatPriv { - EmpathyContactFactory *factory; - EmpathyContact *contact; - gchar *name; - gboolean is_online; - GtkWidget *widget; - GtkWidget *text_view_sw; -}; - -static void empathy_private_chat_class_init (EmpathyPrivateChatClass *klass); -static void empathy_private_chat_init (EmpathyPrivateChat *chat); -static void private_chat_finalize (GObject *object); -static void private_chat_create_ui (EmpathyPrivateChat *chat); -static void private_chat_contact_presence_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyPrivateChat *chat); -static void private_chat_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyPrivateChat *chat); -static void private_chat_widget_destroy_cb (GtkWidget *widget, - EmpathyPrivateChat *chat); -static const gchar * private_chat_get_name (EmpathyChat *chat); -static gchar * private_chat_get_tooltip (EmpathyChat *chat); -static const gchar * private_chat_get_status_icon_name (EmpathyChat *chat); -static GtkWidget * private_chat_get_widget (EmpathyChat *chat); - -G_DEFINE_TYPE (EmpathyPrivateChat, empathy_private_chat, EMPATHY_TYPE_CHAT); - - -static GObject * -private_chat_constructor (GType type, - guint n_props, - GObjectConstructParam *props) -{ - GObject *chat; - EmpathyPrivateChatPriv *priv; - EmpathyTpChat *tp_chat; - TpChan *tp_chan; - McAccount *account; - - chat = G_OBJECT_CLASS (empathy_private_chat_parent_class)->constructor (type, n_props, props); - - priv = GET_PRIV (chat); - - g_object_get (chat, "tp-chat", &tp_chat, NULL); - tp_chan = empathy_tp_chat_get_channel (tp_chat); - account = empathy_tp_chat_get_account (tp_chat); - - priv->factory = empathy_contact_factory_new (); - priv->contact = empathy_contact_factory_get_from_handle (priv->factory, - account, - tp_chan->handle); - - priv->name = g_strdup (empathy_contact_get_name (priv->contact)); - - g_signal_connect (priv->contact, - "notify::name", - G_CALLBACK (private_chat_contact_updated_cb), - chat); - g_signal_connect (priv->contact, - "notify::presence", - G_CALLBACK (private_chat_contact_presence_updated_cb), - chat); - - priv->is_online = empathy_contact_is_online (priv->contact); - - g_object_unref (tp_chat); - - return chat; -} - -static void -empathy_private_chat_class_init (EmpathyPrivateChatClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EmpathyChatClass *chat_class = EMPATHY_CHAT_CLASS (klass); - - object_class->finalize = private_chat_finalize; - object_class->constructor = private_chat_constructor; - - chat_class->get_name = private_chat_get_name; - 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 (EmpathyPrivateChatPriv)); -} - -static void -empathy_private_chat_init (EmpathyPrivateChat *chat) -{ - private_chat_create_ui (chat); -} - -static void -private_chat_finalize (GObject *object) -{ - EmpathyPrivateChat *chat; - EmpathyPrivateChatPriv *priv; - - chat = EMPATHY_PRIVATE_CHAT (object); - priv = GET_PRIV (chat); - - g_signal_handlers_disconnect_by_func (priv->contact, - private_chat_contact_updated_cb, - chat); - g_signal_handlers_disconnect_by_func (priv->contact, - private_chat_contact_presence_updated_cb, - chat); - - if (priv->contact) { - g_object_unref (priv->contact); - } - if (priv->factory) { - g_object_unref (priv->factory); - } - g_free (priv->name); - - G_OBJECT_CLASS (empathy_private_chat_parent_class)->finalize (object); -} - -static void -private_chat_create_ui (EmpathyPrivateChat *chat) -{ - GladeXML *glade; - EmpathyPrivateChatPriv *priv; - GtkWidget *input_text_view_sw; - gchar *filename; - - priv = GET_PRIV (chat); - - filename = empathy_file_lookup ("empathy-chat.glade", "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "chat_widget", - NULL, - "chat_widget", &priv->widget, - "chat_view_sw", &priv->text_view_sw, - "input_text_view_sw", &input_text_view_sw, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - chat, - "chat_widget", "destroy", private_chat_widget_destroy_cb, - NULL); - - g_object_unref (glade); - - g_object_set_data (G_OBJECT (priv->widget), "chat", g_object_ref (chat)); - - gtk_container_add (GTK_CONTAINER (priv->text_view_sw), - GTK_WIDGET (EMPATHY_CHAT (chat)->view)); - gtk_widget_show (GTK_WIDGET (EMPATHY_CHAT (chat)->view)); - - gtk_container_add (GTK_CONTAINER (input_text_view_sw), - EMPATHY_CHAT (chat)->input_text_view); - gtk_widget_show (EMPATHY_CHAT (chat)->input_text_view); -} - -static void -private_chat_contact_presence_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyPrivateChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - priv = GET_PRIV (chat); - - empathy_debug (DEBUG_DOMAIN, "Presence update for contact: %s", - empathy_contact_get_id (contact)); - - if (!empathy_contact_is_online (contact)) { - if (priv->is_online && !EMPATHY_CHAT (chat)->block_events) { - gchar *msg; - - msg = g_strdup_printf (_("%s went offline"), - empathy_contact_get_name (priv->contact)); - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, msg); - g_free (msg); - } - - priv->is_online = FALSE; - - g_signal_emit_by_name (chat, "composing", FALSE); - - } else { - if (!priv->is_online && !EMPATHY_CHAT (chat)->block_events) { - gchar *msg; - - msg = g_strdup_printf (_("%s has come online"), - empathy_contact_get_name (priv->contact)); - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, msg); - g_free (msg); - } - - priv->is_online = TRUE; - - /* If offline message is not supported by CM we need to - * request a new Text Channel. */ - if (!empathy_chat_is_connected (EMPATHY_CHAT (chat))) { - empathy_chat_with_contact (contact); - } - } - - g_signal_emit_by_name (chat, "status-changed"); -} - -static void -private_chat_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyPrivateChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - priv = GET_PRIV (chat); - - if (tp_strdiff (priv->name, empathy_contact_get_name (contact))) { - g_free (priv->name); - priv->name = g_strdup (empathy_contact_get_name (contact)); - g_signal_emit_by_name (chat, "name-changed", priv->name); - } -} - -static void -private_chat_widget_destroy_cb (GtkWidget *widget, - EmpathyPrivateChat *chat) -{ - empathy_debug (DEBUG_DOMAIN, "Destroyed"); - - g_object_unref (chat); -} - -static const gchar * -private_chat_get_name (EmpathyChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_PRIVATE_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - return priv->name; -} - -static gchar * -private_chat_get_tooltip (EmpathyChat *chat) -{ - EmpathyPrivateChatPriv *priv; - const gchar *status; - - g_return_val_if_fail (EMPATHY_IS_PRIVATE_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - status = empathy_contact_get_status (priv->contact); - - return g_strdup_printf ("%s\n%s", - empathy_contact_get_id (priv->contact), - status); -} - -static const gchar * -private_chat_get_status_icon_name (EmpathyChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_PRIVATE_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - return empathy_icon_name_for_contact (priv->contact); -} - -EmpathyContact * -empathy_private_chat_get_contact (EmpathyPrivateChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_PRIVATE_CHAT (chat), NULL); - - priv = GET_PRIV (chat); - - return priv->contact; -} - -static GtkWidget * -private_chat_get_widget (EmpathyChat *chat) -{ - EmpathyPrivateChatPriv *priv; - - priv = GET_PRIV (chat); - - return priv->widget; -} - -EmpathyPrivateChat * -empathy_private_chat_new (EmpathyTpChat *tp_chat) -{ - EmpathyPrivateChat *chat; - - g_return_val_if_fail (EMPATHY_IS_TP_CHAT (tp_chat), NULL); - - chat = g_object_new (EMPATHY_TYPE_PRIVATE_CHAT, - "tp-chat", tp_chat, - NULL); - - return chat; -} - diff --git a/libempathy-gtk/empathy-private-chat.h b/libempathy-gtk/empathy-private-chat.h deleted file mode 100644 index 169809bb0..000000000 --- a/libempathy-gtk/empathy-private-chat.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Geert-Jan Van den Bogaerde <geertjan@gnome.org> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_PRIVATE_CHAT_H__ -#define __EMPATHY_PRIVATE_CHAT_H__ - -#include <libempathy/empathy-tp-chat.h> -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_PRIVATE_CHAT (empathy_private_chat_get_type ()) -#define EMPATHY_PRIVATE_CHAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_PRIVATE_CHAT, EmpathyPrivateChat)) -#define EMPATHY_PRIVATE_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_PRIVATE_CHAT, EmpathyPrivateChatClass)) -#define EMPATHY_IS_PRIVATE_CHAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_PRIVATE_CHAT)) -#define EMPATHY_IS_PRIVATE_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_PRIVATE_CHAT)) -#define EMPATHY_PRIVATE_CHAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_PRIVATE_CHAT, EmpathyPrivateChatClass)) - -typedef struct _EmpathyPrivateChat EmpathyPrivateChat; -typedef struct _EmpathyPrivateChatClass EmpathyPrivateChatClass; -typedef struct _EmpathyPrivateChatPriv EmpathyPrivateChatPriv; - -#include "empathy-chat.h" - -struct _EmpathyPrivateChat { - EmpathyChat parent; -}; - -struct _EmpathyPrivateChatClass { - EmpathyChatClass parent; -}; - -GType empathy_private_chat_get_type (void); -EmpathyPrivateChat * empathy_private_chat_new (EmpathyTpChat *tp_chat); -EmpathyContact * empathy_private_chat_get_contact (EmpathyPrivateChat *chat); - -G_END_DECLS - -#endif /* __EMPATHY_PRIVATE_CHAT_H__ */ |