diff options
Diffstat (limited to 'gnome-2-26/libempathy-gtk')
96 files changed, 0 insertions, 29409 deletions
diff --git a/gnome-2-26/libempathy-gtk/.gitignore b/gnome-2-26/libempathy-gtk/.gitignore deleted file mode 100644 index 3e3f6f051..000000000 --- a/gnome-2-26/libempathy-gtk/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -empathy-gtk-marshal.* -*.gladep diff --git a/gnome-2-26/libempathy-gtk/Makefile.am b/gnome-2-26/libempathy-gtk/Makefile.am deleted file mode 100644 index 46d03167e..000000000 --- a/gnome-2-26/libempathy-gtk/Makefile.am +++ /dev/null @@ -1,199 +0,0 @@ -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ - -DDATADIR=\""$(datadir)"\" \ - -DPKGDATADIR=\""$(pkgdatadir)"\" \ - $(EMPATHY_CFLAGS) \ - $(ENCHANT_CFLAGS) \ - $(WARN_CFLAGS) - -BUILT_SOURCES = \ - empathy-gtk-marshal.h \ - empathy-gtk-marshal.c \ - empathy-gtk-marshal.list \ - empathy-gtk-enum-types.h \ - empathy-gtk-enum-types.c - -lib_LTLIBRARIES = libempathy-gtk.la - -libempathy_gtk_la_SOURCES = \ - empathy-account-chooser.c \ - empathy-account-widget.c \ - empathy-account-widget-irc.c \ - empathy-account-widget-sip.c \ - empathy-avatar-chooser.c \ - empathy-avatar-image.c \ - empathy-cell-renderer-activatable.c \ - empathy-cell-renderer-expander.c \ - empathy-cell-renderer-text.c \ - empathy-chat.c \ - empathy-chat-text-view.c \ - empathy-chat-view.c \ - empathy-conf.c \ - empathy-contact-dialogs.c \ - empathy-contact-list-store.c \ - empathy-contact-list-view.c \ - empathy-contact-menu.c \ - empathy-contact-selector.c \ - empathy-contact-widget.c \ - empathy-geometry.c \ - empathy-audio-sink.c \ - empathy-audio-src.c \ - empathy-video-src.c \ - empathy-video-widget.c \ - empathy-irc-network-dialog.c \ - empathy-log-window.c \ - empathy-new-message-dialog.c \ - empathy-presence-chooser.c \ - empathy-profile-chooser.c \ - empathy-smiley-manager.c \ - empathy-spell.c \ - empathy-spell-dialog.c \ - empathy-theme-boxes.c \ - empathy-theme-irc.c \ - empathy-theme-manager.c \ - empathy-ui-utils.c \ - totem-subtitle-encoding.c totem-subtitle-encoding.h - -# do not distribute generated files -nodist_libempathy_gtk_la_SOURCES =\ - $(BUILT_SOURCES) - -libempathy_gtk_la_LIBADD = \ - $(EMPATHY_LIBS) \ - $(ENCHANT_LIBS) \ - $(top_builddir)/libempathy/libempathy.la - -libempathy_gtk_la_LDFLAGS = \ - -version-info ${LIBEMPATHY_GTK_CURRENT}:${LIBEMPATHY_GTK_REVISION}:${LIBEMPATHY_GTK_AGE} \ - -export-symbols-regex ^empathy_ - -libempathy_gtk_headers = \ - empathy-account-chooser.h \ - empathy-account-widget.h \ - empathy-account-widget-irc.h \ - empathy-account-widget-sip.h \ - empathy-avatar-chooser.h \ - empathy-avatar-image.h \ - empathy-cell-renderer-activatable.h \ - empathy-cell-renderer-expander.h \ - empathy-cell-renderer-text.h \ - empathy-chat.h \ - empathy-chat-text-view.h \ - empathy-chat-view.h \ - empathy-conf.h \ - empathy-contact-dialogs.h \ - empathy-contact-list-store.h \ - empathy-contact-list-view.h \ - empathy-contact-menu.h \ - empathy-contact-selector.h \ - empathy-contact-widget.h \ - empathy-geometry.h \ - empathy-audio-sink.h \ - empathy-audio-src.h \ - empathy-video-src.h \ - empathy-video-widget.h \ - empathy-images.h \ - empathy-irc-network-dialog.h \ - empathy-log-window.h \ - empathy-new-message-dialog.h \ - empathy-presence-chooser.h \ - empathy-profile-chooser.h \ - empathy-smiley-manager.h \ - empathy-spell.h \ - empathy-spell-dialog.h \ - empathy-theme-boxes.h \ - empathy-theme-irc.h \ - empathy-theme-manager.h \ - empathy-ui-utils.h - -libempathy_gtk_includedir = $(includedir)/libempathy-gtk/ -libempathy_gtk_include_HEADERS = \ - $(libempathy_gtk_headers) \ - empathy-gtk-enum-types.h - -gladedir = $(datadir)/empathy -glade_DATA = \ - empathy-contact-widget.glade \ - empathy-contact-dialogs.glade \ - empathy-presence-chooser.glade \ - empathy-account-widget-generic.glade \ - empathy-account-widget-jabber.glade \ - empathy-account-widget-msn.glade \ - empathy-account-widget-sip.glade \ - empathy-account-widget-salut.glade \ - empathy-account-widget-irc.glade \ - empathy-account-widget-icq.glade \ - empathy-account-widget-yahoo.glade \ - empathy-account-widget-groupwise.glade \ - empathy-account-widget-aim.glade \ - empathy-spell-dialog.glade \ - empathy-log-window.glade \ - empathy-chat.glade \ - empathy-new-message-dialog.glade - -empathy-gtk-marshal.list: $(libempathy_gtk_la_SOURCES) Makefile.am - ( cd $(srcdir) && \ - sed -n -e 's/.*empathy_gtk_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ - $(libempathy_gtk_la_SOURCES) ) \ - | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp - if cmp -s $@.tmp $@; then \ - rm $@.tmp; \ - else \ - mv $@.tmp $@; \ - fi - -%-marshal.h: %-marshal.list Makefile - $(GLIB_GENMARSHAL) --header --prefix=_$(subst -,_,$*)_marshal $< > $*-marshal.h - -%-marshal.c: %-marshal.list Makefile - echo "#include \"empathy-gtk-marshal.h\"" > $@ && \ - $(GLIB_GENMARSHAL) --body --prefix=_$(subst -,_,$*)_marshal $< >> $*-marshal.c - -empathy-gtk-enum-types.h: stamp-empathy-gtk-enum-types.h - @true -stamp-empathy-gtk-enum-types.h: Makefile $(libempathy_gtk_headers) - (cd $(srcdir) \ - && glib-mkenums \ - --fhead "#ifndef __LIBEMPATHY_GTK_ENUM_TYPES_H__\n" \ - --fhead "#define __LIBEMPATHY_GTK_ENUM_TYPES_H__ 1\n\n" \ - --fhead "#include <glib-object.h>\n\n" \ - --fhead "G_BEGIN_DECLS\n\n" \ - --ftail "G_END_DECLS\n\n" \ - --ftail "#endif /* __LIBEMPATHY_GTK_ENUM_TYPES_H__ */\n" \ - --fprod "#include <libempathy-gtk/@filename@>\n" \ - --eprod "#define EMPATHY_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \ - --eprod "GType @enum_name@_get_type (void);\n" \ - $(libempathy_gtk_headers) ) > xgen-gth \ - && (cmp -s xgen-gth empathy-gtk-enum-type.h || cp xgen-gth empathy-gtk-enum-types.h) \ - && rm -f xgen-gth \ - && echo timestamp > $(@F) - -empathy-gtk-enum-types.c: Makefile $(libempathy_gtk_headers) - (cd $(srcdir) \ - && glib-mkenums \ - --fhead "#include <config.h>\n" \ - --fhead "#include <glib-object.h>\n" \ - --fhead "#include \"empathy-gtk-enum-types.h\"\n\n" \ - --fprod "\n/* enumerations from \"@filename@\" */" \ - --vhead "static const G@Type@Value _@enum_name@_values[] = {" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ - --vtail " { 0, NULL, NULL }\n};\n\n" \ - --vtail "GType\n@enum_name@_get_type (void)\n{\n" \ - --vtail " static GType type = 0;\n\n" \ - --vtail " if (!type)\n" \ - --vtail " type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \ - --vtail " return type;\n}\n\n" \ - $(libempathy_gtk_headers) ) > xgen-gtc \ - && cp xgen-gtc $(@F) \ - && rm -f xgen-gtc - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libempathy-gtk.pc - -EXTRA_DIST = \ - $(glade_DATA) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - stamp-empathy-gtk-enum-types.h diff --git a/gnome-2-26/libempathy-gtk/empathy-account-chooser.c b/gnome-2-26/libempathy-gtk/empathy-account-chooser.c deleted file mode 100644 index 9bda7c6db..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-chooser.c +++ /dev/null @@ -1,658 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mission-control.h> - -#include <libempathy/empathy-account-manager.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-ui-utils.h" -#include "empathy-account-chooser.h" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountChooser) -typedef struct { - EmpathyAccountManager *manager; - gboolean set_active_item; - gboolean has_all_option; - EmpathyAccountChooserFilterFunc filter; - gpointer filter_data; -} EmpathyAccountChooserPriv; - -typedef struct { - EmpathyAccountChooser *chooser; - McAccount *account; - gboolean set; -} SetAccountData; - -enum { - COL_ACCOUNT_IMAGE, - COL_ACCOUNT_TEXT, - COL_ACCOUNT_ENABLED, /* Usually tied to connected state */ - COL_ACCOUNT_POINTER, - COL_ACCOUNT_COUNT -}; - -static void account_chooser_finalize (GObject *object); -static void account_chooser_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void account_chooser_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void account_chooser_setup (EmpathyAccountChooser *chooser); -static void account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, - EmpathyAccountChooser *chooser); -static void account_chooser_account_add_foreach (McAccount *account, - EmpathyAccountChooser *chooser); -static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, - EmpathyAccountChooser *chooser); -static void account_chooser_account_remove_foreach (McAccount *account, - EmpathyAccountChooser *chooser); -static void account_chooser_update_iter (EmpathyAccountChooser *chooser, - GtkTreeIter *iter); -static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus new_status, - TpConnectionStatus old_status, - EmpathyAccountChooser *chooser); -static gboolean account_chooser_separator_func (GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyAccountChooser *chooser); -static gboolean account_chooser_set_account_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - SetAccountData *data); - -enum { - PROP_0, - PROP_HAS_ALL_OPTION, -}; - -G_DEFINE_TYPE (EmpathyAccountChooser, empathy_account_chooser, GTK_TYPE_COMBO_BOX); - -static void -empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = account_chooser_finalize; - object_class->get_property = account_chooser_get_property; - object_class->set_property = account_chooser_set_property; - - g_object_class_install_property (object_class, - PROP_HAS_ALL_OPTION, - g_param_spec_boolean ("has-all-option", - "Has All Option", - "Have a separate option in the list to mean ALL accounts", - FALSE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyAccountChooserPriv)); -} - -static void -empathy_account_chooser_init (EmpathyAccountChooser *chooser) -{ - EmpathyAccountChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser, - EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserPriv); - - chooser->priv = priv; - priv->set_active_item = FALSE; - priv->filter = NULL; - priv->filter_data = NULL; - - priv->manager = empathy_account_manager_dup_singleton (); - - g_signal_connect (priv->manager, "account-created", - G_CALLBACK (account_chooser_account_created_cb), - chooser); - g_signal_connect (priv->manager, "account-deleted", - G_CALLBACK (account_chooser_account_deleted_cb), - chooser); - g_signal_connect (priv->manager, "account-connection-changed", - G_CALLBACK (account_chooser_connection_changed_cb), - chooser); - - account_chooser_setup (EMPATHY_ACCOUNT_CHOOSER (chooser)); -} - -static void -account_chooser_finalize (GObject *object) -{ - EmpathyAccountChooserPriv *priv = GET_PRIV (object); - - g_signal_handlers_disconnect_by_func (priv->manager, - account_chooser_connection_changed_cb, - object); - g_signal_handlers_disconnect_by_func (priv->manager, - account_chooser_account_created_cb, - object); - g_signal_handlers_disconnect_by_func (priv->manager, - account_chooser_account_deleted_cb, - object); - g_object_unref (priv->manager); - - G_OBJECT_CLASS (empathy_account_chooser_parent_class)->finalize (object); -} - -static void -account_chooser_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyAccountChooserPriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_HAS_ALL_OPTION: - g_value_set_boolean (value, priv->has_all_option); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -account_chooser_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyAccountChooserPriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_HAS_ALL_OPTION: - empathy_account_chooser_set_has_all_option (EMPATHY_ACCOUNT_CHOOSER (object), - g_value_get_boolean (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -GtkWidget * -empathy_account_chooser_new (void) -{ - GtkWidget *chooser; - - chooser = g_object_new (EMPATHY_TYPE_ACCOUNT_CHOOSER, NULL); - - return chooser; -} - -McAccount * -empathy_account_chooser_get_account (EmpathyAccountChooser *chooser) -{ - EmpathyAccountChooserPriv *priv; - McAccount *account; - GtkTreeModel *model; - GtkTreeIter iter; - - g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); - - priv = GET_PRIV (chooser); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser)); - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser), &iter)) { - return NULL; - } - - gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); - - return account; -} - -gboolean -empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account) -{ - GtkComboBox *combobox; - GtkTreeModel *model; - GtkTreeIter iter; - SetAccountData data; - - g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE); - - combobox = GTK_COMBO_BOX (chooser); - model = gtk_combo_box_get_model (combobox); - gtk_combo_box_get_active_iter (combobox, &iter); - - data.chooser = chooser; - data.account = account; - - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) account_chooser_set_account_foreach, - &data); - - return data.set; -} - -gboolean -empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser) -{ - EmpathyAccountChooserPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE); - - priv = GET_PRIV (chooser); - - return priv->has_all_option; -} - -void -empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, - gboolean has_all_option) -{ - EmpathyAccountChooserPriv *priv; - GtkComboBox *combobox; - GtkListStore *store; - GtkTreeModel *model; - GtkTreeIter iter; - - g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser)); - - priv = GET_PRIV (chooser); - - if (priv->has_all_option == has_all_option) { - return; - } - - combobox = GTK_COMBO_BOX (chooser); - model = gtk_combo_box_get_model (combobox); - store = GTK_LIST_STORE (model); - - priv->has_all_option = has_all_option; - - /* - * The first 2 options are the ALL and separator - */ - - if (has_all_option) { - gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser), - (GtkTreeViewRowSeparatorFunc) - account_chooser_separator_func, - chooser, - NULL); - - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, - COL_ACCOUNT_TEXT, NULL, - COL_ACCOUNT_ENABLED, TRUE, - COL_ACCOUNT_POINTER, NULL, - -1); - - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, - COL_ACCOUNT_TEXT, _("All"), - COL_ACCOUNT_ENABLED, TRUE, - COL_ACCOUNT_POINTER, NULL, - -1); - } else { - if (gtk_tree_model_get_iter_first (model, &iter)) { - if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter)) { - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - } - } - - gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser), - (GtkTreeViewRowSeparatorFunc) - NULL, - NULL, - NULL); - } - - g_object_notify (G_OBJECT (chooser), "has-all-option"); -} - -static void -account_chooser_setup (EmpathyAccountChooser *chooser) -{ - EmpathyAccountChooserPriv *priv; - GList *accounts; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkComboBox *combobox; - - priv = GET_PRIV (chooser); - - /* Set up combo box with new store */ - combobox = GTK_COMBO_BOX (chooser); - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox)); - - store = gtk_list_store_new (COL_ACCOUNT_COUNT, - G_TYPE_STRING, /* Image */ - G_TYPE_STRING, /* Name */ - G_TYPE_BOOLEAN, /* Enabled */ - MC_TYPE_ACCOUNT); - - gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store)); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, - "icon-name", COL_ACCOUNT_IMAGE, - "sensitive", COL_ACCOUNT_ENABLED, - NULL); - g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, - "text", COL_ACCOUNT_TEXT, - "sensitive", COL_ACCOUNT_ENABLED, - NULL); - - /* Populate accounts */ - accounts = mc_accounts_list (); - g_list_foreach (accounts, - (GFunc) account_chooser_account_add_foreach, - chooser); - - mc_accounts_list_free (accounts); - g_object_unref (store); -} - -static void -account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, - EmpathyAccountChooser *chooser) -{ - account_chooser_account_add_foreach (account, chooser); -} - -static void -account_chooser_account_add_foreach (McAccount *account, - EmpathyAccountChooser *chooser) -{ - GtkListStore *store; - GtkComboBox *combobox; - GtkTreeIter iter; - gint position; - - combobox = GTK_COMBO_BOX (chooser); - store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox)); - - position = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL); - gtk_list_store_insert_with_values (store, &iter, position, - COL_ACCOUNT_POINTER, account, - -1); - account_chooser_update_iter (chooser, &iter); -} - -static void -account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, - EmpathyAccountChooser *chooser) -{ - account_chooser_account_remove_foreach (account, chooser); -} - -typedef struct { - McAccount *account; - GtkTreeIter *iter; - gboolean found; -} FindAccountData; - -static gboolean -account_chooser_find_account_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - FindAccountData *data = user_data; - McAccount *account; - - gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); - - if (empathy_account_equal (account, data->account)) { - data->found = TRUE; - *(data->iter) = *iter; - g_object_unref (account); - - return TRUE; - } - - g_object_unref (account); - - return FALSE; -} - -static gboolean -account_chooser_find_account (EmpathyAccountChooser *chooser, - McAccount *account, - GtkTreeIter *iter) -{ - GtkListStore *store; - GtkComboBox *combobox; - FindAccountData data; - - combobox = GTK_COMBO_BOX (chooser); - store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox)); - - data.account = account; - data.iter = iter; - gtk_tree_model_foreach (GTK_TREE_MODEL (store), - account_chooser_find_account_foreach, - &data); - - return data.found; -} - -static void -account_chooser_account_remove_foreach (McAccount *account, - EmpathyAccountChooser *chooser) -{ - GtkListStore *store; - GtkComboBox *combobox; - GtkTreeIter iter; - - combobox = GTK_COMBO_BOX (chooser); - store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox)); - - if (account_chooser_find_account (chooser, account, &iter)) { - gtk_list_store_remove (store, &iter); - } -} - -static void -account_chooser_update_iter (EmpathyAccountChooser *chooser, - GtkTreeIter *iter) -{ - EmpathyAccountChooserPriv *priv; - GtkListStore *store; - GtkComboBox *combobox; - McAccount *account; - const gchar *icon_name; - gboolean is_enabled = TRUE; - - priv = GET_PRIV (chooser); - - combobox = GTK_COMBO_BOX (chooser); - store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox)); - - gtk_tree_model_get (GTK_TREE_MODEL (store), iter, - COL_ACCOUNT_POINTER, &account, - -1); - - icon_name = empathy_icon_name_from_account (account); - if (priv->filter) { - is_enabled = priv->filter (account, priv->filter_data); - } - - gtk_list_store_set (store, iter, - COL_ACCOUNT_IMAGE, icon_name, - COL_ACCOUNT_TEXT, mc_account_get_display_name (account), - COL_ACCOUNT_ENABLED, is_enabled, - -1); - - /* set first connected account as active account */ - if (priv->set_active_item == FALSE && is_enabled) { - priv->set_active_item = TRUE; - gtk_combo_box_set_active_iter (combobox, iter); - } - - g_object_unref (account); -} - -static void -account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus new_status, - TpConnectionStatus old_status, - EmpathyAccountChooser *chooser) -{ - GtkTreeIter iter; - - if (account_chooser_find_account (chooser, account, &iter)) { - account_chooser_update_iter (chooser, &iter); - } -} - -static gboolean -account_chooser_separator_func (GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyAccountChooser *chooser) -{ - EmpathyAccountChooserPriv *priv; - gchar *text; - gboolean is_separator; - - priv = GET_PRIV (chooser); - - if (!priv->has_all_option) { - return FALSE; - } - - gtk_tree_model_get (model, iter, COL_ACCOUNT_TEXT, &text, -1); - is_separator = text == NULL; - g_free (text); - - return is_separator; -} - -static gboolean -account_chooser_set_account_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - SetAccountData *data) -{ - McAccount *account; - gboolean equal; - - gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); - - /* Special case so we can make it possible to select the All option */ - if ((data->account == NULL) != (account == NULL)) { - equal = FALSE; - } - else if (data->account == account) { - equal = TRUE; - } else { - equal = empathy_account_equal (data->account, account); - } - - if (account) { - g_object_unref (account); - } - - if (equal) { - GtkComboBox *combobox; - - combobox = GTK_COMBO_BOX (data->chooser); - gtk_combo_box_set_active_iter (combobox, iter); - - data->set = TRUE; - } - - return equal; -} - -static gboolean -account_chooser_filter_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer chooser) -{ - account_chooser_update_iter (chooser, iter); - return FALSE; -} - -void -empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, - EmpathyAccountChooserFilterFunc filter, - gpointer user_data) -{ - EmpathyAccountChooserPriv *priv; - GtkTreeModel *model; - - g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser)); - - priv = GET_PRIV (chooser); - - priv->filter = filter; - priv->filter_data = user_data; - - /* Refilter existing data */ - priv->set_active_item = FALSE; - model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser)); - gtk_tree_model_foreach (model, account_chooser_filter_foreach, chooser); -} - -gboolean -empathy_account_chooser_filter_is_connected (McAccount *account, - gpointer user_data) -{ - MissionControl *mc; - TpConnectionStatus status; - - g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE); - - mc = empathy_mission_control_dup_singleton (); - status = mission_control_get_connection_status (mc, account, NULL); - g_object_unref (mc); - - return status == TP_CONNECTION_STATUS_CONNECTED; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-account-chooser.h b/gnome-2-26/libempathy-gtk/empathy-account-chooser.h deleted file mode 100644 index c15923bc3..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-chooser.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_ACCOUNT_CHOOSER_H__ -#define __EMPATHY_ACCOUNT_CHOOSER_H__ - -#include <gtk/gtkcombobox.h> - -#include <libmissioncontrol/mc-account.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_ACCOUNT_CHOOSER (empathy_account_chooser_get_type ()) -#define EMPATHY_ACCOUNT_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooser)) -#define EMPATHY_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass)) -#define EMPATHY_IS_ACCOUNT_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER)) -#define EMPATHY_IS_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER)) -#define EMPATHY_ACCOUNT_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass)) - -typedef gboolean (* EmpathyAccountChooserFilterFunc) (McAccount *account, - gpointer user_data); - - -typedef struct _EmpathyAccountChooser EmpathyAccountChooser; -typedef struct _EmpathyAccountChooserClass EmpathyAccountChooserClass; - -struct _EmpathyAccountChooser { - GtkComboBox parent; - gpointer priv; -}; - -struct _EmpathyAccountChooserClass { - GtkComboBoxClass parent_class; -}; - -GType empathy_account_chooser_get_type (void) G_GNUC_CONST; -GtkWidget * empathy_account_chooser_new (void); -McAccount * empathy_account_chooser_get_account (EmpathyAccountChooser *chooser); -gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account); -gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser); -void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, - gboolean has_all_option); -void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, - EmpathyAccountChooserFilterFunc filter, - gpointer user_data); -gboolean empathy_account_chooser_filter_is_connected(McAccount *account, - gpointer user_data); - -G_END_DECLS - -#endif /* __EMPATHY_ACCOUNT_CHOOSER_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-aim.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-aim.glade deleted file mode 100644 index c12ea7615..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-aim.glade +++ /dev/null @@ -1,190 +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="account_aim_settings"> - <property name="visible">True</property> - <property name="title">ICQ account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_aim_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_screenname"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Screen _Name:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_screenname</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image834"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_screenname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">5222 0 65555 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-generic.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-generic.glade deleted file mode 100644 index e0ac01a98..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-generic.glade +++ /dev/null @@ -1,89 +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="account_generic_settings"> - <property name="visible">True</property> - <property name="title">generic account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_generic_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <child> - <widget class="GtkViewport" id="viewport1"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="resize_mode">GTK_RESIZE_QUEUE</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </widget> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-groupwise.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-groupwise.glade deleted file mode 100644 index ef47f2d7a..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-groupwise.glade +++ /dev/null @@ -1,192 +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="account_groupwise_settings"> - <property name="visible">True</property> - <property name="title">groupwise account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_groupwise_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_groupwise_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Login I_D:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table_advanced_groupwise_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="adjustment">0 0 65535 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-icq.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-icq.glade deleted file mode 100644 index 83613c39b..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-icq.glade +++ /dev/null @@ -1,218 +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="account_icq_settings"> - <property name="visible">True</property> - <property name="title">ICQ account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_icq_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_uin"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">ICQ _UIN:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_uin</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image834"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_uin"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Charset:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_charset</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">5222 0 65555 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_charset"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.c b/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.c deleted file mode 100644 index a5111381c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.c +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" - -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mc-protocol.h> - -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-irc-network-manager.h> - -#include "empathy-irc-network-dialog.h" -#include "empathy-account-widget.h" -#include "empathy-account-widget-irc.h" -#include "empathy-ui-utils.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC -#include <libempathy/empathy-debug.h> - -#define IRC_NETWORKS_FILENAME "irc-networks.xml" - -typedef struct { - McAccount *account; - EmpathyIrcNetworkManager *network_manager; - - GtkWidget *vbox_settings; - - GtkWidget *combobox_network; - GtkWidget *button_add_network; - GtkWidget *button_network; - GtkWidget *button_remove; -} EmpathyAccountWidgetIrc; - -enum { - COL_NETWORK_OBJ, - COL_NETWORK_NAME, -}; - -static void -account_widget_irc_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetIrc *settings) -{ - g_object_unref (settings->network_manager); - g_object_unref (settings->account); - g_slice_free (EmpathyAccountWidgetIrc, settings); -} - -static void -unset_server_params (EmpathyAccountWidgetIrc *settings) -{ - DEBUG ("Unset server, port and use-ssl"); - mc_account_unset_param (settings->account, "server"); - mc_account_unset_param (settings->account, "port"); - mc_account_unset_param (settings->account, "use-ssl"); -} - -static void -update_server_params (EmpathyAccountWidgetIrc *settings) -{ - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyIrcNetwork *network; - GSList *servers; - gchar *charset; - - if (!gtk_combo_box_get_active_iter ( - GTK_COMBO_BOX (settings->combobox_network), &iter)) - { - unset_server_params (settings); - return; - } - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1); - - g_assert (network != NULL); - - g_object_get (network, "charset", &charset, NULL); - DEBUG ("Setting charset to %s", charset); - mc_account_set_param_string (settings->account, "charset", charset); - g_free (charset); - - servers = empathy_irc_network_get_servers (network); - if (g_slist_length (servers) > 0) - { - /* set the first server as CM server */ - EmpathyIrcServer *server = servers->data; - gchar *address; - guint port; - gboolean ssl; - - g_object_get (server, - "address", &address, - "port", &port, - "ssl", &ssl, - NULL); - - DEBUG ("Setting server to %s", address); - mc_account_set_param_string (settings->account, "server", address); - DEBUG ("Setting port to %u", port); - mc_account_set_param_int (settings->account, "port", port); - DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" ); - mc_account_set_param_boolean (settings->account, "use-ssl", ssl); - - g_free (address); - } - else - { - /* No server. Unset values */ - unset_server_params (settings); - } - - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); - g_object_unref (network); -} - -static void -irc_network_dialog_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetIrc *settings) -{ - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyIrcNetwork *network; - gchar *name; - - /* name could be changed */ - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (settings->combobox_network), - &iter); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1); - - g_object_get (network, "name", &name, NULL); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_NETWORK_NAME, name, -1); - - update_server_params (settings); - - g_object_unref (network); - g_free (name); -} - -static void -display_irc_network_dialog (EmpathyAccountWidgetIrc *settings, - EmpathyIrcNetwork *network) -{ - GtkWindow *window; - GtkWidget *dialog; - - window = empathy_get_toplevel_window (settings->vbox_settings); - dialog = empathy_irc_network_dialog_show (network, GTK_WIDGET (window)); - g_signal_connect (dialog, "destroy", - G_CALLBACK (irc_network_dialog_destroy_cb), settings); -} - -static void -account_widget_irc_button_edit_network_clicked_cb ( - GtkWidget *button, - EmpathyAccountWidgetIrc *settings) -{ - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyIrcNetwork *network; - - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (settings->combobox_network), - &iter); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1); - - g_assert (network != NULL); - - display_irc_network_dialog (settings, network); - - g_object_unref (network); -} - -static void -account_widget_irc_button_remove_clicked_cb (GtkWidget *button, - EmpathyAccountWidgetIrc *settings) -{ - EmpathyIrcNetwork *network; - GtkTreeIter iter; - GtkTreeModel *model; - gchar *name; - - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (settings->combobox_network), - &iter); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1); - - g_assert (network != NULL); - - g_object_get (network, "name", &name, NULL); - DEBUG ("Remove network %s", name); - - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - empathy_irc_network_manager_remove (settings->network_manager, network); - - /* Select the first network */ - if (gtk_tree_model_get_iter_first (model, &iter)) - { - gtk_combo_box_set_active_iter ( - GTK_COMBO_BOX (settings->combobox_network), &iter); - } - - g_free (name); - g_object_unref (network); -} - -static void -account_widget_irc_button_add_network_clicked_cb (GtkWidget *button, - EmpathyAccountWidgetIrc *settings) -{ - EmpathyIrcNetwork *network; - GtkTreeModel *model; - GtkListStore *store; - gchar *name; - GtkTreeIter iter; - - network = empathy_irc_network_new (_("New Network")); - empathy_irc_network_manager_add (settings->network_manager, network); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - store = GTK_LIST_STORE (model); - - g_object_get (network, "name", &name, NULL); - - gtk_list_store_insert_with_values (store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, name, - -1); - - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (settings->combobox_network), - &iter); - - display_irc_network_dialog (settings, network); - - g_free (name); - g_object_unref (network); -} - -static void -account_widget_irc_combobox_network_changed_cb (GtkWidget *combobox, - EmpathyAccountWidgetIrc *settings) -{ - update_server_params (settings); -} - -static void -fill_networks_model (EmpathyAccountWidgetIrc *settings, - EmpathyIrcNetwork *network_to_select) -{ - GSList *networks, *l; - GtkTreeModel *model; - GtkListStore *store; - - networks = empathy_irc_network_manager_get_networks ( - settings->network_manager); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network)); - store = GTK_LIST_STORE (model); - - for (l = networks; l != NULL; l = g_slist_next (l)) - { - gchar *name; - EmpathyIrcNetwork *network = l->data; - GtkTreeIter iter; - - g_object_get (network, "name", &name, NULL); - - gtk_list_store_insert_with_values (store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, name, - -1); - - if (network == network_to_select) - { - gtk_combo_box_set_active_iter ( - GTK_COMBO_BOX (settings->combobox_network), &iter); - } - - g_free (name); - g_object_unref (network); - } - - if (network_to_select == NULL) - { - /* Select the first network */ - GtkTreeIter iter; - - if (gtk_tree_model_get_iter_first (model, &iter)) - { - gtk_combo_box_set_active_iter ( - GTK_COMBO_BOX (settings->combobox_network), &iter); - - update_server_params (settings); - } - } - - g_slist_free (networks); -} - -static void -account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) -{ - gchar *nick = NULL; - gchar *fullname = NULL; - gchar *server = NULL; - gint port = 6667; - gchar *charset; - gboolean ssl = FALSE; - EmpathyIrcNetwork *network = NULL; - - mc_account_get_param_string (settings->account, "account", &nick); - mc_account_get_param_string (settings->account, "fullname", &fullname); - mc_account_get_param_string (settings->account, "server", &server); - mc_account_get_param_string (settings->account, "charset", &charset); - mc_account_get_param_int (settings->account, "port", &port); - mc_account_get_param_boolean (settings->account, "use-ssl", &ssl); - - if (!nick) - { - nick = g_strdup (g_get_user_name ()); - mc_account_set_param_string (settings->account, "account", nick); - } - - if (!fullname) - { - fullname = g_strdup (g_get_real_name ()); - if (!fullname) - { - fullname = g_strdup (nick); - } - mc_account_set_param_string (settings->account, "fullname", fullname); - } - - if (server != NULL) - { - GtkListStore *store; - - network = empathy_irc_network_manager_find_network_by_address ( - settings->network_manager, server); - - - store = GTK_LIST_STORE (gtk_combo_box_get_model ( - GTK_COMBO_BOX (settings->combobox_network))); - - if (network != NULL) - { - gchar *name; - - g_object_set (network, "charset", charset, NULL); - - g_object_get (network, "name", &name, NULL); - DEBUG ("Account use network %s", name); - - g_free (name); - } - else - { - /* We don't have this network. Let's create it */ - EmpathyIrcServer *srv; - GtkTreeIter iter; - - DEBUG ("Create a network %s", server); - network = empathy_irc_network_new (server); - srv = empathy_irc_server_new (server, port, ssl); - - empathy_irc_network_append_server (network, srv); - empathy_irc_network_manager_add (settings->network_manager, network); - - gtk_list_store_insert_with_values (store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, server, - -1); - - gtk_combo_box_set_active_iter ( - GTK_COMBO_BOX (settings->combobox_network), &iter); - - g_object_unref (srv); - g_object_unref (network); - } - } - - - fill_networks_model (settings, network); - - g_free (nick); - g_free (fullname); - g_free (server); - g_free (charset); -} - -/** - * empathy_account_widget_irc_new: - * @account: the #McAccount to configure - * - * Creates a new IRC account widget to configure a given #McAccount - * - * Returns: The toplevel container of the configuration widget - */ -GtkWidget * -empathy_account_widget_irc_new (McAccount *account) -{ - EmpathyAccountWidgetIrc *settings; - gchar *dir, *user_file_with_path, *global_file_with_path; - GladeXML *glade; - GtkListStore *store; - GtkCellRenderer *renderer; - gchar *filename; - - settings = g_slice_new0 (EmpathyAccountWidgetIrc); - settings->account = g_object_ref (account); - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); - user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL); - g_free (dir); - - global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), - "libempathy-gtk", IRC_NETWORKS_FILENAME, NULL); - if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS)) - { - g_free (global_file_with_path); - global_file_with_path = g_build_filename (DATADIR, "empathy", - IRC_NETWORKS_FILENAME, NULL); - } - - settings->network_manager = empathy_irc_network_manager_new ( - global_file_with_path, - user_file_with_path); - - g_free (global_file_with_path); - g_free (user_file_with_path); - - filename = empathy_file_lookup ("empathy-account-widget-irc.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_irc_settings", - NULL, - "vbox_irc_settings", &settings->vbox_settings, - "combobox_network", &settings->combobox_network, - "button_network", &settings->button_network, - "button_add_network", &settings->button_add_network, - "button_remove", &settings->button_remove, - NULL); - g_free (filename); - - /* Fill the networks combobox */ - store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING); - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (settings->combobox_network)); - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (settings->combobox_network), - renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (settings->combobox_network), - renderer, - "text", COL_NETWORK_NAME, - NULL); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COL_NETWORK_NAME, - GTK_SORT_ASCENDING); - - gtk_combo_box_set_model (GTK_COMBO_BOX (settings->combobox_network), - GTK_TREE_MODEL (store)); - g_object_unref (store); - - account_widget_irc_setup (settings); - - empathy_account_widget_handle_params (account, glade, - "entry_nick", "account", - "entry_fullname", "fullname", - "entry_password", "password", - "entry_quit_message", "quit-message", - NULL); - - empathy_glade_connect (glade, settings, - "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb, - "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb, - "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb, - "button_remove", "clicked", account_widget_irc_button_remove_clicked_cb, - "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb, - NULL); - - g_object_unref (glade); - - return settings->vbox_settings; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.glade deleted file mode 100644 index 3e9899f6a..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.glade +++ /dev/null @@ -1,449 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.1 on Wed Mar 5 15:39:45 2008 --> -<glade-interface> - <widget class="GtkWindow" id="account_irc_settings"> - <property name="title">irc account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkTable" id="vbox_irc_settings"> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_quit_message"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_quit_message"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Quit message:</property> - </widget> - <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_fullname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Password:</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_fullname"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Real name:</property> - </widget> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_nick"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_nick"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Nickname:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_nick</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox174"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkComboBox" id="combobox_network"> - <property name="visible">True</property> - <property name="items" translatable="yes"></property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_add_network"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Create a new IRC network</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="stock">gtk-add</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_network"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Edit the selected IRC network</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image834"> - <property name="visible">True</property> - <property name="stock">gtk-edit</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_remove"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Remove the selected IRC network</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image835"> - <property name="visible">True</property> - <property name="stock">gtk-remove</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_network"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Network:</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - </widget> - <widget class="GtkDialog" id="irc_network_dialog"> - <property name="visible">True</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">Network</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="icon_name">gtk-edit</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="skip_taskbar_hint">True</property> - <property name="skip_pager_hint">True</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox10"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkFrame" id="frame14"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <child> - <widget class="GtkAlignment" id="alignment28"> - <property name="visible">True</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkTable" id="table14"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_network"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Network:</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Charset:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_network"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkComboBox" id="combobox_charset"> - <property name="visible">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label_network"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Network</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkFrame" id="frame15"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <child> - <widget class="GtkAlignment" id="alignment29"> - <property name="visible">True</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkTable" id="table15"> - <property name="visible">True</property> - <property name="n_rows">1</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow19"> - <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> - <widget class="GtkTreeView" id="treeview_servers"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="enable_search">False</property> - </widget> - </child> - </widget> - <packing> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkVButtonBox" id="vbuttonbox1"> - <property name="visible">True</property> - <property name="spacing">6</property> - <property name="layout_style">GTK_BUTTONBOX_START</property> - <child> - <widget class="GtkButton" id="button_add"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_remove"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-remove</property> - <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_up"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-go-up</property> - <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_down"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-go-down</property> - <property name="use_stock">True</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="position">3</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label_servers"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Servers</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="position">2</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area10"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button_close"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-close</property> - <property name="use_stock">True</property> - <property name="response_id">-7</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.h b/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.h deleted file mode 100644 index 6ead048eb..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-irc.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __EMPATHY_ACCOUNT_WIDGET_IRC_H__ -#define __EMPATHY_ACCOUNT_WIDGET_IRC_H__ - -#include <gtk/gtkwidget.h> -#include <libmissioncontrol/mc-account.h> - -G_BEGIN_DECLS - -GtkWidget * empathy_account_widget_irc_new (McAccount *account); - -G_END_DECLS - -#endif /* __EMPATHY_ACCOUNT_WIDGET_IRC_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-jabber.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-jabber.glade deleted file mode 100644 index 6e221e380..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-jabber.glade +++ /dev/null @@ -1,337 +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="account_jabber_settings"> - <property name="visible">True</property> - <property name="title">jabber account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_jabber_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Login I_D:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image834"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_resource"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_priority"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">0 -128 127 1 10 0</property> - <property name="climb_rate">1</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_ignore_ssl_errors"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Ignore SSL certificate errors</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_priority"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pri_ority:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_priority</property> - </widget> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_resource"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Reso_urce:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_resource</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_encryption"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Encryption required (TLS/SSL)</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkFrame" id="frame1"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkTable" id="table1"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">5222 0 65555 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_ssl"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use old SS_L</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Override server settings</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-msn.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-msn.glade deleted file mode 100644 index 81a02052e..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-msn.glade +++ /dev/null @@ -1,192 +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="account_msn_settings"> - <property name="visible">True</property> - <property name="title">msn account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_msn_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_msn_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Login I_D:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table_advanced_msn_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="adjustment">0 0 65535 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-salut.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-salut.glade deleted file mode 100644 index 57fd822e3..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-salut.glade +++ /dev/null @@ -1,219 +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="account_salut_settings"> - <property name="visible">True</property> - <property name="title">salut account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_salut_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_nickname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_last_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_first_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_nickname"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Nickname:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_nickname</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_last_name"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Last Name:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_last_name</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_first_name"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_First Name:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_first_name</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_published"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_published"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Published Name:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_published</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_jid"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_email"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_jid"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Jabber ID:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_jid</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_email"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Email:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_email</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.c b/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.c deleted file mode 100644 index c5224df73..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - * Frederic Peters <fpeters@0d.be> - */ - -#include "config.h" - -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mc-protocol.h> - -#include <libempathy/empathy-utils.h> - -#include "empathy-account-widget.h" -#include "empathy-account-widget-sip.h" -#include "empathy-ui-utils.h" - -typedef struct { - McAccount *account; - - GtkWidget *vbox_settings; - - GtkWidget *entry_stun_server; - GtkWidget *spinbutton_stun_part; - GtkWidget *checkbutton_discover_stun; -} EmpathyAccountWidgetSip; - -static void -account_widget_sip_destroy_cb (GtkWidget *widget, - EmpathyAccountWidgetSip *settings) -{ - g_object_unref (settings->account); - g_slice_free (EmpathyAccountWidgetSip, settings); -} - -static void -account_widget_sip_discover_stun_toggled_cb ( - GtkWidget *checkbox, - EmpathyAccountWidgetSip *settings) -{ - gboolean active; - - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); - gtk_widget_set_sensitive(settings->entry_stun_server, !active); - gtk_widget_set_sensitive(settings->spinbutton_stun_part, !active); -} - -/** - * empathy_account_widget_sip_new: - * @account: the #McAccount to configure - * - * Creates a new SIP account widget to configure a given #McAccount - * - * Returns: The toplevel container of the configuration widget - */ -GtkWidget * -empathy_account_widget_sip_new (McAccount *account) -{ - EmpathyAccountWidgetSip *settings; - GladeXML *glade; - gchar *filename; - - settings = g_slice_new0 (EmpathyAccountWidgetSip); - settings->account = g_object_ref (account); - - filename = empathy_file_lookup ("empathy-account-widget-sip.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_sip_settings", - NULL, - "vbox_sip_settings", &settings->vbox_settings, - "entry_stun-server", &settings->entry_stun_server, - "spinbutton_stun-port", &settings->spinbutton_stun_part, - "checkbutton_discover-stun", &settings->checkbutton_discover_stun, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_userid", "account", - "entry_password", "password", - "checkbutton_discover-stun", "discover-stun", - "entry_stun-server", "stun-server", - "spinbutton_stun-port", "stun-port", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun, - settings); - - empathy_glade_connect (glade, settings, - "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb, - "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb, - NULL); - - g_object_unref (glade); - - return settings->vbox_settings; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.glade deleted file mode 100644 index 3d026de1c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.glade +++ /dev/null @@ -1,208 +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="account_sip_settings"> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_sip_settings"> - <property name="visible">True</property> - <child> - <widget class="GtkTable" id="table1"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_userid"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_userid"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Username:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image6"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander_advanced"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkTable" id="table_advanced_sip_settings"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkEntry" id="entry_stun-server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_stun-port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">STUN port:</property> - <property name="mnemonic_widget">spinbutton_stun-port</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_stun-server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">STUN Server:</property> - <property name="mnemonic_widget">entry_stun-server</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_stun-port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">0 0 65535 1 10 0</property> - <property name="climb_rate">1</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_discover-stun"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes" comments="look up the DNS SRV record at the service's domain for the host name of a STUN server.">Discover STUN</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label_expander"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.h b/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.h deleted file mode 100644 index 7e8e5a216..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-sip.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Frederic Peters <fpeters@0d.be> - */ - -#ifndef __EMPATHY_ACCOUNT_WIDGET_SIP_H__ -#define __EMPATHY_ACCOUNT_WIDGET_SIP_H__ - -#include <gtk/gtkwidget.h> -#include <libmissioncontrol/mc-account.h> - -G_BEGIN_DECLS - -GtkWidget * empathy_account_widget_sip_new (McAccount *account); - -G_END_DECLS - -#endif /* __EMPATHY_ACCOUNT_WIDGET_SIP_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget-yahoo.glade b/gnome-2-26/libempathy-gtk/empathy-account-widget-yahoo.glade deleted file mode 100644 index ca64533ee..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget-yahoo.glade +++ /dev/null @@ -1,287 +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="account_yahoo_settings"> - <property name="visible">True</property> - <property name="title">Yahoo! account settings</property> - <property name="resizable">False</property> - <child> - <widget class="GtkVBox" id="vbox_yahoo_settings"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_common_settings"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_forget"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Forget password and clear the entry.</property> - <property name="response_id">0</property> - <child> - <widget class="GtkImage" id="image834"> - <property name="visible">True</property> - <property name="stock">gtk-clear</property> - <property name="icon_size">1</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Yahoo I_D:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <child> - <widget class="GtkTable" id="table_advanced_settings"> - <property name="visible">True</property> - <property name="n_rows">6</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkCheckButton" id="checkbutton_ignore_invites"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Ignore conference and chatroom invitations</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_locale"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Room List locale:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_locale</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Charset:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_charset</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_locale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_charset"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </widget> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </widget> - <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">5050 1 65555 1 10 0</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_yahoojp"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use _Yahoo Japan</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">2</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Advanced</b></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget.c b/gnome-2-26/libempathy-gtk/empathy-account-widget.c deleted file mode 100644 index b48d19e53..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget.c +++ /dev/null @@ -1,747 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Xavier Claessens <xclaesse@gmail.com> - * Martyn Russell <martyn@imendio.com> - */ - -#include <config.h> - -#include <string.h> - -#include <gtk/gtk.h> -#include <glib/gi18n-lib.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mc-protocol.h> - -#include <libempathy/empathy-utils.h> - -#include "empathy-account-widget.h" -#include "empathy-ui-utils.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT -#include <libempathy/empathy-debug.h> - -static gboolean -account_widget_entry_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - McAccount *account) -{ - const gchar *str; - const gchar *param_name; - - str = gtk_entry_get_text (GTK_ENTRY (widget)); - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - if (EMP_STR_EMPTY (str)) { - gchar *value = NULL; - - mc_account_unset_param (account, param_name); - mc_account_get_param_string (account, param_name, &value); - DEBUG ("Unset %s and restore to %s", param_name, value); - gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); - g_free (value); - } else { - McProfile *profile; - const gchar *domain = NULL; - gchar *dup_str = NULL; - - profile = mc_account_get_profile (account); - if (mc_profile_get_capabilities (profile) & - MC_PROFILE_CAPABILITY_SPLIT_ACCOUNT) { - domain = mc_profile_get_default_account_domain (profile); - } - - if (domain && !strstr (str, "@") && - strcmp (param_name, "account") == 0) { - DEBUG ("Adding @%s suffix to account", domain); - str = dup_str = g_strconcat (str, "@", domain, NULL); - gtk_entry_set_text (GTK_ENTRY (widget), str); - } - DEBUG ("Setting %s to %s", param_name, - strstr (param_name, "password") ? "***" : str); - mc_account_set_param_string (account, param_name, str); - g_free (dup_str); - g_object_unref (profile); - } - - return FALSE; -} - -static void -account_widget_int_changed_cb (GtkWidget *widget, - McAccount *account) -{ - const gchar *param_name; - gint value; - - value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - if (value == 0) { - mc_account_unset_param (account, param_name); - mc_account_get_param_int (account, param_name, &value); - DEBUG ("Unset %s and restore to %d", param_name, value); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); - } else { - DEBUG ("Setting %s to %d", param_name, value); - mc_account_set_param_int (account, param_name, value); - } -} - -static void -account_widget_checkbutton_toggled_cb (GtkWidget *widget, - McAccount *account) -{ - gboolean value; - gboolean default_value; - const gchar *param_name; - - value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - /* FIXME: This is ugly! checkbox don't have a "not-set" value so we - * always unset the param and set the value if different from the - * default value. */ - mc_account_unset_param (account, param_name); - mc_account_get_param_boolean (account, param_name, &default_value); - - if (default_value == value) { - DEBUG ("Unset %s and restore to %d", param_name, default_value); - } else { - DEBUG ("Setting %s to %d", param_name, value); - mc_account_set_param_boolean (account, param_name, value); - } -} - -static void -account_widget_forget_clicked_cb (GtkWidget *button, - GtkWidget *entry) -{ - McAccount *account; - const gchar *param_name; - - param_name = g_object_get_data (G_OBJECT (entry), "param_name"); - account = g_object_get_data (G_OBJECT (entry), "account"); - - DEBUG ("Unset %s", param_name); - mc_account_unset_param (account, param_name); - gtk_entry_set_text (GTK_ENTRY (entry), ""); -} - -static void -account_widget_password_changed_cb (GtkWidget *entry, - GtkWidget *button) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (entry)); - gtk_widget_set_sensitive (button, !EMP_STR_EMPTY (str)); -} - -static void -account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, - GtkWidget *spinbutton_port) -{ - McAccount *account; - gboolean value; - gint port = 0; - - value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl)); - account = g_object_get_data (G_OBJECT (spinbutton_port), "account"); - mc_account_get_param_int (account, "port", &port); - - if (value) { - if (port == 5222 || port == 0) { - port = 5223; - } - } else { - if (port == 5223 || port == 0) { - port = 5222; - } - } - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_port), port); -} - -static void -account_widget_setup_widget (GtkWidget *widget, - McAccount *account, - const gchar *param_name) -{ - g_object_set_data_full (G_OBJECT (widget), "param_name", - g_strdup (param_name), g_free); - g_object_set_data_full (G_OBJECT (widget), "account", - g_object_ref (account), g_object_unref); - - if (GTK_IS_SPIN_BUTTON (widget)) { - gint value = 0; - - mc_account_get_param_int (account, param_name, &value); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); - - g_signal_connect (widget, "value-changed", - G_CALLBACK (account_widget_int_changed_cb), - account); - } - else if (GTK_IS_ENTRY (widget)) { - gchar *str = NULL; - - mc_account_get_param_string (account, param_name, &str); - gtk_entry_set_text (GTK_ENTRY (widget), str ? str : ""); - g_free (str); - - if (strstr (param_name, "password")) { - gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE); - } - - g_signal_connect (widget, "focus-out-event", - G_CALLBACK (account_widget_entry_focus_cb), - account); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - gboolean value = FALSE; - - mc_account_get_param_boolean (account, param_name, &value); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); - - g_signal_connect (widget, "toggled", - G_CALLBACK (account_widget_checkbutton_toggled_cb), - account); - } else { - DEBUG ("Unknown type of widget for param %s", param_name); - } -} - -static gchar * -account_widget_generic_format_param_name (const gchar *param_name) -{ - gchar *str; - gchar *p; - - str = g_strdup (param_name); - - if (str && g_ascii_isalpha (str[0])) { - str[0] = g_ascii_toupper (str[0]); - } - - while ((p = strchr (str, '-')) != NULL) { - if (p[1] != '\0' && g_ascii_isalpha (p[1])) { - p[0] = ' '; - p[1] = g_ascii_toupper (p[1]); - } - - p++; - } - - return str; -} - -static void -accounts_widget_generic_setup (McAccount *account, - GtkWidget *table_common_settings, - GtkWidget *table_advanced_settings) -{ - McProtocol *protocol; - McProfile *profile; - GSList *params, *l; - - profile = mc_account_get_profile (account); - protocol = mc_profile_get_protocol (profile); - - if (!protocol) { - /* The CM is not installed, MC shouldn't list them - * see SF bug #1688779 - * FIXME: We should display something asking the user to - * install the CM - */ - g_object_unref (profile); - return; - } - - params = mc_protocol_get_params (protocol); - - for (l = params; l; l = l->next) { - McProtocolParam *param; - GtkWidget *table_settings; - guint n_rows = 0; - GtkWidget *widget = NULL; - gchar *param_name_formatted; - - param = l->data; - if (param->flags & MC_PROTOCOL_PARAM_REQUIRED) { - table_settings = table_common_settings; - } else { - table_settings = table_advanced_settings; - } - param_name_formatted = account_widget_generic_format_param_name (param->name); - g_object_get (table_settings, "n-rows", &n_rows, NULL); - gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2); - - if (param->signature[0] == 's') { - gchar *str; - - str = g_strdup_printf (_("%s:"), param_name_formatted); - widget = gtk_label_new (str); - gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5); - g_free (str); - - gtk_table_attach (GTK_TABLE (table_settings), - widget, - 0, 1, - n_rows - 1, n_rows, - GTK_FILL, 0, - 0, 0); - - widget = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table_settings), - widget, - 1, 2, - n_rows - 1, n_rows, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - } - /* int types: ynqiuxt. double type is 'd' */ - else if (param->signature[0] == 'y' || - param->signature[0] == 'n' || - param->signature[0] == 'q' || - param->signature[0] == 'i' || - param->signature[0] == 'u' || - param->signature[0] == 'x' || - param->signature[0] == 't' || - param->signature[0] == 'd') { - gchar *str = NULL; - gdouble minint = 0; - gdouble maxint = 0; - gdouble step = 1; - - switch (param->signature[0]) { - case 'y': minint = G_MININT8; maxint = G_MAXINT8; break; - case 'n': minint = G_MININT16; maxint = G_MAXINT16; break; - case 'q': minint = 0; maxint = G_MAXUINT16; break; - case 'i': minint = G_MININT32; maxint = G_MAXINT32; break; - case 'u': minint = 0; maxint = G_MAXUINT32; break; - case 'x': minint = G_MININT64; maxint = G_MAXINT64; break; - case 't': minint = 0; maxint = G_MAXUINT64; break; - case 'd': minint = G_MININT32; maxint = G_MAXINT32; step = 0.1; break; - } - - str = g_strdup_printf (_("%s:"), param_name_formatted); - widget = gtk_label_new (str); - gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5); - g_free (str); - - gtk_table_attach (GTK_TABLE (table_settings), - widget, - 0, 1, - n_rows - 1, n_rows, - GTK_FILL, 0, - 0, 0); - - widget = gtk_spin_button_new_with_range (minint, maxint, step); - gtk_table_attach (GTK_TABLE (table_settings), - widget, - 1, 2, - n_rows - 1, n_rows, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - } - else if (param->signature[0] == 'b') { - widget = gtk_check_button_new_with_label (param_name_formatted); - gtk_table_attach (GTK_TABLE (table_settings), - widget, - 0, 2, - n_rows - 1, n_rows, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - } else { - DEBUG ("Unknown signature for param %s: %s", - param_name_formatted, param->signature); - } - - if (widget) { - account_widget_setup_widget (widget, account, param->name); - } - - g_free (param_name_formatted); - } - - g_slist_free (params); - g_object_unref (profile); - g_object_unref (protocol); -} - -static void -account_widget_handle_params_valist (McAccount *account, - GladeXML *gui, - const gchar *first_widget_name, - va_list args) -{ - GtkWidget *widget; - const gchar *widget_name; - - for (widget_name = first_widget_name; widget_name; widget_name = va_arg (args, gchar*)) { - const gchar *param_name; - - param_name = va_arg (args, gchar*); - - widget = glade_xml_get_widget (gui, widget_name); - - if (!widget) { - g_warning ("Glade is missing widget '%s'.", widget_name); - continue; - } - - account_widget_setup_widget (widget, account, param_name); - } -} - -void -empathy_account_widget_handle_params (McAccount *account, - GladeXML *gui, - const gchar *first_widget_name, - ...) -{ - va_list args; - - g_return_if_fail (MC_IS_ACCOUNT (account)); - - va_start (args, first_widget_name); - account_widget_handle_params_valist (account, gui, - first_widget_name, - args); - va_end (args); -} - -void -empathy_account_widget_add_forget_button (McAccount *account, - GladeXML *glade, - const gchar *button, - const gchar *entry) -{ - GtkWidget *button_forget; - GtkWidget *entry_password; - gchar *password = NULL; - - button_forget = glade_xml_get_widget (glade, button); - entry_password = glade_xml_get_widget (glade, entry); - - mc_account_get_param_string (account, "password", &password); - gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password)); - g_free (password); - - g_signal_connect (button_forget, "clicked", - G_CALLBACK (account_widget_forget_clicked_cb), - entry_password); - g_signal_connect (entry_password, "changed", - G_CALLBACK (account_widget_password_changed_cb), - button_forget); -} - -GtkWidget * -empathy_account_widget_generic_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - GtkWidget *table_common_settings; - GtkWidget *table_advanced_settings; - gchar *filename; - - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - - filename = empathy_file_lookup ("empathy-account-widget-generic.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_generic_settings", - NULL, - "vbox_generic_settings", &widget, - "table_common_settings", &table_common_settings, - "table_advanced_settings", &table_advanced_settings, - NULL); - g_free (filename); - - accounts_widget_generic_setup (account, table_common_settings, table_advanced_settings); - - g_object_unref (glade); - - gtk_widget_show_all (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_salut_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-salut.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_salut_settings", - NULL, - "vbox_salut_settings", &widget, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_published", "published-name", - "entry_nickname", "nickname", - "entry_first_name", "first-name", - "entry_last_name", "last-name", - "entry_email", "email", - "entry_jid", "jid", - NULL); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_msn_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-msn.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_msn_settings", - NULL, - "vbox_msn_settings", &widget, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_id", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_jabber_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - GtkWidget *spinbutton_port; - GtkWidget *checkbutton_ssl; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-jabber.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_jabber_settings", - NULL, - "vbox_jabber_settings", &widget, - "spinbutton_port", &spinbutton_port, - "checkbutton_ssl", &checkbutton_ssl, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_id", "account", - "entry_password", "password", - "entry_resource", "resource", - "entry_server", "server", - "spinbutton_port", "port", - "spinbutton_priority", "priority", - "checkbutton_ssl", "old-ssl", - "checkbutton_ignore_ssl_errors", "ignore-ssl-errors", - "checkbutton_encryption", "require-encryption", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_signal_connect (checkbutton_ssl, "toggled", - G_CALLBACK (account_widget_jabber_ssl_toggled_cb), - spinbutton_port); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_icq_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - GtkWidget *spinbutton_port; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-icq.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_icq_settings", - NULL, - "vbox_icq_settings", &widget, - "spinbutton_port", &spinbutton_port, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_uin", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - "entry_charset", "charset", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_aim_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - GtkWidget *spinbutton_port; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-aim.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_aim_settings", - NULL, - "vbox_aim_settings", &widget, - "spinbutton_port", &spinbutton_port, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_screenname", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_yahoo_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-yahoo.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_yahoo_settings", - NULL, - "vbox_yahoo_settings", &widget, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_id", "account", - "entry_password", "password", - "entry_server", "server", - "entry_locale", "room-list-locale", - "entry_charset", "charset", - "spinbutton_port", "port", - "checkbutton_yahoojp", "yahoojp", - "checkbutton_ignore_invites", "ignore-invites", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - -GtkWidget * -empathy_account_widget_groupwise_new (McAccount *account) -{ - GladeXML *glade; - GtkWidget *widget; - gchar *filename; - - filename = empathy_file_lookup ("empathy-account-widget-groupwise.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_groupwise_settings", - NULL, - "vbox_groupwise_settings", &widget, - NULL); - g_free (filename); - - empathy_account_widget_handle_params (account, glade, - "entry_id", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - empathy_account_widget_add_forget_button (account, glade, - "button_forget", - "entry_password"); - - g_object_unref (glade); - - gtk_widget_show (widget); - - return widget; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-account-widget.h b/gnome-2-26/libempathy-gtk/empathy-account-widget.h deleted file mode 100644 index 52e907d00..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-account-widget.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Xavier Claessens <xclaesse@gmail.com> - * Martyn Russell <martyn@imendio.com> - */ - -#ifndef __EMPATHY_ACCOUNT_WIDGET_GENERIC_H__ -#define __EMPATHY_ACCOUNT_WIDGET_GENERIC_H__ - -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mc-account.h> - -G_BEGIN_DECLS - -void empathy_account_widget_handle_params (McAccount *account, - GladeXML *glade, - const gchar *first_widget_name, - ...); -void empathy_account_widget_add_forget_button (McAccount *account, - GladeXML *glade, - const gchar *button, - const gchar *entry); -GtkWidget *empathy_account_widget_generic_new (McAccount *account); -GtkWidget *empathy_account_widget_salut_new (McAccount *account); -GtkWidget *empathy_account_widget_msn_new (McAccount *account); -GtkWidget *empathy_account_widget_jabber_new (McAccount *account); -GtkWidget *empathy_account_widget_icq_new (McAccount *account); -GtkWidget *empathy_account_widget_aim_new (McAccount *account); -GtkWidget *empathy_account_widget_yahoo_new (McAccount *account); -GtkWidget *empathy_account_widget_groupwise_new (McAccount *account); - -G_END_DECLS - -#endif /* __EMPATHY_ACCOUNT_WIDGET_GENERIC_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-audio-sink.c b/gnome-2-26/libempathy-gtk/empathy-audio-sink.c deleted file mode 100644 index 55f64e828..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-audio-sink.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * empathy-gst-audio-sink.c - Source for EmpathyGstAudioSink - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <stdio.h> -#include <stdlib.h> - -#include <gst/farsight/fs-element-added-notifier.h> - -#include "empathy-audio-sink.h" - - -G_DEFINE_TYPE(EmpathyGstAudioSink, empathy_audio_sink, GST_TYPE_BIN) - -/* signal enum */ -#if 0 -enum -{ - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; -#endif - -enum { - PROP_VOLUME = 1, -}; - -/* private structure */ -typedef struct _EmpathyGstAudioSinkPrivate EmpathyGstAudioSinkPrivate; - -struct _EmpathyGstAudioSinkPrivate -{ - gboolean dispose_has_run; - GstElement *sink; - GstElement *volume; - FsElementAddedNotifier *notifier; -}; - -#define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_AUDIO_SINK, \ - EmpathyGstAudioSinkPrivate)) - -static void -empathy_audio_sink_element_added_cb (FsElementAddedNotifier *notifier, - GstBin *bin, GstElement *element, EmpathyGstAudioSink *self) -{ - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self); - - if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume")) - { - gdouble volume; - - volume = empathy_audio_sink_get_volume (self); - empathy_audio_sink_set_volume (self, 1.0); - - if (priv->volume != NULL) - g_object_unref (priv->volume); - priv->volume = g_object_ref (element); - - if (volume != 1.0) - empathy_audio_sink_set_volume (self, volume); - } -} - -static void -empathy_audio_sink_init (EmpathyGstAudioSink *obj) -{ - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (obj); - GstElement *resample; - GstPad *ghost, *sink; - - priv->notifier = fs_element_added_notifier_new (); - g_signal_connect (priv->notifier, "element-added", - G_CALLBACK (empathy_audio_sink_element_added_cb), obj); - - resample = gst_element_factory_make ("audioresample", NULL); - - priv->volume = gst_element_factory_make ("volume", NULL); - g_object_ref (priv->volume); - - priv->sink = gst_element_factory_make ("gconfaudiosink", NULL); - - fs_element_added_notifier_add (priv->notifier, GST_BIN (priv->sink)); - - gst_bin_add_many (GST_BIN (obj), resample, priv->volume, priv->sink, NULL); - gst_element_link_many (resample, priv->volume, priv->sink, NULL); - - sink = gst_element_get_static_pad (resample, "sink"); - - ghost = gst_ghost_pad_new ("sink", sink); - gst_element_add_pad (GST_ELEMENT (obj), ghost); - - gst_object_unref (G_OBJECT (sink)); -} - -static void empathy_audio_sink_dispose (GObject *object); -static void empathy_audio_sink_finalize (GObject *object); - -static void -empathy_audio_sink_set_property (GObject *object, - guint property_id, const GValue *value, GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_VOLUME: - empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (object), - g_value_get_double (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -empathy_audio_sink_get_property (GObject *object, - guint property_id, GValue *value, GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_VOLUME: - g_value_set_double (value, - empathy_audio_sink_get_volume (EMPATHY_GST_AUDIO_SINK (object))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -empathy_audio_sink_class_init (EmpathyGstAudioSinkClass - *empathy_audio_sink_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_sink_class); - GParamSpec *param_spec; - - g_type_class_add_private (empathy_audio_sink_class, - sizeof (EmpathyGstAudioSinkPrivate)); - - object_class->dispose = empathy_audio_sink_dispose; - object_class->finalize = empathy_audio_sink_finalize; - - object_class->set_property = empathy_audio_sink_set_property; - object_class->get_property = empathy_audio_sink_get_property; - - param_spec = g_param_spec_double ("volume", "Volume", "volume control", - 0.0, 5.0, 1.0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_VOLUME, param_spec); -} - -void -empathy_audio_sink_dispose (GObject *object) -{ - EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (object); - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (priv->notifier != NULL) - g_object_unref (priv->notifier); - priv->notifier = NULL; - - if (priv->volume != NULL) - g_object_unref (priv->volume); - priv->volume = NULL; - - if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose) - G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose (object); -} - -void -empathy_audio_sink_finalize (GObject *object) -{ - //EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (object); - //EmpathyGstAudioSinkPrivate *priv = - // EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (empathy_audio_sink_parent_class)->finalize (object); -} - -GstElement * -empathy_audio_sink_new (void) -{ - return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_AUDIO_SINK, NULL)); -} - -void -empathy_audio_sink_set_volume (EmpathyGstAudioSink *sink, gdouble volume) -{ - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink); - - g_object_set (G_OBJECT (priv->volume), "volume", volume, NULL); -} - -gdouble -empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink) -{ - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink); - gdouble volume; - - g_object_get (G_OBJECT (priv->volume), "volume", &volume, NULL); - - return volume; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-audio-sink.h b/gnome-2-26/libempathy-gtk/empathy-audio-sink.h deleted file mode 100644 index 57579dc3e..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-audio-sink.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * empathy-gst-video-sink.h - Header for EmpathyGstAudioSink - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __EMPATHY_GST_AUDIO_SINK_H__ -#define __EMPATHY_GST_AUDIO_SINK_H__ - -#include <glib-object.h> -#include <gst/gst.h> - -G_BEGIN_DECLS - -typedef struct _EmpathyGstAudioSink EmpathyGstAudioSink; -typedef struct _EmpathyGstAudioSinkClass EmpathyGstAudioSinkClass; - -struct _EmpathyGstAudioSinkClass { - GstBinClass parent_class; -}; - -struct _EmpathyGstAudioSink { - GstBin parent; -}; - -GType empathy_audio_sink_get_type (void); - -/* TYPE MACROS */ -#define EMPATHY_TYPE_GST_AUDIO_SINK \ - (empathy_audio_sink_get_type()) -#define EMPATHY_GST_AUDIO_SINK(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_GST_AUDIO_SINK, \ - EmpathyGstAudioSink)) -#define EMPATHY_GST_AUDIO_SINK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_GST_AUDIO_SINK, \ - EmpathyGstAudioSinkClass)) -#define EMPATHY_IS_GST_AUDIO_SINK(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_GST_AUDIO_SINK)) -#define EMPATHY_IS_GST_AUDIO_SINK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_GST_AUDIO_SINK)) -#define EMPATHY_GST_AUDIO_SINK_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_GST_AUDIO_SINK, \ - EmpathyGstAudioSinkClass)) - -GstElement *empathy_audio_sink_new (void); - -void empathy_audio_sink_set_volume (EmpathyGstAudioSink *sink, gdouble volume); - -gdouble empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink); - -G_END_DECLS - -#endif /* #ifndef __EMPATHY_GST_AUDIO_SINK_H__*/ diff --git a/gnome-2-26/libempathy-gtk/empathy-audio-src.c b/gnome-2-26/libempathy-gtk/empathy-audio-src.c deleted file mode 100644 index 0497439bf..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-audio-src.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * empathy-gst-audio-src.c - Source for EmpathyGstAudioSrc - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <stdio.h> -#include <stdlib.h> - -#include <gst/farsight/fs-element-added-notifier.h> -#include "empathy-audio-src.h" - -G_DEFINE_TYPE(EmpathyGstAudioSrc, empathy_audio_src, GST_TYPE_BIN) - -/* signal enum */ -enum -{ - PEAK_LEVEL_CHANGED, - RMS_LEVEL_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -enum { - PROP_VOLUME = 1, - PROP_RMS_LEVEL, - PROP_PEAK_LEVEL, -}; - -/* private structure */ -typedef struct _EmpathyGstAudioSrcPrivate EmpathyGstAudioSrcPrivate; - -struct _EmpathyGstAudioSrcPrivate -{ - gboolean dispose_has_run; - GstElement *src; - GstElement *volume; - GstElement *level; - FsElementAddedNotifier *notifier; - - gdouble peak_level; - gdouble rms_level; - - GMutex *lock; - guint idle_id; -}; - -#define EMPATHY_GST_AUDIO_SRC_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_AUDIO_SRC, \ - EmpathyGstAudioSrcPrivate)) - -static void -empathy_audio_src_element_added_cb (FsElementAddedNotifier *notifier, - GstBin *bin, GstElement *element, EmpathyGstAudioSrc *self) -{ - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume")) - { - gdouble volume; - - volume = empathy_audio_src_get_volume (self); - empathy_audio_src_set_volume (self, 1.0); - - if (priv->volume != NULL) - g_object_unref (priv->volume); - priv->volume = g_object_ref (element); - - if (volume != 1.0) - empathy_audio_src_set_volume (self, volume); - } -} - -static void -empathy_audio_src_init (EmpathyGstAudioSrc *obj) -{ - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj); - GstPad *ghost, *src; - - priv->peak_level = -G_MAXDOUBLE; - priv->lock = g_mutex_new (); - - priv->notifier = fs_element_added_notifier_new (); - g_signal_connect (priv->notifier, "element-added", - G_CALLBACK (empathy_audio_src_element_added_cb), obj); - - priv->src = gst_element_factory_make ("gconfaudiosrc", NULL); - gst_bin_add (GST_BIN (obj), priv->src); - - fs_element_added_notifier_add (priv->notifier, GST_BIN (priv->src)); - - priv->volume = gst_element_factory_make ("volume", NULL); - g_object_ref (priv->volume); - - gst_bin_add (GST_BIN (obj), priv->volume); - gst_element_link (priv->src, priv->volume); - - priv->level = gst_element_factory_make ("level", NULL); - gst_bin_add (GST_BIN (obj), priv->level); - gst_element_link (priv->volume, priv->level); - - src = gst_element_get_static_pad (priv->level, "src"); - - ghost = gst_ghost_pad_new ("src", src); - gst_element_add_pad (GST_ELEMENT (obj), ghost); - - gst_object_unref (G_OBJECT (src)); -} - -static void empathy_audio_src_dispose (GObject *object); -static void empathy_audio_src_finalize (GObject *object); -static void empathy_audio_src_handle_message (GstBin *bin, - GstMessage *message); - -static gboolean empathy_audio_src_levels_updated (gpointer user_data); - -static void -empathy_audio_src_set_property (GObject *object, - guint property_id, const GValue *value, GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_VOLUME: - empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (object), - g_value_get_double (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -empathy_audio_src_get_property (GObject *object, - guint property_id, GValue *value, GParamSpec *pspec) -{ - EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (object); - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - switch (property_id) - { - case PROP_VOLUME: - g_value_set_double (value, - empathy_audio_src_get_volume (self)); - break; - case PROP_PEAK_LEVEL: - g_mutex_lock (priv->lock); - g_value_set_double (value, priv->peak_level); - g_mutex_unlock (priv->lock); - break; - case PROP_RMS_LEVEL: - g_mutex_lock (priv->lock); - g_value_set_double (value, priv->rms_level); - g_mutex_unlock (priv->lock); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -empathy_audio_src_class_init (EmpathyGstAudioSrcClass - *empathy_audio_src_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_src_class); - GstBinClass *gstbin_class = GST_BIN_CLASS (empathy_audio_src_class); - GParamSpec *param_spec; - - g_type_class_add_private (empathy_audio_src_class, - sizeof (EmpathyGstAudioSrcPrivate)); - - object_class->dispose = empathy_audio_src_dispose; - object_class->finalize = empathy_audio_src_finalize; - - object_class->set_property = empathy_audio_src_set_property; - object_class->get_property = empathy_audio_src_get_property; - - gstbin_class->handle_message = - GST_DEBUG_FUNCPTR (empathy_audio_src_handle_message); - - param_spec = g_param_spec_double ("volume", "Volume", "volume contol", - 0.0, 5.0, 1.0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_VOLUME, param_spec); - - param_spec = g_param_spec_double ("peak-level", "peak level", "peak level", - -G_MAXDOUBLE, G_MAXDOUBLE, 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_VOLUME, param_spec); - - signals[PEAK_LEVEL_CHANGED] = g_signal_new ("peak-level-changed", - G_TYPE_FROM_CLASS (empathy_audio_src_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); - - param_spec = g_param_spec_double ("rms-level", "RMS level", "RMS level", - -G_MAXDOUBLE, G_MAXDOUBLE, 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_VOLUME, param_spec); - - - signals[RMS_LEVEL_CHANGED] = g_signal_new ("rms-level-changed", - G_TYPE_FROM_CLASS (empathy_audio_src_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); -} - -void -empathy_audio_src_dispose (GObject *object) -{ - EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (object); - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (priv->idle_id != 0) - g_source_remove (priv->idle_id); - - priv->idle_id = 0; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (empathy_audio_src_parent_class)->dispose) - G_OBJECT_CLASS (empathy_audio_src_parent_class)->dispose (object); -} - -void -empathy_audio_src_finalize (GObject *object) -{ - EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (object); - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - g_mutex_free (priv->lock); - - G_OBJECT_CLASS (empathy_audio_src_parent_class)->finalize (object); -} - -static gboolean -empathy_audio_src_levels_updated (gpointer user_data) -{ - EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (user_data); - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - g_mutex_lock (priv->lock); - - g_signal_emit (self, signals[PEAK_LEVEL_CHANGED], 0, priv->peak_level); - g_signal_emit (self, signals[RMS_LEVEL_CHANGED], 0, priv->rms_level); - priv->idle_id = 0; - - g_mutex_unlock (priv->lock); - - return FALSE; -} - -static void -empathy_audio_src_handle_message (GstBin *bin, GstMessage *message) -{ - EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (bin); - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - - if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT && - GST_MESSAGE_SRC (message) == GST_OBJECT (priv->level)) - { - const GstStructure *s; - const gchar *name; - const GValue *list; - guint i, len; - gdouble peak = -G_MAXDOUBLE; - gdouble rms = -G_MAXDOUBLE; - - s = gst_message_get_structure (message); - name = gst_structure_get_name (s); - - if (g_strcmp0 ("level", name) != 0) - goto out; - - list = gst_structure_get_value (s, "peak"); - len = gst_value_list_get_size (list); - - for (i =0 ; i < len; i++) - { - const GValue *value; - gdouble db; - - value = gst_value_list_get_value (list, i); - db = g_value_get_double (value); - peak = MAX (db, peak); - } - - list = gst_structure_get_value (s, "rms"); - len = gst_value_list_get_size (list); - - for (i =0 ; i < len; i++) - { - const GValue *value; - gdouble db; - - value = gst_value_list_get_value (list, i); - db = g_value_get_double (value); - rms = MAX (db, rms); - } - - g_mutex_lock (priv->lock); - - priv->peak_level = peak; - priv->rms_level = rms; - if (priv->idle_id == 0) - priv->idle_id = g_idle_add (empathy_audio_src_levels_updated, self); - - g_mutex_unlock (priv->lock); - } - -out: - GST_BIN_CLASS (empathy_audio_src_parent_class)->handle_message (bin, - message); -} - -GstElement * -empathy_audio_src_new (void) -{ - return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_AUDIO_SRC, NULL)); -} - -void -empathy_audio_src_set_volume (EmpathyGstAudioSrc *src, gdouble volume) -{ - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (src); - GParamSpec *pspec; - GParamSpecDouble *pspec_double; - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (priv->volume), - "volume"); - - g_assert (pspec != NULL); - - pspec_double = G_PARAM_SPEC_DOUBLE (pspec); - - volume = CLAMP (volume, pspec_double->minimum, pspec_double->maximum); - - g_object_set (G_OBJECT (priv->volume), "volume", volume, NULL); -} - -gdouble -empathy_audio_src_get_volume (EmpathyGstAudioSrc *src) -{ - EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (src); - gdouble volume; - - g_object_get (G_OBJECT (priv->volume), "volume", &volume, NULL); - - return volume; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-audio-src.h b/gnome-2-26/libempathy-gtk/empathy-audio-src.h deleted file mode 100644 index 4f48fe1f7..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-audio-src.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * empathy-gst-video-src.h - Header for EmpathyGstAudioSrc - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __EMPATHY_GST_AUDIO_SRC_H__ -#define __EMPATHY_GST_AUDIO_SRC_H__ - -#include <glib-object.h> -#include <gst/gst.h> - -G_BEGIN_DECLS - -typedef struct _EmpathyGstAudioSrc EmpathyGstAudioSrc; -typedef struct _EmpathyGstAudioSrcClass EmpathyGstAudioSrcClass; - -struct _EmpathyGstAudioSrcClass { - GstBinClass parent_class; -}; - -struct _EmpathyGstAudioSrc { - GstBin parent; -}; - -GType empathy_audio_src_get_type (void); - -/* TYPE MACROS */ -#define EMPATHY_TYPE_GST_AUDIO_SRC \ - (empathy_audio_src_get_type()) -#define EMPATHY_GST_AUDIO_SRC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_GST_AUDIO_SRC, \ - EmpathyGstAudioSrc)) -#define EMPATHY_GST_AUDIO_SRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_GST_AUDIO_SRC, \ - EmpathyGstAudioSrcClass)) -#define EMPATHY_IS_GST_AUDIO_SRC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_GST_AUDIO_SRC)) -#define EMPATHY_IS_GST_AUDIO_SRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_GST_AUDIO_SRC)) -#define EMPATHY_GST_AUDIO_SRC_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_GST_AUDIO_SRC, \ - EmpathyGstAudioSrcClass)) - -GstElement *empathy_audio_src_new (void); - -void empathy_audio_src_set_volume (EmpathyGstAudioSrc *src, gdouble volume); -gdouble empathy_audio_src_get_volume (EmpathyGstAudioSrc *src); - -G_END_DECLS - -#endif /* #ifndef __EMPATHY_GST_AUDIO_SRC_H__*/ diff --git a/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.c b/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.c deleted file mode 100644 index 5d1c90fcb..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.c +++ /dev/null @@ -1,1092 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-2007 Imendio AB. - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Based on Novell's e-image-chooser. - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <gio/gio.h> - -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-contact-factory.h> - -#include "empathy-avatar-chooser.h" -#include "empathy-conf.h" -#include "empathy-ui-utils.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#define AVATAR_SIZE_SAVE 96 -#define AVATAR_SIZE_VIEW 64 -#define DEFAULT_DIR DATADIR"/pixmaps/faces" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAvatarChooser) -typedef struct { - EmpathyContactFactory *contact_factory; - McAccount *account; - EmpathyTpContactFactory *tp_contact_factory; - GtkFileChooser *chooser_dialog; - - gulong ready_handler_id; - - EmpathyAvatar *avatar; -} EmpathyAvatarChooserPriv; - -static void avatar_chooser_finalize (GObject *object); -static void avatar_chooser_set_account (EmpathyAvatarChooser *self, - McAccount *account); -static void avatar_chooser_set_image (EmpathyAvatarChooser *chooser, - EmpathyAvatar *avatar, - GdkPixbuf *pixbuf, - gboolean set_locally); -static gboolean avatar_chooser_drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EmpathyAvatarChooser *chooser); -static void avatar_chooser_drag_leave_cb (GtkWidget *widget, - GdkDragContext *context, - guint time, - EmpathyAvatarChooser *chooser); -static gboolean avatar_chooser_drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EmpathyAvatarChooser *chooser); -static void avatar_chooser_drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint time, - EmpathyAvatarChooser *chooser); -static void avatar_chooser_clicked_cb (GtkWidget *button, - EmpathyAvatarChooser *chooser); - -enum { - CHANGED, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_ACCOUNT -}; - -static guint signals [LAST_SIGNAL]; - -G_DEFINE_TYPE (EmpathyAvatarChooser, empathy_avatar_chooser, GTK_TYPE_BUTTON); - -/* - * Drag and drop stuff - */ -#define URI_LIST_TYPE "text/uri-list" - -enum DndTargetType { - DND_TARGET_TYPE_URI_LIST -}; - -static const GtkTargetEntry drop_types[] = { - { URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST }, -}; - -static void -avatar_chooser_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (object); - - switch (param_id) { - case PROP_ACCOUNT: - g_value_set_object (value, priv->account); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -avatar_chooser_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyAvatarChooser *self = EMPATHY_AVATAR_CHOOSER (object); - - switch (param_id) { - case PROP_ACCOUNT: - avatar_chooser_set_account (self, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -empathy_avatar_chooser_class_init (EmpathyAvatarChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->finalize = avatar_chooser_finalize; - object_class->get_property = avatar_chooser_get_property; - object_class->set_property = avatar_chooser_set_property; - - signals[CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - param_spec = g_param_spec_object ("account", - "McAccount", - "McAccount whose avatar should be " - "shown and modified by this widget", - MC_TYPE_ACCOUNT, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - PROP_ACCOUNT, - param_spec); - - g_type_class_add_private (object_class, sizeof (EmpathyAvatarChooserPriv)); -} - -static void -empathy_avatar_chooser_init (EmpathyAvatarChooser *chooser) -{ - EmpathyAvatarChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser, - EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooserPriv); - - chooser->priv = priv; - gtk_drag_dest_set (GTK_WIDGET (chooser), - GTK_DEST_DEFAULT_ALL, - drop_types, - G_N_ELEMENTS (drop_types), - GDK_ACTION_COPY); - - g_signal_connect (chooser, "drag-motion", - G_CALLBACK (avatar_chooser_drag_motion_cb), - chooser); - g_signal_connect (chooser, "drag-leave", - G_CALLBACK (avatar_chooser_drag_leave_cb), - chooser); - g_signal_connect (chooser, "drag-drop", - G_CALLBACK (avatar_chooser_drag_drop_cb), - chooser); - g_signal_connect (chooser, "drag-data-received", - G_CALLBACK (avatar_chooser_drag_data_received_cb), - chooser); - g_signal_connect (chooser, "clicked", - G_CALLBACK (avatar_chooser_clicked_cb), - chooser); - - priv->contact_factory = empathy_contact_factory_dup_singleton (); - - empathy_avatar_chooser_set (chooser, NULL); -} - -static void -avatar_chooser_finalize (GObject *object) -{ - EmpathyAvatarChooserPriv *priv; - - priv = GET_PRIV (object); - - avatar_chooser_set_account (EMPATHY_AVATAR_CHOOSER (object), NULL); - g_assert (priv->account == NULL); - g_assert (priv->tp_contact_factory == NULL); - - g_object_unref (priv->contact_factory); - - if (priv->avatar != NULL) { - empathy_avatar_unref (priv->avatar); - } - - G_OBJECT_CLASS (empathy_avatar_chooser_parent_class)->finalize (object); -} - -static void -avatar_chooser_tp_cf_ready_cb (EmpathyTpContactFactory *tp_cf, - GParamSpec *unused, - EmpathyAvatarChooser *self) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (self); - gboolean ready; - - /* sanity check that we're listening on the right ETpCF */ - g_assert (priv->tp_contact_factory == tp_cf); - - ready = empathy_tp_contact_factory_is_ready (tp_cf); - gtk_widget_set_sensitive (GTK_WIDGET (self), ready); -} - -static void -avatar_chooser_set_account (EmpathyAvatarChooser *self, - McAccount *account) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (self); - - if (priv->account != NULL) { - g_object_unref (priv->account); - priv->account = NULL; - - g_assert (priv->tp_contact_factory != NULL); - - g_signal_handler_disconnect (priv->tp_contact_factory, - priv->ready_handler_id); - priv->ready_handler_id = 0; - - g_object_unref (priv->tp_contact_factory); - priv->tp_contact_factory = NULL; - } - - if (account != NULL) { - priv->account = g_object_ref (account); - priv->tp_contact_factory = g_object_ref ( - empathy_contact_factory_get_tp_factory ( - priv->contact_factory, priv->account)); - - priv->ready_handler_id = g_signal_connect ( - priv->tp_contact_factory, "notify::ready", - G_CALLBACK (avatar_chooser_tp_cf_ready_cb), self); - avatar_chooser_tp_cf_ready_cb (priv->tp_contact_factory, NULL, - self); - } -} - -static void -avatar_chooser_error_show (EmpathyAvatarChooser *chooser, - const gchar *primary_text, - const gchar *secondary_text) -{ - GtkWidget *parent; - GtkWidget *dialog; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (chooser)); - if (!GTK_IS_WINDOW (parent)) { - parent = NULL; - } - - dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CLOSE, - "%s", primary_text); - - if (secondary_text != NULL) { - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", secondary_text); - } - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - -} - -static gboolean -str_in_strv (const gchar *str, - gchar **strv) -{ - if (strv == NULL) { - return FALSE; - } - - while (*strv != NULL) { - if (g_str_equal (str, *strv)) { - return TRUE; - } - strv++; - } - return FALSE; -} - -/* The caller must free the strings stored in satisfactory_format_name and - * satisfactory_mime_type. - */ -static gboolean -avatar_chooser_need_mime_type_conversion (const gchar *current_mime_type, - gchar **accepted_mime_types, - gchar **satisfactory_format_name, - gchar **satisfactory_mime_type) -{ - gchar *good_mime_types[] = {"image/jpeg", "image/png", NULL}; - guint i; - GSList *formats, *l; - gboolean found = FALSE; - - *satisfactory_format_name = NULL; - *satisfactory_mime_type = NULL; - - /* If there is no accepted format there is nothing we can do */ - if (accepted_mime_types == NULL || *accepted_mime_types == NULL) { - return TRUE; - } - - /* If the current mime type is good and accepted, don't change it! - * jpeg is compress better pictures, but png is better for logos and - * could have an alpha layer. */ - if (str_in_strv (current_mime_type, good_mime_types) && - str_in_strv (current_mime_type, accepted_mime_types)) { - *satisfactory_mime_type = g_strdup (current_mime_type); - *satisfactory_format_name = g_strdup (current_mime_type + - strlen ("image/")); - return FALSE; - } - - /* The current mime type is either not accepted or not good to use. - * Check if one of the good format is supported... */ - for (i = 0; good_mime_types[i] != NULL; i++) { - if (str_in_strv (good_mime_types[i], accepted_mime_types)) { - *satisfactory_mime_type = g_strdup (good_mime_types[i]); - *satisfactory_format_name = g_strdup (good_mime_types[i] + - strlen ("image/")); - return TRUE; - } - } - - /* Pick the first supported format we can write */ - formats = gdk_pixbuf_get_formats (); - for (l = formats; !found && l != NULL; l = l->next) { - GdkPixbufFormat *format = l->data; - gchar **format_mime_types; - gchar **iter; - - if (!gdk_pixbuf_format_is_writable (format)) { - continue; - } - - format_mime_types = gdk_pixbuf_format_get_mime_types (format); - for (iter = format_mime_types; *iter != NULL; iter++) { - if (str_in_strv (*iter, accepted_mime_types)) { - *satisfactory_format_name = gdk_pixbuf_format_get_name (format); - *satisfactory_mime_type = g_strdup (*iter); - found = TRUE; - break; - } - } - g_strfreev (format_mime_types); - } - g_slist_free (formats); - - return TRUE; -} - -static EmpathyAvatar * -avatar_chooser_maybe_convert_and_scale (EmpathyAvatarChooser *chooser, - GdkPixbuf *pixbuf, - EmpathyAvatar *avatar) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - EmpathyTpContactFactory *tp_cf = priv->tp_contact_factory; - guint max_width = 0, max_height = 0, max_size = 0; - gchar **mime_types = NULL; - gboolean needs_conversion = FALSE; - gint width, height; - gchar *new_format_name = NULL; - gchar *new_mime_type = NULL; - gdouble min_factor, max_factor; - gdouble factor; - gchar *converted_image_data = NULL; - gsize converted_image_size = 0; - - /* This should only be called if the user is setting a new avatar, - * which should only be allowed once the avatar requirements have been - * discovered. - */ - g_return_val_if_fail (tp_cf != NULL, NULL); - g_return_val_if_fail (empathy_tp_contact_factory_is_ready (tp_cf), - NULL); - - g_object_get (tp_cf, - "avatar-mime-types", &mime_types, /* Needs g_strfreev-ing */ - "avatar-max-width", &max_width, - "avatar-max-height", &max_height, - "avatar-max-size", &max_size, - NULL); - - /* Smaller is the factor, smaller will be the image. - * 0 is an empty image, 1 is the full size. */ - min_factor = 0; - max_factor = 1; - factor = 1; - - /* Check if we need to convert to another image format */ - if (avatar_chooser_need_mime_type_conversion (avatar->format, - mime_types, - &new_format_name, - &new_mime_type)) { - DEBUG ("Format conversion needed, we'll use mime type '%s' " - "and format name '%s'. Current mime type is '%s'", - new_mime_type, new_format_name, avatar->format); - needs_conversion = TRUE; - } - g_strfreev (mime_types); - - /* If there is no format we can use, report error to the user. */ - if (new_mime_type == NULL || new_format_name == NULL) { - avatar_chooser_error_show (chooser, _("Couldn't convert image"), - _("None of the accepted image formats is " - "supported on your system")); - return NULL; - } - - /* If width or height are too big, it needs converting. */ - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - if ((max_width > 0 && width > max_width) || - (max_height > 0 && height > max_height)) { - gdouble h_factor, v_factor; - - h_factor = (gdouble) max_width / width; - v_factor = (gdouble) max_height / height; - factor = max_factor = MIN (h_factor, v_factor); - - DEBUG ("Image dimensions (%dx%d) are too big. Max is %dx%d.", - width, height, max_width, max_height); - - needs_conversion = TRUE; - } - - /* If the data len is too big and no other conversion is needed, - * try with a lower factor. */ - if (max_size > 0 && avatar->len > max_size && !needs_conversion) { - DEBUG ("Image data (%"G_GSIZE_FORMAT" bytes) is too big " - "(max is %u bytes), conversion needed.", - avatar->len, max_size); - - factor = 0.5; - needs_conversion = TRUE; - } - - /* If no conversion is needed, return the avatar */ - if (!needs_conversion) { - g_free (new_format_name); - g_free (new_mime_type); - return empathy_avatar_ref (avatar); - } - - do { - GdkPixbuf *pixbuf_scaled = NULL; - gboolean saved; - gint new_width, new_height; - GError *error = NULL; - - g_free (converted_image_data); - - if (factor != 1) { - new_width = width * factor; - new_height = height * factor; - pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, - new_width, - new_height, - GDK_INTERP_HYPER); - } else { - new_width = width; - new_height = height; - pixbuf_scaled = g_object_ref (pixbuf); - } - - DEBUG ("Trying with factor %f (%dx%d) and format %s...", factor, - new_width, new_height, new_format_name); - - saved = gdk_pixbuf_save_to_buffer (pixbuf_scaled, - &converted_image_data, - &converted_image_size, - new_format_name, - &error, NULL); - - if (!saved) { - g_free (new_format_name); - g_free (new_mime_type); - avatar_chooser_error_show (chooser, - _("Couldn't convert image"), - error ? error->message : NULL); - g_clear_error (&error); - return NULL; - } - - DEBUG ("Produced an image data of %"G_GSIZE_FORMAT" bytes.", - converted_image_size); - - if (max_size == 0) - break; - - /* Make a binary search for the bigest factor that produce - * an image data size less than max_size */ - if (converted_image_size > max_size) - max_factor = factor; - if (converted_image_size < max_size) - min_factor = factor; - factor = (min_factor + max_factor)/2; - - /* We are done if either: - * - min_factor == max_factor. That happens if we resized to - * the max required dimension and the produced data size is - * less than max_size. - * - The data size is close enough to max_size. Here we accept - * a difference of 1k. - */ - } while (min_factor != max_factor && - ABS (max_size - converted_image_size) > 1024); - g_free (new_format_name); - - /* Takes ownership of new_mime_type and converted_image_data */ - avatar = empathy_avatar_new (converted_image_data, - converted_image_size, new_mime_type, NULL); - - return avatar; -} - -static void -avatar_chooser_clear_image (EmpathyAvatarChooser *chooser) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - GtkWidget *image; - - if (priv->avatar == NULL) { - return; - } - - empathy_avatar_unref (priv->avatar); - priv->avatar = NULL; - - image = gtk_image_new_from_icon_name ("stock_person", GTK_ICON_SIZE_DIALOG); - gtk_button_set_image (GTK_BUTTON (chooser), image); - g_signal_emit (chooser, signals[CHANGED], 0); -} - -static void -avatar_chooser_set_image_from_data (EmpathyAvatarChooser *chooser, - gchar *data, - gsize size, - gboolean set_locally) -{ - GdkPixbuf *pixbuf; - EmpathyAvatar *avatar = NULL; - gchar *mime_type = NULL; - - if (data == NULL) { - avatar_chooser_clear_image (chooser); - return; - } - - pixbuf = empathy_pixbuf_from_data_and_mime (data, size, &mime_type); - if (pixbuf == NULL) { - g_free (data); - return; - } - - /* avatar takes ownership of data and mime_type */ - avatar = empathy_avatar_new (data, size, mime_type, NULL); - - avatar_chooser_set_image (chooser, avatar, pixbuf, set_locally); -} - -static void -avatar_chooser_set_image_from_avatar (EmpathyAvatarChooser *chooser, - EmpathyAvatar *avatar, - gboolean set_locally) -{ - GdkPixbuf *pixbuf; - gchar *mime_type = NULL; - - g_assert (avatar != NULL); - - pixbuf = empathy_pixbuf_from_data_and_mime (avatar->data, - avatar->len, - &mime_type); - if (pixbuf == NULL) { - DEBUG ("couldn't make a pixbuf from avatar; giving up"); - return; - } - - if (avatar->format == NULL) { - avatar->format = mime_type; - } else { - if (strcmp (mime_type, avatar->format)) { - DEBUG ("avatar->format is %s; gdkpixbuf yields %s!", - avatar->format, mime_type); - } - g_free (mime_type); - } - - empathy_avatar_ref (avatar); - - avatar_chooser_set_image (chooser, avatar, pixbuf, set_locally); -} - -static void -avatar_chooser_set_image (EmpathyAvatarChooser *chooser, - EmpathyAvatar *avatar, - GdkPixbuf *pixbuf, - gboolean set_locally) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - GdkPixbuf *pixbuf_view; - GtkWidget *image; - - g_assert (avatar != NULL); - g_assert (pixbuf != NULL); - - if (set_locally) { - EmpathyAvatar *conv; - - conv = avatar_chooser_maybe_convert_and_scale (chooser, - pixbuf, avatar); - empathy_avatar_unref (avatar); - - if (conv == NULL) { - /* An error occured; don't change the avatar. */ - return; - } - - avatar = conv; - } - - if (priv->avatar != NULL) { - empathy_avatar_unref (priv->avatar); - } - priv->avatar = avatar; - - pixbuf_view = empathy_pixbuf_scale_down_if_necessary (pixbuf, AVATAR_SIZE_VIEW); - image = gtk_image_new_from_pixbuf (pixbuf_view); - - gtk_button_set_image (GTK_BUTTON (chooser), image); - g_signal_emit (chooser, signals[CHANGED], 0); - - g_object_unref (pixbuf_view); - g_object_unref (pixbuf); -} - -static void -avatar_chooser_set_image_from_file (EmpathyAvatarChooser *chooser, - const gchar *filename) -{ - gchar *image_data = NULL; - gsize image_size = 0; - GError *error = NULL; - - if (!g_file_get_contents (filename, &image_data, &image_size, &error)) { - DEBUG ("Failed to load image from '%s': %s", filename, - error ? error->message : "No error given"); - - g_clear_error (&error); - return; - } - - avatar_chooser_set_image_from_data (chooser, image_data, image_size, TRUE); -} - -static gboolean -avatar_chooser_drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EmpathyAvatarChooser *chooser) -{ - EmpathyAvatarChooserPriv *priv; - GList *p; - - priv = GET_PRIV (chooser); - - for (p = context->targets; p != NULL; p = p->next) { - gchar *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - - if (!strcmp (possible_type, URI_LIST_TYPE)) { - g_free (possible_type); - gdk_drag_status (context, GDK_ACTION_COPY, time); - - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static void -avatar_chooser_drag_leave_cb (GtkWidget *widget, - GdkDragContext *context, - guint time, - EmpathyAvatarChooser *chooser) -{ -} - -static gboolean -avatar_chooser_drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EmpathyAvatarChooser *chooser) -{ - EmpathyAvatarChooserPriv *priv; - GList *p; - - priv = GET_PRIV (chooser); - - if (context->targets == NULL) { - return FALSE; - } - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, URI_LIST_TYPE)) { - g_free (possible_type); - gtk_drag_get_data (widget, context, - GDK_POINTER_TO_ATOM (p->data), - time); - - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static void -avatar_chooser_drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint time, - EmpathyAvatarChooser *chooser) -{ - gchar *target_type; - gboolean handled = FALSE; - - target_type = gdk_atom_name (selection_data->target); - if (!strcmp (target_type, URI_LIST_TYPE)) { - GFile *file; - GFileInputStream *input_stream; - gchar *nl; - gchar *data = NULL; - - nl = strstr (selection_data->data, "\r\n"); - if (nl) { - gchar *uri; - - uri = g_strndup (selection_data->data, - nl - (gchar*) selection_data->data); - - file = g_file_new_for_uri (uri); - g_free (uri); - } else { - file = g_file_new_for_uri (selection_data->data); - } - - input_stream = g_file_read (file, NULL, NULL); - - if (input_stream != NULL) { - GFileInfo *info; - - info = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_SIZE, - 0, NULL, NULL); - if (info != NULL) { - goffset size; - gssize bytes_read; - - size = g_file_info_get_size (info); - data = g_malloc (size); - - bytes_read = g_input_stream_read (G_INPUT_STREAM (input_stream), - data, size, - NULL, NULL); - if (bytes_read != -1) { - avatar_chooser_set_image_from_data ( - chooser, data, - (gsize) bytes_read, - TRUE); - handled = TRUE; - } - - g_free (data); - g_object_unref (info); - } - - g_object_unref (input_stream); - } - - g_object_unref (file); - } - - gtk_drag_finish (context, handled, FALSE, time); -} - -static void -avatar_chooser_update_preview_cb (GtkFileChooser *file_chooser, - EmpathyAvatarChooser *chooser) -{ - gchar *filename; - - filename = gtk_file_chooser_get_preview_filename (file_chooser); - - if (filename) { - GtkWidget *image; - GdkPixbuf *pixbuf = NULL; - GdkPixbuf *scaled_pixbuf; - - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - - image = gtk_file_chooser_get_preview_widget (file_chooser); - - if (pixbuf) { - scaled_pixbuf = empathy_pixbuf_scale_down_if_necessary (pixbuf, AVATAR_SIZE_SAVE); - gtk_image_set_from_pixbuf (GTK_IMAGE (image), scaled_pixbuf); - g_object_unref (scaled_pixbuf); - g_object_unref (pixbuf); - } else { - gtk_image_set_from_stock (GTK_IMAGE (image), - "gtk-dialog-question", - GTK_ICON_SIZE_DIALOG); - } - } - - gtk_file_chooser_set_preview_widget_active (file_chooser, TRUE); -} - -static void -avatar_chooser_response_cb (GtkWidget *widget, - gint response, - EmpathyAvatarChooser *chooser) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - - priv->chooser_dialog = NULL; - - if (response == GTK_RESPONSE_CANCEL) { - goto out; - } - - /* Check if we went non-ready since displaying the dialog. */ - if (!empathy_tp_contact_factory_is_ready (priv->tp_contact_factory)) { - DEBUG ("Can't set avatar when contact factory isn't ready."); - goto out; - } - - if (response == GTK_RESPONSE_OK) { - gchar *filename; - gchar *path; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); - avatar_chooser_set_image_from_file (chooser, filename); - g_free (filename); - - path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget)); - if (path) { - empathy_conf_set_string (empathy_conf_get (), - EMPATHY_PREFS_UI_AVATAR_DIRECTORY, - path); - g_free (path); - } - } - else if (response == GTK_RESPONSE_NO) { - /* This corresponds to "No Image", not to "Cancel" */ - avatar_chooser_clear_image (chooser); - } - -out: - gtk_widget_destroy (widget); -} - -static void -avatar_chooser_clicked_cb (GtkWidget *button, - EmpathyAvatarChooser *chooser) -{ - GtkFileChooser *chooser_dialog; - GtkWidget *image; - gchar *saved_dir = NULL; - const gchar *default_dir = DEFAULT_DIR; - const gchar *pics_dir; - GtkFileFilter *filter; - EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - - if (priv->chooser_dialog) { - gtk_window_present (GTK_WINDOW (priv->chooser_dialog)); - return; - } - - priv->chooser_dialog = GTK_FILE_CHOOSER ( - gtk_file_chooser_dialog_new (_("Select Your Avatar Image"), - empathy_get_toplevel_window (GTK_WIDGET (chooser)), - GTK_FILE_CHOOSER_ACTION_OPEN, - _("No Image"), - GTK_RESPONSE_NO, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, - GTK_RESPONSE_OK, - NULL)); - chooser_dialog = priv->chooser_dialog; - gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser_dialog), TRUE); - - /* Get special dirs */ - empathy_conf_get_string (empathy_conf_get (), - EMPATHY_PREFS_UI_AVATAR_DIRECTORY, - &saved_dir); - if (saved_dir && !g_file_test (saved_dir, G_FILE_TEST_IS_DIR)) { - g_free (saved_dir); - saved_dir = NULL; - } - if (!g_file_test (default_dir, G_FILE_TEST_IS_DIR)) { - default_dir = NULL; - } - pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); - if (pics_dir && !g_file_test (pics_dir, G_FILE_TEST_IS_DIR)) { - pics_dir = NULL; - } - - /* Set current dir to the last one or to DEFAULT_DIR or to home */ - if (saved_dir) { - gtk_file_chooser_set_current_folder (chooser_dialog, saved_dir); - } - else if (pics_dir) { - gtk_file_chooser_set_current_folder (chooser_dialog, pics_dir); - } - else if (default_dir) { - gtk_file_chooser_set_current_folder (chooser_dialog, default_dir); - } else { - gtk_file_chooser_set_current_folder (chooser_dialog, g_get_home_dir ()); - } - - /* Add shortcuts to special dirs */ - if (saved_dir) { - gtk_file_chooser_add_shortcut_folder (chooser_dialog, saved_dir, NULL); - } - else if (pics_dir) { - gtk_file_chooser_add_shortcut_folder (chooser_dialog, pics_dir, NULL); - } - if (default_dir) { - gtk_file_chooser_add_shortcut_folder (chooser_dialog, default_dir, NULL); - } - - /* Setup preview image */ - image = gtk_image_new (); - gtk_file_chooser_set_preview_widget (chooser_dialog, image); - gtk_widget_set_size_request (image, AVATAR_SIZE_SAVE, AVATAR_SIZE_SAVE); - gtk_widget_show (image); - gtk_file_chooser_set_use_preview_label (chooser_dialog, FALSE); - g_signal_connect (chooser_dialog, "update-preview", - G_CALLBACK (avatar_chooser_update_preview_cb), - chooser); - - /* Setup filers */ - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("Images")); - gtk_file_filter_add_pixbuf_formats (filter); - gtk_file_chooser_add_filter (chooser_dialog, filter); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("All Files")); - gtk_file_filter_add_pattern(filter, "*"); - gtk_file_chooser_add_filter (chooser_dialog, filter); - - /* Setup response */ - gtk_dialog_set_default_response (GTK_DIALOG (chooser_dialog), GTK_RESPONSE_OK); - g_signal_connect (chooser_dialog, "response", - G_CALLBACK (avatar_chooser_response_cb), - chooser); - - gtk_widget_show (GTK_WIDGET (chooser_dialog)); - g_free (saved_dir); -} - -GtkWidget * -empathy_avatar_chooser_new () -{ - return g_object_new (EMPATHY_TYPE_AVATAR_CHOOSER, NULL); -} - -void -empathy_avatar_chooser_set (EmpathyAvatarChooser *chooser, - EmpathyAvatar *avatar) -{ - g_return_if_fail (EMPATHY_IS_AVATAR_CHOOSER (chooser)); - - if (avatar != NULL) { - avatar_chooser_set_image_from_avatar (chooser, avatar, FALSE); - } else { - avatar_chooser_clear_image (chooser); - } -} - -void -empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser *chooser, - const gchar **data, - gsize *data_size, - const gchar **mime_type) -{ - EmpathyAvatarChooserPriv *priv; - - g_return_if_fail (EMPATHY_IS_AVATAR_CHOOSER (chooser)); - - priv = GET_PRIV (chooser); - - if (priv->avatar != NULL) { - if (data != NULL) { - *data = priv->avatar->data; - } - if (data_size != NULL) { - *data_size = priv->avatar->len; - } - if (mime_type != NULL) { - *mime_type = priv->avatar->format; - } - } else { - if (data != NULL) { - *data = NULL; - } - if (data_size != NULL) { - *data_size = 0; - } - if (mime_type != NULL) { - *mime_type = NULL; - } - } -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.h b/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.h deleted file mode 100644 index bdc5b40ae..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-avatar-chooser.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-2007 Imendio AB. - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Based on Novell's e-image-chooser. - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_AVATAR_CHOOSER_H__ -#define __EMPATHY_AVATAR_CHOOSER_H__ - -#include <gtk/gtkbutton.h> - -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_AVATAR_CHOOSER (empathy_avatar_chooser_get_type ()) -#define EMPATHY_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooser)) -#define EMPATHY_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooserClass)) -#define EMPATHY_IS_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER)) -#define EMPATHY_IS_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER)) - -typedef struct _EmpathyAvatarChooser EmpathyAvatarChooser; -typedef struct _EmpathyAvatarChooserClass EmpathyAvatarChooserClass; - -struct _EmpathyAvatarChooser { - GtkButton parent; - gpointer priv; -}; - -struct _EmpathyAvatarChooserClass { - GtkButtonClass parent_class; -}; - -GType empathy_avatar_chooser_get_type (void); -GtkWidget *empathy_avatar_chooser_new (void); -void empathy_avatar_chooser_set (EmpathyAvatarChooser *chooser, - EmpathyAvatar *avatar); -void empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser *chooser, - const gchar **data, - gsize *data_size, - const gchar **mime_type); - -#endif /* __EMPATHY_AVATAR_CHOOSER_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-avatar-image.c b/gnome-2-26/libempathy-gtk/empathy-avatar-image.c deleted file mode 100644 index 51f30bdd5..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-avatar-image.c +++ /dev/null @@ -1,302 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <glib/gi18n-lib.h> -#include <gdk/gdkkeysyms.h> -#include <gdk/gdk.h> -#include <gtk/gtk.h> -#include <gdk/gdkx.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-avatar-image.h" -#include "empathy-ui-utils.h" - -#define MAX_SMALL 64 -#define MAX_LARGE 400 - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAvatarImage) -typedef struct { - GtkWidget *image; - GtkWidget *popup; - GdkPixbuf *pixbuf; -} EmpathyAvatarImagePriv; - -static void avatar_image_finalize (GObject *object); -static void avatar_image_add_filter (EmpathyAvatarImage *avatar_image); -static void avatar_image_remove_filter (EmpathyAvatarImage *avatar_image); -static gboolean avatar_image_button_press_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean avatar_image_button_release_event (GtkWidget *widget, - GdkEventButton *event); - -G_DEFINE_TYPE (EmpathyAvatarImage, empathy_avatar_image, GTK_TYPE_EVENT_BOX); - -static void -empathy_avatar_image_class_init (EmpathyAvatarImageClass *klass) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = G_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - - object_class->finalize = avatar_image_finalize; - - widget_class->button_press_event = avatar_image_button_press_event; - widget_class->button_release_event = avatar_image_button_release_event; - - g_type_class_add_private (object_class, sizeof (EmpathyAvatarImagePriv)); -} - -static void -empathy_avatar_image_init (EmpathyAvatarImage *avatar_image) -{ - EmpathyAvatarImagePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (avatar_image, - EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImagePriv); - - avatar_image->priv = priv; - priv->image = gtk_image_new (); - gtk_container_add (GTK_CONTAINER (avatar_image), priv->image); - empathy_avatar_image_set (avatar_image, NULL); - gtk_widget_show (priv->image); - - avatar_image_add_filter (avatar_image); -} - -static void -avatar_image_finalize (GObject *object) -{ - EmpathyAvatarImagePriv *priv; - - priv = GET_PRIV (object); - - avatar_image_remove_filter (EMPATHY_AVATAR_IMAGE (object)); - - if (priv->popup) { - gtk_widget_destroy (priv->popup); - } - - if (priv->pixbuf) { - g_object_unref (priv->pixbuf); - } - - G_OBJECT_CLASS (empathy_avatar_image_parent_class)->finalize (object); -} - -static GdkFilterReturn -avatar_image_filter_func (GdkXEvent *gdkxevent, - GdkEvent *event, - gpointer data) -{ - XEvent *xevent = gdkxevent; - Atom atom; - EmpathyAvatarImagePriv *priv; - - priv = GET_PRIV (data); - - switch (xevent->type) { - case PropertyNotify: - atom = gdk_x11_get_xatom_by_name ("_NET_CURRENT_DESKTOP"); - if (xevent->xproperty.atom == atom) { - if (priv->popup) { - gtk_widget_destroy (priv->popup); - priv->popup = NULL; - } - } - break; - } - - return GDK_FILTER_CONTINUE; -} - -static void -avatar_image_add_filter (EmpathyAvatarImage *avatar_image) -{ - Window window; - GdkWindow *gdkwindow; - gint mask; - - mask = PropertyChangeMask; - - window = GDK_ROOT_WINDOW (); - gdkwindow = gdk_xid_table_lookup (window); - - gdk_error_trap_push (); - if (gdkwindow) { - XWindowAttributes attrs; - XGetWindowAttributes (gdk_display, window, &attrs); - mask |= attrs.your_event_mask; - } - - XSelectInput (gdk_display, window, mask); - - gdk_error_trap_pop (); - - gdk_window_add_filter (NULL, avatar_image_filter_func, avatar_image); -} - -static void -avatar_image_remove_filter (EmpathyAvatarImage *avatar_image) -{ - gdk_window_remove_filter (NULL, avatar_image_filter_func, avatar_image); -} - -static gboolean -avatar_image_button_press_event (GtkWidget *widget, GdkEventButton *event) -{ - EmpathyAvatarImagePriv *priv; - GtkWidget *popup; - GtkWidget *frame; - GtkWidget *image; - gint x, y; - gint popup_width, popup_height; - gint width, height; - GdkPixbuf *pixbuf; - - priv = GET_PRIV (widget); - - if (priv->popup) { - gtk_widget_destroy (priv->popup); - priv->popup = NULL; - } - - if (event->button != 1 || event->type != GDK_BUTTON_PRESS || !priv->pixbuf) { - return FALSE; - } - - popup_width = gdk_pixbuf_get_width (priv->pixbuf); - popup_height = gdk_pixbuf_get_height (priv->pixbuf); - - width = priv->image->allocation.width; - height = priv->image->allocation.height; - - /* Don't show a popup if the popup is smaller then the currently avatar - * image. - */ - if (popup_height <= height && popup_width <= width) { - return TRUE; - } - - pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_LARGE); - popup_width = gdk_pixbuf_get_width (pixbuf); - popup_height = gdk_pixbuf_get_height (pixbuf); - - popup = gtk_window_new (GTK_WINDOW_POPUP); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - - gtk_container_add (GTK_CONTAINER (popup), frame); - - image = gtk_image_new (); - gtk_container_add (GTK_CONTAINER (frame), image); - - gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); - g_object_unref (pixbuf); - - gdk_window_get_origin (priv->image->window, &x, &y); - - x = x - (popup_width - width) / 2; - y = y - (popup_height - height) / 2; - - gtk_window_move (GTK_WINDOW (popup), x, y); - - priv->popup = popup; - - gtk_widget_show_all (popup); - - return TRUE; -} - -static gboolean -avatar_image_button_release_event (GtkWidget *widget, GdkEventButton *event) -{ - EmpathyAvatarImagePriv *priv; - - priv = GET_PRIV (widget); - - if (event->button != 1 || event->type != GDK_BUTTON_RELEASE) { - return FALSE; - } - - if (!priv->popup) { - return TRUE; - } - - gtk_widget_destroy (priv->popup); - priv->popup = NULL; - - return TRUE; -} - -GtkWidget * -empathy_avatar_image_new (void) -{ - EmpathyAvatarImage *avatar_image; - - avatar_image = g_object_new (EMPATHY_TYPE_AVATAR_IMAGE, NULL); - - return GTK_WIDGET (avatar_image); -} - -void -empathy_avatar_image_set (EmpathyAvatarImage *avatar_image, - EmpathyAvatar *avatar) -{ - EmpathyAvatarImagePriv *priv = GET_PRIV (avatar_image); - GdkPixbuf *scaled_pixbuf; - - g_return_if_fail (EMPATHY_IS_AVATAR_IMAGE (avatar_image)); - - if (priv->pixbuf) { - g_object_unref (priv->pixbuf); - priv->pixbuf = NULL; - } - - if (avatar) { - priv->pixbuf = empathy_pixbuf_from_data (avatar->data, avatar->len); - } - - if (!priv->pixbuf) { - gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - "stock_person", - GTK_ICON_SIZE_DIALOG); - return; - } - - scaled_pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_SMALL); - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled_pixbuf); - - if (scaled_pixbuf != priv->pixbuf) { - gtk_widget_set_tooltip_text (GTK_WIDGET (avatar_image), - _("Click to enlarge")); - } else { - gtk_widget_set_tooltip_text (GTK_WIDGET (avatar_image), - NULL); - } - - g_object_unref (scaled_pixbuf); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-avatar-image.h b/gnome-2-26/libempathy-gtk/empathy-avatar-image.h deleted file mode 100644 index d6a6cd0b0..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-avatar-image.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_AVATAR_IMAGE_H__ -#define __EMPATHY_AVATAR_IMAGE_H__ - -#include <gtk/gtkeventbox.h> - -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_AVATAR_IMAGE (empathy_avatar_image_get_type ()) -#define EMPATHY_AVATAR_IMAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImage)) -#define EMPATHY_AVATAR_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImageClass)) -#define EMPATHY_IS_AVATAR_IMAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_AVATAR_IMAGE)) -#define EMPATHY_IS_AVATAR_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_AVATAR_IMAGE)) -#define EMPATHY_AVATAR_IMAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImageClass)) - -typedef struct _EmpathyAvatarImage EmpathyAvatarImage; -typedef struct _EmpathyAvatarImageClass EmpathyAvatarImageClass; - -struct _EmpathyAvatarImage { - GtkEventBox parent; - gpointer priv; -}; - -struct _EmpathyAvatarImageClass { - GtkEventBoxClass parent_class; -}; - -GType empathy_avatar_image_get_type (void) G_GNUC_CONST; -GtkWidget * empathy_avatar_image_new (void); -void empathy_avatar_image_set (EmpathyAvatarImage *avatar_image, - EmpathyAvatar *avatar); - -G_END_DECLS - -#endif /* __EMPATHY_AVATAR_IMAGE_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.c b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.c deleted file mode 100644 index fc218e88b..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Raphael Slinckx <raphael@slinckx.net> - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Raphael Slinckx <raphael@slinckx.net> - */ - -#include <gtk/gtktreeview.h> - -#include "empathy-cell-renderer-activatable.h" - -static void empathy_cell_renderer_activatable_init (EmpathyCellRendererActivatable *cell); -static void empathy_cell_renderer_activatable_class_init (EmpathyCellRendererActivatableClass *klass); -static gboolean cell_renderer_activatable_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags); - -enum { - PATH_ACTIVATED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (EmpathyCellRendererActivatable, empathy_cell_renderer_activatable, GTK_TYPE_CELL_RENDERER_PIXBUF) - -static void -empathy_cell_renderer_activatable_init (EmpathyCellRendererActivatable *cell) -{ - g_object_set (cell, - "xpad", 0, - "ypad", 0, - "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, - "follow-state", TRUE, - NULL); -} - -static void -empathy_cell_renderer_activatable_class_init (EmpathyCellRendererActivatableClass *klass) -{ - GtkCellRendererClass *cell_class; - - cell_class = GTK_CELL_RENDERER_CLASS (klass); - cell_class->activate = cell_renderer_activatable_activate; - - signals[PATH_ACTIVATED] = - g_signal_new ("path-activated", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, G_TYPE_STRING); -} - -GtkCellRenderer * -empathy_cell_renderer_activatable_new (void) -{ - return g_object_new (EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, NULL); -} - -static gboolean -cell_renderer_activatable_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path_string, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - EmpathyCellRendererActivatable *activatable; - gint ex, ey, bx, by, bw, bh; - - activatable = EMPATHY_CELL_RENDERER_ACTIVATABLE (cell); - - if (!GTK_IS_TREE_VIEW (widget) || event == NULL || - event->type != GDK_BUTTON_PRESS) { - return FALSE; - } - - ex = (gint) ((GdkEventButton *) event)->x; - ey = (gint) ((GdkEventButton *) event)->y; - bx = background_area->x; - by = background_area->y; - bw = background_area->width; - bh = background_area->height; - - if (ex < bx || ex > (bx+bw) || ey < by || ey > (by+bh)){ - /* Click wasn't on the icon */ - return FALSE; - } - - g_signal_emit (activatable, signals[PATH_ACTIVATED], 0, path_string); - - return TRUE; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.h b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.h deleted file mode 100644 index 5962c200f..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-activatable.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Raphael Slinckx <raphael@slinckx.net> - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Raphael Slinckx <raphael@slinckx.net> - */ - -#ifndef __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__ -#define __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__ - -#include <gtk/gtkcellrendererpixbuf.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE (empathy_cell_renderer_activatable_get_type ()) -#define EMPATHY_CELL_RENDERER_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatable)) -#define EMPATHY_CELL_RENDERER_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatableClass)) -#define EMPATHY_IS_CELL_RENDERER_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE)) -#define EMPATHY_IS_CELL_RENDERER_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE)) -#define EMPATHY_CELL_RENDERER_ACTIVATABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CELL_RENDERER_ACTIVATABLE, EmpathyCellRendererActivatableClass)) - -typedef struct _EmpathyCellRendererActivatable EmpathyCellRendererActivatable; -typedef struct _EmpathyCellRendererActivatableClass EmpathyCellRendererActivatableClass; - -struct _EmpathyCellRendererActivatable { - GtkCellRendererPixbuf parent; -}; - -struct _EmpathyCellRendererActivatableClass { - GtkCellRendererPixbufClass parent_class; -}; - -GType empathy_cell_renderer_activatable_get_type (void) G_GNUC_CONST; -GtkCellRenderer *empathy_cell_renderer_activatable_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_CELL_RENDERER_ACTIVATABLE_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.c b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.c deleted file mode 100644 index fc9189d2d..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.c +++ /dev/null @@ -1,478 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-2007 Imendio AB - * - * 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: Kristian Rietveld <kris@imendio.com> - */ - -/* To do: - * - should probably cancel animation if model changes - * - need to handle case where node-in-animation is removed - * - it only handles a single animation at a time; but I guess users - * aren't fast enough to trigger two or more animations at once anyway :P - * (could guard for this by just cancelling the "old" animation, and - * start the new one). - */ - -#include <gtk/gtktreeview.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-cell-renderer-expander.h" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCellRendererExpander) -typedef struct { - GtkExpanderStyle expander_style; - gint expander_size; - - GtkTreeView *animation_view; - GtkTreeRowReference *animation_node; - GtkExpanderStyle animation_style; - guint animation_timeout; - GdkRectangle animation_area; - - guint activatable : 1; - guint animation_expanding : 1; -} EmpathyCellRendererExpanderPriv; - -enum { - PROP_0, - PROP_EXPANDER_STYLE, - PROP_EXPANDER_SIZE, - PROP_ACTIVATABLE -}; - -static void empathy_cell_renderer_expander_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void empathy_cell_renderer_expander_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void empathy_cell_renderer_expander_finalize (GObject *object); -static void empathy_cell_renderer_expander_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); -static void empathy_cell_renderer_expander_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags); -static gboolean empathy_cell_renderer_expander_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags); - -G_DEFINE_TYPE (EmpathyCellRendererExpander, empathy_cell_renderer_expander, GTK_TYPE_CELL_RENDERER) - -static void -empathy_cell_renderer_expander_init (EmpathyCellRendererExpander *expander) -{ - EmpathyCellRendererExpanderPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (expander, - EMPATHY_TYPE_CELL_RENDERER_EXPANDER, EmpathyCellRendererExpanderPriv); - - expander->priv = priv; - priv->expander_style = GTK_EXPANDER_COLLAPSED; - priv->expander_size = 12; - priv->activatable = TRUE; - priv->animation_node = NULL; - - GTK_CELL_RENDERER (expander)->xpad = 2; - GTK_CELL_RENDERER (expander)->ypad = 2; - GTK_CELL_RENDERER (expander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; -} - -static void -empathy_cell_renderer_expander_class_init (EmpathyCellRendererExpanderClass *klass) -{ - GObjectClass *object_class; - GtkCellRendererClass *cell_class; - - object_class = G_OBJECT_CLASS (klass); - cell_class = GTK_CELL_RENDERER_CLASS (klass); - - object_class->finalize = empathy_cell_renderer_expander_finalize; - - object_class->get_property = empathy_cell_renderer_expander_get_property; - object_class->set_property = empathy_cell_renderer_expander_set_property; - - cell_class->get_size = empathy_cell_renderer_expander_get_size; - cell_class->render = empathy_cell_renderer_expander_render; - cell_class->activate = empathy_cell_renderer_expander_activate; - - g_object_class_install_property (object_class, - PROP_EXPANDER_STYLE, - g_param_spec_enum ("expander-style", - "Expander Style", - "Style to use when painting the expander", - GTK_TYPE_EXPANDER_STYLE, - GTK_EXPANDER_COLLAPSED, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_EXPANDER_SIZE, - g_param_spec_int ("expander-size", - "Expander Size", - "The size of the expander", - 0, - G_MAXINT, - 12, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ACTIVATABLE, - g_param_spec_boolean ("activatable", - "Activatable", - "The expander can be activated", - TRUE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyCellRendererExpanderPriv)); -} - -static void -empathy_cell_renderer_expander_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyCellRendererExpander *expander; - EmpathyCellRendererExpanderPriv *priv; - - expander = EMPATHY_CELL_RENDERER_EXPANDER (object); - priv = GET_PRIV (expander); - - switch (param_id) { - case PROP_EXPANDER_STYLE: - g_value_set_enum (value, priv->expander_style); - break; - - case PROP_EXPANDER_SIZE: - g_value_set_int (value, priv->expander_size); - break; - - case PROP_ACTIVATABLE: - g_value_set_boolean (value, priv->activatable); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -empathy_cell_renderer_expander_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyCellRendererExpander *expander; - EmpathyCellRendererExpanderPriv *priv; - - expander = EMPATHY_CELL_RENDERER_EXPANDER (object); - priv = GET_PRIV (expander); - - switch (param_id) { - case PROP_EXPANDER_STYLE: - priv->expander_style = g_value_get_enum (value); - break; - - case PROP_EXPANDER_SIZE: - priv->expander_size = g_value_get_int (value); - break; - - case PROP_ACTIVATABLE: - priv->activatable = g_value_get_boolean (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -empathy_cell_renderer_expander_finalize (GObject *object) -{ - EmpathyCellRendererExpanderPriv *priv; - - priv = GET_PRIV (object); - - if (priv->animation_timeout) { - g_source_remove (priv->animation_timeout); - priv->animation_timeout = 0; - } - - if (priv->animation_node) { - gtk_tree_row_reference_free (priv->animation_node); - } - - (* G_OBJECT_CLASS (empathy_cell_renderer_expander_parent_class)->finalize) (object); -} - -GtkCellRenderer * -empathy_cell_renderer_expander_new (void) -{ - return g_object_new (EMPATHY_TYPE_CELL_RENDERER_EXPANDER, NULL); -} - -static void -empathy_cell_renderer_expander_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - EmpathyCellRendererExpander *expander; - EmpathyCellRendererExpanderPriv *priv; - - expander = (EmpathyCellRendererExpander*) cell; - priv = GET_PRIV (expander); - - if (cell_area) { - if (x_offset) { - *x_offset = cell->xalign * (cell_area->width - (priv->expander_size + (2 * cell->xpad))); - *x_offset = MAX (*x_offset, 0); - } - - if (y_offset) { - *y_offset = cell->yalign * (cell_area->height - (priv->expander_size + (2 * cell->ypad))); - *y_offset = MAX (*y_offset, 0); - } - } else { - if (x_offset) - *x_offset = 0; - - if (y_offset) - *y_offset = 0; - } - - if (width) - *width = cell->xpad * 2 + priv->expander_size; - - if (height) - *height = cell->ypad * 2 + priv->expander_size; -} - -static void -empathy_cell_renderer_expander_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) -{ - EmpathyCellRendererExpander *expander; - EmpathyCellRendererExpanderPriv *priv; - GtkExpanderStyle expander_style; - gint x_offset, y_offset; - - expander = (EmpathyCellRendererExpander*) cell; - priv = GET_PRIV (expander); - - if (priv->animation_node) { - GtkTreePath *path; - GdkRectangle rect; - - /* Not sure if I like this ... */ - path = gtk_tree_row_reference_get_path (priv->animation_node); - gtk_tree_view_get_background_area (priv->animation_view, path, - NULL, &rect); - gtk_tree_path_free (path); - - if (background_area->y == rect.y) - expander_style = priv->animation_style; - else - expander_style = priv->expander_style; - } else - expander_style = priv->expander_style; - - empathy_cell_renderer_expander_get_size (cell, widget, cell_area, - &x_offset, &y_offset, - NULL, NULL); - - gtk_paint_expander (widget->style, - window, - GTK_STATE_NORMAL, - expose_area, - widget, - "treeview", - cell_area->x + x_offset + cell->xpad + priv->expander_size / 2, - cell_area->y + y_offset + cell->ypad + priv->expander_size / 2, - expander_style); -} - -static void -invalidate_node (GtkTreeView *tree_view, - GtkTreePath *path) -{ - GdkWindow *bin_window; - GdkRectangle rect; - - bin_window = gtk_tree_view_get_bin_window (tree_view); - - gtk_tree_view_get_background_area (tree_view, path, NULL, &rect); - - rect.x = 0; - rect.width = GTK_WIDGET (tree_view)->allocation.width; - - gdk_window_invalidate_rect (bin_window, &rect, TRUE); -} - -static gboolean -do_animation (EmpathyCellRendererExpander *expander) -{ - EmpathyCellRendererExpanderPriv *priv; - GtkTreePath *path; - gboolean done = FALSE; - - priv = GET_PRIV (expander); - - if (priv->animation_expanding) { - if (priv->animation_style == GTK_EXPANDER_SEMI_COLLAPSED) - priv->animation_style = GTK_EXPANDER_SEMI_EXPANDED; - else if (priv->animation_style == GTK_EXPANDER_SEMI_EXPANDED) { - priv->animation_style = GTK_EXPANDER_EXPANDED; - done = TRUE; - } - } else { - if (priv->animation_style == GTK_EXPANDER_SEMI_EXPANDED) - priv->animation_style = GTK_EXPANDER_SEMI_COLLAPSED; - else if (priv->animation_style == GTK_EXPANDER_SEMI_COLLAPSED) { - priv->animation_style = GTK_EXPANDER_COLLAPSED; - done = TRUE; - } - } - - path = gtk_tree_row_reference_get_path (priv->animation_node); - invalidate_node (priv->animation_view, path); - gtk_tree_path_free (path); - - if (done) { - gtk_tree_row_reference_free (priv->animation_node); - priv->animation_node = NULL; - priv->animation_timeout = 0; - } - - return !done; -} - -static gboolean -animation_timeout (gpointer data) -{ - gboolean retval; - - GDK_THREADS_ENTER (); - - retval = do_animation (data); - - GDK_THREADS_LEAVE (); - - return retval; -} - -static void -empathy_cell_renderer_expander_start_animation (EmpathyCellRendererExpander *expander, - GtkTreeView *tree_view, - GtkTreePath *path, - gboolean expanding, - GdkRectangle *background_area) -{ - EmpathyCellRendererExpanderPriv *priv; - - priv = GET_PRIV (expander); - - if (expanding) { - priv->animation_style = GTK_EXPANDER_SEMI_COLLAPSED; - } else { - priv->animation_style = GTK_EXPANDER_SEMI_EXPANDED; - } - - invalidate_node (tree_view, path); - - priv->animation_expanding = expanding; - priv->animation_view = tree_view; - priv->animation_node = gtk_tree_row_reference_new (gtk_tree_view_get_model (tree_view), path); - priv->animation_timeout = g_timeout_add (50, animation_timeout, expander); -} - -static gboolean -empathy_cell_renderer_expander_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path_string, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - EmpathyCellRendererExpander *expander; - EmpathyCellRendererExpanderPriv *priv; - GtkTreePath *path; - gboolean animate; - gboolean expanding; - - expander = EMPATHY_CELL_RENDERER_EXPANDER (cell); - priv = GET_PRIV (cell); - - if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable) - return FALSE; - - path = gtk_tree_path_new_from_string (path_string); - - if (gtk_tree_path_get_depth (path) > 1) { - gtk_tree_path_free (path); - return TRUE; - } - - g_object_get (gtk_widget_get_settings (GTK_WIDGET (widget)), - "gtk-enable-animations", &animate, - NULL); - - if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { - gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path); - expanding = FALSE; - } else { - gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE); - expanding = TRUE; - } - - if (animate) { - empathy_cell_renderer_expander_start_animation (expander, - GTK_TREE_VIEW (widget), - path, - expanding, - background_area); - } - - gtk_tree_path_free (path); - - return TRUE; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.h b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.h deleted file mode 100644 index d052612bf..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-expander.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-2007 Imendio AB - * - * 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: Kristian Rietveld <kris@imendio.com> - */ - -#ifndef __EMPATHY_CELL_RENDERER_EXPANDER_H__ -#define __EMPATHY_CELL_RENDERER_EXPANDER_H__ - -#include <gtk/gtkcellrenderer.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CELL_RENDERER_EXPANDER (empathy_cell_renderer_expander_get_type ()) -#define EMPATHY_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_CELL_RENDERER_EXPANDER, EmpathyCellRendererExpander)) -#define EMPATHY_CELL_RENDERER_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_CELL_RENDERER_EXPANDER, EmpathyCellRendererExpanderClass)) -#define EMPATHY_IS_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_CELL_RENDERER_EXPANDER)) -#define EMPATHY_IS_CELL_RENDERER_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_CELL_RENDERER_EXPANDER)) -#define EMPATHY_CELL_RENDERER_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_CELL_RENDERER_EXPANDER, EmpathyCellRendererExpanderClass)) - -typedef struct _EmpathyCellRendererExpander EmpathyCellRendererExpander; -typedef struct _EmpathyCellRendererExpanderClass EmpathyCellRendererExpanderClass; - -struct _EmpathyCellRendererExpander { - GtkCellRenderer parent; - gpointer priv; -}; - -struct _EmpathyCellRendererExpanderClass { - GtkCellRendererClass parent_class; - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - -GType empathy_cell_renderer_expander_get_type (void) G_GNUC_CONST; -GtkCellRenderer *empathy_cell_renderer_expander_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_CELL_RENDERER_EXPANDER_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.c b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.c deleted file mode 100644 index 567a1d9d3..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.c +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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> - */ - -#include "config.h" - -#include <string.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-cell-renderer-text.h" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyCellRendererText) -typedef struct { - gchar *name; - gchar *status; - gboolean is_group; - - gboolean is_valid; - gboolean is_selected; - - gboolean show_status; -} EmpathyCellRendererTextPriv; - -static void cell_renderer_text_finalize (GObject *object); -static void cell_renderer_text_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void cell_renderer_text_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void cell_renderer_text_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); -static void cell_renderer_text_render (GtkCellRenderer *cell, - GdkDrawable *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags); -static void cell_renderer_text_update_text (EmpathyCellRendererText *cell, - GtkWidget *widget, - gboolean selected); - -/* Properties */ -enum { - PROP_0, - PROP_NAME, - PROP_STATUS, - PROP_IS_GROUP, - PROP_SHOW_STATUS, -}; - -G_DEFINE_TYPE (EmpathyCellRendererText, empathy_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT); - -static void -empathy_cell_renderer_text_class_init (EmpathyCellRendererTextClass *klass) -{ - GObjectClass *object_class; - GtkCellRendererClass *cell_class; - - object_class = G_OBJECT_CLASS (klass); - cell_class = GTK_CELL_RENDERER_CLASS (klass); - - object_class->finalize = cell_renderer_text_finalize; - - object_class->get_property = cell_renderer_text_get_property; - object_class->set_property = cell_renderer_text_set_property; - - cell_class->get_size = cell_renderer_text_get_size; - cell_class->render = cell_renderer_text_render; - - g_object_class_install_property (object_class, - PROP_NAME, - g_param_spec_string ("name", - "Name", - "Contact name", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_STATUS, - g_param_spec_string ("status", - "Status", - "Contact status string", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_IS_GROUP, - g_param_spec_boolean ("is_group", - "Is group", - "Whether this cell is a group", - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_SHOW_STATUS, - g_param_spec_boolean ("show-status", - "Show status", - "Whether to show the status line", - TRUE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyCellRendererTextPriv)); -} - -static void -empathy_cell_renderer_text_init (EmpathyCellRendererText *cell) -{ - EmpathyCellRendererTextPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (cell, - EMPATHY_TYPE_CELL_RENDERER_TEXT, EmpathyCellRendererTextPriv); - - cell->priv = priv; - g_object_set (cell, - "ellipsize", PANGO_ELLIPSIZE_END, - NULL); - - priv->name = g_strdup (""); - priv->status = g_strdup (""); - priv->show_status = TRUE; -} - -static void -cell_renderer_text_finalize (GObject *object) -{ - EmpathyCellRendererText *cell; - EmpathyCellRendererTextPriv *priv; - - cell = EMPATHY_CELL_RENDERER_TEXT (object); - priv = GET_PRIV (cell); - - g_free (priv->name); - g_free (priv->status); - - (G_OBJECT_CLASS (empathy_cell_renderer_text_parent_class)->finalize) (object); -} - -static void -cell_renderer_text_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyCellRendererText *cell; - EmpathyCellRendererTextPriv *priv; - - cell = EMPATHY_CELL_RENDERER_TEXT (object); - priv = GET_PRIV (cell); - - switch (param_id) { - case PROP_NAME: - g_value_set_string (value, priv->name); - break; - case PROP_STATUS: - g_value_set_string (value, priv->status); - break; - case PROP_IS_GROUP: - g_value_set_boolean (value, priv->is_group); - break; - case PROP_SHOW_STATUS: - g_value_set_boolean (value, priv->show_status); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -cell_renderer_text_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyCellRendererText *cell; - EmpathyCellRendererTextPriv *priv; - const gchar *str; - - cell = EMPATHY_CELL_RENDERER_TEXT (object); - priv = GET_PRIV (cell); - - switch (param_id) { - case PROP_NAME: - g_free (priv->name); - str = g_value_get_string (value); - priv->name = g_strdup (str ? str : ""); - g_strdelimit (priv->name, "\n\r\t", ' '); - priv->is_valid = FALSE; - break; - case PROP_STATUS: - g_free (priv->status); - str = g_value_get_string (value); - priv->status = g_strdup (str ? str : ""); - g_strdelimit (priv->status, "\n\r\t", ' '); - priv->is_valid = FALSE; - break; - case PROP_IS_GROUP: - priv->is_group = g_value_get_boolean (value); - priv->is_valid = FALSE; - break; - case PROP_SHOW_STATUS: - priv->show_status = g_value_get_boolean (value); - priv->is_valid = FALSE; - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -cell_renderer_text_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - EmpathyCellRendererText *celltext; - EmpathyCellRendererTextPriv *priv; - - celltext = EMPATHY_CELL_RENDERER_TEXT (cell); - priv = GET_PRIV (cell); - - /* Only update if not already valid so we get the right size. */ - cell_renderer_text_update_text (celltext, widget, priv->is_selected); - - (GTK_CELL_RENDERER_CLASS (empathy_cell_renderer_text_parent_class)->get_size) (cell, widget, - cell_area, - x_offset, y_offset, - width, height); -} - -static void -cell_renderer_text_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) -{ - EmpathyCellRendererText *celltext; - - celltext = EMPATHY_CELL_RENDERER_TEXT (cell); - - cell_renderer_text_update_text (celltext, - widget, - (flags & GTK_CELL_RENDERER_SELECTED)); - - (GTK_CELL_RENDERER_CLASS (empathy_cell_renderer_text_parent_class)->render) ( - cell, window, - widget, - background_area, - cell_area, - expose_area, flags); -} - -static void -cell_renderer_text_update_text (EmpathyCellRendererText *cell, - GtkWidget *widget, - gboolean selected) -{ - EmpathyCellRendererTextPriv *priv; - PangoAttrList *attr_list; - PangoAttribute *attr_color, *attr_size; - GtkStyle *style; - gchar *str; - - priv = GET_PRIV (cell); - - if (priv->is_valid && priv->is_selected == selected) { - return; - } - - if (priv->is_group) { - g_object_set (cell, - "visible", TRUE, - "weight", PANGO_WEIGHT_BOLD, - "text", priv->name, - "attributes", NULL, - "xpad", 1, - "ypad", 1, - NULL); - - priv->is_selected = selected; - priv->is_valid = TRUE; - return; - } - - style = gtk_widget_get_style (widget); - - attr_list = pango_attr_list_new (); - - attr_size = pango_attr_size_new (pango_font_description_get_size (style->font_desc) / 1.2); - attr_size->start_index = strlen (priv->name) + 1; - attr_size->end_index = -1; - pango_attr_list_insert (attr_list, attr_size); - - if (!selected) { - GdkColor color; - - color = style->text_aa[GTK_STATE_NORMAL]; - - attr_color = pango_attr_foreground_new (color.red, color.green, color.blue); - attr_color->start_index = attr_size->start_index; - attr_color->end_index = -1; - pango_attr_list_insert (attr_list, attr_color); - } - - if (!priv->status || !priv->status[0] || !priv->show_status) { - str = g_strdup (priv->name); - } else { - str = g_strdup_printf ("%s\n%s", priv->name, priv->status); - } - - g_object_set (cell, - "visible", TRUE, - "weight", PANGO_WEIGHT_NORMAL, - "text", str, - "attributes", attr_list, - "xpad", 0, - "ypad", 1, - NULL); - - g_free (str); - pango_attr_list_unref (attr_list); - - priv->is_selected = selected; - priv->is_valid = TRUE; -} - -GtkCellRenderer * -empathy_cell_renderer_text_new (void) -{ - return g_object_new (EMPATHY_TYPE_CELL_RENDERER_TEXT, NULL); -} diff --git a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.h b/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.h deleted file mode 100644 index 7de8b2d08..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-cell-renderer-text.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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> - */ - -#ifndef __EMPATHY_CELL_RENDERER_TEXT_H__ -#define __EMPATHY_CELL_RENDERER_TEXT_H__ - -#include <gtk/gtkcellrenderertext.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CELL_RENDERER_TEXT (empathy_cell_renderer_text_get_type ()) -#define EMPATHY_CELL_RENDERER_TEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CELL_RENDERER_TEXT, EmpathyCellRendererText)) -#define EMPATHY_CELL_RENDERER_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CELL_RENDERER_TEXT, EmpathyCellRendererTextClass)) -#define EMPATHY_IS_CELL_RENDERER_TEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CELL_RENDERER_TEXT)) -#define EMPATHY_IS_CELL_RENDERER_TEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CELL_RENDERER_TEXT)) -#define EMPATHY_CELL_RENDERER_TEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CELL_RENDERER_TEXT, EmpathyCellRendererTextClass)) - -typedef struct _EmpathyCellRendererText EmpathyCellRendererText; -typedef struct _EmpathyCellRendererTextClass EmpathyCellRendererTextClass; - -struct _EmpathyCellRendererText { - GtkCellRendererText parent; - gpointer priv; -}; - -struct _EmpathyCellRendererTextClass { - GtkCellRendererTextClass parent_class; -}; - -GType empathy_cell_renderer_text_get_type (void) G_GNUC_CONST; -GtkCellRenderer * empathy_cell_renderer_text_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_CELL_RENDERER_TEXT_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-chat-text-view.c b/gnome-2-26/libempathy-gtk/empathy-chat-text-view.c deleted file mode 100644 index f15d076ff..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat-text-view.c +++ /dev/null @@ -1,1365 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 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 <sys/types.h> -#include <string.h> -#include <time.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtksizegroup.h> -#include <glade/glade.h> - -#include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-account.h> - -#include <libempathy/empathy-utils.h> - -#include "empathy-chat-text-view.h" -#include "empathy-chat.h" -#include "empathy-conf.h" -#include "empathy-ui-utils.h" -#include "empathy-smiley-manager.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_CHAT -#include <libempathy/empathy-debug.h> - -/* Number of seconds between timestamps when using normal mode, 5 minutes. */ -#define TIMESTAMP_INTERVAL 300 - -#define MAX_LINES 800 -#define MAX_SCROLL_TIME 0.4 /* seconds */ -#define SCROLL_DELAY 33 /* milliseconds */ - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatTextView) - -typedef struct { - GtkTextBuffer *buffer; - guint scroll_timeout; - GTimer *scroll_time; - GtkTextMark *find_mark_previous; - GtkTextMark *find_mark_next; - gboolean find_wrapped; - gboolean find_last_direction; - EmpathyContact *last_contact; - time_t last_timestamp; - gboolean allow_scrolling; - guint notify_system_fonts_id; - EmpathySmileyManager *smiley_manager; - gboolean only_if_date; -} EmpathyChatTextViewPriv; - -static void chat_text_view_iface_init (EmpathyChatViewIface *iface); - -G_DEFINE_TYPE_WITH_CODE (EmpathyChatTextView, empathy_chat_text_view, - GTK_TYPE_TEXT_VIEW, - G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CHAT_VIEW, - chat_text_view_iface_init)); - -enum { - PROP_0, - PROP_LAST_CONTACT, - PROP_ONLY_IF_DATE -}; - -static gboolean -chat_text_view_url_event_cb (GtkTextTag *tag, - GObject *object, - GdkEvent *event, - GtkTextIter *iter, - EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv; - GtkTextIter start, end; - gchar *str; - - priv = GET_PRIV (view); - - /* If the link is being selected, don't do anything. */ - gtk_text_buffer_get_selection_bounds (priv->buffer, &start, &end); - if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end)) { - return FALSE; - } - - if (event->type == GDK_BUTTON_RELEASE && event->button.button == 1) { - start = end = *iter; - - if (gtk_text_iter_backward_to_tag_toggle (&start, tag) && - gtk_text_iter_forward_to_tag_toggle (&end, tag)) { - str = gtk_text_buffer_get_text (priv->buffer, - &start, - &end, - FALSE); - - empathy_url_show (GTK_WIDGET (view), str); - g_free (str); - } - } - - return FALSE; -} - -static gboolean -chat_text_view_event_cb (EmpathyChatTextView *view, - GdkEventMotion *event, - GtkTextTag *tag) -{ - static GdkCursor *hand = NULL; - static GdkCursor *beam = NULL; - GtkTextWindowType type; - GtkTextIter iter; - GdkWindow *win; - gint x, y, buf_x, buf_y; - - type = gtk_text_view_get_window_type (GTK_TEXT_VIEW (view), - event->window); - - if (type != GTK_TEXT_WINDOW_TEXT) { - return FALSE; - } - - /* Get where the pointer really is. */ - win = gtk_text_view_get_window (GTK_TEXT_VIEW (view), type); - if (!win) { - return FALSE; - } - - gdk_window_get_pointer (win, &x, &y, NULL); - - /* Get the iter where the cursor is at */ - gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), type, - x, y, - &buf_x, &buf_y); - - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), - &iter, - buf_x, buf_y); - - if (gtk_text_iter_has_tag (&iter, tag)) { - if (!hand) { - hand = gdk_cursor_new (GDK_HAND2); - beam = gdk_cursor_new (GDK_XTERM); - } - gdk_window_set_cursor (win, hand); - } else { - if (!beam) { - beam = gdk_cursor_new (GDK_XTERM); - } - gdk_window_set_cursor (win, beam); - } - - return FALSE; -} - -static void -chat_text_view_create_tags (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GtkTextTag *tag; - - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_CUT, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY, NULL); - gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT, NULL); - - tag = gtk_text_buffer_create_tag (priv->buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK, NULL); - g_signal_connect (tag, "event", - G_CALLBACK (chat_text_view_url_event_cb), - view); - - g_signal_connect (view, "motion-notify-event", - G_CALLBACK (chat_text_view_event_cb), - tag); -} - -static void -chat_text_view_system_font_update (EmpathyChatTextView *view) -{ - PangoFontDescription *font_description = NULL; - gchar *font_name; - - if (empathy_conf_get_string (empathy_conf_get (), - "/desktop/gnome/interface/document_font_name", - &font_name) && font_name) { - font_description = pango_font_description_from_string (font_name); - g_free (font_name); - } else { - font_description = NULL; - } - - gtk_widget_modify_font (GTK_WIDGET (view), font_description); - - if (font_description) { - pango_font_description_free (font_description); - } -} - -static void -chat_text_view_notify_system_font_cb (EmpathyConf *conf, - const gchar *key, - gpointer user_data) -{ - EmpathyChatTextView *view = user_data; - - chat_text_view_system_font_update (view); -} - -static void -chat_text_view_clear_view_cb (GtkMenuItem *menuitem, EmpathyChatTextView *view) -{ - empathy_chat_view_clear (EMPATHY_CHAT_VIEW (view)); -} - -static void -chat_text_view_open_address_cb (GtkMenuItem *menuitem, const gchar *url) -{ - empathy_url_show (GTK_WIDGET (menuitem), url); -} - -static void -chat_text_view_copy_address_cb (GtkMenuItem *menuitem, const gchar *url) -{ - GtkClipboard *clipboard; - - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text (clipboard, url, -1); - - clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY); - gtk_clipboard_set_text (clipboard, url, -1); -} - -static void -chat_text_view_populate_popup (EmpathyChatTextView *view, - GtkMenu *menu, - gpointer user_data) -{ - EmpathyChatTextViewPriv *priv; - GtkTextTagTable *table; - GtkTextTag *tag; - gint x, y; - GtkTextIter iter, start, end; - GtkWidget *item; - gchar *str = NULL; - - priv = GET_PRIV (view); - - /* Clear menu item */ - if (gtk_text_buffer_get_char_count (priv->buffer) > 0) { - item = gtk_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLEAR, NULL); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_view_clear_view_cb), - view); - } - - /* Link context menu items */ - table = gtk_text_buffer_get_tag_table (priv->buffer); - tag = gtk_text_tag_table_lookup (table, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK); - - gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); - - gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), - GTK_TEXT_WINDOW_WIDGET, - x, y, - &x, &y); - - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &iter, x, y); - - start = end = iter; - - if (gtk_text_iter_backward_to_tag_toggle (&start, tag) && - gtk_text_iter_forward_to_tag_toggle (&end, tag)) { - str = gtk_text_buffer_get_text (priv->buffer, - &start, &end, FALSE); - } - - if (EMP_STR_EMPTY (str)) { - g_free (str); - return; - } - - /* NOTE: Set data just to get the string freed when not needed. */ - g_object_set_data_full (G_OBJECT (menu), - "url", str, - (GDestroyNotify) g_free); - - item = gtk_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_menu_item_new_with_mnemonic (_("_Copy Link Address")); - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_view_copy_address_cb), - str); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_menu_item_new_with_mnemonic (_("_Open Link")); - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_view_open_address_cb), - str); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); -} - -static gboolean -chat_text_view_is_scrolled_down (EmpathyChatTextView *view) -{ - GtkWidget *sw; - - sw = gtk_widget_get_parent (GTK_WIDGET (view)); - if (GTK_IS_SCROLLED_WINDOW (sw)) { - GtkAdjustment *vadj; - - vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)); - - if (vadj->value + vadj->page_size / 2 < vadj->upper - vadj->page_size) { - return FALSE; - } - } - - return TRUE; -} - -static void -chat_text_view_maybe_trim_buffer (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv; - GtkTextIter top, bottom; - gint line; - gint remove; - GtkTextTagTable *table; - GtkTextTag *tag; - - priv = GET_PRIV (view); - - gtk_text_buffer_get_end_iter (priv->buffer, &bottom); - line = gtk_text_iter_get_line (&bottom); - if (line < MAX_LINES) { - return; - } - - remove = line - MAX_LINES; - gtk_text_buffer_get_start_iter (priv->buffer, &top); - - bottom = top; - if (!gtk_text_iter_forward_lines (&bottom, remove)) { - return; - } - - /* Track backwords to a place where we can safely cut, we don't do it in - * the middle of a tag. - */ - table = gtk_text_buffer_get_tag_table (priv->buffer); - tag = gtk_text_tag_table_lookup (table, EMPATHY_CHAT_TEXT_VIEW_TAG_CUT); - if (!tag) { - return; - } - - if (!gtk_text_iter_forward_to_tag_toggle (&bottom, tag)) { - return; - } - - if (!gtk_text_iter_equal (&top, &bottom)) { - gtk_text_buffer_delete (priv->buffer, &top, &bottom); - } -} - -static void -chat_text_view_append_timestamp (EmpathyChatTextView *view, - time_t timestamp, - gboolean show_date) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GtkTextIter iter; - gchar *tmp; - GString *str; - - str = g_string_new ("- "); - - /* Append date if needed */ - if (show_date) { - GDate *date; - gchar buf[256]; - - date = g_date_new (); - g_date_set_time_t (date, timestamp); - /* Translators: timestamp displayed between conversations in - * chat windows (strftime format string) */ - g_date_strftime (buf, 256, _("%A %B %d %Y"), date); - g_string_append (str, buf); - g_string_append (str, ", "); - g_date_free (date); - } - - /* Append time */ - tmp = empathy_time_to_string_local (timestamp, EMPATHY_TIME_FORMAT_DISPLAY_SHORT); - g_string_append (str, tmp); - g_free (tmp); - - g_string_append (str, " -\n"); - - /* Insert the string in the buffer */ - empathy_chat_text_view_append_spacing (view); - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (priv->buffer, - &iter, - str->str, -1, - EMPATHY_CHAT_TEXT_VIEW_TAG_TIME, - NULL); - - priv->last_timestamp = timestamp; - - g_string_free (str, TRUE); -} - -static void -chat_text_maybe_append_date_and_time (EmpathyChatTextView *view, - time_t timestamp) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GDate *date, *last_date; - gboolean append_date = FALSE; - gboolean append_time = FALSE; - - /* Get the date from last message */ - last_date = g_date_new (); - g_date_set_time_t (last_date, priv->last_timestamp); - - /* Get the date of the message we are appending */ - date = g_date_new (); - g_date_set_time_t (date, timestamp); - - /* If last message was from another day we append date and time */ - if (g_date_compare (date, last_date) > 0) { - append_date = TRUE; - append_time = TRUE; - } - - g_date_free (last_date); - g_date_free (date); - - /* If last message is 'old' append the time */ - if (timestamp - priv->last_timestamp >= TIMESTAMP_INTERVAL) { - append_time = TRUE; - } - - if (append_date || (!priv->only_if_date && append_time)) { - chat_text_view_append_timestamp (view, timestamp, append_date); - } -} - -static void -chat_text_view_size_allocate (GtkWidget *widget, - GtkAllocation *alloc) -{ - gboolean down; - - down = chat_text_view_is_scrolled_down (EMPATHY_CHAT_TEXT_VIEW (widget)); - - GTK_WIDGET_CLASS (empathy_chat_text_view_parent_class)->size_allocate (widget, alloc); - - if (down) { - GtkAdjustment *adj; - - adj = GTK_TEXT_VIEW (widget)->vadjustment; - gtk_adjustment_set_value (adj, adj->upper - adj->page_size); - } -} - -static gboolean -chat_text_view_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - /* Don't handle drag motion, since we don't want the view to scroll as - * the result of dragging something across it. */ - - return FALSE; -} - -static void -chat_text_view_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (object); - - switch (param_id) { - case PROP_LAST_CONTACT: - g_value_set_object (value, priv->last_contact); - break; - case PROP_ONLY_IF_DATE: - g_value_set_boolean (value, priv->only_if_date); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -chat_text_view_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (object); - - switch (param_id) { - case PROP_ONLY_IF_DATE: - priv->only_if_date = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -chat_text_view_finalize (GObject *object) -{ - EmpathyChatTextView *view; - EmpathyChatTextViewPriv *priv; - - view = EMPATHY_CHAT_TEXT_VIEW (object); - priv = GET_PRIV (view); - - DEBUG ("%p", object); - - empathy_conf_notify_remove (empathy_conf_get (), priv->notify_system_fonts_id); - - if (priv->last_contact) { - g_object_unref (priv->last_contact); - } - if (priv->scroll_time) { - g_timer_destroy (priv->scroll_time); - } - if (priv->scroll_timeout) { - g_source_remove (priv->scroll_timeout); - } - - G_OBJECT_CLASS (empathy_chat_text_view_parent_class)->finalize (object); -} - -static void -empathy_chat_text_view_class_init (EmpathyChatTextViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->finalize = chat_text_view_finalize; - object_class->get_property = chat_text_view_get_property; - object_class->set_property = chat_text_view_set_property; - - widget_class->size_allocate = chat_text_view_size_allocate; - widget_class->drag_motion = chat_text_view_drag_motion; - - g_object_class_install_property (object_class, - PROP_LAST_CONTACT, - g_param_spec_object ("last-contact", - "Last contact", - "The sender of the last received message", - EMPATHY_TYPE_CONTACT, - G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_ONLY_IF_DATE, - g_param_spec_boolean ("only-if-date", - "Only if date", - "Display timestamp only if the date changes", - FALSE, - G_PARAM_READWRITE)); - - - g_type_class_add_private (object_class, sizeof (EmpathyChatTextViewPriv)); -} - -static void -empathy_chat_text_view_init (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (view, - EMPATHY_TYPE_CHAT_TEXT_VIEW, EmpathyChatTextViewPriv); - - view->priv = priv; - priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - priv->last_timestamp = 0; - priv->allow_scrolling = TRUE; - priv->smiley_manager = empathy_smiley_manager_dup_singleton (); - - g_object_set (view, - "wrap-mode", GTK_WRAP_WORD_CHAR, - "editable", FALSE, - "cursor-visible", FALSE, - NULL); - - priv->notify_system_fonts_id = - empathy_conf_notify_add (empathy_conf_get (), - "/desktop/gnome/interface/document_font_name", - chat_text_view_notify_system_font_cb, - view); - chat_text_view_system_font_update (view); - chat_text_view_create_tags (view); - - g_signal_connect (view, - "populate-popup", - G_CALLBACK (chat_text_view_populate_popup), - NULL); -} - -/* Code stolen from pidgin/gtkimhtml.c */ -static gboolean -chat_text_view_scroll_cb (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv; - GtkAdjustment *adj; - gdouble max_val; - - priv = GET_PRIV (view); - adj = GTK_TEXT_VIEW (view)->vadjustment; - max_val = adj->upper - adj->page_size; - - g_return_val_if_fail (priv->scroll_time != NULL, FALSE); - - if (g_timer_elapsed (priv->scroll_time, NULL) > MAX_SCROLL_TIME) { - /* time's up. jump to the end and kill the timer */ - gtk_adjustment_set_value (adj, max_val); - g_timer_destroy (priv->scroll_time); - priv->scroll_time = NULL; - priv->scroll_timeout = 0; - return FALSE; - } - - /* scroll by 1/3rd the remaining distance */ - gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) + ((max_val - gtk_adjustment_get_value (adj)) / 3)); - return TRUE; -} - -static void -chat_text_view_scroll_down (EmpathyChatView *view) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - if (!priv->allow_scrolling) { - return; - } - - DEBUG ("Scrolling down"); - - if (priv->scroll_time) { - g_timer_reset (priv->scroll_time); - } else { - priv->scroll_time = g_timer_new(); - } - if (!priv->scroll_timeout) { - priv->scroll_timeout = g_timeout_add (SCROLL_DELAY, - (GSourceFunc) chat_text_view_scroll_cb, - view); - } -} - -static void -chat_text_view_append_message (EmpathyChatView *view, - EmpathyMessage *msg) -{ - EmpathyChatTextView *text_view = EMPATHY_CHAT_TEXT_VIEW (view); - EmpathyChatTextViewPriv *priv = GET_PRIV (text_view); - gboolean bottom; - time_t timestamp; - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - g_return_if_fail (EMPATHY_IS_MESSAGE (msg)); - - if (!empathy_message_get_body (msg)) { - return; - } - - bottom = chat_text_view_is_scrolled_down (text_view); - - chat_text_view_maybe_trim_buffer (EMPATHY_CHAT_TEXT_VIEW (view)); - - timestamp = empathy_message_get_timestamp (msg); - chat_text_maybe_append_date_and_time (text_view, timestamp); - if (EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message) { - EMPATHY_CHAT_TEXT_VIEW_GET_CLASS (view)->append_message (text_view, - msg); - } - - if (bottom) { - chat_text_view_scroll_down (view); - } - - if (priv->last_contact) { - g_object_unref (priv->last_contact); - } - priv->last_contact = g_object_ref (empathy_message_get_sender (msg)); - g_object_notify (G_OBJECT (view), "last-contact"); -} - -static void -chat_text_view_append_event (EmpathyChatView *view, - const gchar *str) -{ - EmpathyChatTextView *text_view = EMPATHY_CHAT_TEXT_VIEW (view); - EmpathyChatTextViewPriv *priv = GET_PRIV (text_view); - gboolean bottom; - GtkTextIter iter; - gchar *msg; - - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - g_return_if_fail (!EMP_STR_EMPTY (str)); - - bottom = chat_text_view_is_scrolled_down (text_view); - chat_text_view_maybe_trim_buffer (EMPATHY_CHAT_TEXT_VIEW (view)); - chat_text_maybe_append_date_and_time (text_view, - empathy_time_get_current ()); - - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - msg = g_strdup_printf (" - %s\n", str); - gtk_text_buffer_insert_with_tags_by_name (priv->buffer, &iter, - msg, -1, - EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT, - NULL); - g_free (msg); - - if (bottom) { - chat_text_view_scroll_down (view); - } - - if (priv->last_contact) { - g_object_unref (priv->last_contact); - priv->last_contact = NULL; - g_object_notify (G_OBJECT (view), "last-contact"); - } -} - -static void -chat_text_view_scroll (EmpathyChatView *view, - gboolean allow_scrolling) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - DEBUG ("Scrolling %s", allow_scrolling ? "enabled" : "disabled"); - - priv->allow_scrolling = allow_scrolling; - if (allow_scrolling) { - empathy_chat_view_scroll_down (view); - } -} - -static gboolean -chat_text_view_get_has_selection (EmpathyChatView *view) -{ - GtkTextBuffer *buffer; - - g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), FALSE); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - return gtk_text_buffer_get_has_selection (buffer); -} - -static void -chat_text_view_clear (EmpathyChatView *view) -{ - GtkTextBuffer *buffer; - EmpathyChatTextViewPriv *priv; - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - gtk_text_buffer_set_text (buffer, "", -1); - - /* We set these back to the initial values so we get - * timestamps when clearing the window to know when - * conversations start. - */ - priv = GET_PRIV (view); - - priv->last_timestamp = 0; -} - -static gboolean -chat_text_view_find_previous (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search) -{ - EmpathyChatTextViewPriv *priv; - GtkTextBuffer *buffer; - GtkTextIter iter_at_mark; - GtkTextIter iter_match_start; - GtkTextIter iter_match_end; - gboolean found; - gboolean from_start = FALSE; - - g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), FALSE); - g_return_val_if_fail (search_criteria != NULL, FALSE); - - priv = GET_PRIV (view); - - buffer = priv->buffer; - - if (EMP_STR_EMPTY (search_criteria)) { - if (priv->find_mark_previous) { - gtk_text_buffer_get_start_iter (buffer, &iter_at_mark); - - gtk_text_buffer_move_mark (buffer, - priv->find_mark_previous, - &iter_at_mark); - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view), - priv->find_mark_previous, - 0.0, - TRUE, - 0.0, - 0.0); - gtk_text_buffer_select_range (buffer, - &iter_at_mark, - &iter_at_mark); - } - - return FALSE; - } - - if (new_search) { - from_start = TRUE; - } - - if (priv->find_mark_previous) { - gtk_text_buffer_get_iter_at_mark (buffer, - &iter_at_mark, - priv->find_mark_previous); - } else { - gtk_text_buffer_get_end_iter (buffer, &iter_at_mark); - from_start = TRUE; - } - - priv->find_last_direction = FALSE; - - found = empathy_text_iter_backward_search (&iter_at_mark, - search_criteria, - &iter_match_start, - &iter_match_end, - NULL); - - if (!found) { - gboolean result = FALSE; - - if (from_start) { - return result; - } - - /* Here we wrap around. */ - if (!new_search && !priv->find_wrapped) { - priv->find_wrapped = TRUE; - result = chat_text_view_find_previous (view, - search_criteria, - FALSE); - priv->find_wrapped = FALSE; - } - - return result; - } - - /* Set new mark and show on screen */ - if (!priv->find_mark_previous) { - priv->find_mark_previous = gtk_text_buffer_create_mark (buffer, NULL, - &iter_match_start, - TRUE); - } else { - gtk_text_buffer_move_mark (buffer, - priv->find_mark_previous, - &iter_match_start); - } - - if (!priv->find_mark_next) { - priv->find_mark_next = gtk_text_buffer_create_mark (buffer, NULL, - &iter_match_end, - TRUE); - } else { - gtk_text_buffer_move_mark (buffer, - priv->find_mark_next, - &iter_match_end); - } - - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view), - priv->find_mark_previous, - 0.0, - TRUE, - 0.5, - 0.5); - - gtk_text_buffer_move_mark_by_name (buffer, "selection_bound", &iter_match_start); - gtk_text_buffer_move_mark_by_name (buffer, "insert", &iter_match_end); - - return TRUE; -} - -static gboolean -chat_text_view_find_next (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search) -{ - EmpathyChatTextViewPriv *priv; - GtkTextBuffer *buffer; - GtkTextIter iter_at_mark; - GtkTextIter iter_match_start; - GtkTextIter iter_match_end; - gboolean found; - gboolean from_start = FALSE; - - g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), FALSE); - g_return_val_if_fail (search_criteria != NULL, FALSE); - - priv = GET_PRIV (view); - - buffer = priv->buffer; - - if (EMP_STR_EMPTY (search_criteria)) { - if (priv->find_mark_next) { - gtk_text_buffer_get_start_iter (buffer, &iter_at_mark); - - gtk_text_buffer_move_mark (buffer, - priv->find_mark_next, - &iter_at_mark); - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view), - priv->find_mark_next, - 0.0, - TRUE, - 0.0, - 0.0); - gtk_text_buffer_select_range (buffer, - &iter_at_mark, - &iter_at_mark); - } - - return FALSE; - } - - if (new_search) { - from_start = TRUE; - } - - if (priv->find_mark_next) { - gtk_text_buffer_get_iter_at_mark (buffer, - &iter_at_mark, - priv->find_mark_next); - } else { - gtk_text_buffer_get_start_iter (buffer, &iter_at_mark); - from_start = TRUE; - } - - priv->find_last_direction = TRUE; - - found = empathy_text_iter_forward_search (&iter_at_mark, - search_criteria, - &iter_match_start, - &iter_match_end, - NULL); - - if (!found) { - gboolean result = FALSE; - - if (from_start) { - return result; - } - - /* Here we wrap around. */ - if (!new_search && !priv->find_wrapped) { - priv->find_wrapped = TRUE; - result = chat_text_view_find_next (view, - search_criteria, - FALSE); - priv->find_wrapped = FALSE; - } - - return result; - } - - /* Set new mark and show on screen */ - if (!priv->find_mark_next) { - priv->find_mark_next = gtk_text_buffer_create_mark (buffer, NULL, - &iter_match_end, - TRUE); - } else { - gtk_text_buffer_move_mark (buffer, - priv->find_mark_next, - &iter_match_end); - } - - if (!priv->find_mark_previous) { - priv->find_mark_previous = gtk_text_buffer_create_mark (buffer, NULL, - &iter_match_start, - TRUE); - } else { - gtk_text_buffer_move_mark (buffer, - priv->find_mark_previous, - &iter_match_start); - } - - gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view), - priv->find_mark_next, - 0.0, - TRUE, - 0.5, - 0.5); - - gtk_text_buffer_move_mark_by_name (buffer, "selection_bound", &iter_match_start); - gtk_text_buffer_move_mark_by_name (buffer, "insert", &iter_match_end); - - return TRUE; -} - -static void -chat_text_view_find_abilities (EmpathyChatView *view, - const gchar *search_criteria, - gboolean *can_do_previous, - gboolean *can_do_next) -{ - EmpathyChatTextViewPriv *priv; - GtkTextBuffer *buffer; - GtkTextIter iter_at_mark; - GtkTextIter iter_match_start; - GtkTextIter iter_match_end; - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - g_return_if_fail (search_criteria != NULL); - g_return_if_fail (can_do_previous != NULL && can_do_next != NULL); - - priv = GET_PRIV (view); - - buffer = priv->buffer; - - if (can_do_previous) { - if (priv->find_mark_previous) { - gtk_text_buffer_get_iter_at_mark (buffer, - &iter_at_mark, - priv->find_mark_previous); - } else { - gtk_text_buffer_get_start_iter (buffer, &iter_at_mark); - } - - *can_do_previous = empathy_text_iter_backward_search (&iter_at_mark, - search_criteria, - &iter_match_start, - &iter_match_end, - NULL); - } - - if (can_do_next) { - if (priv->find_mark_next) { - gtk_text_buffer_get_iter_at_mark (buffer, - &iter_at_mark, - priv->find_mark_next); - } else { - gtk_text_buffer_get_start_iter (buffer, &iter_at_mark); - } - - *can_do_next = empathy_text_iter_forward_search (&iter_at_mark, - search_criteria, - &iter_match_start, - &iter_match_end, - NULL); - } -} - -static void -chat_text_view_highlight (EmpathyChatView *view, - const gchar *text) -{ - GtkTextBuffer *buffer; - GtkTextIter iter; - GtkTextIter iter_start; - GtkTextIter iter_end; - GtkTextIter iter_match_start; - GtkTextIter iter_match_end; - gboolean found; - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - gtk_text_buffer_get_start_iter (buffer, &iter); - - gtk_text_buffer_get_bounds (buffer, &iter_start, &iter_end); - gtk_text_buffer_remove_tag_by_name (buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT, - &iter_start, - &iter_end); - - if (EMP_STR_EMPTY (text)) { - return; - } - - while (1) { - found = empathy_text_iter_forward_search (&iter, - text, - &iter_match_start, - &iter_match_end, - NULL); - - if (!found) { - break; - } - - gtk_text_buffer_apply_tag_by_name (buffer, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT, - &iter_match_start, - &iter_match_end); - - iter = iter_match_end; - gtk_text_iter_forward_char (&iter); - } -} - -static void -chat_text_view_copy_clipboard (EmpathyChatView *view) -{ - GtkTextBuffer *buffer; - GtkClipboard *clipboard; - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - - gtk_text_buffer_copy_clipboard (buffer, clipboard); -} - -static void -chat_text_view_iface_init (EmpathyChatViewIface *iface) -{ - iface->append_message = chat_text_view_append_message; - iface->append_event = chat_text_view_append_event; - iface->scroll = chat_text_view_scroll; - iface->scroll_down = chat_text_view_scroll_down; - iface->get_has_selection = chat_text_view_get_has_selection; - iface->clear = chat_text_view_clear; - iface->find_previous = chat_text_view_find_previous; - iface->find_next = chat_text_view_find_next; - iface->find_abilities = chat_text_view_find_abilities; - iface->highlight = chat_text_view_highlight; - iface->copy_clipboard = chat_text_view_copy_clipboard; -} - -EmpathyContact * -empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - - g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), NULL); - - return priv->last_contact; -} - -void -empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view, - gboolean only_if_date) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - - g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); - - if (only_if_date != priv->only_if_date) { - priv->only_if_date = only_if_date; - g_object_notify (G_OBJECT (view), "only-if-date"); - } -} - -static void -chat_text_view_insert_text_with_emoticons (EmpathyChatTextView *view, - GtkTextIter *iter, - const gchar *str) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - gboolean use_smileys = FALSE; - GSList *smileys, *l; - - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SHOW_SMILEYS, - &use_smileys); - - if (!use_smileys) { - gtk_text_buffer_insert (priv->buffer, iter, str, -1); - return; - } - - smileys = empathy_smiley_manager_parse (priv->smiley_manager, str); - for (l = smileys; l; l = l->next) { - EmpathySmiley *smiley; - - smiley = l->data; - if (smiley->pixbuf) { - gtk_text_buffer_insert_pixbuf (priv->buffer, iter, smiley->pixbuf); - } else { - gtk_text_buffer_insert (priv->buffer, iter, smiley->str, -1); - } - empathy_smiley_free (smiley); - } - g_slist_free (smileys); -} - -void -empathy_chat_text_view_append_body (EmpathyChatTextView *view, - const gchar *body, - const gchar *tag) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GtkTextIter start_iter, end_iter; - GtkTextMark *mark; - GtkTextIter iter; - GRegex *uri_regex; - GMatchInfo *match_info; - gboolean match; - gint last = 0; - gint s = 0, e = 0; - gchar *tmp; - - priv = GET_PRIV (view); - - gtk_text_buffer_get_end_iter (priv->buffer, &start_iter); - mark = gtk_text_buffer_create_mark (priv->buffer, NULL, &start_iter, TRUE); - - uri_regex = empathy_uri_regex_dup_singleton (); - for (match = g_regex_match (uri_regex, body, 0, &match_info); match; - match = g_match_info_next (match_info, NULL)) { - if (!g_match_info_fetch_pos (match_info, 0, &s, &e)) - continue; - - if (s > last) { - tmp = empathy_substring (body, last, s); - - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - chat_text_view_insert_text_with_emoticons (view, - &iter, - tmp); - g_free (tmp); - } - - tmp = empathy_substring (body, s, e); - - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (priv->buffer, - &iter, - tmp, - -1, - EMPATHY_CHAT_TEXT_VIEW_TAG_LINK, - NULL); - - g_free (tmp); - last = e; - } - g_match_info_free (match_info); - g_regex_unref (uri_regex); - - if (last < strlen (body)) { - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - chat_text_view_insert_text_with_emoticons (view, - &iter, - body + last); - } - - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - gtk_text_buffer_insert (priv->buffer, &iter, "\n", 1); - - /* Apply the style to the inserted text. */ - gtk_text_buffer_get_iter_at_mark (priv->buffer, &start_iter, mark); - gtk_text_buffer_get_end_iter (priv->buffer, &end_iter); - - gtk_text_buffer_apply_tag_by_name (priv->buffer, - tag, - &start_iter, - &end_iter); - - gtk_text_buffer_delete_mark (priv->buffer, mark); -} - -void -empathy_chat_text_view_append_spacing (EmpathyChatTextView *view) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GtkTextIter iter; - - gtk_text_buffer_get_end_iter (priv->buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (priv->buffer, - &iter, - "\n", - -1, - EMPATHY_CHAT_TEXT_VIEW_TAG_CUT, - EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING, - NULL); -} - -GtkTextTag * -empathy_chat_text_view_tag_set (EmpathyChatTextView *view, - const gchar *tag_name, - const gchar *first_property_name, - ...) -{ - EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GtkTextTag *tag; - GtkTextTagTable *table; - va_list list; - - g_return_val_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view), NULL); - g_return_val_if_fail (tag_name != NULL, NULL); - - table = gtk_text_buffer_get_tag_table (priv->buffer); - tag = gtk_text_tag_table_lookup (table, tag_name); - - if (tag && first_property_name) { - va_start (list, first_property_name); - g_object_set_valist (G_OBJECT (tag), first_property_name, list); - va_end (list); - } - - return tag; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-chat-text-view.h b/gnome-2-26/libempathy-gtk/empathy-chat-text-view.h deleted file mode 100644 index 120d370f1..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat-text-view.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 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> - */ - -#ifndef __EMPATHY_CHAT_TEXT_VIEW_H__ -#define __EMPATHY_CHAT_TEXT_VIEW_H__ - -#include <gtk/gtktextview.h> - -#include <libempathy/empathy-contact.h> -#include <libempathy/empathy-message.h> - -#include "empathy-chat-view.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CHAT_TEXT_VIEW (empathy_chat_text_view_get_type ()) -#define EMPATHY_CHAT_TEXT_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHAT_TEXT_VIEW, EmpathyChatTextView)) -#define EMPATHY_CHAT_TEXT_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CHAT_TEXT_VIEW, EmpathyChatTextViewClass)) -#define EMPATHY_IS_CHAT_TEXT_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHAT_TEXT_VIEW)) -#define EMPATHY_IS_CHAT_TEXT_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHAT_TEXT_VIEW)) -#define EMPATHY_CHAT_TEXT_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHAT_TEXT_VIEW, EmpathyChatTextViewClass)) - -typedef struct _EmpathyChatTextView EmpathyChatTextView; -typedef struct _EmpathyChatTextViewClass EmpathyChatTextViewClass; - -struct _EmpathyChatTextView { - GtkTextView parent; - gpointer priv; -}; - -struct _EmpathyChatTextViewClass { - GtkTextViewClass parent_class; - - /* <vtable> */ - void (*append_message) (EmpathyChatTextView *view, - EmpathyMessage *message); -}; - -#define EMPATHY_CHAT_TEXT_VIEW_TAG_CUT "cut" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT "highlight" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING "spacing" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_TIME "time" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION "action" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_BODY "body" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT "event" -#define EMPATHY_CHAT_TEXT_VIEW_TAG_LINK "link" - -GType empathy_chat_text_view_get_type (void) G_GNUC_CONST; -EmpathyContact * empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view); -void empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view, - gboolean only_if_date); -void empathy_chat_text_view_append_body (EmpathyChatTextView *view, - const gchar *body, - const gchar *tag); -void empathy_chat_text_view_append_spacing (EmpathyChatTextView *view); -GtkTextTag * empathy_chat_text_view_tag_set (EmpathyChatTextView *view, - const gchar *tag_name, - const gchar *first_property_name, - ...); - -G_END_DECLS - -#endif /* __EMPATHY_CHAT_TEXT_VIEW_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-chat-view.c b/gnome-2-26/libempathy-gtk/empathy-chat-view.c deleted file mode 100644 index 23877a275..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat-view.c +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include "empathy-chat-view.h" -#include "empathy-smiley-manager.h" - -static void chat_view_base_init (gpointer klass); - -GType -empathy_chat_view_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo type_info = { - sizeof (EmpathyChatViewIface), - chat_view_base_init, - NULL, - }; - - type = g_type_register_static (G_TYPE_INTERFACE, - "EmpathyChatView", - &type_info, 0); - - g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET); - } - - return type; -} - -static void -chat_view_base_init (gpointer klass) -{ - static gboolean initialized = FALSE; - - if (!initialized) { - initialized = TRUE; - } -} - -void -empathy_chat_view_append_message (EmpathyChatView *view, - EmpathyMessage *msg) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message (view, - msg); - } -} - -void -empathy_chat_view_append_event (EmpathyChatView *view, - const gchar *str) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event (view, - str); - } -} - -void -empathy_chat_view_scroll (EmpathyChatView *view, - gboolean allow_scrolling) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll (view, - allow_scrolling); - } -} - -void -empathy_chat_view_scroll_down (EmpathyChatView *view) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down (view); - } -} - -gboolean -empathy_chat_view_get_has_selection (EmpathyChatView *view) -{ - g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection) { - return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection (view); - } - return FALSE; -} - -void -empathy_chat_view_clear (EmpathyChatView *view) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear (view); - } -} - -gboolean -empathy_chat_view_find_previous (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search) -{ - g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous) { - return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous (view, - search_criteria, - new_search); - } - return FALSE; -} - -gboolean -empathy_chat_view_find_next (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search) -{ - g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next) { - return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next (view, - search_criteria, - new_search); - } - return FALSE; -} - - -void -empathy_chat_view_find_abilities (EmpathyChatView *view, - const gchar *search_criteria, - gboolean *can_do_previous, - gboolean *can_do_next) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities (view, - search_criteria, - can_do_previous, - can_do_next); - } -} - -void -empathy_chat_view_highlight (EmpathyChatView *view, - const gchar *text) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight (view, text); - } -} - -void -empathy_chat_view_copy_clipboard (EmpathyChatView *view) -{ - g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view)); - - if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard) { - EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard (view); - } -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-chat-view.h b/gnome-2-26/libempathy-gtk/empathy-chat-view.h deleted file mode 100644 index 08fba1508..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat-view.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CHAT_VIEW_H__ -#define __EMPATHY_CHAT_VIEW_H__ - -#include <gtk/gtktextview.h> - -#include <libempathy/empathy-contact.h> -#include <libempathy/empathy-message.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CHAT_VIEW (empathy_chat_view_get_type ()) -#define EMPATHY_CHAT_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHAT_VIEW, EmpathyChatView)) -#define EMPATHY_IS_CHAT_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHAT_VIEW)) -#define EMPATHY_TYPE_CHAT_VIEW_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EMPATHY_TYPE_CHAT_VIEW, EmpathyChatViewIface)) - -typedef struct _EmpathyChatView EmpathyChatView; -typedef struct _EmpathyChatViewIface EmpathyChatViewIface; - -struct _EmpathyChatViewIface { - GTypeInterface base_iface; - - /* VTabled */ - void (*append_message) (EmpathyChatView *view, - EmpathyMessage *msg); - void (*append_event) (EmpathyChatView *view, - const gchar *str); - void (*scroll) (EmpathyChatView *view, - gboolean allow_scrolling); - void (*scroll_down) (EmpathyChatView *view); - gboolean (*get_has_selection) (EmpathyChatView *view); - void (*clear) (EmpathyChatView *view); - gboolean (*find_previous) (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search); - gboolean (*find_next) (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search); - void (*find_abilities) (EmpathyChatView *view, - const gchar *search_criteria, - gboolean *can_do_previous, - gboolean *can_do_next); - void (*highlight) (EmpathyChatView *view, - const gchar *text); - void (*copy_clipboard) (EmpathyChatView *view); -}; - -GType empathy_chat_view_get_type (void) G_GNUC_CONST; -void empathy_chat_view_append_message (EmpathyChatView *view, - EmpathyMessage *msg); -void empathy_chat_view_append_event (EmpathyChatView *view, - const gchar *str); -void empathy_chat_view_scroll (EmpathyChatView *view, - gboolean allow_scrolling); -void empathy_chat_view_scroll_down (EmpathyChatView *view); -gboolean empathy_chat_view_get_has_selection (EmpathyChatView *view); -void empathy_chat_view_clear (EmpathyChatView *view); -gboolean empathy_chat_view_find_previous (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search); -gboolean empathy_chat_view_find_next (EmpathyChatView *view, - const gchar *search_criteria, - gboolean new_search); -void empathy_chat_view_find_abilities (EmpathyChatView *view, - const gchar *search_criteria, - gboolean *can_do_previous, - gboolean *can_do_next); -void empathy_chat_view_highlight (EmpathyChatView *view, - const gchar *text); -void empathy_chat_view_copy_clipboard (EmpathyChatView *view); - -G_END_DECLS - -#endif /* __EMPATHY_CHAT_VIEW_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-chat.c b/gnome-2-26/libempathy-gtk/empathy-chat.c deleted file mode 100644 index 652c6651d..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat.c +++ /dev/null @@ -1,1855 +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 <stdlib.h> - -#include <gdk/gdkkeysyms.h> -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> - -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-account-manager.h> -#include <libempathy/empathy-log-manager.h> -#include <libempathy/empathy-contact-list.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-dispatcher.h> - -#include "empathy-chat.h" -#include "empathy-conf.h" -#include "empathy-spell.h" -#include "empathy-spell-dialog.h" -#include "empathy-contact-list-store.h" -#include "empathy-contact-list-view.h" -#include "empathy-contact-menu.h" -#include "empathy-theme-manager.h" -#include "empathy-smiley-manager.h" -#include "empathy-ui-utils.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_CHAT -#include <libempathy/empathy-debug.h> - -#define CHAT_DIR_CREATE_MODE (S_IRUSR | S_IWUSR | S_IXUSR) -#define CHAT_FILE_CREATE_MODE (S_IRUSR | S_IWUSR) -#define IS_ENTER(v) (v == GDK_Return || v == GDK_ISO_Enter || v == GDK_KP_Enter) -#define MAX_INPUT_HEIGHT 150 -#define COMPOSING_STOP_TIMEOUT 5 - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat) -typedef struct { - EmpathyTpChat *tp_chat; - gulong tp_chat_destroy_handler; - McAccount *account; - gchar *id; - gchar *name; - gchar *subject; - EmpathyContact *remote_contact; - - EmpathyLogManager *log_manager; - EmpathyAccountManager *account_manager; - GSList *sent_messages; - gint sent_messages_index; - GList *compositors; - GCompletion *completion; - guint composing_stop_timeout_id; - guint block_events_timeout_id; - TpHandleType handle_type; - gint contacts_width; - gboolean has_input_vscroll; - - 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; - GtkWidget *contact_list_view; -} EmpathyChatPriv; - -enum { - COMPOSING, - NEW_MESSAGE, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_TP_CHAT, - PROP_ACCOUNT, - PROP_ID, - PROP_NAME, - PROP_SUBJECT, - PROP_REMOTE_CONTACT, -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (EmpathyChat, empathy_chat, GTK_TYPE_BIN); - -static void -chat_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyChat *chat = EMPATHY_CHAT (object); - EmpathyChatPriv *priv = GET_PRIV (object); - - switch (param_id) { - case PROP_TP_CHAT: - g_value_set_object (value, priv->tp_chat); - break; - case PROP_ACCOUNT: - g_value_set_object (value, priv->account); - break; - case PROP_NAME: - g_value_set_string (value, empathy_chat_get_name (chat)); - break; - case PROP_ID: - g_value_set_string (value, priv->id); - break; - 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; - }; -} - -static void -chat_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyChat *chat = EMPATHY_CHAT (object); - - switch (param_id) { - case PROP_TP_CHAT: - empathy_chat_set_tp_chat (chat, EMPATHY_TP_CHAT (g_value_get_object (value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -chat_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus current, - TpConnectionStatus previous, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - if (current == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat && - empathy_account_equal (account, priv->account) && - priv->handle_type != TP_HANDLE_TYPE_NONE) { - - DEBUG ("Account reconnected, request a new Text channel"); - - switch (priv->handle_type) { - case TP_HANDLE_TYPE_CONTACT: - empathy_dispatcher_chat_with_contact_id (account, priv->id, - NULL, NULL); - break; - case TP_HANDLE_TYPE_ROOM: - empathy_dispatcher_join_muc (account, priv->id, NULL, NULL); - break; - default: - g_assert_not_reached (); - break; - } - } -} - -static void -chat_composing_remove_timeout (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - priv = GET_PRIV (chat); - - if (priv->composing_stop_timeout_id) { - g_source_remove (priv->composing_stop_timeout_id); - priv->composing_stop_timeout_id = 0; - } -} - -static gboolean -chat_composing_stop_timeout_cb (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - priv = GET_PRIV (chat); - - priv->composing_stop_timeout_id = 0; - empathy_tp_chat_set_state (priv->tp_chat, - TP_CHANNEL_CHAT_STATE_PAUSED); - - return FALSE; -} - -static void -chat_composing_start (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - priv = GET_PRIV (chat); - - if (priv->composing_stop_timeout_id) { - /* Just restart the timeout */ - chat_composing_remove_timeout (chat); - } else { - empathy_tp_chat_set_state (priv->tp_chat, - TP_CHANNEL_CHAT_STATE_COMPOSING); - } - - priv->composing_stop_timeout_id = g_timeout_add_seconds ( - COMPOSING_STOP_TIMEOUT, - (GSourceFunc) chat_composing_stop_timeout_cb, - chat); -} - -static void -chat_composing_stop (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - priv = GET_PRIV (chat); - - chat_composing_remove_timeout (chat); - empathy_tp_chat_set_state (priv->tp_chat, - TP_CHANNEL_CHAT_STATE_ACTIVE); -} - -static void -chat_sent_message_add (EmpathyChat *chat, - const gchar *str) -{ - EmpathyChatPriv *priv; - GSList *list; - GSList *item; - - priv = GET_PRIV (chat); - - /* 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); - g_free (item->data); - g_slist_free1 (item); - } - - /* Trim the list to the last 10 items */ - while (g_slist_length (list) > 10) { - item = g_slist_last (list); - if (item) { - list = g_slist_remove_link (list, item); - g_free (item->data); - g_slist_free1 (item); - } - } - - /* Add new message */ - list = g_slist_prepend (list, g_strdup (str)); - - /* Set list and reset the index */ - priv->sent_messages = list; - priv->sent_messages_index = -1; -} - -static const gchar * -chat_sent_message_get_next (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - gint max; - - priv = GET_PRIV (chat); - - if (!priv->sent_messages) { - DEBUG ("No sent messages, next message is NULL"); - return NULL; - } - - max = g_slist_length (priv->sent_messages) - 1; - - 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); -} - -static const gchar * -chat_sent_message_get_last (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - 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; - } - - if (priv->sent_messages_index >= 0) { - priv->sent_messages_index--; - } - - DEBUG ("Returning last message index:%d", priv->sent_messages_index); - - return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index); -} - -static void -chat_send (EmpathyChat *chat, - const gchar *msg) -{ - EmpathyChatPriv *priv; - EmpathyMessage *message; - - priv = GET_PRIV (chat); - - if (EMP_STR_EMPTY (msg)) { - return; - } - - chat_sent_message_add (chat, msg); - - if (g_str_has_prefix (msg, "/clear")) { - empathy_chat_view_clear (chat->view); - return; - } - - message = empathy_message_new (msg); - - empathy_tp_chat_send (priv->tp_chat, message); - - g_object_unref (message); -} - -static void -chat_input_text_view_send (EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - GtkTextBuffer *buffer; - GtkTextIter start, end; - gchar *msg; - - priv = GET_PRIV (chat); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - - gtk_text_buffer_get_bounds (buffer, &start, &end); - msg = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - - /* clear the input field */ - gtk_text_buffer_set_text (buffer, "", -1); - - chat_send (chat, msg); - g_free (msg); -} - -static void -chat_state_changed_cb (EmpathyTpChat *tp_chat, - EmpathyContact *contact, - TpChannelChatState state, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - GList *l; - gboolean was_composing; - - priv = GET_PRIV (chat); - - if (empathy_contact_is_user (contact)) { - /* We don't care about our own chat state */ - return; - } - - was_composing = (priv->compositors != NULL); - - /* Find the contact in the list. After that l is the list elem or NULL */ - for (l = priv->compositors; l; l = l->next) { - if (contact == l->data) { - break; - } - } - - switch (state) { - case TP_CHANNEL_CHAT_STATE_GONE: - case TP_CHANNEL_CHAT_STATE_INACTIVE: - case TP_CHANNEL_CHAT_STATE_PAUSED: - case TP_CHANNEL_CHAT_STATE_ACTIVE: - /* Contact is not composing */ - if (l) { - priv->compositors = g_list_remove_link (priv->compositors, l); - g_object_unref (l->data); - g_list_free1 (l); - } - break; - case TP_CHANNEL_CHAT_STATE_COMPOSING: - /* Contact is composing */ - if (!l) { - priv->compositors = g_list_prepend (priv->compositors, - g_object_ref (contact)); - } - break; - default: - g_assert_not_reached (); - } - - DEBUG ("Was composing: %s now composing: %s", - was_composing ? "yes" : "no", - priv->compositors ? "yes" : "no"); - - if ((was_composing && !priv->compositors) || - (!was_composing && priv->compositors)) { - /* Composing state changed */ - g_signal_emit (chat, signals[COMPOSING], 0, - priv->compositors != NULL); - } -} - -static void -chat_message_received (EmpathyChat *chat, EmpathyMessage *message) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - EmpathyContact *sender; - - sender = empathy_message_get_sender (message); - - DEBUG ("Appending new message from %s (%d)", - empathy_contact_get_name (sender), - empathy_contact_get_handle (sender)); - - empathy_chat_view_append_message (chat->view, message); - - /* We received a message so the contact is no longer composing */ - chat_state_changed_cb (priv->tp_chat, sender, - TP_CHANNEL_CHAT_STATE_ACTIVE, - chat); - - g_signal_emit (chat, signals[NEW_MESSAGE], 0, message); -} - -static void -chat_message_received_cb (EmpathyTpChat *tp_chat, - EmpathyMessage *message, - EmpathyChat *chat) -{ - chat_message_received (chat, message); - empathy_tp_chat_acknowledge_message (tp_chat, message); -} - -static void -chat_send_error_cb (EmpathyTpChat *tp_chat, - EmpathyMessage *message, - TpChannelTextSendError error_code, - EmpathyChat *chat) -{ - const gchar *error; - gchar *str; - - switch (error_code) { - case TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE: - error = _("offline"); - break; - case TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT: - error = _("invalid contact"); - break; - case TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED: - error = _("permission denied"); - break; - case TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG: - error = _("too long message"); - break; - case TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED: - error = _("not implemented"); - break; - default: - error = _("unknown"); - break; - } - - str = g_strdup_printf (_("Error sending message '%s': %s"), - empathy_message_get_body (message), - error); - empathy_chat_view_append_event (chat->view, str); - g_free (str); -} - -static void -chat_property_changed_cb (EmpathyTpChat *tp_chat, - const gchar *name, - GValue *value, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - if (!tp_strdiff (name, "subject")) { - g_free (priv->subject); - priv->subject = g_value_dup_string (value); - g_object_notify (G_OBJECT (chat), "subject"); - - if (EMP_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; - - if (!EMP_STR_EMPTY (priv->subject)) { - str = g_strdup_printf (_("Topic set to: %s"), priv->subject); - } else { - str = g_strdup (_("No topic defined")); - } - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, str); - g_free (str); - } - } - else if (!tp_strdiff (name, "name")) { - g_free (priv->name); - priv->name = g_value_dup_string (value); - g_object_notify (G_OBJECT (chat), "name"); - } -} - -static gboolean -chat_get_is_command (const gchar *str) -{ - g_return_val_if_fail (str != NULL, FALSE); - - if (str[0] != '/') { - return FALSE; - } - - if (g_str_has_prefix (str, "/me")) { - return TRUE; - } - else if (g_str_has_prefix (str, "/nick")) { - return TRUE; - } - else if (g_str_has_prefix (str, "/topic")) { - return TRUE; - } - - return FALSE; -} - -static void -chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - GtkTextIter start, end; - gchar *str; - gboolean spell_checker = FALSE; - - priv = GET_PRIV (chat); - - if (gtk_text_buffer_get_char_count (buffer) == 0) { - chat_composing_stop (chat); - } else { - chat_composing_start (chat); - } - - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, - &spell_checker); - - gtk_text_buffer_get_start_iter (buffer, &start); - - if (!spell_checker) { - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_remove_tag_by_name (buffer, "misspelled", &start, &end); - return; - } - - if (!empathy_spell_supported ()) { - return; - } - - /* NOTE: this is really inefficient, we shouldn't have to - reiterate the whole buffer each time and check each work - every time. */ - while (TRUE) { - gboolean correct = FALSE; - - /* if at start */ - if (gtk_text_iter_is_start (&start)) { - end = start; - - if (!gtk_text_iter_forward_word_end (&end)) { - /* no whole word yet */ - break; - } - } else { - if (!gtk_text_iter_forward_word_end (&end)) { - /* must be the end of the buffer */ - break; - } - - start = end; - gtk_text_iter_backward_word_start (&start); - } - - str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - - /* spell check string */ - if (!chat_get_is_command (str)) { - correct = empathy_spell_check (str); - } else { - correct = TRUE; - } - - if (!correct) { - gtk_text_buffer_apply_tag_by_name (buffer, "misspelled", &start, &end); - } else { - gtk_text_buffer_remove_tag_by_name (buffer, "misspelled", &start, &end); - } - - g_free (str); - - /* set start iter to the end iters position */ - start = end; - } -} - -static gboolean -chat_input_key_press_event_cb (GtkWidget *widget, - GdkEventKey *event, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - GtkAdjustment *adj; - gdouble val; - GtkWidget *text_view_sw; - - priv = GET_PRIV (chat); - - /* Catch ctrl+up/down so we can traverse messages we sent */ - if ((event->state & GDK_CONTROL_MASK) && - (event->keyval == GDK_Up || - event->keyval == GDK_Down)) { - GtkTextBuffer *buffer; - const gchar *str; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - - if (event->keyval == GDK_Up) { - str = chat_sent_message_get_next (chat); - } else { - str = chat_sent_message_get_last (chat); - } - - g_signal_handlers_block_by_func (buffer, - chat_input_text_buffer_changed_cb, - chat); - gtk_text_buffer_set_text (buffer, str ? str : "", -1); - g_signal_handlers_unblock_by_func (buffer, - chat_input_text_buffer_changed_cb, - chat); - - return TRUE; - } - - /* Catch enter but not ctrl/shift-enter */ - if (IS_ENTER (event->keyval) && - !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))) { - GtkTextView *view; - - /* This is to make sure that kinput2 gets the enter. And if - * it's handled there we shouldn't send on it. This is because - * kinput2 uses Enter to commit letters. See: - * http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=104299 - */ - - view = GTK_TEXT_VIEW (chat->input_text_view); - if (gtk_im_context_filter_keypress (view->im_context, event)) { - GTK_TEXT_VIEW (chat->input_text_view)->need_im_reset = TRUE; - return TRUE; - } - - chat_input_text_view_send (chat); - return TRUE; - } - - text_view_sw = gtk_widget_get_parent (GTK_WIDGET (chat->view)); - - if (IS_ENTER (event->keyval) && - (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))) { - /* Newline for shift/control-enter. */ - return FALSE; - } - if (!(event->state & GDK_CONTROL_MASK) && - event->keyval == GDK_Page_Up) { - adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (text_view_sw)); - gtk_adjustment_set_value (adj, adj->value - adj->page_size); - return TRUE; - } - if ((event->state & GDK_CONTROL_MASK) != GDK_CONTROL_MASK && - event->keyval == GDK_Page_Down) { - adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (text_view_sw)); - val = MIN (adj->value + adj->page_size, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, val); - return TRUE; - } - 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 gboolean -chat_text_view_focus_in_event_cb (GtkWidget *widget, - GdkEvent *event, - EmpathyChat *chat) -{ - gtk_widget_grab_focus (chat->input_text_view); - - return TRUE; -} - -static gboolean -chat_input_set_size_request_idle (gpointer sw) -{ - gtk_widget_set_size_request (sw, -1, MAX_INPUT_HEIGHT); - - return FALSE; -} - -static void -chat_input_size_request_cb (GtkWidget *widget, - GtkRequisition *requisition, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - GtkWidget *sw; - - sw = gtk_widget_get_parent (widget); - if (requisition->height >= MAX_INPUT_HEIGHT && !priv->has_input_vscroll) { - g_idle_add (chat_input_set_size_request_idle, sw); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - priv->has_input_vscroll = TRUE; - } - - if (requisition->height < MAX_INPUT_HEIGHT && priv->has_input_vscroll) { - gtk_widget_set_size_request (sw, -1, -1); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_NEVER, - GTK_POLICY_NEVER); - priv->has_input_vscroll = FALSE; - } -} - -static void -chat_input_realize_cb (GtkWidget *widget, - EmpathyChat *chat) -{ - DEBUG ("Setting focus to the input text view"); - gtk_widget_grab_focus (widget); -} - -static void -chat_insert_smiley_activate_cb (EmpathySmileyManager *manager, - EmpathySmiley *smiley, - gpointer user_data) -{ - EmpathyChat *chat = EMPATHY_CHAT (user_data); - GtkTextBuffer *buffer; - GtkTextIter iter; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, smiley->str, -1); - - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, " ", -1); -} - -typedef struct { - EmpathyChat *chat; - gchar *word; - - GtkTextIter start; - GtkTextIter end; -} EmpathyChatSpell; - -static EmpathyChatSpell * -chat_spell_new (EmpathyChat *chat, - const gchar *word, - GtkTextIter start, - GtkTextIter end) -{ - EmpathyChatSpell *chat_spell; - - chat_spell = g_slice_new0 (EmpathyChatSpell); - - chat_spell->chat = g_object_ref (chat); - chat_spell->word = g_strdup (word); - chat_spell->start = start; - chat_spell->end = end; - - return chat_spell; -} - -static void -chat_spell_free (EmpathyChatSpell *chat_spell) -{ - g_object_unref (chat_spell->chat); - g_free (chat_spell->word); - g_slice_free (EmpathyChatSpell, chat_spell); -} - -static void -chat_text_check_word_spelling_cb (GtkMenuItem *menuitem, - EmpathyChatSpell *chat_spell) -{ - empathy_spell_dialog_show (chat_spell->chat, - &chat_spell->start, - &chat_spell->end, - chat_spell->word); -} - -static void -chat_text_send_cb (GtkMenuItem *menuitem, - EmpathyChat *chat) -{ - chat_input_text_view_send (chat); -} - -static void -chat_input_populate_popup_cb (GtkTextView *view, - GtkMenu *menu, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - GtkTextBuffer *buffer; - GtkTextTagTable *table; - GtkTextTag *tag; - gint x, y; - GtkTextIter iter, start, end; - GtkWidget *item; - gchar *str = NULL; - EmpathyChatSpell *chat_spell; - EmpathySmileyManager *smiley_manager; - GtkWidget *smiley_menu; - GtkWidget *image; - - priv = GET_PRIV (chat); - buffer = gtk_text_view_get_buffer (view); - - /* Add the emoticon menu. */ - item = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_image_menu_item_new_with_mnemonic (_("Insert Smiley")); - image = gtk_image_new_from_icon_name ("face-smile", - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - smiley_manager = empathy_smiley_manager_dup_singleton (); - smiley_menu = empathy_smiley_menu_new (smiley_manager, - chat_insert_smiley_activate_cb, - chat); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), smiley_menu); - g_object_unref (smiley_manager); - - /* Add the Send menu item. */ - gtk_text_buffer_get_bounds (buffer, &start, &end); - str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - if (!EMP_STR_EMPTY (str)) { - item = gtk_menu_item_new_with_mnemonic (_("_Send")); - g_signal_connect (G_OBJECT (item), "activate", - G_CALLBACK (chat_text_send_cb), chat); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - } - str = NULL; - - /* Add the spell check menu item. */ - table = gtk_text_buffer_get_tag_table (buffer); - tag = gtk_text_tag_table_lookup (table, "misspelled"); - gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); - gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), - GTK_TEXT_WINDOW_WIDGET, - x, y, - &x, &y); - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &iter, x, y); - start = end = iter; - if (gtk_text_iter_backward_to_tag_toggle (&start, tag) && - gtk_text_iter_forward_to_tag_toggle (&end, tag)) { - - str = gtk_text_buffer_get_text (buffer, - &start, &end, FALSE); - } - if (!EMP_STR_EMPTY (str)) { - chat_spell = chat_spell_new (chat, str, start, end); - g_object_set_data_full (G_OBJECT (menu), - "chat_spell", chat_spell, - (GDestroyNotify) chat_spell_free); - - item = gtk_separator_menu_item_new (); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - item = gtk_image_menu_item_new_with_mnemonic (_("_Check Word Spelling...")); - image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_check_word_spelling_cb), - chat_spell); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - } -} - -static gboolean -chat_log_filter (EmpathyMessage *message, - gpointer user_data) -{ - EmpathyChat *chat = (EmpathyChat *) user_data; - EmpathyChatPriv *priv = GET_PRIV (chat); - const GList *pending; - - pending = empathy_tp_chat_get_pending_messages (priv->tp_chat); - - for (; pending; pending = g_list_next (pending)) { - if (empathy_message_equal (message, pending->data)) { - return FALSE; - } - } - - return TRUE; -} - -static void -chat_add_logs (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - gboolean is_chatroom; - GList *messages, *l; - - if (!priv->id) { - return; - } - - /* Turn off scrolling temporarily */ - empathy_chat_view_scroll (chat->view, FALSE); - - /* Add messages from last conversation */ - is_chatroom = priv->handle_type == TP_HANDLE_TYPE_ROOM; - - messages = empathy_log_manager_get_filtered_messages (priv->log_manager, - priv->account, - priv->id, - is_chatroom, - 5, - chat_log_filter, - chat); - - for (l = messages; l; l = g_list_next (l)) { - empathy_chat_view_append_message (chat->view, l->data); - g_object_unref (l->data); - } - - g_list_free (messages); - - /* Turn back on scrolling */ - empathy_chat_view_scroll (chat->view, TRUE); -} - -static gint -chat_contacts_completion_func (const gchar *s1, - const gchar *s2, - gsize n) -{ - gchar *tmp, *nick1, *nick2; - gint ret; - - if (s1 == s2) { - return 0; - } - if (!s1 || !s2) { - return s1 ? -1 : +1; - } - - 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; -} - -static void -chat_members_changed_cb (EmpathyTpChat *tp_chat, - EmpathyContact *contact, - EmpathyContact *actor, - guint reason, - gchar *message, - gboolean is_member, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - if (priv->block_events_timeout_id == 0) { - gchar *str; - - empathy_contact_run_until_ready (contact, - EMPATHY_CONTACT_READY_NAME, - NULL); - - 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 (chat->view, str); - g_free (str); - } -} - -static gboolean -chat_reset_size_request (gpointer widget) -{ - gtk_widget_set_size_request (widget, -1, -1); - - return FALSE; -} - -static void -chat_set_show_contacts (EmpathyChat *chat, gboolean show) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - if (!priv->scrolled_window_contacts) { - return; - } - - if (show) { - EmpathyContactListStore *store; - gint min_width; - - /* We are adding the contact list to the chat, we don't want the - * chat view to become too small. If the chat view is already - * smaller than 250 make sure that size won't change. If the - * chat view is bigger the contact list will take some space on - * it but we make sure the chat view don't become smaller than - * 250. Relax the size request once the resize is done */ - min_width = MIN (priv->vbox_left->allocation.width, 250); - gtk_widget_set_size_request (priv->vbox_left, min_width, -1); - g_idle_add (chat_reset_size_request, priv->vbox_left); - - if (priv->contacts_width > 0) { - gtk_paned_set_position (GTK_PANED (priv->hpaned), - priv->contacts_width); - } - - store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat)); - priv->contact_list_view = GTK_WIDGET (empathy_contact_list_view_new (store, - EMPATHY_CONTACT_LIST_FEATURE_NONE, - EMPATHY_CONTACT_FEATURE_CHAT | - EMPATHY_CONTACT_FEATURE_CALL | - EMPATHY_CONTACT_FEATURE_LOG | - EMPATHY_CONTACT_FEATURE_INFO)); - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts), - priv->contact_list_view); - gtk_widget_show (priv->contact_list_view); - gtk_widget_show (priv->scrolled_window_contacts); - g_object_unref (store); - } else { - priv->contacts_width = gtk_paned_get_position (GTK_PANED (priv->hpaned)); - gtk_widget_hide (priv->scrolled_window_contacts); - if (priv->contact_list_view) { - gtk_widget_destroy (priv->contact_list_view); - priv->contact_list_view = NULL; - } - } -} - -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); - 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) { - TpChannel *channel; - - channel = empathy_tp_chat_get_channel (priv->tp_chat); - g_object_get (channel, "handle-type", &priv->handle_type, NULL); - g_free (priv->id); - priv->id = g_strdup (empathy_tp_chat_get_id (priv->tp_chat)); - } - - chat_set_show_contacts (chat, priv->remote_contact == NULL); - - g_object_notify (G_OBJECT (chat), "remote-contact"); - g_object_notify (G_OBJECT (chat), "id"); -} - -static void -chat_destroy_cb (EmpathyTpChat *tp_chat, - EmpathyChat *chat) -{ - EmpathyChatPriv *priv; - - priv = GET_PRIV (chat); - - if (!priv->tp_chat) { - return; - } - - g_object_unref (priv->tp_chat); - priv->tp_chat = NULL; - g_object_notify (G_OBJECT (chat), "tp-chat"); - - empathy_chat_view_append_event (chat->view, _("Disconnected")); - gtk_widget_set_sensitive (chat->input_text_view, FALSE); - chat_set_show_contacts (chat, FALSE); -} - -static void -show_pending_messages (EmpathyChat *chat) { - EmpathyChatPriv *priv = GET_PRIV (chat); - const GList *messages, *l; - - if (chat->view == NULL || priv->tp_chat == NULL) - return; - - messages = empathy_tp_chat_get_pending_messages (priv->tp_chat); - - for (l = messages; l != NULL ; l = g_list_next (l)) { - EmpathyMessage *message = EMPATHY_MESSAGE (l->data); - chat_message_received (chat, message); - } - empathy_tp_chat_acknowledge_messages (priv->tp_chat, messages); -} - -static void -chat_create_ui (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - GladeXML *glade; - GList *list = NULL; - gchar *filename; - GtkTextBuffer *buffer; - - filename = empathy_file_lookup ("empathy-chat.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "chat_widget", - NULL, - "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); - g_object_unref (glade); - - /* Add message view. */ - chat->view = empathy_theme_manager_create_view (empathy_theme_manager_get ()); - g_signal_connect (chat->view, "focus_in_event", - G_CALLBACK (chat_text_view_focus_in_event_cb), - chat); - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_chat), - GTK_WIDGET (chat->view)); - gtk_widget_show (GTK_WIDGET (chat->view)); - - /* Add input GtkTextView */ - chat->input_text_view = g_object_new (GTK_TYPE_TEXT_VIEW, - "pixels-above-lines", 2, - "pixels-below-lines", 2, - "pixels-inside-wrap", 1, - "right-margin", 2, - "left-margin", 2, - "wrap-mode", GTK_WRAP_WORD_CHAR, - NULL); - g_signal_connect (chat->input_text_view, "key-press-event", - G_CALLBACK (chat_input_key_press_event_cb), - chat); - g_signal_connect (chat->input_text_view, "size-request", - G_CALLBACK (chat_input_size_request_cb), - chat); - g_signal_connect (chat->input_text_view, "realize", - G_CALLBACK (chat_input_realize_cb), - chat); - g_signal_connect (chat->input_text_view, "populate-popup", - G_CALLBACK (chat_input_populate_popup_cb), - chat); - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - g_signal_connect (buffer, "changed", - G_CALLBACK (chat_input_text_buffer_changed_cb), - chat); - gtk_text_buffer_create_tag (buffer, "misspelled", - "underline", PANGO_UNDERLINE_ERROR, - NULL); - gtk_container_add (GTK_CONTAINER (priv->scrolled_window_input), - chat->input_text_view); - gtk_widget_show (chat->input_text_view); - - /* Create contact list */ - chat_set_show_contacts (chat, priv->remote_contact == NULL); - - /* 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); - 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); - - /* Add the main widget in the chat widget */ - gtk_container_add (GTK_CONTAINER (chat), priv->widget); -} - -static void -chat_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin = GTK_BIN (widget); - - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (bin->child, &child_requisition); - - requisition->width += child_requisition.width; - requisition->height += child_requisition.height; - } -} - -static void -chat_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin = GTK_BIN (widget); - GtkAllocation child_allocation; - - widget->allocation = *allocation; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - { - child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width; - child_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width; - child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0); - child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0); - - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} - -static void -chat_finalize (GObject *object) -{ - EmpathyChat *chat; - EmpathyChatPriv *priv; - - chat = EMPATHY_CHAT (object); - priv = GET_PRIV (chat); - - DEBUG ("Finalized: %p", object); - - g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL); - g_slist_free (priv->sent_messages); - - g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL); - g_list_free (priv->compositors); - - chat_composing_remove_timeout (chat); - - g_signal_handlers_disconnect_by_func (priv->account_manager, - chat_connection_changed_cb, object); - - g_object_unref (priv->account_manager); - g_object_unref (priv->log_manager); - - if (priv->tp_chat) { - g_signal_handler_disconnect (priv->tp_chat, priv->tp_chat_destroy_handler); - empathy_tp_chat_close (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); - } - - g_free (priv->id); - g_free (priv->name); - g_free (priv->subject); - - G_OBJECT_CLASS (empathy_chat_parent_class)->finalize (object); -} - -static void -chat_constructed (GObject *object) -{ - EmpathyChat *chat = EMPATHY_CHAT (object); - - chat_create_ui (chat); - chat_add_logs (chat); - show_pending_messages (chat); -} - -static void -empathy_chat_class_init (EmpathyChatClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = chat_finalize; - object_class->get_property = chat_get_property; - object_class->set_property = chat_set_property; - object_class->constructed = chat_constructed; - - widget_class->size_request = chat_size_request; - widget_class->size_allocate = chat_size_allocate; - - g_object_class_install_property (object_class, - PROP_TP_CHAT, - g_param_spec_object ("tp-chat", - "Empathy tp chat", - "The tp chat object", - EMPATHY_TYPE_TP_CHAT, - G_PARAM_CONSTRUCT | - G_PARAM_READWRITE)); - 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)); - 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_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_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_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_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, G_TYPE_BOOLEAN); - - signals[NEW_MESSAGE] = - g_signal_new ("new-message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, EMPATHY_TYPE_MESSAGE); - - g_type_class_add_private (object_class, sizeof (EmpathyChatPriv)); -} - -static gboolean -chat_block_events_timeout_cb (gpointer data) -{ - EmpathyChatPriv *priv = GET_PRIV (data); - - priv->block_events_timeout_id = 0; - - return FALSE; -} - -static void -empathy_chat_init (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chat, - EMPATHY_TYPE_CHAT, EmpathyChatPriv); - - chat->priv = priv; - priv->log_manager = empathy_log_manager_dup_singleton (); - priv->contacts_width = -1; - priv->sent_messages = NULL; - priv->sent_messages_index = -1; - priv->account_manager = empathy_account_manager_dup_singleton (); - - g_signal_connect (priv->account_manager, - "account-connection-changed", - G_CALLBACK (chat_connection_changed_cb), - chat); - - /* Block events for some time to avoid having "has come online" or - * "joined" messages. */ - priv->block_events_timeout_id = - g_timeout_add_seconds (1, chat_block_events_timeout_cb, 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); -} - -EmpathyChat * -empathy_chat_new (EmpathyTpChat *tp_chat) -{ - return g_object_new (EMPATHY_TYPE_CHAT, "tp-chat", tp_chat, NULL); -} - -EmpathyTpChat * -empathy_chat_get_tp_chat (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - return priv->tp_chat; -} - -void -empathy_chat_set_tp_chat (EmpathyChat *chat, - EmpathyTpChat *tp_chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat)); - g_return_if_fail (empathy_tp_chat_is_ready (tp_chat)); - - if (priv->tp_chat) { - return; - } - - if (priv->account) { - g_object_unref (priv->account); - } - - priv->tp_chat = g_object_ref (tp_chat); - priv->account = g_object_ref (empathy_tp_chat_get_account (tp_chat)); - - g_signal_connect (tp_chat, "message-received", - G_CALLBACK (chat_message_received_cb), - chat); - g_signal_connect (tp_chat, "send-error", - G_CALLBACK (chat_send_error_cb), - chat); - g_signal_connect (tp_chat, "chat-state-changed", - G_CALLBACK (chat_state_changed_cb), - chat); - g_signal_connect (tp_chat, "property-changed", - G_CALLBACK (chat_property_changed_cb), - chat); - 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); - priv->tp_chat_destroy_handler = - 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) { - empathy_chat_view_append_event (chat->view, _("Connected")); - } - } - - g_object_notify (G_OBJECT (chat), "tp-chat"); - g_object_notify (G_OBJECT (chat), "id"); - g_object_notify (G_OBJECT (chat), "account"); - - /* This is a noop when tp-chat is set at object construction time and causes - * the pending messages to be show when it's set on the object after it has - * been created */ - show_pending_messages (chat); -} - -McAccount * -empathy_chat_get_account (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - return priv->account; -} - -const gchar * -empathy_chat_get_id (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - return priv->id; -} - -const gchar * -empathy_chat_get_name (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - const gchar *ret; - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - ret = priv->name; - if (!ret && priv->remote_contact) { - ret = empathy_contact_get_name (priv->remote_contact); - } - - if (!ret) - ret = priv->id; - - return ret ? ret : _("Conversation"); -} - -const gchar * -empathy_chat_get_subject (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - 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; -} - -guint -empathy_chat_get_members_count (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), 0); - - if (priv->tp_chat) { - return empathy_tp_chat_get_members_count (priv->tp_chat); - } - - return 0; -} - -GtkWidget * -empathy_chat_get_contact_menu (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - GtkWidget *menu = NULL; - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); - - if (priv->remote_contact) { - menu = empathy_contact_menu_new (priv->remote_contact, - EMPATHY_CONTACT_FEATURE_CALL | - EMPATHY_CONTACT_FEATURE_LOG | - EMPATHY_CONTACT_FEATURE_INFO); - } - else if (priv->contact_list_view) { - EmpathyContactListView *view; - - view = EMPATHY_CONTACT_LIST_VIEW (priv->contact_list_view); - menu = empathy_contact_list_view_get_contact_menu (view); - } - - return menu; -} - -void -empathy_chat_clear (EmpathyChat *chat) -{ - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - - empathy_chat_view_clear (chat->view); -} - -void -empathy_chat_scroll_down (EmpathyChat *chat) -{ - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - - empathy_chat_view_scroll_down (chat->view); -} - -void -empathy_chat_cut (EmpathyChat *chat) -{ - GtkTextBuffer *buffer; - - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - if (gtk_text_buffer_get_has_selection (buffer)) { - GtkClipboard *clipboard; - - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - - gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE); - } -} - -void -empathy_chat_copy (EmpathyChat *chat) -{ - GtkTextBuffer *buffer; - - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - - if (empathy_chat_view_get_has_selection (chat->view)) { - empathy_chat_view_copy_clipboard (chat->view); - return; - } - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - if (gtk_text_buffer_get_has_selection (buffer)) { - GtkClipboard *clipboard; - - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - - gtk_text_buffer_copy_clipboard (buffer, clipboard); - } -} - -void -empathy_chat_paste (EmpathyChat *chat) -{ - GtkTextBuffer *buffer; - GtkClipboard *clipboard; - - g_return_if_fail (EMPATHY_IS_CHAT (chat)); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - - gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE); -} - -void -empathy_chat_correct_word (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *new_word) -{ - GtkTextBuffer *buffer; - - g_return_if_fail (chat != NULL); - g_return_if_fail (new_word != NULL); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); - - gtk_text_buffer_delete (buffer, start, end); - gtk_text_buffer_insert (buffer, start, - new_word, - -1); -} - -gboolean -empathy_chat_is_room (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), FALSE); - - return (priv->handle_type == TP_HANDLE_TYPE_ROOM); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-chat.glade b/gnome-2-26/libempathy-gtk/empathy-chat.glade deleted file mode 100644 index f313c2f55..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat.glade +++ /dev/null @@ -1,120 +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="chat_window"> - <property name="visible">True</property> - <property name="border_width">6</property> - <property name="title" translatable="yes">Group Chat</property> - <property name="icon_name">system-users</property> - <child> - <widget class="GtkVBox" id="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="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">False</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/gnome-2-26/libempathy-gtk/empathy-chat.h b/gnome-2-26/libempathy-gtk/empathy-chat.h deleted file mode 100644 index 6b7fcf26e..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-chat.h +++ /dev/null @@ -1,88 +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> - */ - -#ifndef __EMPATHY_CHAT_H__ -#define __EMPATHY_CHAT_H__ - -#include <gtk/gtkbin.h> - -#include <libempathy/empathy-contact.h> -#include <libempathy/empathy-message.h> -#include <libempathy/empathy-tp-chat.h> - -#include "empathy-chat-view.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CHAT (empathy_chat_get_type ()) -#define EMPATHY_CHAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHAT, EmpathyChat)) -#define EMPATHY_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CHAT, EmpathyChatClass)) -#define EMPATHY_IS_CHAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHAT)) -#define EMPATHY_IS_CHAT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHAT)) -#define EMPATHY_CHAT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHAT, EmpathyChatClass)) - -typedef struct _EmpathyChat EmpathyChat; -typedef struct _EmpathyChatClass EmpathyChatClass; - -struct _EmpathyChat { - GtkBin parent; - gpointer priv; - - /* Protected */ - EmpathyChatView *view; - GtkWidget *input_text_view; -}; - -struct _EmpathyChatClass { - GtkBinClass parent; -}; - -GType empathy_chat_get_type (void); -EmpathyChat * empathy_chat_new (EmpathyTpChat *tp_chat); -EmpathyTpChat * empathy_chat_get_tp_chat (EmpathyChat *chat); -void empathy_chat_set_tp_chat (EmpathyChat *chat, - EmpathyTpChat *tp_chat); -McAccount * empathy_chat_get_account (EmpathyChat *chat); -const gchar * empathy_chat_get_id (EmpathyChat *chat); -const gchar * empathy_chat_get_name (EmpathyChat *chat); -const gchar * empathy_chat_get_subject (EmpathyChat *chat); -EmpathyContact * empathy_chat_get_remote_contact (EmpathyChat *chat); -guint empathy_chat_get_members_count (EmpathyChat *chat); -GtkWidget * empathy_chat_get_contact_menu (EmpathyChat *chat); -void empathy_chat_clear (EmpathyChat *chat); -void empathy_chat_scroll_down (EmpathyChat *chat); -void empathy_chat_cut (EmpathyChat *chat); -void empathy_chat_copy (EmpathyChat *chat); -void empathy_chat_paste (EmpathyChat *chat); -void empathy_chat_correct_word (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *new_word); -gboolean empathy_chat_is_room (EmpathyChat *chat); -G_END_DECLS - -#endif /* __EMPATHY_CHAT_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-conf.c b/gnome-2-26/libempathy-gtk/empathy-conf.c deleted file mode 100644 index fae2c37db..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-conf.c +++ /dev/null @@ -1,371 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006 Imendio AB - * - * 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: Richard Hult <richard@imendio.com> - */ - -#include "config.h" - -#include <string.h> - -#include <gconf/gconf-client.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-conf.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#define EMPATHY_CONF_ROOT "/apps/empathy" -#define DESKTOP_INTERFACE_ROOT "/desktop/gnome/interface" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyConf) -typedef struct { - GConfClient *gconf_client; -} EmpathyConfPriv; - -typedef struct { - EmpathyConf *conf; - EmpathyConfNotifyFunc func; - gpointer user_data; -} EmpathyConfNotifyData; - -static void conf_finalize (GObject *object); - -G_DEFINE_TYPE (EmpathyConf, empathy_conf, G_TYPE_OBJECT); - -static EmpathyConf *global_conf = NULL; - -static void -empathy_conf_class_init (EmpathyConfClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - - object_class->finalize = conf_finalize; - - g_type_class_add_private (object_class, sizeof (EmpathyConfPriv)); -} - -static void -empathy_conf_init (EmpathyConf *conf) -{ - EmpathyConfPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (conf, - EMPATHY_TYPE_CONF, EmpathyConfPriv); - - conf->priv = priv; - priv->gconf_client = gconf_client_get_default (); - - gconf_client_add_dir (priv->gconf_client, - EMPATHY_CONF_ROOT, - GCONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - gconf_client_add_dir (priv->gconf_client, - DESKTOP_INTERFACE_ROOT, - GCONF_CLIENT_PRELOAD_NONE, - NULL); -} - -static void -conf_finalize (GObject *object) -{ - EmpathyConfPriv *priv; - - priv = GET_PRIV (object); - - gconf_client_remove_dir (priv->gconf_client, - EMPATHY_CONF_ROOT, - NULL); - gconf_client_remove_dir (priv->gconf_client, - DESKTOP_INTERFACE_ROOT, - NULL); - - g_object_unref (priv->gconf_client); - - G_OBJECT_CLASS (empathy_conf_parent_class)->finalize (object); -} - -EmpathyConf * -empathy_conf_get (void) -{ - if (!global_conf) { - global_conf = g_object_new (EMPATHY_TYPE_CONF, NULL); - } - - return global_conf; -} - -void -empathy_conf_shutdown (void) -{ - if (global_conf) { - g_object_unref (global_conf); - global_conf = NULL; - } -} - -gboolean -empathy_conf_set_int (EmpathyConf *conf, - const gchar *key, - gint value) -{ - EmpathyConfPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - DEBUG ("Setting int:'%s' to %d", key, value); - - priv = GET_PRIV (conf); - - return gconf_client_set_int (priv->gconf_client, - key, - value, - NULL); -} - -gboolean -empathy_conf_get_int (EmpathyConf *conf, - const gchar *key, - gint *value) -{ - EmpathyConfPriv *priv; - GError *error = NULL; - - *value = 0; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - priv = GET_PRIV (conf); - - *value = gconf_client_get_int (priv->gconf_client, - key, - &error); - - if (error) { - g_error_free (error); - return FALSE; - } - - return TRUE; -} - -gboolean -empathy_conf_set_bool (EmpathyConf *conf, - const gchar *key, - gboolean value) -{ - EmpathyConfPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - DEBUG ("Setting bool:'%s' to %d ---> %s", key, value, - value ? "true" : "false"); - - priv = GET_PRIV (conf); - - return gconf_client_set_bool (priv->gconf_client, - key, - value, - NULL); -} - -gboolean -empathy_conf_get_bool (EmpathyConf *conf, - const gchar *key, - gboolean *value) -{ - EmpathyConfPriv *priv; - GError *error = NULL; - - *value = FALSE; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - g_return_val_if_fail (value != NULL, FALSE); - - priv = GET_PRIV (conf); - - *value = gconf_client_get_bool (priv->gconf_client, - key, - &error); - - if (error) { - g_error_free (error); - return FALSE; - } - - return TRUE; -} - -gboolean -empathy_conf_set_string (EmpathyConf *conf, - const gchar *key, - const gchar *value) -{ - EmpathyConfPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - DEBUG ("Setting string:'%s' to '%s'", key, value); - - priv = GET_PRIV (conf); - - return gconf_client_set_string (priv->gconf_client, - key, - value, - NULL); -} - -gboolean -empathy_conf_get_string (EmpathyConf *conf, - const gchar *key, - gchar **value) -{ - EmpathyConfPriv *priv; - GError *error = NULL; - - *value = NULL; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - priv = GET_PRIV (conf); - - *value = gconf_client_get_string (priv->gconf_client, - key, - &error); - - if (error) { - g_error_free (error); - return FALSE; - } - - return TRUE; -} - -gboolean -empathy_conf_set_string_list (EmpathyConf *conf, - const gchar *key, - GSList *value) -{ - EmpathyConfPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - priv = GET_PRIV (conf); - - return gconf_client_set_list (priv->gconf_client, - key, - GCONF_VALUE_STRING, - value, - NULL); -} - -gboolean -empathy_conf_get_string_list (EmpathyConf *conf, - const gchar *key, - GSList **value) -{ - EmpathyConfPriv *priv; - GError *error = NULL; - - *value = NULL; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - priv = GET_PRIV (conf); - - *value = gconf_client_get_list (priv->gconf_client, - key, - GCONF_VALUE_STRING, - &error); - if (error) { - g_error_free (error); - return FALSE; - } - - return TRUE; -} - -static void -conf_notify_data_free (EmpathyConfNotifyData *data) -{ - g_object_unref (data->conf); - g_slice_free (EmpathyConfNotifyData, data); -} - -static void -conf_notify_func (GConfClient *client, - guint id, - GConfEntry *entry, - gpointer user_data) -{ - EmpathyConfNotifyData *data; - - data = user_data; - - data->func (data->conf, - gconf_entry_get_key (entry), - data->user_data); -} - -guint -empathy_conf_notify_add (EmpathyConf *conf, - const gchar *key, - EmpathyConfNotifyFunc func, - gpointer user_data) -{ - EmpathyConfPriv *priv; - guint id; - EmpathyConfNotifyData *data; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), 0); - - priv = GET_PRIV (conf); - - data = g_slice_new (EmpathyConfNotifyData); - data->func = func; - data->user_data = user_data; - data->conf = g_object_ref (conf); - - id = gconf_client_notify_add (priv->gconf_client, - key, - conf_notify_func, - data, - (GFreeFunc) conf_notify_data_free, - NULL); - - return id; -} - -gboolean -empathy_conf_notify_remove (EmpathyConf *conf, - guint id) -{ - EmpathyConfPriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE); - - priv = GET_PRIV (conf); - - gconf_client_notify_remove (priv->gconf_client, id); - - return TRUE; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-conf.h b/gnome-2-26/libempathy-gtk/empathy-conf.h deleted file mode 100644 index 2051a7f38..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-conf.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006 Imendio AB - * - * 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. - */ - -#ifndef __EMPATHY_CONF_H__ -#define __EMPATHY_CONF_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CONF (empathy_conf_get_type ()) -#define EMPATHY_CONF(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONF, EmpathyConf)) -#define EMPATHY_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CONF, EmpathyConfClass)) -#define EMPATHY_IS_CONF(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONF)) -#define EMPATHY_IS_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONF)) -#define EMPATHY_CONF_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONF, EmpathyConfClass)) - -typedef struct _EmpathyConf EmpathyConf; -typedef struct _EmpathyConfClass EmpathyConfClass; - -struct _EmpathyConf { - GObject parent; - gpointer priv; -}; - -struct _EmpathyConfClass { - GObjectClass parent_class; -}; - -#define EMPATHY_PREFS_PATH "/apps/empathy" -#define EMPATHY_PREFS_NOTIFICATIONS_ENABLED EMPATHY_PREFS_PATH "/notifications/notifications_enabled" -#define EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY EMPATHY_PREFS_PATH "/notifications/notifications_disabled_away" -#define EMPATHY_PREFS_NOTIFICATIONS_FOCUS EMPATHY_PREFS_PATH "/notifications/notifications_focus" -#define EMPATHY_PREFS_SOUNDS_ENABLED EMPATHY_PREFS_PATH "/sounds/sounds_enabled" -#define EMPATHY_PREFS_SOUNDS_DISABLED_AWAY EMPATHY_PREFS_PATH "/sounds/sounds_disabled_away" -#define EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE EMPATHY_PREFS_PATH "/sounds/sounds_incoming_message" -#define EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE EMPATHY_PREFS_PATH "/sounds/sounds_outgoing_message" -#define EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION EMPATHY_PREFS_PATH "/sounds/sounds_new_conversation" -#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN EMPATHY_PREFS_PATH "/sounds/sounds_service_login" -#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT EMPATHY_PREFS_PATH "/sounds/sounds_service_logout" -#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN EMPATHY_PREFS_PATH "/sounds/sounds_contact_login" -#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT EMPATHY_PREFS_PATH "/sounds/sounds_contact_logout" -#define EMPATHY_PREFS_POPUPS_WHEN_AVAILABLE EMPATHY_PREFS_PATH "/notifications/popups_when_available" -#define EMPATHY_PREFS_CHAT_SHOW_SMILEYS EMPATHY_PREFS_PATH "/conversation/graphical_smileys" -#define EMPATHY_PREFS_CHAT_THEME EMPATHY_PREFS_PATH "/conversation/theme" -#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES EMPATHY_PREFS_PATH "/conversation/spell_checker_languages" -#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED EMPATHY_PREFS_PATH "/conversation/spell_checker_enabled" -#define EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR EMPATHY_PREFS_PATH "/conversation/nick_completion_char" -#define EMPATHY_PREFS_CHAT_AVATAR_IN_ICON EMPATHY_PREFS_PATH "/conversation/avatar_in_icon" -#define EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS EMPATHY_PREFS_PATH "/ui/separate_chat_windows" -#define EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN EMPATHY_PREFS_PATH "/ui/main_window_hidden" -#define EMPATHY_PREFS_UI_AVATAR_DIRECTORY EMPATHY_PREFS_PATH "/ui/avatar_directory" -#define EMPATHY_PREFS_UI_SHOW_AVATARS EMPATHY_PREFS_PATH "/ui/show_avatars" -#define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST EMPATHY_PREFS_PATH "/ui/compact_contact_list" -#define EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE EMPATHY_PREFS_PATH "/contacts/show_offline" -#define EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM EMPATHY_PREFS_PATH "/contacts/sort_criterium" -#define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW EMPATHY_PREFS_PATH "/hints/close_main_window" -#define EMPATHY_PREFS_SALUT_ACCOUNT_CREATED EMPATHY_PREFS_PATH "/accounts/salut_created" -#define EMPATHY_PREFS_USE_NM EMPATHY_PREFS_PATH "/use_nm" -#define EMPATHY_PREFS_AUTOCONNECT EMPATHY_PREFS_PATH "/autoconnect" -#define EMPATHY_PREFS_IMPORT_ASKED EMPATHY_PREFS_PATH "/import_asked" -#define EMPATHY_PREFS_FILE_TRANSFER_DEFAULT_FOLDER EMPATHY_PREFS_PATH "/file_transfer/default_folder" - -typedef void (*EmpathyConfNotifyFunc) (EmpathyConf *conf, - const gchar *key, - gpointer user_data); - -GType empathy_conf_get_type (void) G_GNUC_CONST; -EmpathyConf *empathy_conf_get (void); -void empathy_conf_shutdown (void); -guint empathy_conf_notify_add (EmpathyConf *conf, - const gchar *key, - EmpathyConfNotifyFunc func, - gpointer data); -gboolean empathy_conf_notify_remove (EmpathyConf *conf, - guint id); -gboolean empathy_conf_set_int (EmpathyConf *conf, - const gchar *key, - gint value); -gboolean empathy_conf_get_int (EmpathyConf *conf, - const gchar *key, - gint *value); -gboolean empathy_conf_set_bool (EmpathyConf *conf, - const gchar *key, - gboolean value); -gboolean empathy_conf_get_bool (EmpathyConf *conf, - const gchar *key, - gboolean *value); -gboolean empathy_conf_set_string (EmpathyConf *conf, - const gchar *key, - const gchar *value); -gboolean empathy_conf_get_string (EmpathyConf *conf, - const gchar *key, - gchar **value); -gboolean empathy_conf_set_string_list (EmpathyConf *conf, - const gchar *key, - GSList *value); -gboolean empathy_conf_get_string_list (EmpathyConf *conf, - const gchar *key, - GSList **value); - -G_END_DECLS - -#endif /* __EMPATHY_CONF_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.c b/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.c deleted file mode 100644 index f7a769d98..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.c +++ /dev/null @@ -1,334 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> -#include <stdlib.h> - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <glib/gi18n-lib.h> - -#include <libmissioncontrol/mission-control.h> - -#include <libempathy/empathy-contact-manager.h> -#include <libempathy/empathy-contact-list.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-contact-dialogs.h" -#include "empathy-contact-widget.h" -#include "empathy-ui-utils.h" - -static GList *subscription_dialogs = NULL; -static GList *information_dialogs = NULL; -static GtkWidget *new_contact_dialog = NULL; - - -static gint -contact_dialogs_find (GtkDialog *dialog, - EmpathyContact *contact) -{ - GtkWidget *contact_widget; - EmpathyContact *this_contact; - - contact_widget = g_object_get_data (G_OBJECT (dialog), "contact_widget"); - this_contact = empathy_contact_widget_get_contact (contact_widget); - - return contact != this_contact; -} - -/* - * Subscription dialog - */ - -static void -subscription_dialog_response_cb (GtkDialog *dialog, - gint response, - GtkWidget *contact_widget) -{ - EmpathyContactManager *manager; - EmpathyContact *contact; - - manager = empathy_contact_manager_dup_singleton (); - contact = empathy_contact_widget_get_contact (contact_widget); - - if (response == GTK_RESPONSE_YES) { - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), - contact, ""); - } - else if (response == GTK_RESPONSE_NO) { - empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager), - contact, ""); - } - - subscription_dialogs = g_list_remove (subscription_dialogs, dialog); - gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (manager); -} - -void -empathy_subscription_dialog_show (EmpathyContact *contact, - GtkWindow *parent) -{ - GtkWidget *dialog; - GtkWidget *hbox_subscription; - GtkWidget *contact_widget; - GList *l; - gchar *filename; - - g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - - l = g_list_find_custom (subscription_dialogs, - contact, - (GCompareFunc) contact_dialogs_find); - if (l) { - gtk_window_present (GTK_WINDOW (l->data)); - return; - } - - filename = empathy_file_lookup ("empathy-contact-dialogs.glade", - "libempathy-gtk"); - empathy_glade_get_file_simple (filename, - "subscription_request_dialog", - NULL, - "subscription_request_dialog", &dialog, - "hbox_subscription", &hbox_subscription, - NULL); - g_free (filename); - - contact_widget = empathy_contact_widget_new (contact, - EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | - EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); - gtk_box_pack_end (GTK_BOX (hbox_subscription), - contact_widget, - TRUE, TRUE, - 0); - - g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); - subscription_dialogs = g_list_prepend (subscription_dialogs, dialog); - - g_signal_connect (dialog, "response", - G_CALLBACK (subscription_dialog_response_cb), - contact_widget); - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - } - - gtk_widget_show (dialog); -} - -/* - * Information dialog - */ - -static void -contact_information_response_cb (GtkDialog *dialog, - gint response, - GtkWidget *contact_widget) -{ - information_dialogs = g_list_remove (information_dialogs, dialog); - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -void -empathy_contact_information_dialog_show (EmpathyContact *contact, - GtkWindow *parent, - gboolean edit, - gboolean is_user) -{ - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *contact_widget; - GList *l; - EmpathyContactWidgetFlags flags = 0; - - g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - - l = g_list_find_custom (information_dialogs, - contact, - (GCompareFunc) contact_dialogs_find); - if (l) { - gtk_window_present (GTK_WINDOW (l->data)); - return; - } - - /* Create dialog */ - dialog = gtk_dialog_new (); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - if (is_user) { - gtk_window_set_title (GTK_WINDOW (dialog), _("Personal Information")); - } - else if (edit) { - gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Contact Information")); - } - else { - gtk_window_set_title (GTK_WINDOW (dialog), _("Contact Information")); - } - - /* Close button */ - button = gtk_button_new_with_label (GTK_STOCK_CLOSE); - gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), - button, - GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_window_set_default (GTK_WINDOW (dialog), button); - gtk_widget_show (button); - - /* Contact info widget */ - if (edit) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_ALIAS; - } - if (is_user) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT; - flags |= EMPATHY_CONTACT_WIDGET_EDIT_AVATAR; - } - if (!is_user && edit) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_GROUPS; - } - contact_widget = empathy_contact_widget_new (contact, flags); - gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - contact_widget, - TRUE, TRUE, 0); - if (flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { - empathy_contact_widget_set_account_filter (contact_widget, - empathy_account_chooser_filter_is_connected, - NULL); - } - - g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); - information_dialogs = g_list_prepend (information_dialogs, dialog); - - g_signal_connect (dialog, "response", - G_CALLBACK (contact_information_response_cb), - contact_widget); - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - } - - gtk_widget_show (dialog); -} - -/* - * New contact dialog - */ - -static gboolean -can_add_contact_to_account (McAccount *account, - gpointer user_data) -{ - EmpathyContactManager *mgr; - gboolean result; - - mgr = empathy_contact_manager_dup_singleton (); - result = empathy_contact_manager_can_add (mgr, account); - g_object_unref (mgr); - - return result; -} - -static void -new_contact_response_cb (GtkDialog *dialog, - gint response, - GtkWidget *contact_widget) -{ - EmpathyContactManager *manager; - EmpathyContact *contact; - - manager = empathy_contact_manager_dup_singleton (); - contact = empathy_contact_widget_get_contact (contact_widget); - - if (contact && response == GTK_RESPONSE_OK) { - empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), - contact, - _("I would like to add you to my contact list.")); - } - - new_contact_dialog = NULL; - gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (manager); -} - -void -empathy_new_contact_dialog_show (GtkWindow *parent) -{ - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *contact_widget; - - if (new_contact_dialog) { - gtk_window_present (GTK_WINDOW (new_contact_dialog)); - return; - } - - /* Create dialog */ - dialog = gtk_dialog_new (); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_window_set_title (GTK_WINDOW (dialog), _("New Contact")); - - /* Cancel button */ - button = gtk_button_new_with_label (GTK_STOCK_CANCEL); - gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), - button, - GTK_RESPONSE_CANCEL); - gtk_widget_show (button); - - /* Add button */ - button = gtk_button_new_with_label (GTK_STOCK_ADD); - gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), - button, - GTK_RESPONSE_OK); - gtk_widget_show (button); - - /* Contact info widget */ - contact_widget = empathy_contact_widget_new (NULL, - EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | - EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT | - EMPATHY_CONTACT_WIDGET_EDIT_ID | - EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - contact_widget, - TRUE, TRUE, 0); - empathy_contact_widget_set_account_filter (contact_widget, - can_add_contact_to_account, - NULL); - - new_contact_dialog = dialog; - - g_signal_connect (dialog, "response", - G_CALLBACK (new_contact_response_cb), - contact_widget); - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - } - - gtk_widget_show (dialog); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.glade b/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.glade deleted file mode 100644 index 75d8af6a8..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.glade +++ /dev/null @@ -1,92 +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="GtkDialog" id="subscription_request_dialog"> - <property name="border_width">5</property> - <property name="title" translatable="yes">Subscription Request</property> - <property name="role">subscription_request</property> - <property name="resizable">False</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox4"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkHBox" id="hbox_subscription"> - <property name="visible">True</property> - <property name="border_width">5</property> - <property name="spacing">12</property> - <child> - <widget class="GtkImage" id="image5"> - <property name="visible">True</property> - <property name="yalign">0</property> - <property name="stock">gtk-dialog-question</property> - <property name="icon_size">6</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area4"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button19"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label" translatable="yes">Decide _Later</property> - <property name="use_underline">True</property> - <property name="response_id">-6</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button20"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-no</property> - <property name="use_stock">True</property> - <property name="response_id">-9</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button21"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="label">gtk-yes</property> - <property name="use_stock">True</property> - <property name="response_id">-8</property> - </widget> - <packing> - <property name="position">2</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.h b/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.h deleted file mode 100644 index e375f959c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-dialogs.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CONTACT_DIALOGS_H__ -#define __EMPATHY_CONTACT_DIALOGS_H__ - -#include <gtk/gtk.h> - -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -void empathy_subscription_dialog_show (EmpathyContact *contact, - GtkWindow *parent); -void empathy_contact_information_dialog_show (EmpathyContact *contact, - GtkWindow *parent, - gboolean edit, - gboolean is_user); -void empathy_new_contact_dialog_show (GtkWindow *parent); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_DIALOGS_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-list-store.c b/gnome-2-26/libempathy-gtk/empathy-contact-list-store.c deleted file mode 100644 index e7982f3aa..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-list-store.c +++ /dev/null @@ -1,1518 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib.h> -#include <gtk/gtk.h> - -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-contact-list-store.h" -#include "empathy-ui-utils.h" -#include "empathy-gtk-enum-types.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT -#include <libempathy/empathy-debug.h> - -/* Active users are those which have recently changed state - * (e.g. online, offline or from normal to a busy state). - */ - -/* Time in seconds user is shown as active */ -#define ACTIVE_USER_SHOW_TIME 7 - -/* Time in seconds after connecting which we wait before active users are enabled */ -#define ACTIVE_USER_WAIT_TO_ENABLE_TIME 5 - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactListStore) -typedef struct { - EmpathyContactList *list; - gboolean show_offline; - gboolean show_avatars; - gboolean show_groups; - gboolean is_compact; - gboolean show_active; - EmpathyContactListStoreSort sort_criterium; - guint inhibit_active; -} EmpathyContactListStorePriv; - -typedef struct { - GtkTreeIter iter; - const gchar *name; - gboolean found; -} FindGroup; - -typedef struct { - EmpathyContact *contact; - gboolean found; - GList *iters; -} FindContact; - -typedef struct { - EmpathyContactListStore *store; - EmpathyContact *contact; - gboolean remove; -} ShowActiveData; - -static void contact_list_store_finalize (GObject *object); -static void contact_list_store_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void contact_list_store_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void contact_list_store_setup (EmpathyContactListStore *store); -static gboolean contact_list_store_inibit_active_cb (EmpathyContactListStore *store); -static void contact_list_store_members_changed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContact *actor, - guint reason, - gchar *message, - gboolean is_member, - EmpathyContactListStore *store); -static void contact_list_store_groups_changed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - gchar *group, - gboolean is_member, - EmpathyContactListStore *store); -static void contact_list_store_add_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_remove_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_contact_update (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyContactListStore *store); -static void contact_list_store_contact_set_active (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean active, - gboolean set_changed); -static ShowActiveData * contact_list_store_contact_active_new (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean remove); -static void contact_list_store_contact_active_free (ShowActiveData *data); -static gboolean contact_list_store_contact_active_cb (ShowActiveData *data); -static gboolean contact_list_store_get_group_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindGroup *fg); -static void contact_list_store_get_group (EmpathyContactListStore *store, - const gchar *name, - GtkTreeIter *iter_group_to_set, - GtkTreeIter *iter_separator_to_set, - gboolean *created); -static gint contact_list_store_state_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data); -static gint contact_list_store_name_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data); -static gboolean contact_list_store_find_contact_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindContact *fc); -static GList * contact_list_store_find_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static gboolean contact_list_store_update_list_mode_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - EmpathyContactListStore *store); - -enum { - PROP_0, - PROP_CONTACT_LIST, - PROP_SHOW_OFFLINE, - PROP_SHOW_AVATARS, - PROP_SHOW_GROUPS, - PROP_IS_COMPACT, - PROP_SORT_CRITERIUM -}; - -G_DEFINE_TYPE (EmpathyContactListStore, empathy_contact_list_store, GTK_TYPE_TREE_STORE); - -static gboolean -contact_list_store_iface_setup (gpointer user_data) -{ - EmpathyContactListStore *store = user_data; - EmpathyContactListStorePriv *priv = GET_PRIV (store); - GList *contacts, *l; - - /* Signal connection. */ - g_signal_connect (priv->list, - "members-changed", - G_CALLBACK (contact_list_store_members_changed_cb), - store); - g_signal_connect (priv->list, - "groups-changed", - G_CALLBACK (contact_list_store_groups_changed_cb), - store); - - /* Add contacts already created. */ - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - contact_list_store_members_changed_cb (priv->list, l->data, - NULL, 0, NULL, - TRUE, - store); - - g_object_unref (l->data); - } - g_list_free (contacts); - - return FALSE; -} - - -static void -contact_list_store_set_contact_list (EmpathyContactListStore *store, - EmpathyContactList *list_iface) -{ - EmpathyContactListStorePriv *priv = GET_PRIV (store); - - priv->list = g_object_ref (list_iface); - - /* Let a chance to have all properties set before populating */ - g_idle_add (contact_list_store_iface_setup, store); -} - -static void -empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = contact_list_store_finalize; - object_class->get_property = contact_list_store_get_property; - object_class->set_property = contact_list_store_set_property; - - g_object_class_install_property (object_class, - PROP_CONTACT_LIST, - g_param_spec_object ("contact-list", - "The contact list iface", - "The contact list iface", - EMPATHY_TYPE_CONTACT_LIST, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_SHOW_OFFLINE, - g_param_spec_boolean ("show-offline", - "Show Offline", - "Whether contact list should display " - "offline contacts", - FALSE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_SHOW_AVATARS, - g_param_spec_boolean ("show-avatars", - "Show Avatars", - "Whether contact list should display " - "avatars for contacts", - TRUE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_SHOW_GROUPS, - g_param_spec_boolean ("show-groups", - "Show Groups", - "Whether contact list should display " - "contact groups", - TRUE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_IS_COMPACT, - g_param_spec_boolean ("is-compact", - "Is Compact", - "Whether the contact list is in compact mode or not", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_SORT_CRITERIUM, - g_param_spec_enum ("sort-criterium", - "Sort citerium", - "The sort criterium to use for sorting the contact list", - EMPATHY_TYPE_CONTACT_LIST_STORE_SORT, - EMPATHY_CONTACT_LIST_STORE_SORT_NAME, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyContactListStorePriv)); -} - -static void -empathy_contact_list_store_init (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (store, - EMPATHY_TYPE_CONTACT_LIST_STORE, EmpathyContactListStorePriv); - - store->priv = priv; - priv->show_avatars = TRUE; - priv->show_groups = TRUE; - priv->inhibit_active = g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME, - (GSourceFunc) contact_list_store_inibit_active_cb, - store); - contact_list_store_setup (store); -} - -static void -contact_list_store_finalize (GObject *object) -{ - EmpathyContactListStorePriv *priv = GET_PRIV (object); - GList *contacts, *l; - - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - g_signal_handlers_disconnect_by_func (l->data, - G_CALLBACK (contact_list_store_contact_updated_cb), - object); - - g_object_unref (l->data); - } - g_list_free (contacts); - - g_signal_handlers_disconnect_by_func (priv->list, - G_CALLBACK (contact_list_store_members_changed_cb), - object); - g_signal_handlers_disconnect_by_func (priv->list, - G_CALLBACK (contact_list_store_groups_changed_cb), - object); - g_object_unref (priv->list); - - if (priv->inhibit_active) { - g_source_remove (priv->inhibit_active); - } - - G_OBJECT_CLASS (empathy_contact_list_store_parent_class)->finalize (object); -} - -static void -contact_list_store_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyContactListStorePriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_CONTACT_LIST: - g_value_set_object (value, priv->list); - break; - case PROP_SHOW_OFFLINE: - g_value_set_boolean (value, priv->show_offline); - break; - case PROP_SHOW_AVATARS: - g_value_set_boolean (value, priv->show_avatars); - break; - case PROP_SHOW_GROUPS: - g_value_set_boolean (value, priv->show_groups); - break; - case PROP_IS_COMPACT: - g_value_set_boolean (value, priv->is_compact); - break; - case PROP_SORT_CRITERIUM: - g_value_set_enum (value, priv->sort_criterium); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -contact_list_store_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyContactListStorePriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_CONTACT_LIST: - contact_list_store_set_contact_list (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_object (value)); - break; - case PROP_SHOW_OFFLINE: - empathy_contact_list_store_set_show_offline (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_boolean (value)); - break; - case PROP_SHOW_AVATARS: - empathy_contact_list_store_set_show_avatars (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_boolean (value)); - break; - case PROP_SHOW_GROUPS: - empathy_contact_list_store_set_show_groups (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_boolean (value)); - break; - case PROP_IS_COMPACT: - empathy_contact_list_store_set_is_compact (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_boolean (value)); - break; - case PROP_SORT_CRITERIUM: - empathy_contact_list_store_set_sort_criterium (EMPATHY_CONTACT_LIST_STORE (object), - g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -EmpathyContactListStore * -empathy_contact_list_store_new (EmpathyContactList *list_iface) -{ - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list_iface), NULL); - - return g_object_new (EMPATHY_TYPE_CONTACT_LIST_STORE, - "contact-list", list_iface, - NULL); -} - -EmpathyContactList * -empathy_contact_list_store_get_list_iface (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), FALSE); - - priv = GET_PRIV (store); - - return priv->list; -} - -gboolean -empathy_contact_list_store_get_show_offline (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), FALSE); - - priv = GET_PRIV (store); - - return priv->show_offline; -} - -void -empathy_contact_list_store_set_show_offline (EmpathyContactListStore *store, - gboolean show_offline) -{ - EmpathyContactListStorePriv *priv; - GList *contacts, *l; - gboolean show_active; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - priv->show_offline = show_offline; - show_active = priv->show_active; - - /* Disable temporarily. */ - priv->show_active = FALSE; - - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - contact_list_store_contact_update (store, l->data); - - g_object_unref (l->data); - } - g_list_free (contacts); - - /* Restore to original setting. */ - priv->show_active = show_active; - - g_object_notify (G_OBJECT (store), "show-offline"); -} - -gboolean -empathy_contact_list_store_get_show_avatars (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE); - - priv = GET_PRIV (store); - - return priv->show_avatars; -} - -void -empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store, - gboolean show_avatars) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - priv->show_avatars = show_avatars; - - model = GTK_TREE_MODEL (store); - - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) - contact_list_store_update_list_mode_foreach, - store); - - g_object_notify (G_OBJECT (store), "show-avatars"); -} - -gboolean -empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE); - - priv = GET_PRIV (store); - - return priv->show_groups; -} - -void -empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store, - gboolean show_groups) -{ - EmpathyContactListStorePriv *priv; - GList *contacts, *l; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - if (priv->show_groups == show_groups) { - return; - } - - priv->show_groups = show_groups; - - /* Remove all contacts and add them back, not optimized but that's the - * easy way :) */ - gtk_tree_store_clear (GTK_TREE_STORE (store)); - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - contact_list_store_members_changed_cb (priv->list, l->data, - NULL, 0, NULL, - TRUE, - store); - - g_object_unref (l->data); - } - g_list_free (contacts); - - g_object_notify (G_OBJECT (store), "show-groups"); -} - -gboolean -empathy_contact_list_store_get_is_compact (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), TRUE); - - priv = GET_PRIV (store); - - return priv->is_compact; -} - -void -empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store, - gboolean is_compact) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - priv->is_compact = is_compact; - - model = GTK_TREE_MODEL (store); - - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) - contact_list_store_update_list_mode_foreach, - store); - - g_object_notify (G_OBJECT (store), "is-compact"); -} - -EmpathyContactListStoreSort -empathy_contact_list_store_get_sort_criterium (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), 0); - - priv = GET_PRIV (store); - - return priv->sort_criterium; -} - -void -empathy_contact_list_store_set_sort_criterium (EmpathyContactListStore *store, - EmpathyContactListStoreSort sort_criterium) -{ - EmpathyContactListStorePriv *priv; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - priv->sort_criterium = sort_criterium; - - switch (sort_criterium) { - case EMPATHY_CONTACT_LIST_STORE_SORT_STATE: - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - EMPATHY_CONTACT_LIST_STORE_COL_STATUS, - GTK_SORT_ASCENDING); - break; - - case EMPATHY_CONTACT_LIST_STORE_SORT_NAME: - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - EMPATHY_CONTACT_LIST_STORE_COL_NAME, - GTK_SORT_ASCENDING); - break; - } - - g_object_notify (G_OBJECT (store), "sort-criterium"); -} - -gboolean -empathy_contact_list_store_row_separator_func (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gboolean is_separator = FALSE; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), FALSE); - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator, - -1); - - return is_separator; -} - -gchar * -empathy_contact_list_store_get_parent_group (GtkTreeModel *model, - GtkTreePath *path, - gboolean *path_is_group) -{ - GtkTreeIter parent_iter, iter; - gchar *name = NULL; - gboolean is_group; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL); - - if (path_is_group) { - *path_is_group = FALSE; - } - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - return NULL; - } - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - - if (!is_group) { - g_free (name); - name = NULL; - - if (!gtk_tree_model_iter_parent (model, &parent_iter, &iter)) { - return NULL; - } - - iter = parent_iter; - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - if (!is_group) { - g_free (name); - return NULL; - } - } - - if (path_is_group) { - *path_is_group = TRUE; - } - - return name; -} - -gboolean -empathy_contact_list_store_search_equal_func (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - gpointer search_data) -{ - gchar *name, *name_folded; - gchar *key_folded; - gboolean ret; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), FALSE); - - if (!key) { - return TRUE; - } - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - - if (!name) { - return TRUE; - } - - name_folded = g_utf8_casefold (name, -1); - key_folded = g_utf8_casefold (key, -1); - - if (name_folded && key_folded && - strstr (name_folded, key_folded)) { - ret = FALSE; - } else { - ret = TRUE; - } - - g_free (name); - g_free (name_folded); - g_free (key_folded); - - return ret; -} - -static void -contact_list_store_setup (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - GType types[] = {G_TYPE_STRING, /* Status icon-name */ - GDK_TYPE_PIXBUF, /* Avatar pixbuf */ - G_TYPE_BOOLEAN, /* Avatar pixbuf visible */ - G_TYPE_STRING, /* Name */ - G_TYPE_STRING, /* Status string */ - G_TYPE_BOOLEAN, /* Show status */ - EMPATHY_TYPE_CONTACT, /* Contact type */ - G_TYPE_BOOLEAN, /* Is group */ - G_TYPE_BOOLEAN, /* Is active */ - G_TYPE_BOOLEAN, /* Is online */ - G_TYPE_BOOLEAN, /* Is separator */ - G_TYPE_BOOLEAN}; /* Can VoIP */ - - priv = GET_PRIV (store); - - gtk_tree_store_set_column_types (GTK_TREE_STORE (store), - EMPATHY_CONTACT_LIST_STORE_COL_COUNT, - types); - - /* Set up sorting */ - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), - EMPATHY_CONTACT_LIST_STORE_COL_NAME, - contact_list_store_name_sort_func, - store, NULL); - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), - EMPATHY_CONTACT_LIST_STORE_COL_STATUS, - contact_list_store_state_sort_func, - store, NULL); - - priv->sort_criterium = EMPATHY_CONTACT_LIST_STORE_SORT_NAME; - empathy_contact_list_store_set_sort_criterium (store, priv->sort_criterium); -} - -static gboolean -contact_list_store_inibit_active_cb (EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - priv = GET_PRIV (store); - - priv->show_active = TRUE; - priv->inhibit_active = 0; - - return FALSE; -} - -static void -contact_list_store_members_changed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContact *actor, - guint reason, - gchar *message, - gboolean is_member, - EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - - priv = GET_PRIV (store); - - DEBUG ("Contact %s (%d) %s", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - is_member ? "added" : "removed"); - - if (is_member) { - g_signal_connect (contact, "notify::presence", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::presence-message", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::name", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::avatar", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::capabilities", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - - contact_list_store_add_contact (store, contact); - } else { - g_signal_handlers_disconnect_by_func (contact, - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - - contact_list_store_remove_contact (store, contact); - } -} - -static void -contact_list_store_groups_changed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - gchar *group, - gboolean is_member, - EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - gboolean show_active; - - priv = GET_PRIV (store); - - DEBUG ("Updating groups for contact %s (%d)", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact)); - - /* We do this to make sure the groups are correct, if not, we - * would have to check the groups already set up for each - * contact and then see what has been updated. - */ - show_active = priv->show_active; - priv->show_active = FALSE; - contact_list_store_remove_contact (store, contact); - contact_list_store_add_contact (store, contact); - priv->show_active = show_active; -} - -static void -contact_list_store_add_contact (EmpathyContactListStore *store, - EmpathyContact *contact) -{ - EmpathyContactListStorePriv *priv; - GtkTreeIter iter; - GList *groups = NULL, *l; - - priv = GET_PRIV (store); - - if (EMP_STR_EMPTY (empathy_contact_get_name (contact)) || - (!priv->show_offline && !empathy_contact_is_online (contact))) { - return; - } - - if (priv->show_groups) { - groups = empathy_contact_list_get_groups (priv->list, contact); - } - - /* If no groups just add it at the top level. */ - if (!groups) { - gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL); - gtk_tree_store_set (GTK_TREE_STORE (store), &iter, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, empathy_contact_can_voip (contact), - -1); - } - - /* Else add to each group. */ - for (l = groups; l; l = l->next) { - GtkTreeIter iter_group; - - contact_list_store_get_group (store, l->data, &iter_group, NULL, NULL); - - gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter, - &iter_group, NULL); - gtk_tree_store_set (GTK_TREE_STORE (store), &iter, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, empathy_contact_can_voip (contact), - -1); - g_free (l->data); - } - g_list_free (groups); - - contact_list_store_contact_update (store, contact); - -} - -static void -contact_list_store_remove_contact (EmpathyContactListStore *store, - EmpathyContact *contact) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - GList *iters, *l; - - priv = GET_PRIV (store); - - iters = contact_list_store_find_contact (store, contact); - if (!iters) { - return; - } - - /* Clean up model */ - model = GTK_TREE_MODEL (store); - - for (l = iters; l; l = l->next) { - GtkTreeIter parent; - - /* NOTE: it is only <= 2 here because we have - * separators after the group name, otherwise it - * should be 1. - */ - if (gtk_tree_model_iter_parent (model, &parent, l->data) && - gtk_tree_model_iter_n_children (model, &parent) <= 2) { - gtk_tree_store_remove (GTK_TREE_STORE (store), &parent); - } else { - gtk_tree_store_remove (GTK_TREE_STORE (store), l->data); - } - } - - g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL); - g_list_free (iters); -} - -static void -contact_list_store_contact_update (EmpathyContactListStore *store, - EmpathyContact *contact) -{ - EmpathyContactListStorePriv *priv; - ShowActiveData *data; - GtkTreeModel *model; - GList *iters, *l; - gboolean in_list; - gboolean should_be_in_list; - gboolean was_online = TRUE; - gboolean now_online = FALSE; - gboolean set_model = FALSE; - gboolean do_remove = FALSE; - gboolean do_set_active = FALSE; - gboolean do_set_refresh = FALSE; - gboolean show_avatar = FALSE; - GdkPixbuf *pixbuf_avatar; - - priv = GET_PRIV (store); - - model = GTK_TREE_MODEL (store); - - iters = contact_list_store_find_contact (store, contact); - if (!iters) { - in_list = FALSE; - } else { - in_list = TRUE; - } - - /* Get online state now. */ - now_online = empathy_contact_is_online (contact); - - if (priv->show_offline || now_online) { - should_be_in_list = TRUE; - } else { - should_be_in_list = FALSE; - } - - if (!in_list && !should_be_in_list) { - /* Nothing to do. */ - DEBUG ("Contact:'%s' in list:NO, should be:NO", - empathy_contact_get_name (contact)); - - g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL); - g_list_free (iters); - return; - } - else if (in_list && !should_be_in_list) { - DEBUG ("Contact:'%s' in list:YES, should be:NO", - empathy_contact_get_name (contact)); - - if (priv->show_active) { - do_remove = TRUE; - do_set_active = TRUE; - do_set_refresh = TRUE; - - set_model = TRUE; - DEBUG ("Remove item (after timeout)"); - } else { - DEBUG ("Remove item (now)!"); - contact_list_store_remove_contact (store, contact); - } - } - else if (!in_list && should_be_in_list) { - DEBUG ("Contact:'%s' in list:NO, should be:YES", - empathy_contact_get_name (contact)); - - contact_list_store_add_contact (store, contact); - - if (priv->show_active) { - do_set_active = TRUE; - - DEBUG ("Set active (contact added)"); - } - } else { - DEBUG ("Contact:'%s' in list:YES, should be:YES", - empathy_contact_get_name (contact)); - - /* Get online state before. */ - if (iters && g_list_length (iters) > 0) { - gtk_tree_model_get (model, iters->data, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, &was_online, - -1); - } - - /* Is this really an update or an online/offline. */ - if (priv->show_active) { - if (was_online != now_online) { - do_set_active = TRUE; - do_set_refresh = TRUE; - - DEBUG ("Set active (contact updated %s)", - was_online ? "online -> offline" : - "offline -> online"); - } else { - /* Was TRUE for presence updates. */ - /* do_set_active = FALSE; */ - do_set_refresh = TRUE; - - DEBUG ("Set active (contact updated)"); - } - } - - set_model = TRUE; - } - - if (priv->show_avatars && !priv->is_compact) { - show_avatar = TRUE; - } - pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32); - for (l = iters; l && set_model; l = l->next) { - gtk_tree_store_set (GTK_TREE_STORE (store), l->data, - EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, empathy_icon_name_for_contact (contact), - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), - EMPATHY_CONTACT_LIST_STORE_COL_STATUS, empathy_contact_get_status (contact), - EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, !priv->is_compact, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, now_online, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, empathy_contact_can_voip (contact), - -1); - } - - if (pixbuf_avatar) { - g_object_unref (pixbuf_avatar); - } - - if (priv->show_active && do_set_active) { - contact_list_store_contact_set_active (store, contact, do_set_active, do_set_refresh); - - if (do_set_active) { - data = contact_list_store_contact_active_new (store, contact, do_remove); - g_timeout_add_seconds (ACTIVE_USER_SHOW_TIME, - (GSourceFunc) contact_list_store_contact_active_cb, - data); - } - } - - /* FIXME: when someone goes online then offline quickly, the - * first timeout sets the user to be inactive and the second - * timeout removes the user from the contact list, really we - * should remove the first timeout. - */ - g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL); - g_list_free (iters); -} - -static void -contact_list_store_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyContactListStore *store) -{ - DEBUG ("Contact:'%s' updated, checking roster is in sync...", - empathy_contact_get_name (contact)); - - contact_list_store_contact_update (store, contact); -} - -static void -contact_list_store_contact_set_active (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean active, - gboolean set_changed) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - GList *iters, *l; - - priv = GET_PRIV (store); - model = GTK_TREE_MODEL (store); - - iters = contact_list_store_find_contact (store, contact); - for (l = iters; l; l = l->next) { - GtkTreePath *path; - - gtk_tree_store_set (GTK_TREE_STORE (store), l->data, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, active, - -1); - - DEBUG ("Set item %s", active ? "active" : "inactive"); - - if (set_changed) { - path = gtk_tree_model_get_path (model, l->data); - gtk_tree_model_row_changed (model, path, l->data); - gtk_tree_path_free (path); - } - } - - g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL); - g_list_free (iters); - -} - -static ShowActiveData * -contact_list_store_contact_active_new (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean remove) -{ - ShowActiveData *data; - - DEBUG ("Contact:'%s' now active, and %s be removed", - empathy_contact_get_name (contact), - remove ? "WILL" : "WILL NOT"); - - data = g_slice_new0 (ShowActiveData); - - data->store = g_object_ref (store); - data->contact = g_object_ref (contact); - data->remove = remove; - - return data; -} - -static void -contact_list_store_contact_active_free (ShowActiveData *data) -{ - g_object_unref (data->contact); - g_object_unref (data->store); - - g_slice_free (ShowActiveData, data); -} - -static gboolean -contact_list_store_contact_active_cb (ShowActiveData *data) -{ - EmpathyContactListStorePriv *priv; - - priv = GET_PRIV (data->store); - - if (data->remove && - !priv->show_offline && - !empathy_contact_is_online (data->contact)) { - DEBUG ("Contact:'%s' active timeout, removing item", - empathy_contact_get_name (data->contact)); - contact_list_store_remove_contact (data->store, data->contact); - } - - DEBUG ("Contact:'%s' no longer active", - empathy_contact_get_name (data->contact)); - - contact_list_store_contact_set_active (data->store, - data->contact, - FALSE, - TRUE); - - contact_list_store_contact_active_free (data); - - return FALSE; -} - -static gboolean -contact_list_store_get_group_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindGroup *fg) -{ - gchar *str; - gboolean is_group; - - /* Groups are only at the top level. */ - if (gtk_tree_path_get_depth (path) != 1) { - return FALSE; - } - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &str, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - -1); - - if (is_group && !tp_strdiff (str, fg->name)) { - fg->found = TRUE; - fg->iter = *iter; - } - - g_free (str); - - return fg->found; -} - -static void -contact_list_store_get_group (EmpathyContactListStore *store, - const gchar *name, - GtkTreeIter *iter_group_to_set, - GtkTreeIter *iter_separator_to_set, - gboolean *created) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - GtkTreeIter iter_group; - GtkTreeIter iter_separator; - FindGroup fg; - - priv = GET_PRIV (store); - - memset (&fg, 0, sizeof (fg)); - - fg.name = name; - - model = GTK_TREE_MODEL (store); - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) contact_list_store_get_group_foreach, - &fg); - - if (!fg.found) { - if (created) { - *created = TRUE; - } - - gtk_tree_store_append (GTK_TREE_STORE (store), &iter_group, NULL); - gtk_tree_store_set (GTK_TREE_STORE (store), &iter_group, - EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, NULL, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, name, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, TRUE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, FALSE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, - -1); - - if (iter_group_to_set) { - *iter_group_to_set = iter_group; - } - - gtk_tree_store_append (GTK_TREE_STORE (store), - &iter_separator, - &iter_group); - gtk_tree_store_set (GTK_TREE_STORE (store), &iter_separator, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, TRUE, - -1); - - if (iter_separator_to_set) { - *iter_separator_to_set = iter_separator; - } - } else { - if (created) { - *created = FALSE; - } - - if (iter_group_to_set) { - *iter_group_to_set = fg.iter; - } - - iter_separator = fg.iter; - - if (gtk_tree_model_iter_next (model, &iter_separator)) { - gboolean is_separator; - - gtk_tree_model_get (model, &iter_separator, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator, - -1); - - if (is_separator && iter_separator_to_set) { - *iter_separator_to_set = iter_separator; - } - } - } -} - -static guint -contact_list_store_ordered_presence (McPresence state) -{ - switch (state) { - case MC_PRESENCE_UNSET: - case MC_PRESENCE_OFFLINE: - return 5; - case MC_PRESENCE_AVAILABLE: - return 0; - case MC_PRESENCE_AWAY: - return 2; - case MC_PRESENCE_EXTENDED_AWAY: - return 3; - case MC_PRESENCE_HIDDEN: - return 4; - case MC_PRESENCE_DO_NOT_DISTURB: - return 1; - default: - g_return_val_if_reached (6); - } -} - -static gint -contact_list_store_state_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data) -{ - gint ret_val = 0; - gchar *name_a, *name_b; - gboolean is_separator_a, is_separator_b; - EmpathyContact *contact_a, *contact_b; - guint presence_a, presence_b; - - gtk_tree_model_get (model, iter_a, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_a, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_a, - -1); - gtk_tree_model_get (model, iter_b, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_b, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_b, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_b, - -1); - - /* Separator or group? */ - if (is_separator_a || is_separator_b) { - if (is_separator_a) { - ret_val = -1; - } else if (is_separator_b) { - ret_val = 1; - } - } else if (!contact_a && contact_b) { - ret_val = 1; - } else if (contact_a && !contact_b) { - ret_val = -1; - } else if (!contact_a && !contact_b) { - /* Handle groups */ - ret_val = g_utf8_collate (name_a, name_b); - } - - if (ret_val) { - goto free_and_out; - } - - /* If we managed to get this far, we can start looking at - * the presences. - */ - presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)); - presence_a = contact_list_store_ordered_presence (presence_a); - presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b)); - presence_b = contact_list_store_ordered_presence (presence_b); - - if (presence_a < presence_b) { - ret_val = -1; - } else if (presence_a > presence_b) { - ret_val = 1; - } else { - /* Fallback: compare by name */ - ret_val = g_utf8_collate (name_a, name_b); - } - -free_and_out: - g_free (name_a); - g_free (name_b); - - if (contact_a) { - g_object_unref (contact_a); - } - - if (contact_b) { - g_object_unref (contact_b); - } - - return ret_val; -} - -static gint -contact_list_store_name_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data) -{ - gchar *name_a, *name_b; - EmpathyContact *contact_a, *contact_b; - gboolean is_separator_a, is_separator_b; - gint ret_val; - - gtk_tree_model_get (model, iter_a, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_a, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_a, - -1); - gtk_tree_model_get (model, iter_b, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_b, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact_b, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, &is_separator_b, - -1); - - /* If contact is NULL it means it's a group. */ - - if (is_separator_a || is_separator_b) { - if (is_separator_a) { - ret_val = -1; - } else if (is_separator_b) { - ret_val = 1; - } - } else if (!contact_a && contact_b) { - ret_val = 1; - } else if (contact_a && !contact_b) { - ret_val = -1; - } else { - ret_val = g_utf8_collate (name_a, name_b); - } - - g_free (name_a); - g_free (name_b); - - if (contact_a) { - g_object_unref (contact_a); - } - - if (contact_b) { - g_object_unref (contact_b); - } - - return ret_val; -} - -static gboolean -contact_list_store_find_contact_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindContact *fc) -{ - EmpathyContact *contact; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, - -1); - - if (contact == fc->contact) { - fc->found = TRUE; - fc->iters = g_list_append (fc->iters, gtk_tree_iter_copy (iter)); - } - - if (contact) { - g_object_unref (contact); - } - - return FALSE; -} - -static GList * -contact_list_store_find_contact (EmpathyContactListStore *store, - EmpathyContact *contact) -{ - EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - GList *l = NULL; - FindContact fc; - - priv = GET_PRIV (store); - - memset (&fc, 0, sizeof (fc)); - - fc.contact = contact; - - model = GTK_TREE_MODEL (store); - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) contact_list_store_find_contact_foreach, - &fc); - - if (fc.found) { - l = fc.iters; - } - - return l; -} - -static gboolean -contact_list_store_update_list_mode_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - EmpathyContactListStore *store) -{ - EmpathyContactListStorePriv *priv; - gboolean show_avatar = FALSE; - - priv = GET_PRIV (store); - - if (priv->show_avatars && !priv->is_compact) { - show_avatar = TRUE; - } - - gtk_tree_store_set (GTK_TREE_STORE (store), iter, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar, - EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, !priv->is_compact, - -1); - - return FALSE; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-list-store.h b/gnome-2-26/libempathy-gtk/empathy-contact-list-store.h deleted file mode 100644 index 10354ff11..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-list-store.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CONTACT_LIST_STORE_H__ -#define __EMPATHY_CONTACT_LIST_STORE_H__ - -#include <gtk/gtktreestore.h> - -#include <libempathy/empathy-contact-list.h> -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CONTACT_LIST_STORE (empathy_contact_list_store_get_type ()) -#define EMPATHY_CONTACT_LIST_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_LIST_STORE, EmpathyContactListStore)) -#define EMPATHY_CONTACT_LIST_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CONTACT_LIST_STORE, EmpathyContactListStoreClass)) -#define EMPATHY_IS_CONTACT_LIST_STORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST_STORE)) -#define EMPATHY_IS_CONTACT_LIST_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_LIST_STORE)) -#define EMPATHY_CONTACT_LIST_STORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_LIST_STORE, EmpathyContactListStoreClass)) - -typedef struct _EmpathyContactListStore EmpathyContactListStore; -typedef struct _EmpathyContactListStoreClass EmpathyContactListStoreClass; - -typedef enum { - EMPATHY_CONTACT_LIST_STORE_SORT_STATE, - EMPATHY_CONTACT_LIST_STORE_SORT_NAME -} EmpathyContactListStoreSort; - -typedef enum { - EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, - EMPATHY_CONTACT_LIST_STORE_COL_STATUS, - EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, - EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, - EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, - EMPATHY_CONTACT_LIST_STORE_COL_COUNT -} EmpathyContactListStoreCol; - -struct _EmpathyContactListStore { - GtkTreeStore parent; - gpointer priv; -}; - -struct _EmpathyContactListStoreClass { - GtkTreeStoreClass parent_class; -}; - -GType empathy_contact_list_store_get_type (void) G_GNUC_CONST; -EmpathyContactListStore * empathy_contact_list_store_new (EmpathyContactList *list_iface); -EmpathyContactList * empathy_contact_list_store_get_list_iface (EmpathyContactListStore *store); -gboolean empathy_contact_list_store_get_show_offline (EmpathyContactListStore *store); -void empathy_contact_list_store_set_show_offline (EmpathyContactListStore *store, - gboolean show_offline); -gboolean empathy_contact_list_store_get_show_avatars (EmpathyContactListStore *store); -void empathy_contact_list_store_set_show_avatars (EmpathyContactListStore *store, - gboolean show_avatars); -gboolean empathy_contact_list_store_get_show_groups (EmpathyContactListStore *store); -void empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store, - gboolean show_groups); -gboolean empathy_contact_list_store_get_is_compact (EmpathyContactListStore *store); -void empathy_contact_list_store_set_is_compact (EmpathyContactListStore *store, - gboolean is_compact); -EmpathyContactListStoreSort empathy_contact_list_store_get_sort_criterium (EmpathyContactListStore *store); -void empathy_contact_list_store_set_sort_criterium (EmpathyContactListStore *store, - EmpathyContactListStoreSort sort_criterium); -gboolean empathy_contact_list_store_row_separator_func (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data); -gchar * empathy_contact_list_store_get_parent_group (GtkTreeModel *model, - GtkTreePath *path, - gboolean *path_is_group); -gboolean empathy_contact_list_store_search_equal_func (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - gpointer search_data); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_LIST_STORE_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-list-view.c b/gnome-2-26/libempathy-gtk/empathy-contact-list-view.c deleted file mode 100644 index 6cb8b7e8c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-list-view.c +++ /dev/null @@ -1,1398 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mc-account.h> - -#include <libempathy/empathy-call-factory.h> -#include <libempathy/empathy-contact-factory.h> -#include <libempathy/empathy-contact-list.h> -#include <libempathy/empathy-contact-groups.h> -#include <libempathy/empathy-dispatcher.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-contact-list-view.h" -#include "empathy-contact-list-store.h" -#include "empathy-images.h" -#include "empathy-cell-renderer-expander.h" -#include "empathy-cell-renderer-text.h" -#include "empathy-cell-renderer-activatable.h" -#include "empathy-ui-utils.h" -#include "empathy-gtk-enum-types.h" -#include "empathy-gtk-marshal.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT -#include <libempathy/empathy-debug.h> - -/* Active users are those which have recently changed state - * (e.g. online, offline or from normal to a busy state). - */ - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactListView) -typedef struct { - EmpathyContactListStore *store; - GtkTreeRowReference *drag_row; - EmpathyContactListFeatureFlags list_features; - EmpathyContactFeatureFlags contact_features; - GtkWidget *tooltip_widget; -} EmpathyContactListViewPriv; - -typedef struct { - EmpathyContactListView *view; - GtkTreePath *path; - guint timeout_id; -} DragMotionData; - -typedef struct { - EmpathyContactListView *view; - EmpathyContact *contact; - gboolean remove; -} ShowActiveData; - -enum { - PROP_0, - PROP_STORE, - PROP_LIST_FEATURES, - PROP_CONTACT_FEATURES, -}; - -enum DndDragType { - DND_DRAG_TYPE_CONTACT_ID, - DND_DRAG_TYPE_URL, - DND_DRAG_TYPE_STRING, -}; - -static const GtkTargetEntry drag_types_dest[] = { - { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID }, - { "text/uri-list", 0, DND_DRAG_TYPE_URL }, - { "text/plain", 0, DND_DRAG_TYPE_STRING }, - { "STRING", 0, DND_DRAG_TYPE_STRING }, -}; - -static const GtkTargetEntry drag_types_source[] = { - { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID }, -}; - -static GdkAtom drag_atoms_dest[G_N_ELEMENTS (drag_types_dest)]; -static GdkAtom drag_atoms_source[G_N_ELEMENTS (drag_types_source)]; - -enum { - DRAG_CONTACT_RECEIVED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (EmpathyContactListView, empathy_contact_list_view, GTK_TYPE_TREE_VIEW); - -static void -contact_list_view_tooltip_destroy_cb (GtkWidget *widget, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - - if (priv->tooltip_widget) { - DEBUG ("Tooltip destroyed"); - priv->tooltip_widget = NULL; - g_object_unref (widget); - } -} - -static gboolean -contact_list_view_query_tooltip_cb (EmpathyContactListView *view, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip, - gpointer user_data) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - EmpathyContact *contact; - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path; - static gint running = 0; - gboolean ret = FALSE; - - /* Avoid an infinite loop. See GNOME bug #574377 */ - if (running > 0) { - return FALSE; - } - running++; - - if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y, - keyboard_mode, - &model, &path, &iter)) { - goto OUT; - } - - gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path); - gtk_tree_path_free (path); - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, - -1); - if (!contact) { - goto OUT; - } - - if (!priv->tooltip_widget) { - priv->tooltip_widget = empathy_contact_widget_new (contact, - EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP); - g_object_ref (priv->tooltip_widget); - g_signal_connect (priv->tooltip_widget, "destroy", - G_CALLBACK (contact_list_view_tooltip_destroy_cb), - view); - } else { - empathy_contact_widget_set_contact (priv->tooltip_widget, - contact); - } - - gtk_tooltip_set_custom (tooltip, priv->tooltip_widget); - ret = TRUE; - - g_object_unref (contact); -OUT: - running--; - - return ret; -} - -static void -contact_list_view_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection, - guint info, - guint time) -{ - EmpathyContactListViewPriv *priv; - EmpathyContactList *list; - EmpathyContactFactory *factory; - McAccount *account; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeViewDropPosition position; - EmpathyContact *contact = NULL; - const gchar *id; - gchar **strv; - gchar *new_group = NULL; - gchar *old_group = NULL; - gboolean is_row; - - priv = GET_PRIV (widget); - - id = (const gchar*) selection->data; - DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", - context->action == GDK_ACTION_MOVE ? "move" : "", - context->action == GDK_ACTION_COPY ? "copy" : "", - id); - - strv = g_strsplit (id, "/", 2); - factory = empathy_contact_factory_dup_singleton (); - account = mc_account_lookup (strv[0]); - if (account) { - contact = empathy_contact_factory_get_from_id (factory, - account, - strv[1]); - g_object_unref (account); - } - g_object_unref (factory); - g_strfreev (strv); - - if (!contact) { - DEBUG ("No contact found associated with drag & drop"); - return; - } - - empathy_contact_run_until_ready (contact, - EMPATHY_CONTACT_READY_HANDLE, - NULL); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - /* Get source group information. */ - if (priv->drag_row) { - path = gtk_tree_row_reference_get_path (priv->drag_row); - if (path) { - old_group = empathy_contact_list_store_get_parent_group (model, path, NULL); - gtk_tree_path_free (path); - } - } - - /* Get destination group information. */ - is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, - y, - &path, - &position); - - if (is_row) { - new_group = empathy_contact_list_store_get_parent_group (model, path, NULL); - gtk_tree_path_free (path); - } - - DEBUG ("contact %s (%d) dragged from '%s' to '%s'", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - old_group, new_group); - - list = empathy_contact_list_store_get_list_iface (priv->store); - if (new_group) { - empathy_contact_list_add_to_group (list, contact, new_group); - } - if (old_group && context->action == GDK_ACTION_MOVE) { - empathy_contact_list_remove_from_group (list, contact, old_group); - } - - g_free (old_group); - g_free (new_group); - - gtk_drag_finish (context, TRUE, FALSE, GDK_CURRENT_TIME); -} - -static gboolean -contact_list_view_drag_motion_cb (DragMotionData *data) -{ - gtk_tree_view_expand_row (GTK_TREE_VIEW (data->view), - data->path, - FALSE); - - data->timeout_id = 0; - - return FALSE; -} - -static gboolean -contact_list_view_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - static DragMotionData *dm = NULL; - GtkTreePath *path; - gboolean is_row; - gboolean is_different = FALSE; - gboolean cleanup = TRUE; - - is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), - x, - y, - &path, - NULL, - NULL, - NULL); - - cleanup &= (!dm); - - if (is_row) { - cleanup &= (dm && gtk_tree_path_compare (dm->path, path) != 0); - is_different = (!dm || (dm && gtk_tree_path_compare (dm->path, path) != 0)); - } else { - cleanup &= FALSE; - } - - if (!is_different && !cleanup) { - return TRUE; - } - - if (dm) { - gtk_tree_path_free (dm->path); - if (dm->timeout_id) { - g_source_remove (dm->timeout_id); - } - - g_free (dm); - - dm = NULL; - } - - if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { - dm = g_new0 (DragMotionData, 1); - - dm->view = EMPATHY_CONTACT_LIST_VIEW (widget); - dm->path = gtk_tree_path_copy (path); - - dm->timeout_id = g_timeout_add_seconds (1, - (GSourceFunc) contact_list_view_drag_motion_cb, - dm); - } - - return TRUE; -} - -static void -contact_list_view_drag_begin (GtkWidget *widget, - GdkDragContext *context) -{ - EmpathyContactListViewPriv *priv; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - - priv = GET_PRIV (widget); - - GTK_WIDGET_CLASS (empathy_contact_list_view_parent_class)->drag_begin (widget, - context); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return; - } - - path = gtk_tree_model_get_path (model, &iter); - priv->drag_row = gtk_tree_row_reference_new (model, path); - gtk_tree_path_free (path); -} - -static void -contact_list_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection, - guint info, - guint time) -{ - EmpathyContactListViewPriv *priv; - GtkTreePath *src_path; - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyContact *contact; - McAccount *account; - const gchar *contact_id; - const gchar *account_id; - gchar *str; - - priv = GET_PRIV (widget); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - if (!priv->drag_row) { - return; - } - - src_path = gtk_tree_row_reference_get_path (priv->drag_row); - if (!src_path) { - return; - } - - if (!gtk_tree_model_get_iter (model, &iter, src_path)) { - gtk_tree_path_free (src_path); - return; - } - - gtk_tree_path_free (src_path); - - contact = empathy_contact_list_view_get_selected (EMPATHY_CONTACT_LIST_VIEW (widget)); - if (!contact) { - return; - } - - account = empathy_contact_get_account (contact); - account_id = mc_account_get_unique_name (account); - contact_id = empathy_contact_get_id (contact); - g_object_unref (contact); - str = g_strconcat (account_id, "/", contact_id, NULL); - - switch (info) { - case DND_DRAG_TYPE_CONTACT_ID: - gtk_selection_data_set (selection, drag_atoms_source[info], 8, - (guchar*)str, strlen (str) + 1); - break; - } - - g_free (str); -} - -static void -contact_list_view_drag_end (GtkWidget *widget, - GdkDragContext *context) -{ - EmpathyContactListViewPriv *priv; - - priv = GET_PRIV (widget); - - GTK_WIDGET_CLASS (empathy_contact_list_view_parent_class)->drag_end (widget, - context); - - if (priv->drag_row) { - gtk_tree_row_reference_free (priv->drag_row); - priv->drag_row = NULL; - } -} - -static gboolean -contact_list_view_drag_drop (GtkWidget *widget, - GdkDragContext *drag_context, - gint x, - gint y, - guint time) -{ - return FALSE; -} - -typedef struct { - EmpathyContactListView *view; - guint button; - guint32 time; -} MenuPopupData; - -static gboolean -contact_list_view_popup_menu_idle_cb (gpointer user_data) -{ - MenuPopupData *data = user_data; - GtkWidget *menu; - - menu = empathy_contact_list_view_get_contact_menu (data->view); - if (!menu) { - menu = empathy_contact_list_view_get_group_menu (data->view); - } - - if (menu) { - gtk_widget_show (menu); - gtk_menu_popup (GTK_MENU (menu), - NULL, NULL, NULL, NULL, - data->button, data->time); - } - - g_slice_free (MenuPopupData, data); - - return FALSE; -} - -static gboolean -contact_list_view_button_press_event_cb (EmpathyContactListView *view, - GdkEventButton *event, - gpointer user_data) -{ - if (event->button == 3) { - MenuPopupData *data; - - data = g_slice_new (MenuPopupData); - data->view = view; - data->button = event->button; - data->time = event->time; - g_idle_add (contact_list_view_popup_menu_idle_cb, data); - } - - return FALSE; -} - -static gboolean -contact_list_view_key_press_event_cb (EmpathyContactListView *view, - GdkEventKey *event, - gpointer user_data) -{ - if (event->keyval == GDK_Menu) { - MenuPopupData *data; - - data = g_slice_new (MenuPopupData); - data->view = view; - data->button = 0; - data->time = event->time; - g_idle_add (contact_list_view_popup_menu_idle_cb, data); - } - - return FALSE; -} - -static void -contact_list_view_row_activated (GtkTreeView *view, - GtkTreePath *path, - GtkTreeViewColumn *column) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - EmpathyContact *contact; - GtkTreeModel *model; - GtkTreeIter iter; - - if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT)) { - return; - } - - model = GTK_TREE_MODEL (priv->store); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, - -1); - - if (contact) { - DEBUG ("Starting a chat"); - empathy_dispatcher_chat_with_contact (contact, NULL, NULL); - g_object_unref (contact); - } -} - -static void -contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell, - const gchar *path_string, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - GtkTreeModel *model; - GtkTreeIter iter; - EmpathyContact *contact; - - if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CALL)) { - return; - } - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string)) { - return; - } - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, - -1); - - if (contact) { - EmpathyCallFactory *factory; - - factory = empathy_call_factory_get (); - empathy_call_factory_new_call (factory, contact); - - g_object_unref (contact); - } -} - -static void -contact_list_view_cell_set_background (EmpathyContactListView *view, - GtkCellRenderer *cell, - gboolean is_group, - gboolean is_active) -{ - GdkColor color; - GtkStyle *style; - - style = gtk_widget_get_style (GTK_WIDGET (view)); - - if (!is_group && is_active) { - color = style->bg[GTK_STATE_SELECTED]; - - /* Here we take the current theme colour and add it to - * the colour for white and average the two. This - * gives a colour which is inline with the theme but - * slightly whiter. - */ - color.red = (color.red + (style->white).red) / 2; - color.green = (color.green + (style->white).green) / 2; - color.blue = (color.blue + (style->white).blue) / 2; - - g_object_set (cell, - "cell-background-gdk", &color, - NULL); - } else { - g_object_set (cell, - "cell-background-gdk", NULL, - NULL); - } -} - -static void -contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - gchar *icon_name; - gboolean is_group; - gboolean is_active; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active, - EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, &icon_name, - -1); - - g_object_set (cell, - "visible", !is_group, - "icon-name", icon_name, - NULL); - - g_free (icon_name); - - contact_list_view_cell_set_background (view, cell, is_group, is_active); -} - -static void -contact_list_view_voip_cell_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - gboolean is_group; - gboolean is_active; - gboolean can_voip; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active, - EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, &can_voip, - -1); - - g_object_set (cell, - "visible", !is_group && can_voip, - "icon-name", EMPATHY_IMAGE_VOIP, - NULL); - - contact_list_view_cell_set_background (view, cell, is_group, is_active); -} - -static void -contact_list_view_avatar_cell_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - GdkPixbuf *pixbuf; - gboolean show_avatar; - gboolean is_group; - gboolean is_active; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, &pixbuf, - EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, &show_avatar, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active, - -1); - - g_object_set (cell, - "visible", !is_group && show_avatar, - "pixbuf", pixbuf, - NULL); - - if (pixbuf) { - g_object_unref (pixbuf); - } - - contact_list_view_cell_set_background (view, cell, is_group, is_active); -} - -static void -contact_list_view_text_cell_data_func (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - gboolean is_group; - gboolean is_active; - gboolean show_status; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active, - EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, &show_status, - -1); - - g_object_set (cell, - "show-status", show_status, - NULL); - - contact_list_view_cell_set_background (view, cell, is_group, is_active); -} - -static void -contact_list_view_expander_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - gboolean is_group; - gboolean is_active; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active, - -1); - - if (gtk_tree_model_iter_has_child (model, iter)) { - GtkTreePath *path; - gboolean row_expanded; - - path = gtk_tree_model_get_path (model, iter); - row_expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (column->tree_view), path); - gtk_tree_path_free (path); - - g_object_set (cell, - "visible", TRUE, - "expander-style", row_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, - NULL); - } else { - g_object_set (cell, "visible", FALSE, NULL); - } - - contact_list_view_cell_set_background (view, cell, is_group, is_active); -} - -static void -contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view, - GtkTreeIter *iter, - GtkTreePath *path, - gpointer user_data) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - GtkTreeModel *model; - gchar *name; - gboolean expanded; - - if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) { - return; - } - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - - expanded = GPOINTER_TO_INT (user_data); - empathy_contact_group_set_expanded (name, expanded); - - g_free (name); -} - -static void -contact_list_view_row_has_child_toggled_cb (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - gboolean is_group = FALSE; - gchar *name = NULL; - - gtk_tree_model_get (model, iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - - if (!is_group || EMP_STR_EMPTY (name)) { - g_free (name); - return; - } - - if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) || - empathy_contact_group_get_expanded (name)) { - g_signal_handlers_block_by_func (view, - contact_list_view_row_expand_or_collapse_cb, - GINT_TO_POINTER (TRUE)); - gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, TRUE); - g_signal_handlers_unblock_by_func (view, - contact_list_view_row_expand_or_collapse_cb, - GINT_TO_POINTER (TRUE)); - } else { - g_signal_handlers_block_by_func (view, - contact_list_view_row_expand_or_collapse_cb, - GINT_TO_POINTER (FALSE)); - gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), path); - g_signal_handlers_unblock_by_func (view, - contact_list_view_row_expand_or_collapse_cb, - GINT_TO_POINTER (FALSE)); - } - - g_free (name); -} - -static void -contact_list_view_setup (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv; - GtkCellRenderer *cell; - GtkTreeViewColumn *col; - gint i; - - priv = GET_PRIV (view); - - gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (view), - empathy_contact_list_store_search_equal_func, - NULL, NULL); - - g_signal_connect (priv->store, "row-has-child-toggled", - G_CALLBACK (contact_list_view_row_has_child_toggled_cb), - view); - gtk_tree_view_set_model (GTK_TREE_VIEW (view), - GTK_TREE_MODEL (priv->store)); - - /* Setup view */ - g_object_set (view, - "headers-visible", FALSE, - "reorderable", TRUE, - "show-expanders", FALSE, - NULL); - - col = gtk_tree_view_column_new (); - - /* State */ - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func ( - col, cell, - (GtkTreeCellDataFunc) contact_list_view_pixbuf_cell_data_func, - view, NULL); - - g_object_set (cell, - "xpad", 5, - "ypad", 1, - "visible", FALSE, - NULL); - - /* Name */ - cell = empathy_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (col, cell, TRUE); - gtk_tree_view_column_set_cell_data_func ( - col, cell, - (GtkTreeCellDataFunc) contact_list_view_text_cell_data_func, - view, NULL); - - gtk_tree_view_column_add_attribute (col, cell, - "name", EMPATHY_CONTACT_LIST_STORE_COL_NAME); - gtk_tree_view_column_add_attribute (col, cell, - "status", EMPATHY_CONTACT_LIST_STORE_COL_STATUS); - gtk_tree_view_column_add_attribute (col, cell, - "is_group", EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP); - - /* Voip Capability Icon */ - cell = empathy_cell_renderer_activatable_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func ( - col, cell, - (GtkTreeCellDataFunc) contact_list_view_voip_cell_data_func, - view, NULL); - - g_object_set (cell, - "visible", FALSE, - NULL); - - g_signal_connect (cell, "path-activated", - G_CALLBACK (contact_list_view_voip_activated_cb), - view); - - /* Avatar */ - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func ( - col, cell, - (GtkTreeCellDataFunc) contact_list_view_avatar_cell_data_func, - view, NULL); - - g_object_set (cell, - "xpad", 0, - "ypad", 0, - "visible", FALSE, - "width", 32, - "height", 32, - NULL); - - /* Expander */ - cell = empathy_cell_renderer_expander_new (); - gtk_tree_view_column_pack_end (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func ( - col, cell, - (GtkTreeCellDataFunc) contact_list_view_expander_cell_data_func, - view, NULL); - - /* Actually add the column now we have added all cell renderers */ - gtk_tree_view_append_column (GTK_TREE_VIEW (view), col); - - /* Drag & Drop. */ - for (i = 0; i < G_N_ELEMENTS (drag_types_dest); ++i) { - drag_atoms_dest[i] = gdk_atom_intern (drag_types_dest[i].target, - FALSE); - } - - for (i = 0; i < G_N_ELEMENTS (drag_types_source); ++i) { - drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target, - FALSE); - } -} - -static void -contact_list_view_set_list_features (EmpathyContactListView *view, - EmpathyContactListFeatureFlags features) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - gboolean has_tooltip; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); - - priv->list_features = features; - - /* Update DnD source/dest */ - if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) { - gtk_drag_source_set (GTK_WIDGET (view), - GDK_BUTTON1_MASK, - drag_types_source, - G_N_ELEMENTS (drag_types_source), - GDK_ACTION_MOVE | GDK_ACTION_COPY); - } else { - gtk_drag_source_unset (GTK_WIDGET (view)); - - } - - if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) { - gtk_drag_dest_set (GTK_WIDGET (view), - GTK_DEST_DEFAULT_ALL, - drag_types_dest, - G_N_ELEMENTS (drag_types_dest), - GDK_ACTION_MOVE | GDK_ACTION_COPY); - } else { - /* FIXME: URI could still be droped depending on FT feature */ - gtk_drag_dest_unset (GTK_WIDGET (view)); - } - - /* Update has-tooltip */ - has_tooltip = (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP) != 0; - gtk_widget_set_has_tooltip (GTK_WIDGET (view), has_tooltip); -} - -static void -contact_list_view_finalize (GObject *object) -{ - EmpathyContactListViewPriv *priv; - - priv = GET_PRIV (object); - - if (priv->store) { - g_object_unref (priv->store); - } - if (priv->tooltip_widget) { - gtk_widget_destroy (priv->tooltip_widget); - } - - G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object); -} - -static void -contact_list_view_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyContactListViewPriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_STORE: - g_value_set_object (value, priv->store); - break; - case PROP_LIST_FEATURES: - g_value_set_flags (value, priv->list_features); - break; - case PROP_CONTACT_FEATURES: - g_value_set_flags (value, priv->contact_features); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -contact_list_view_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyContactListView *view = EMPATHY_CONTACT_LIST_VIEW (object); - EmpathyContactListViewPriv *priv = GET_PRIV (object); - - switch (param_id) { - case PROP_STORE: - priv->store = g_value_dup_object (value); - contact_list_view_setup (view); - break; - case PROP_LIST_FEATURES: - contact_list_view_set_list_features (view, g_value_get_flags (value)); - break; - case PROP_CONTACT_FEATURES: - priv->contact_features = g_value_get_flags (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GtkTreeViewClass *tree_view_class = GTK_TREE_VIEW_CLASS (klass); - - object_class->finalize = contact_list_view_finalize; - object_class->get_property = contact_list_view_get_property; - object_class->set_property = contact_list_view_set_property; - - widget_class->drag_data_received = contact_list_view_drag_data_received; - widget_class->drag_drop = contact_list_view_drag_drop; - widget_class->drag_begin = contact_list_view_drag_begin; - widget_class->drag_data_get = contact_list_view_drag_data_get; - widget_class->drag_end = contact_list_view_drag_end; - widget_class->drag_motion = contact_list_view_drag_motion; - - /* We use the class method to let user of this widget to connect to - * the signal and stop emission of the signal so the default handler - * won't be called. */ - tree_view_class->row_activated = contact_list_view_row_activated; - - signals[DRAG_CONTACT_RECEIVED] = - g_signal_new ("drag-contact-received", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _empathy_gtk_marshal_VOID__OBJECT_STRING_STRING, - G_TYPE_NONE, - 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING); - - g_object_class_install_property (object_class, - PROP_STORE, - g_param_spec_object ("store", - "The store of the view", - "The store of the view", - EMPATHY_TYPE_CONTACT_LIST_STORE, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LIST_FEATURES, - g_param_spec_flags ("list-features", - "Features of the view", - "Falgs for all enabled features", - EMPATHY_TYPE_CONTACT_LIST_FEATURE_FLAGS, - EMPATHY_CONTACT_LIST_FEATURE_NONE, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_CONTACT_FEATURES, - g_param_spec_flags ("contact-features", - "Features of the contact menu", - "Falgs for all enabled features for the menu", - EMPATHY_TYPE_CONTACT_FEATURE_FLAGS, - EMPATHY_CONTACT_FEATURE_NONE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv)); -} - -static void -empathy_contact_list_view_init (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (view, - EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewPriv); - - view->priv = priv; - /* Get saved group states. */ - empathy_contact_groups_get_all (); - - gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (view), - empathy_contact_list_store_row_separator_func, - NULL, NULL); - - /* Connect to tree view signals rather than override. */ - g_signal_connect (view, "button-press-event", - G_CALLBACK (contact_list_view_button_press_event_cb), - NULL); - g_signal_connect (view, "key-press-event", - G_CALLBACK (contact_list_view_key_press_event_cb), - NULL); - g_signal_connect (view, "row-expanded", - G_CALLBACK (contact_list_view_row_expand_or_collapse_cb), - GINT_TO_POINTER (TRUE)); - g_signal_connect (view, "row-collapsed", - G_CALLBACK (contact_list_view_row_expand_or_collapse_cb), - GINT_TO_POINTER (FALSE)); - g_signal_connect (view, "query-tooltip", - G_CALLBACK (contact_list_view_query_tooltip_cb), - NULL); -} - -EmpathyContactListView * -empathy_contact_list_view_new (EmpathyContactListStore *store, - EmpathyContactListFeatureFlags list_features, - EmpathyContactFeatureFlags contact_features) -{ - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL); - - return g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, - "store", store, - "contact-features", contact_features, - "list-features", list_features, - NULL); -} - -EmpathyContact * -empathy_contact_list_view_get_selected (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreeModel *model; - EmpathyContact *contact; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - - priv = GET_PRIV (view); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return NULL; - } - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, - -1); - - return contact; -} - -gchar * -empathy_contact_list_view_get_selected_group (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreeModel *model; - gboolean is_group; - gchar *name; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - - priv = GET_PRIV (view); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return NULL; - } - - gtk_tree_model_get (model, &iter, - EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name, - -1); - - if (!is_group) { - g_free (name); - return NULL; - } - - return name; -} - -static gboolean -contact_list_view_remove_dialog_show (GtkWindow *parent, - const gchar *message, - const gchar *secondary_text) -{ - GtkWidget *dialog; - gboolean res; - - dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, - "%s", message); - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_NO, - GTK_STOCK_DELETE, GTK_RESPONSE_YES, - NULL); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", secondary_text); - - gtk_widget_show (dialog); - - res = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - return (res == GTK_RESPONSE_YES); -} - -static void -contact_list_view_group_remove_activate_cb (GtkMenuItem *menuitem, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - gchar *group; - - group = empathy_contact_list_view_get_selected_group (view); - if (group) { - gchar *text; - GtkWindow *parent; - - text = g_strdup_printf (_("Do you really want to remove the group '%s'?"), group); - parent = empathy_get_toplevel_window (GTK_WIDGET (view)); - if (contact_list_view_remove_dialog_show (parent, _("Removing group"), text)) { - EmpathyContactList *list; - - list = empathy_contact_list_store_get_list_iface (priv->store); - empathy_contact_list_remove_group (list, group); - } - - g_free (text); - } - - g_free (group); -} - -GtkWidget * -empathy_contact_list_view_get_group_menu (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - gchar *group; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - - if (!(priv->list_features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME | - EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) { - return NULL; - } - - group = empathy_contact_list_view_get_selected_group (view); - if (!group) { - return NULL; - } - - menu = gtk_menu_new (); - - /* FIXME: Not implemented yet - if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME) { - item = gtk_menu_item_new_with_mnemonic (_("Re_name")); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - g_signal_connect (item, "activate", - G_CALLBACK (contact_list_view_group_rename_activate_cb), - view); - }*/ - - if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE) { - item = gtk_image_menu_item_new_with_mnemonic (_("_Remove")); - image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - g_signal_connect (item, "activate", - G_CALLBACK (contact_list_view_group_remove_activate_cb), - view); - } - - g_free (group); - - return menu; -} - -static void -contact_list_view_remove_activate_cb (GtkMenuItem *menuitem, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - EmpathyContact *contact; - - contact = empathy_contact_list_view_get_selected (view); - - if (contact) { - gchar *text; - GtkWindow *parent; - - parent = empathy_get_toplevel_window (GTK_WIDGET (view)); - text = g_strdup_printf (_("Do you really want to remove the contact '%s'?"), - empathy_contact_get_name (contact)); - if (contact_list_view_remove_dialog_show (parent, _("Removing contact"), text)) { - EmpathyContactList *list; - - list = empathy_contact_list_store_get_list_iface (priv->store); - empathy_contact_list_remove (list, contact, - _("Sorry, I don't want you in my contact list anymore.")); - } - - g_free (text); - g_object_unref (contact); - } -} - -GtkWidget * -empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv = GET_PRIV (view); - EmpathyContact *contact; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - - contact = empathy_contact_list_view_get_selected (view); - if (!contact) { - return NULL; - } - - menu = empathy_contact_menu_new (contact, priv->contact_features); - - if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) { - g_object_unref (contact); - return menu; - } - - if (menu) { - /* Separator */ - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - } else { - menu = gtk_menu_new (); - } - - /* Remove contact */ - if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) { - item = gtk_image_menu_item_new_with_mnemonic (_("_Remove")); - image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - g_signal_connect (item, "activate", - G_CALLBACK (contact_list_view_remove_activate_cb), - view); - } - - g_object_unref (contact); - - return menu; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-list-view.h b/gnome-2-26/libempathy-gtk/empathy-contact-list-view.h deleted file mode 100644 index 82990d64f..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-list-view.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-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> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CONTACT_LIST_VIEW_H__ -#define __EMPATHY_CONTACT_LIST_VIEW_H__ - -#include <gtk/gtktreeview.h> - -#include <libempathy/empathy-contact.h> - -#include "empathy-contact-list-store.h" -#include "empathy-contact-menu.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CONTACT_LIST_VIEW (empathy_contact_list_view_get_type ()) -#define EMPATHY_CONTACT_LIST_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListView)) -#define EMPATHY_CONTACT_LIST_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewClass)) -#define EMPATHY_IS_CONTACT_LIST_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST_VIEW)) -#define EMPATHY_IS_CONTACT_LIST_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONTACT_LIST_VIEW)) -#define EMPATHY_CONTACT_LIST_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewClass)) - -typedef struct _EmpathyContactListView EmpathyContactListView; -typedef struct _EmpathyContactListViewClass EmpathyContactListViewClass; - -typedef enum { - EMPATHY_CONTACT_LIST_FEATURE_NONE = 0, - EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE = 1 << 0, - EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME = 1 << 1, - EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE = 1 << 2, - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE = 1 << 3, - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP = 1 << 4, - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG = 1 << 5, - EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP = 1 << 6, - EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 7) - 1, -} EmpathyContactListFeatureFlags; - -struct _EmpathyContactListView { - GtkTreeView parent; - gpointer priv; -}; - -struct _EmpathyContactListViewClass { - GtkTreeViewClass parent_class; -}; - -GType empathy_contact_list_view_get_type (void) G_GNUC_CONST; -EmpathyContactListView * empathy_contact_list_view_new (EmpathyContactListStore *store, - EmpathyContactListFeatureFlags list_features, - EmpathyContactFeatureFlags contact_features); -EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); -gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); -GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view); -GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_LIST_VIEW_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-menu.c b/gnome-2-26/libempathy-gtk/empathy-contact-menu.c deleted file mode 100644 index f311b1290..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-menu.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> - -#include <libempathy/empathy-call-factory.h> -#include <libempathy/empathy-log-manager.h> -#include <libempathy/empathy-dispatcher.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-chatroom-manager.h> - -#include "empathy-contact-menu.h" -#include "empathy-images.h" -#include "empathy-log-window.h" -#include "empathy-contact-dialogs.h" -#include "empathy-ui-utils.h" - -GtkWidget * -empathy_contact_menu_new (EmpathyContact *contact, - EmpathyContactFeatureFlags features) -{ - GtkWidget *menu; - GtkMenuShell *shell; - GtkWidget *item; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - if (features == EMPATHY_CONTACT_FEATURE_NONE) { - return NULL; - } - - menu = gtk_menu_new (); - shell = GTK_MENU_SHELL (menu); - - /* Chat */ - if (features & EMPATHY_CONTACT_FEATURE_CHAT) { - item = empathy_contact_chat_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - /* Call */ - if (features & EMPATHY_CONTACT_FEATURE_CALL) { - item = empathy_contact_call_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - /* Log */ - if (features & EMPATHY_CONTACT_FEATURE_LOG) { - item = empathy_contact_log_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - /* Invite */ - item = empathy_contact_invite_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - - /* File transfer */ - item = empathy_contact_file_transfer_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - - /* Separator */ - if (features & (EMPATHY_CONTACT_FEATURE_EDIT | - EMPATHY_CONTACT_FEATURE_INFO)) { - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - /* Edit */ - if (features & EMPATHY_CONTACT_FEATURE_EDIT) { - item = empathy_contact_edit_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - /* Info */ - if (features & EMPATHY_CONTACT_FEATURE_INFO) { - item = empathy_contact_info_menu_item_new (contact); - gtk_menu_shell_append (shell, item); - gtk_widget_show (item); - } - - return menu; -} - -static void -empathy_contact_chat_menu_item_activated (GtkMenuItem *item, - EmpathyContact *contact) -{ - empathy_dispatcher_chat_with_contact (contact, NULL, NULL); -} - - -GtkWidget * -empathy_contact_chat_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("_Chat")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (image); - - g_signal_connect (item, "activate", - G_CALLBACK (empathy_contact_chat_menu_item_activated), - contact); - - return item; -} - -static void -empathy_contact_call_menu_item_activated (GtkMenuItem *item, - EmpathyContact *contact) -{ - EmpathyCallFactory *factory; - - factory = empathy_call_factory_get (); - empathy_call_factory_new_call (factory, contact); -} - -GtkWidget * -empathy_contact_call_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("_Call")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_set_sensitive (item, empathy_contact_can_voip (contact)); - gtk_widget_show (image); - - g_signal_connect (item, "activate", - G_CALLBACK (empathy_contact_call_menu_item_activated), - contact); - - return item; -} - -static void -contact_log_menu_item_activate_cb (EmpathyContact *contact) -{ - empathy_log_window_show (empathy_contact_get_account (contact), - empathy_contact_get_id (contact), - FALSE, NULL); -} - -GtkWidget * -empathy_contact_log_menu_item_new (EmpathyContact *contact) -{ - EmpathyLogManager *manager; - gboolean have_log; - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - manager = empathy_log_manager_dup_singleton (); - have_log = empathy_log_manager_exists (manager, - empathy_contact_get_account (contact), - empathy_contact_get_id (contact), - FALSE); - g_object_unref (manager); - - item = gtk_image_menu_item_new_with_mnemonic (_("_View Previous Conversations")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_set_sensitive (item, have_log); - gtk_widget_show (image); - - g_signal_connect_swapped (item, "activate", - G_CALLBACK (contact_log_menu_item_activate_cb), - contact); - - return item; -} - -GtkWidget * -empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("Send file")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_DOCUMENT_SEND, - GTK_ICON_SIZE_MENU); - gtk_widget_set_sensitive (item, empathy_contact_can_send_files (contact)); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (image); - - g_signal_connect_swapped (item, "activate", - G_CALLBACK (empathy_send_file_with_file_chooser), - contact); - - return item; -} - -static void -contact_info_menu_item_activate_cb (EmpathyContact *contact) -{ - empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE); -} - -GtkWidget * -empathy_contact_info_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (image); - - g_signal_connect_swapped (item, "activate", - G_CALLBACK (contact_info_menu_item_activate_cb), - contact); - - return item; -} - -static void -contact_edit_menu_item_activate_cb (EmpathyContact *contact) -{ - empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE); -} - -GtkWidget * -empathy_contact_edit_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("_Edit")); - image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (image); - - g_signal_connect_swapped (item, "activate", - G_CALLBACK (contact_edit_menu_item_activate_cb), - contact); - - return item; -} - -typedef struct { - EmpathyContact *contact; - EmpathyChatroom *chatroom; -} RoomSubMenuData; - -static RoomSubMenuData * -room_sub_menu_data_new (EmpathyContact *contact, - EmpathyChatroom *chatroom) -{ - RoomSubMenuData *data; - - data = g_slice_new (RoomSubMenuData); - data->contact = g_object_ref (contact); - data->chatroom = g_object_ref (chatroom); - - return data; -} - -static void -room_sub_menu_data_free (RoomSubMenuData *data) -{ - /* FIXME: seems this is never called... */ - g_object_unref (data->contact); - g_object_unref (data->chatroom); - g_slice_free (RoomSubMenuData, data); -} - -static void -room_sub_menu_activate_cb (GtkWidget *item, - RoomSubMenuData *data) -{ - TpHandle handle; - GArray handles = {(gchar *) &handle, 1}; - EmpathyTpChat *chat; - TpChannel *channel; - - chat = empathy_chatroom_get_tp_chat (data->chatroom); - if (chat == NULL) { - /* channel was invalidated. Ignoring */ - return; - } - - /* send invitation */ - handle = empathy_contact_get_handle (data->contact); - channel = empathy_tp_chat_get_channel (chat); - tp_cli_channel_interface_group_call_add_members (channel, -1, &handles, - _("Inviting to this room"), NULL, NULL, NULL, NULL); -} - -static GtkWidget * -create_room_sub_menu (EmpathyContact *contact, - EmpathyChatroom *chatroom) -{ - GtkWidget *item; - RoomSubMenuData *data; - - item = gtk_menu_item_new_with_label (empathy_chatroom_get_name (chatroom)); - data = room_sub_menu_data_new (contact, chatroom); - g_signal_connect_data (item, "activate", - G_CALLBACK (room_sub_menu_activate_cb), data, - (GClosureNotify) room_sub_menu_data_free, 0); - - return item; -} - -GtkWidget * -empathy_contact_invite_menu_item_new (EmpathyContact *contact) -{ - GtkWidget *item; - GtkWidget *image; - GtkWidget *room_item; - EmpathyChatroomManager *mgr; - GList *rooms, *l; - GtkWidget *submenu; - GtkMenuShell *submenu_shell; - gboolean have_rooms = FALSE; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - item = gtk_image_menu_item_new_with_mnemonic (_("_Invite to chatroom")); - image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_GROUP_MESSAGE, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - - mgr = empathy_chatroom_manager_dup_singleton (NULL); - rooms = empathy_chatroom_manager_get_chatrooms (mgr, - empathy_contact_get_account (contact)); - - /* create rooms sub menu */ - submenu = gtk_menu_new (); - submenu_shell = GTK_MENU_SHELL (submenu); - - for (l = rooms; l != NULL; l = g_list_next (l)) { - EmpathyChatroom *chatroom = l->data; - - if (empathy_chatroom_get_tp_chat (chatroom) != NULL) { - have_rooms = TRUE; - - room_item = create_room_sub_menu (contact, chatroom); - gtk_menu_shell_append (submenu_shell, room_item); - gtk_widget_show (room_item); - } - } - - if (have_rooms) { - gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); - } else { - gtk_widget_set_sensitive (item, FALSE); - gtk_widget_destroy (submenu); - } - - gtk_widget_show (image); - - g_object_unref (mgr); - g_list_free (rooms); - - return item; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-menu.h b/gnome-2-26/libempathy-gtk/empathy-contact-menu.h deleted file mode 100644 index fddc40c49..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-menu.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CONTACT_MENU_H__ -#define __EMPATHY_CONTACT_MENU_H__ - -#include <gtk/gtkmenu.h> - -#include <libempathy/empathy-contact.h> - -G_BEGIN_DECLS - -typedef enum { - EMPATHY_CONTACT_FEATURE_NONE = 0, - EMPATHY_CONTACT_FEATURE_CHAT = 1 << 0, - EMPATHY_CONTACT_FEATURE_CALL = 1 << 1, - EMPATHY_CONTACT_FEATURE_LOG = 1 << 2, - EMPATHY_CONTACT_FEATURE_EDIT = 1 << 3, - EMPATHY_CONTACT_FEATURE_INFO = 1 << 4, - EMPATHY_CONTACT_FEATURE_ALL = (1 << 5) - 1, -} EmpathyContactFeatureFlags; - -GtkWidget * empathy_contact_menu_new (EmpathyContact *contact, - EmpathyContactFeatureFlags features); -GtkWidget * empathy_contact_chat_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_call_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_log_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_info_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_edit_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_invite_menu_item_new (EmpathyContact *contact); -GtkWidget * empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_MENU_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-selector.c b/gnome-2-26/libempathy-gtk/empathy-contact-selector.c deleted file mode 100644 index 8607fa0af..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-selector.c +++ /dev/null @@ -1,344 +0,0 @@ -/* -* Copyright (C) 2007 Marco Barisione <marco@barisione.org> -* Copyright (C) 2008 Collabora Ltd. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -* -* Authors: Marco Barisione <marco@barisione.org> -* Elliot Fairweather <elliot.fairweather@collabora.co.uk> -*/ - -#include "config.h" - -#include <glib/gi18n.h> -#include <gtk/gtk.h> - -#include <libempathy/empathy-contact.h> -#include <libempathy-gtk/empathy-contact-list-store.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-contact-selector.h" - -G_DEFINE_TYPE (EmpathyContactSelector, empathy_contact_selector, - GTK_TYPE_COMBO_BOX) - -enum -{ - PROP_0, - PROP_CONTACT_LIST -}; - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContactSelector) -typedef struct -{ - EmpathyContactList *contact_list; - EmpathyContactListStore *store; - gboolean dispose_run; -} EmpathyContactSelectorPriv; - -static void contact_selector_manage_blank_contact ( - EmpathyContactSelector *selector); - -static guint -contact_selector_get_number_online_contacts (GtkTreeStore *store) -{ - GtkTreeIter tmp_iter; - gboolean is_online; - guint number_online_contacts = 0; - gboolean ok; - - for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter); - ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)) - { - gtk_tree_model_get (GTK_TREE_MODEL (store), - &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, - &is_online, -1); - if (is_online) - number_online_contacts++; - } - - return number_online_contacts; -} - -static gboolean -contact_selector_get_iter_for_blank_contact (GtkTreeStore *store, - GtkTreeIter *blank_iter) -{ - GtkTreeIter tmp_iter; - EmpathyContact *tmp_contact; - gboolean is_present = FALSE; - gboolean ok; - - for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &tmp_iter); - ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &tmp_iter)) - { - gtk_tree_model_get (GTK_TREE_MODEL (store), - &tmp_iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, - &tmp_contact, -1); - if (tmp_contact == NULL) - { - *blank_iter = tmp_iter; - is_present = TRUE; - break; - } - g_object_unref (tmp_contact); - } - - return is_present; -} - -static void -contact_selector_add_blank_contact (EmpathyContactSelector *selector) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (selector); - GtkTreeIter blank_iter; - - gtk_tree_store_insert_with_values ( - GTK_TREE_STORE (priv->store),&blank_iter, NULL, 0, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, NULL, - EMPATHY_CONTACT_LIST_STORE_COL_NAME, (_("Select a contact")), - EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, FALSE, -1); - g_signal_handlers_block_by_func (selector, - contact_selector_manage_blank_contact, selector); - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &blank_iter); - g_signal_handlers_unblock_by_func (selector, - contact_selector_manage_blank_contact, selector); -} - -static void -contact_selector_remove_blank_contact (EmpathyContactSelector *selector) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (selector); - GtkTreeIter blank_iter; - - if (contact_selector_get_iter_for_blank_contact ( - GTK_TREE_STORE (priv->store), &blank_iter)) - gtk_tree_store_remove (GTK_TREE_STORE (priv->store), &blank_iter); -} - -static void -contact_selector_manage_sensitivity (EmpathyContactSelector *selector) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (selector); - guint number_online_contacts; - - number_online_contacts = contact_selector_get_number_online_contacts ( - GTK_TREE_STORE (priv->store)); - - if (number_online_contacts != 0) - gtk_widget_set_sensitive (GTK_WIDGET (selector), TRUE); - else - gtk_widget_set_sensitive (GTK_WIDGET (selector), FALSE); -} - -static void -contact_selector_manage_blank_contact (EmpathyContactSelector *selector) -{ - gboolean is_popup_shown; - - g_object_get (selector, "popup-shown", &is_popup_shown, NULL); - - if (is_popup_shown) - { - contact_selector_remove_blank_contact (selector); - } - else - { - if (gtk_combo_box_get_active (GTK_COMBO_BOX (selector)) == -1) - { - contact_selector_add_blank_contact (selector); - } - else - { - contact_selector_remove_blank_contact (selector); - } - } - - contact_selector_manage_sensitivity (selector); -} - -static GObject * -contact_selector_constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - GObject *object; - EmpathyContactSelector *contact_selector; - EmpathyContactSelectorPriv *priv; - GtkCellLayout *cell_layout; - GtkCellRenderer *renderer; - - object = G_OBJECT_CLASS (empathy_contact_selector_parent_class)->constructor - (type, n_construct_params, construct_params); - priv = GET_PRIV (object); - contact_selector = EMPATHY_CONTACT_SELECTOR (object); - cell_layout = GTK_CELL_LAYOUT (object); - - priv->store = empathy_contact_list_store_new (priv->contact_list); - - g_object_set (priv->store, "is-compact", TRUE, "show-avatars", FALSE, - "show-offline", FALSE, "show-groups", FALSE, - "sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME, NULL); - - g_signal_connect_swapped (priv->store, "row-changed", - G_CALLBACK (contact_selector_manage_sensitivity), - contact_selector); - g_signal_connect_swapped (contact_selector, "changed", - G_CALLBACK (contact_selector_manage_blank_contact), - contact_selector); - g_signal_connect_swapped (contact_selector, "notify::popup-shown", - G_CALLBACK (contact_selector_manage_blank_contact), - contact_selector); - - gtk_combo_box_set_model (GTK_COMBO_BOX (contact_selector), - GTK_TREE_MODEL (priv->store)); - gtk_widget_set_sensitive (GTK_WIDGET (contact_selector), FALSE); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); - gtk_cell_layout_set_attributes (cell_layout, renderer, - "icon-name", EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); - gtk_cell_layout_set_attributes (cell_layout, renderer, - "text", EMPATHY_CONTACT_LIST_STORE_COL_NAME, NULL); - - contact_selector_manage_blank_contact (contact_selector); - contact_selector_manage_sensitivity (contact_selector); - - return object; -} - -static void -empathy_contact_selector_init (EmpathyContactSelector *empathy_contact_selector) -{ - EmpathyContactSelectorPriv *priv = - G_TYPE_INSTANCE_GET_PRIVATE (empathy_contact_selector, - EMPATHY_TYPE_CONTACT_SELECTOR, EmpathyContactSelectorPriv); - - empathy_contact_selector->priv = priv; - - priv->dispose_run = FALSE; -} - -static void -contact_selector_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (object); - - switch (prop_id) - { - case PROP_CONTACT_LIST: - priv->contact_list = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -contact_selector_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (object); - - switch (prop_id) - { - case PROP_CONTACT_LIST: - g_value_set_object (value, priv->contact_list); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -contact_selector_dispose (GObject *object) -{ - EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (object); - EmpathyContactSelectorPriv *priv = GET_PRIV (selector); - - if (priv->dispose_run) - return; - - priv->dispose_run = TRUE; - - if (priv->contact_list) - { - g_object_unref (priv->contact_list); - priv->contact_list = NULL; - } - - if (priv->store) - { - g_object_unref (priv->store); - priv->store = NULL; - } - - (G_OBJECT_CLASS (empathy_contact_selector_parent_class)->dispose) (object); -} - -static void -empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->constructor = contact_selector_constructor; - object_class->dispose = contact_selector_dispose; - object_class->set_property = contact_selector_set_property; - object_class->get_property = contact_selector_get_property; - g_type_class_add_private (klass, sizeof (EmpathyContactSelectorPriv)); - - g_object_class_install_property (object_class, PROP_CONTACT_LIST, - g_param_spec_object ("contact-list", "contact list", "contact list", - EMPATHY_TYPE_CONTACT_LIST, G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); -} - -/* public methods */ - -GtkWidget * -empathy_contact_selector_new (EmpathyContactList *contact_list) -{ - g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (contact_list), NULL); - - return GTK_WIDGET (g_object_new (EMPATHY_TYPE_CONTACT_SELECTOR, - "contact-list", contact_list, NULL)); -} - -EmpathyContact * -empathy_contact_selector_dup_selected (EmpathyContactSelector *selector) -{ - EmpathyContactSelectorPriv *priv = GET_PRIV (selector); - EmpathyContact *contact = NULL; - GtkTreeIter iter; - - g_return_val_if_fail (EMPATHY_IS_CONTACT_SELECTOR (selector), NULL); - - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (selector), &iter)) - return NULL; - - gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, - EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, -1); - - return contact; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-selector.h b/gnome-2-26/libempathy-gtk/empathy-contact-selector.h deleted file mode 100644 index 19ca8cef8..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-selector.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright (C) 2007 Marco Barisione <marco@barisione.org> -* Copyright (C) 2008 Collabora Ltd. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -* -* Authors: Marco Barisione <marco@barisione.org> -* Elliot Fairweather <elliot.fairweather@collabora.co.uk> -*/ - -#ifndef __EMPATHY_CONTACT_SELECTOR_H__ -#define __EMPATHY_CONTACT_SELECTOR_H__ - -G_BEGIN_DECLS - -#include <glib-object.h> -#include <gtk/gtk.h> - -#include <libempathy/empathy-contact.h> -#include <libempathy-gtk/empathy-contact-list-store.h> - -#define EMPATHY_TYPE_CONTACT_SELECTOR (empathy_contact_selector_get_type ()) -#define EMPATHY_CONTACT_SELECTOR(object) (G_TYPE_CHECK_INSTANCE_CAST \ - ((object), EMPATHY_TYPE_CONTACT_SELECTOR, EmpathyContactSelector)) -#define EMPATHY_CONTACT_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \ - EMPATHY_TYPE_CONTACT_SELECTOR, EmpathyContactSelectorClass)) -#define EMPATHY_IS_CONTACT_SELECTOR(object) (G_TYPE_CHECK_INSTANCE_TYPE \ - ((object), EMPATHY_TYPE_CONTACT_SELECTOR)) -#define EMPATHY_IS_CONTACT_SELECTOR_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_CONTACT_SELECTOR)) -#define EMPATHY_CONTACT_SELECTOR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS \ - ((object), EMPATHY_TYPE_CONTACT_SELECTOR, EmpathyContactSelectorClass)) - -typedef struct _EmpathyContactSelector EmpathyContactSelector; -typedef struct _EmpathyContactSelectorClass EmpathyContactSelectorClass; - -struct _EmpathyContactSelector -{ - GtkComboBox parent; - gpointer priv; -}; - -struct _EmpathyContactSelectorClass -{ - GtkComboBoxClass parent_class; -}; - -GType empathy_contact_selector_get_type (void) G_GNUC_CONST; - -GtkWidget * empathy_contact_selector_new (EmpathyContactList *contact_list); - -EmpathyContact * empathy_contact_selector_dup_selected (EmpathyContactSelector *selector); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_SELECTOR_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-widget.c b/gnome-2-26/libempathy-gtk/empathy-contact-widget.c deleted file mode 100644 index 07058e4bc..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-widget.c +++ /dev/null @@ -1,1153 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> -#include <stdlib.h> - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <glib/gi18n-lib.h> - -#include <libmissioncontrol/mc-account.h> -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-contact-factory.h> -#include <libempathy/empathy-contact-manager.h> -#include <libempathy/empathy-contact-list.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-contact-widget.h" -#include "empathy-account-chooser.h" -#include "empathy-avatar-chooser.h" -#include "empathy-avatar-image.h" -#include "empathy-ui-utils.h" - -/* Delay before updating the widget when the id entry changed (seconds) */ -#define ID_CHANGED_TIMEOUT 1 - -typedef struct -{ - EmpathyContactFactory *factory; - EmpathyContactManager *manager; - EmpathyContact *contact; - EmpathyContactWidgetFlags flags; - GtkCellRenderer *renderer; - guint widget_id_timeout; - - GtkWidget *vbox_contact_widget; - - /* Contact */ - GtkWidget *vbox_contact; - GtkWidget *widget_avatar; - GtkWidget *widget_account; - GtkWidget *widget_id; - GtkWidget *widget_alias; - GtkWidget *label_alias; - GtkWidget *entry_alias; - GtkWidget *hbox_presence; - GtkWidget *image_state; - GtkWidget *label_status; - GtkWidget *table_contact; - GtkWidget *vbox_avatar; - - /* Groups */ - GtkWidget *vbox_groups; - GtkWidget *entry_group; - GtkWidget *button_group; - GtkWidget *treeview_groups; - - /* Details */ - GtkWidget *vbox_details; - GtkWidget *table_details; - GtkWidget *hbox_details_requested; - - /* Client */ - GtkWidget *vbox_client; - GtkWidget *table_client; - GtkWidget *hbox_client_requested; -} EmpathyContactWidget; - -typedef struct -{ - EmpathyContactWidget *information; - const gchar *name; - gboolean found; - GtkTreeIter found_iter; -} FindName; - -static void contact_widget_destroy_cb (GtkWidget *widget, - EmpathyContactWidget *information); -static void contact_widget_remove_contact (EmpathyContactWidget *information); -static void contact_widget_set_contact (EmpathyContactWidget *information, - EmpathyContact *contact); -static void contact_widget_contact_setup (EmpathyContactWidget *information); -static void contact_widget_contact_update (EmpathyContactWidget *information); -static void contact_widget_change_contact (EmpathyContactWidget *information); -static void contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, - EmpathyContactWidget *information); -static void contact_widget_account_changed_cb (GtkComboBox *widget, - EmpathyContactWidget *information); -static gboolean contact_widget_id_focus_out_cb (GtkWidget *widget, - GdkEventFocus *event, EmpathyContactWidget *information); -static gboolean contact_widget_entry_alias_focus_event_cb ( - GtkEditable *editable, GdkEventFocus *event, - EmpathyContactWidget *information); -static void contact_widget_name_notify_cb (EmpathyContactWidget *information); -static void contact_widget_presence_notify_cb ( - EmpathyContactWidget *information); -static void contact_widget_avatar_notify_cb ( - EmpathyContactWidget *information); -static void contact_widget_groups_setup ( - EmpathyContactWidget *information); -static void contact_widget_groups_update (EmpathyContactWidget *information); -static void contact_widget_model_setup (EmpathyContactWidget *information); -static void contact_widget_model_populate_columns ( - EmpathyContactWidget *information); -static void contact_widget_groups_populate_data ( - EmpathyContactWidget *information); -static void contact_widget_groups_notify_cb ( - EmpathyContactWidget *information); -static gboolean contact_widget_model_find_name ( - EmpathyContactWidget *information,const gchar *name, GtkTreeIter *iter); -static gboolean contact_widget_model_find_name_foreach (GtkTreeModel *model, - GtkTreePath *path, GtkTreeIter *iter, FindName *data); -static void contact_widget_cell_toggled (GtkCellRendererToggle *cell, - gchar *path_string, EmpathyContactWidget *information); -static void contact_widget_entry_group_changed_cb (GtkEditable *editable, - EmpathyContactWidget *information); -static void contact_widget_entry_group_activate_cb (GtkEntry *entry, - EmpathyContactWidget *information); -static void contact_widget_button_group_clicked_cb (GtkButton *button, - EmpathyContactWidget *information); -static void contact_widget_details_setup (EmpathyContactWidget *information); -static void contact_widget_details_update (EmpathyContactWidget *information); -static void contact_widget_client_setup (EmpathyContactWidget *information); -static void contact_widget_client_update (EmpathyContactWidget *information); - -enum -{ - COL_NAME, - COL_ENABLED, - COL_EDITABLE, - COL_COUNT -}; - -GtkWidget * -empathy_contact_widget_new (EmpathyContact *contact, - EmpathyContactWidgetFlags flags) -{ - EmpathyContactWidget *information; - GladeXML *glade; - gchar *filename; - - information = g_slice_new0 (EmpathyContactWidget); - information->flags = flags; - information->factory = empathy_contact_factory_dup_singleton (); - - filename = empathy_file_lookup ("empathy-contact-widget.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "vbox_contact_widget", - NULL, - "vbox_contact_widget", &information->vbox_contact_widget, - "vbox_contact", &information->vbox_contact, - "hbox_presence", &information->hbox_presence, - "label_alias", &information->label_alias, - "image_state", &information->image_state, - "label_status", &information->label_status, - "table_contact", &information->table_contact, - "vbox_avatar", &information->vbox_avatar, - "vbox_groups", &information->vbox_groups, - "entry_group", &information->entry_group, - "button_group", &information->button_group, - "treeview_groups", &information->treeview_groups, - "vbox_details", &information->vbox_details, - "table_details", &information->table_details, - "hbox_details_requested", &information->hbox_details_requested, - "vbox_client", &information->vbox_client, - "table_client", &information->table_client, - "hbox_client_requested", &information->hbox_client_requested, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - information, - "vbox_contact_widget", "destroy", contact_widget_destroy_cb, - "entry_group", "changed", contact_widget_entry_group_changed_cb, - "entry_group", "activate", contact_widget_entry_group_activate_cb, - "button_group", "clicked", contact_widget_button_group_clicked_cb, - NULL); - - g_object_unref (glade); - - g_object_set_data (G_OBJECT (information->vbox_contact_widget), - "EmpathyContactWidget", - information); - - /* Create widgets */ - contact_widget_contact_setup (information); - contact_widget_groups_setup (information); - contact_widget_details_setup (information); - contact_widget_client_setup (information); - - contact_widget_set_contact (information, contact); - - gtk_widget_show (information->vbox_contact_widget); - - return information->vbox_contact_widget; -} - -EmpathyContact * -empathy_contact_widget_get_contact (GtkWidget *widget) -{ - EmpathyContactWidget *information; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); - if (!information) - return NULL; - - return information->contact; -} - -void -empathy_contact_widget_set_contact (GtkWidget *widget, - EmpathyContact *contact) -{ - EmpathyContactWidget *information; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - - information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); - if (!information) - return; - - contact_widget_set_contact (information, contact); -} - -void -empathy_contact_widget_set_account_filter ( - GtkWidget *widget, - EmpathyAccountChooserFilterFunc filter, - gpointer user_data) -{ - EmpathyContactWidget *information; - EmpathyAccountChooser *chooser; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - - information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); - if (!information) - return; - - chooser = EMPATHY_ACCOUNT_CHOOSER (information->widget_account); - if (chooser) - empathy_account_chooser_set_filter (chooser, filter, user_data); -} - -static void -contact_widget_destroy_cb (GtkWidget *widget, - EmpathyContactWidget *information) -{ - contact_widget_remove_contact (information); - - if (information->widget_id_timeout != 0) - { - g_source_remove (information->widget_id_timeout); - } - if (information->factory) - { - g_object_unref (information->factory); - } - if (information->manager) - { - g_object_unref (information->manager); - } - - g_slice_free (EmpathyContactWidget, information); -} - -static void -contact_widget_remove_contact (EmpathyContactWidget *information) -{ - if (information->contact) - { - g_signal_handlers_disconnect_by_func (information->contact, - contact_widget_name_notify_cb, information); - g_signal_handlers_disconnect_by_func (information->contact, - contact_widget_presence_notify_cb, information); - g_signal_handlers_disconnect_by_func (information->contact, - contact_widget_avatar_notify_cb, information); - g_signal_handlers_disconnect_by_func (information->contact, - contact_widget_groups_notify_cb, information); - - g_object_unref (information->contact); - information->contact = NULL; - } -} - -static void -contact_widget_set_contact (EmpathyContactWidget *information, - EmpathyContact *contact) -{ - if (contact == information->contact) - return; - - contact_widget_remove_contact (information); - if (contact) - information->contact = g_object_ref (contact); - - /* Update information for widgets */ - contact_widget_contact_update (information); - contact_widget_groups_update (information); - contact_widget_details_update (information); - contact_widget_client_update (information); -} - -static gboolean -contact_widget_id_activate_timeout (EmpathyContactWidget *self) -{ - contact_widget_change_contact (self); - return FALSE; -} - -static void -contact_widget_id_changed_cb (GtkEntry *entry, - EmpathyContactWidget *self) -{ - if (self->widget_id_timeout != 0) - { - g_source_remove (self->widget_id_timeout); - } - - self->widget_id_timeout = - g_timeout_add_seconds (ID_CHANGED_TIMEOUT, - (GSourceFunc) contact_widget_id_activate_timeout, self); -} - -static void -save_avatar_menu_activate_cb (GtkWidget *widget, - EmpathyContactWidget *information) -{ - GtkWidget *dialog; - EmpathyAvatar *avatar; - gchar *ext = NULL, *filename; - - dialog = gtk_file_chooser_dialog_new (_("Save Avatar"), - NULL, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), - TRUE); - - /* look for the avatar extension */ - avatar = empathy_contact_get_avatar (information->contact); - if (avatar->format != NULL) - { - gchar **splitted; - - splitted = g_strsplit (avatar->format, "/", 2); - if (splitted[0] != NULL && splitted[1] != NULL) - ext = g_strdup (splitted[1]); - - g_strfreev (splitted); - } - else - { - /* Avatar was loaded from the cache so was converted to PNG */ - ext = g_strdup ("png"); - } - - if (ext != NULL) - { - gchar *id; - - id = tp_escape_as_identifier (empathy_contact_get_id ( - information->contact)); - - filename = g_strdup_printf ("%s.%s", id, ext); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename); - - g_free (id); - g_free (ext); - g_free (filename); - } - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) - { - GError *error = NULL; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - - if (!empathy_avatar_save_to_file (avatar, filename, &error)) - { - /* Save error */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (NULL, 0, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Unable to save avatar")); - - gtk_message_dialog_format_secondary_text ( - GTK_MESSAGE_DIALOG (dialog), "%s", error->message); - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - - gtk_window_present (GTK_WINDOW (dialog)); - - g_clear_error (&error); - } - - g_free (filename); - } - - gtk_widget_destroy (dialog); -} - -static void -popup_avatar_menu (EmpathyContactWidget *information, - GtkWidget *parent, - GdkEventButton *event) -{ - GtkWidget *menu, *item; - gint button, event_time; - - if (information->contact == NULL || - empathy_contact_get_avatar (information->contact) == NULL) - return; - - menu = gtk_menu_new (); - - /* Add "Save as..." entry */ - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE_AS, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - g_signal_connect (item, "activate", - G_CALLBACK (save_avatar_menu_activate_cb), information); - - if (event) - { - button = event->button; - event_time = event->time; - } - else - { - button = 0; - event_time = gtk_get_current_event_time (); - } - - gtk_menu_attach_to_widget (GTK_MENU (menu), parent, NULL); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - button, event_time); -} - -static gboolean -widget_avatar_popup_menu_cb (GtkWidget *widget, - EmpathyContactWidget *information) -{ - popup_avatar_menu (information, widget, NULL); - - return TRUE; -} - -static gboolean -widget_avatar_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - EmpathyContactWidget *information) -{ - /* Ignore double-clicks and triple-clicks */ - if (event->button == 3 && event->type == GDK_BUTTON_PRESS) - { - popup_avatar_menu (information, widget, event); - return TRUE; - } - - return FALSE; -} - -static void -update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser, - EmpathyAvatarChooser *avatar_chooser) -{ - McAccount *account; - - account = empathy_account_chooser_get_account (account_chooser); - g_object_set (avatar_chooser, "account", account, NULL); -} - -static void -contact_widget_contact_setup (EmpathyContactWidget *information) -{ - /* Setup account label/chooser */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) - { - information->widget_account = empathy_account_chooser_new (); - - g_signal_connect (information->widget_account, "changed", - G_CALLBACK (contact_widget_account_changed_cb), - information); - } - else - { - information->widget_account = gtk_label_new (NULL); - if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { - gtk_label_set_selectable (GTK_LABEL (information->widget_account), TRUE); - } - gtk_misc_set_alignment (GTK_MISC (information->widget_account), 0, 0.5); - } - gtk_table_attach_defaults (GTK_TABLE (information->table_contact), - information->widget_account, - 1, 2, 0, 1); - gtk_widget_show (information->widget_account); - - /* Set up avatar chooser/display */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) - { - information->widget_avatar = empathy_avatar_chooser_new (); - g_signal_connect (information->widget_avatar, "changed", - G_CALLBACK (contact_widget_avatar_changed_cb), - information); - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) - { - g_signal_connect (information->widget_account, "changed", - G_CALLBACK (update_avatar_chooser_account_cb), - information->widget_avatar); - update_avatar_chooser_account_cb ( - EMPATHY_ACCOUNT_CHOOSER (information->widget_account), - EMPATHY_AVATAR_CHOOSER (information->widget_avatar)); - } - } - else - { - information->widget_avatar = empathy_avatar_image_new (); - - g_signal_connect (information->widget_avatar, "popup-menu", - G_CALLBACK (widget_avatar_popup_menu_cb), information); - g_signal_connect (information->widget_avatar, "button-press-event", - G_CALLBACK (widget_avatar_button_press_event_cb), information); - } - - gtk_box_pack_start (GTK_BOX (information->vbox_avatar), - information->widget_avatar, - FALSE, FALSE, - 6); - gtk_widget_show (information->widget_avatar); - - /* Setup id label/entry */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) - { - information->widget_id = gtk_entry_new (); - g_signal_connect (information->widget_id, "focus-out-event", - G_CALLBACK (contact_widget_id_focus_out_cb), - information); - g_signal_connect (information->widget_id, "changed", - G_CALLBACK (contact_widget_id_changed_cb), - information); - } - else - { - information->widget_id = gtk_label_new (NULL); - if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { - gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE); - } - gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5); - } - gtk_table_attach_defaults (GTK_TABLE (information->table_contact), - information->widget_id, - 1, 2, 1, 2); - gtk_widget_show (information->widget_id); - - /* Setup alias label/entry */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS) - { - information->widget_alias = gtk_entry_new (); - g_signal_connect (information->widget_alias, "focus-out-event", - G_CALLBACK (contact_widget_entry_alias_focus_event_cb), - information); - /* Make return activate the window default (the Close button) */ - gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias), - TRUE); - } - else - { - information->widget_alias = gtk_label_new (NULL); - if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { - gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE); - } - gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5); - } - gtk_table_attach_defaults (GTK_TABLE (information->table_contact), - information->widget_alias, - 1, 2, 2, 3); - if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) { - gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE); - } - gtk_widget_show (information->widget_alias); -} - -static void -contact_widget_contact_update (EmpathyContactWidget *information) -{ - McAccount *account = NULL; - const gchar *id = NULL; - - /* Connect and get info from new contact */ - if (information->contact) - { - g_signal_connect_swapped (information->contact, "notify::name", - G_CALLBACK (contact_widget_name_notify_cb), information); - g_signal_connect_swapped (information->contact, "notify::presence", - G_CALLBACK (contact_widget_presence_notify_cb), information); - g_signal_connect_swapped (information->contact, - "notify::presence-message", - G_CALLBACK (contact_widget_presence_notify_cb), information); - g_signal_connect_swapped (information->contact, "notify::avatar", - G_CALLBACK (contact_widget_avatar_notify_cb), information); - - account = empathy_contact_get_account (information->contact); - id = empathy_contact_get_id (information->contact); - } - - /* Update account widget */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) - { - if (account) - { - g_signal_handlers_block_by_func (information->widget_account, - contact_widget_account_changed_cb, - information); - empathy_account_chooser_set_account ( - EMPATHY_ACCOUNT_CHOOSER (information->widget_account), account); - g_signal_handlers_unblock_by_func (information->widget_account, - contact_widget_account_changed_cb, information); - } - } - else - { - if (account) - { - const gchar *name; - - name = mc_account_get_display_name (account); - gtk_label_set_label (GTK_LABEL (information->widget_account), name); - } - } - - /* Update id widget */ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) - gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : ""); - else - gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : ""); - - /* Update other widgets */ - if (information->contact) - { - contact_widget_name_notify_cb (information); - contact_widget_presence_notify_cb (information); - contact_widget_avatar_notify_cb (information); - - gtk_widget_show (information->label_alias); - gtk_widget_show (information->widget_alias); - gtk_widget_show (information->hbox_presence); - gtk_widget_show (information->widget_avatar); - } - else - { - gtk_widget_hide (information->label_alias); - gtk_widget_hide (information->widget_alias); - gtk_widget_hide (information->hbox_presence); - gtk_widget_hide (information->widget_avatar); - } -} - -static void -contact_widget_change_contact (EmpathyContactWidget *information) -{ - EmpathyContact *contact; - McAccount *account; - - account = empathy_account_chooser_get_account ( - EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); - if (!account) - return; - - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) - { - const gchar *id; - - id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); - if (EMP_STR_EMPTY (id)) - return; - - contact = empathy_contact_factory_get_from_id (information->factory, - account, id); - } - else - { - contact = empathy_contact_factory_get_user (information->factory, - account); - } - - if (contact) - { - empathy_contact_run_until_ready (contact, - EMPATHY_CONTACT_READY_HANDLE | - EMPATHY_CONTACT_READY_ID, - NULL); - contact_widget_set_contact (information, contact); - g_object_unref (contact); - } -} - -static void -contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, - EmpathyContactWidget *information) -{ - if (information->contact && empathy_contact_is_user (information->contact)) - { - McAccount *account; - const gchar *data; - gsize size; - const gchar *mime_type; - - account = empathy_contact_get_account (information->contact); - empathy_avatar_chooser_get_image_data ( - EMPATHY_AVATAR_CHOOSER (information->widget_avatar), - &data, &size, &mime_type); - empathy_contact_factory_set_avatar (information->factory, account, - data, size, mime_type); - } -} - -static void -contact_widget_account_changed_cb (GtkComboBox *widget, - EmpathyContactWidget *information) -{ - contact_widget_change_contact (information); -} - -static gboolean -contact_widget_id_focus_out_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyContactWidget *information) -{ - contact_widget_change_contact (information); - return FALSE; -} - -static gboolean -contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, - GdkEventFocus *event, - EmpathyContactWidget *information) -{ - if (information->contact) - { - const gchar *alias; - - alias = gtk_entry_get_text (GTK_ENTRY (editable)); - empathy_contact_factory_set_alias (information->factory, - information->contact, alias); - } - - return FALSE; -} - -static void -contact_widget_name_notify_cb (EmpathyContactWidget *information) -{ - if (GTK_IS_ENTRY (information->widget_alias)) - gtk_entry_set_text (GTK_ENTRY (information->widget_alias), - empathy_contact_get_name (information->contact)); - else - gtk_label_set_label (GTK_LABEL (information->widget_alias), - empathy_contact_get_name (information->contact)); -} - -static void -contact_widget_presence_notify_cb (EmpathyContactWidget *information) -{ - gtk_label_set_text (GTK_LABEL (information->label_status), - empathy_contact_get_status (information->contact)); - gtk_image_set_from_icon_name (GTK_IMAGE (information->image_state), - empathy_icon_name_for_contact (information->contact), - GTK_ICON_SIZE_BUTTON); -} - -static void -contact_widget_avatar_notify_cb (EmpathyContactWidget *information) -{ - EmpathyAvatar *avatar = NULL; - - if (information->contact) - avatar = empathy_contact_get_avatar (information->contact); - - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) - { - g_signal_handlers_block_by_func (information->widget_avatar, - contact_widget_avatar_changed_cb, - information); - empathy_avatar_chooser_set ( - EMPATHY_AVATAR_CHOOSER (information->widget_avatar), avatar); - g_signal_handlers_unblock_by_func (information->widget_avatar, - contact_widget_avatar_changed_cb, information); - } - else - empathy_avatar_image_set ( - EMPATHY_AVATAR_IMAGE (information->widget_avatar), avatar); -} - -static void -contact_widget_groups_setup (EmpathyContactWidget *information) -{ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS) - { - information->manager = empathy_contact_manager_dup_singleton (); - contact_widget_model_setup (information); - } -} - -static void -contact_widget_groups_update (EmpathyContactWidget *information) -{ - if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS && - information->contact) - { - g_signal_connect_swapped (information->contact, "notify::groups", - G_CALLBACK (contact_widget_groups_notify_cb), information); - contact_widget_groups_populate_data (information); - - gtk_widget_show (information->vbox_groups); - } - else - gtk_widget_hide (information->vbox_groups); -} - -static void -contact_widget_model_setup (EmpathyContactWidget *information) -{ - GtkTreeView *view; - GtkListStore *store; - GtkTreeSelection *selection; - - view = GTK_TREE_VIEW (information->treeview_groups); - - store = gtk_list_store_new (COL_COUNT, - G_TYPE_STRING, /* name */ - G_TYPE_BOOLEAN, /* enabled */ - G_TYPE_BOOLEAN); /* editable */ - - gtk_tree_view_set_model (view, GTK_TREE_MODEL (store)); - - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - contact_widget_model_populate_columns (information); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COL_NAME, GTK_SORT_ASCENDING); - - g_object_unref (store); -} - -static void -contact_widget_model_populate_columns (EmpathyContactWidget *information) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - guint col_offset; - - view = GTK_TREE_VIEW (information->treeview_groups); - model = gtk_tree_view_get_model (view); - - renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (renderer, "toggled", - G_CALLBACK (contact_widget_cell_toggled), information); - - column = gtk_tree_view_column_new_with_attributes (_("Select"), renderer, - "active", COL_ENABLED, NULL); - - gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); - gtk_tree_view_column_set_fixed_width (column, 50); - gtk_tree_view_append_column (view, column); - - renderer = gtk_cell_renderer_text_new (); - col_offset = gtk_tree_view_insert_column_with_attributes (view, - -1, _("Group"), - renderer, - "text", COL_NAME, - /* "editable", COL_EDITABLE, */ - NULL); - - g_object_set_data (G_OBJECT (renderer), - "column", GINT_TO_POINTER (COL_NAME)); - - column = gtk_tree_view_get_column (view, col_offset - 1); - gtk_tree_view_column_set_sort_column_id (column, COL_NAME); - gtk_tree_view_column_set_resizable (column,FALSE); - gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); - - if (information->renderer) - g_object_unref (information->renderer); - - information->renderer = g_object_ref (renderer); -} - -static void -contact_widget_groups_populate_data (EmpathyContactWidget *information) -{ - GtkTreeView *view; - GtkListStore *store; - GtkTreeIter iter; - GList *my_groups, *l; - GList *all_groups; - - view = GTK_TREE_VIEW (information->treeview_groups); - store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); - gtk_list_store_clear (store); - - all_groups = empathy_contact_list_get_all_groups ( - EMPATHY_CONTACT_LIST (information->manager)); - my_groups = empathy_contact_list_get_groups ( - EMPATHY_CONTACT_LIST (information->manager), - information->contact); - - for (l = all_groups; l; l = l->next) - { - const gchar *group_str; - gboolean enabled; - - group_str = l->data; - - enabled = g_list_find_custom (my_groups, - group_str, (GCompareFunc) strcmp) != NULL; - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_NAME, group_str, - COL_EDITABLE, TRUE, - COL_ENABLED, enabled, - -1); - } - - g_list_foreach (all_groups, (GFunc) g_free, NULL); - g_list_foreach (my_groups, (GFunc) g_free, NULL); - g_list_free (all_groups); - g_list_free (my_groups); -} - -static void -contact_widget_groups_notify_cb (EmpathyContactWidget *information) -{ - /* FIXME: not implemented */ -} - -static gboolean -contact_widget_model_find_name (EmpathyContactWidget *information, - const gchar *name, - GtkTreeIter *iter) -{ - GtkTreeView *view; - GtkTreeModel *model; - FindName data; - - if (EMP_STR_EMPTY (name)) - return FALSE; - - data.information = information; - data.name = name; - data.found = FALSE; - - view = GTK_TREE_VIEW (information->treeview_groups); - model = gtk_tree_view_get_model (view); - - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) contact_widget_model_find_name_foreach, - &data); - - if (data.found == TRUE) - { - *iter = data.found_iter; - return TRUE; - } - - return FALSE; -} - -static gboolean -contact_widget_model_find_name_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindName *data) -{ - gchar *name; - - gtk_tree_model_get (model, iter, - COL_NAME, &name, - -1); - - if (!name) - return FALSE; - - if (data->name && strcmp (data->name, name) == 0) - { - data->found = TRUE; - data->found_iter = *iter; - - g_free (name); - - return TRUE; - } - - g_free (name); - - return FALSE; -} - -static void -contact_widget_cell_toggled (GtkCellRendererToggle *cell, - gchar *path_string, - EmpathyContactWidget *information) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkListStore *store; - GtkTreePath *path; - GtkTreeIter iter; - gboolean enabled; - gchar *group; - - view = GTK_TREE_VIEW (information->treeview_groups); - model = gtk_tree_view_get_model (view); - store = GTK_LIST_STORE (model); - - path = gtk_tree_path_new_from_string (path_string); - - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, - COL_ENABLED, &enabled, - COL_NAME, &group, - -1); - - gtk_list_store_set (store, &iter, COL_ENABLED, !enabled, -1); - gtk_tree_path_free (path); - - if (group) - { - if (enabled) - { - empathy_contact_list_remove_from_group ( - EMPATHY_CONTACT_LIST (information->manager), information->contact, - group); - } - else - { - empathy_contact_list_add_to_group ( - EMPATHY_CONTACT_LIST (information->manager), information->contact, - group); - } - g_free (group); - } -} - -static void -contact_widget_entry_group_changed_cb (GtkEditable *editable, - EmpathyContactWidget *information) -{ - GtkTreeIter iter; - const gchar *group; - - group = gtk_entry_get_text (GTK_ENTRY (information->entry_group)); - - if (contact_widget_model_find_name (information, group, &iter)) - gtk_widget_set_sensitive (GTK_WIDGET (information->button_group), FALSE); - else - gtk_widget_set_sensitive (GTK_WIDGET (information->button_group), - !EMP_STR_EMPTY (group)); -} - -static void -contact_widget_entry_group_activate_cb (GtkEntry *entry, - EmpathyContactWidget *information) -{ - gtk_widget_activate (GTK_WIDGET (information->button_group)); -} - -static void -contact_widget_button_group_clicked_cb (GtkButton *button, - EmpathyContactWidget *information) -{ - GtkTreeView *view; - GtkListStore *store; - GtkTreeIter iter; - const gchar *group; - - view = GTK_TREE_VIEW (information->treeview_groups); - store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); - - group = gtk_entry_get_text (GTK_ENTRY (information->entry_group)); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_NAME, group, - COL_ENABLED, TRUE, - -1); - - empathy_contact_list_add_to_group ( - EMPATHY_CONTACT_LIST (information->manager), information->contact, - group); -} - -static void -contact_widget_details_setup (EmpathyContactWidget *information) -{ - /* FIXME: Needs new telepathy spec */ - gtk_widget_hide (information->vbox_details); -} - -static void -contact_widget_details_update (EmpathyContactWidget *information) -{ - /* FIXME: Needs new telepathy spec */ -} - -static void -contact_widget_client_setup (EmpathyContactWidget *information) -{ - /* FIXME: Needs new telepathy spec */ - gtk_widget_hide (information->vbox_client); -} - -static void -contact_widget_client_update (EmpathyContactWidget *information) -{ - /* FIXME: Needs new telepathy spec */ -} diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-widget.glade b/gnome-2-26/libempathy-gtk/empathy-contact-widget.glade deleted file mode 100644 index 721ebe3fe..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-widget.glade +++ /dev/null @@ -1,558 +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="contact_window"> - <property name="visible">True</property> - <property name="title" translatable="yes">Contact information</property> - <child> - <widget class="GtkVBox" id="vbox_contact_widget"> - <property name="spacing">6</property> - <child> - <widget class="GtkVBox" id="vbox_contact"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label654"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Contact</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="GtkAlignment" id="alignment31"> - <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkHBox" id="hbox189"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkVBox" id="vbox225"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_contact"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <widget class="GtkLabel" id="label680"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Account:</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label655"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes" comments="Identifier to connect to Instant Messaging network">Identifier:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_alias"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Alias:</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkHBox" id="hbox_presence"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkImage" id="image_state"> - <property name="visible">True</property> - <property name="stock">gtk-missing-image</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_status"> - <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> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkVBox" id="vbox_avatar"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox_groups"> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label672"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Groups</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="GtkAlignment" id="alignment33"> - <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkVBox" id="vbox224"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label679"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Select the groups you want this contact to appear in. Note that you can select more than one group or no groups.</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox188"> - <property name="visible">True</property> - <property name="spacing">12</property> - <child> - <widget class="GtkEntry" id="entry_group"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_group"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Add Group</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow17"> - <property name="height_request">100</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> - <widget class="GtkTreeView" id="treeview_groups"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">False</property> - <property name="enable_search">False</property> - </widget> - </child> - </widget> - <packing> - <property name="position">2</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox_details"> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label649"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Contact Details</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="GtkAlignment" id="alignment30"> - <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkVBox" id="vbox218"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_details"> - <property name="n_rows">4</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <widget class="GtkLabel" id="label670"> - <property name="xalign">0</property> - <property name="label" translatable="yes">Fullname:</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label650"> - <property name="xalign">0</property> - <property name="label" translatable="yes">Email:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label651"> - <property name="xalign">0</property> - <property name="label" translatable="yes">Web site:</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label652"> - <property name="xalign">0</property> - <property name="label" translatable="yes">Birthday:</property> - </widget> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkHBox" id="hbox_details_requested"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkImage" id="image885"> - <property name="visible">True</property> - <property name="stock">gtk-dialog-info</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label653"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Information requested...</property> - <property name="use_markup">True</property> - <property name="wrap">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="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox_client"> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label662"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Client Information</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="GtkAlignment" id="alignment32"> - <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkVBox" id="vbox222"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkTable" id="table_client"> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkLabel" id="label668"> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes">OS:</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label667"> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes">Version:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label666"> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes">Client:</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_client"> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="xpad">2</property> - <property name="wrap">True</property> - <property name="selectable">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_version"> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="xpad">2</property> - <property name="wrap">True</property> - <property name="selectable">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_os"> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="xpad">2</property> - <property name="wrap">True</property> - <property name="selectable">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox_client_requested"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkImage" id="image887"> - <property name="visible">True</property> - <property name="stock">gtk-dialog-info</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label669"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Information requested...</property> - <property name="use_markup">True</property> - <property name="wrap">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="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">3</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-contact-widget.h b/gnome-2-26/libempathy-gtk/empathy-contact-widget.h deleted file mode 100644 index 4ba75e17f..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-contact-widget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CONTACT_WIDGET_H__ -#define __EMPATHY_CONTACT_WIDGET_H__ - -#include <gtk/gtk.h> - -#include <libempathy/empathy-contact.h> -#include "empathy-account-chooser.h" - -G_BEGIN_DECLS - -typedef enum -{ - EMPATHY_CONTACT_WIDGET_EDIT_NONE = 0, - EMPATHY_CONTACT_WIDGET_EDIT_ALIAS = 1 << 0, - EMPATHY_CONTACT_WIDGET_EDIT_AVATAR = 1 << 1, - EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT = 1 << 2, - EMPATHY_CONTACT_WIDGET_EDIT_ID = 1 << 3, - EMPATHY_CONTACT_WIDGET_EDIT_GROUPS = 1 << 4, - EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP = 1 << 5, -} EmpathyContactWidgetFlags; - -GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, - EmpathyContactWidgetFlags flags); -EmpathyContact *empathy_contact_widget_get_contact (GtkWidget *widget); -void empathy_contact_widget_set_contact (GtkWidget *widget, - EmpathyContact *contact); -void empathy_contact_widget_set_account_filter (GtkWidget *widget, - EmpathyAccountChooserFilterFunc filter, gpointer user_data); - -G_END_DECLS - -#endif /* __EMPATHY_CONTACT_WIDGET_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-geometry.c b/gnome-2-26/libempathy-gtk/empathy-geometry.c deleted file mode 100644 index b3bd09ca1..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-geometry.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <sys/stat.h> - -#include <glib.h> -#include <gdk/gdk.h> - -#include "empathy-geometry.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#define GEOMETRY_DIR_CREATE_MODE (S_IRUSR | S_IWUSR | S_IXUSR) -#define GEOMETRY_FILE_CREATE_MODE (S_IRUSR | S_IWUSR) - -#define GEOMETRY_KEY_FILENAME "geometry.ini" -#define GEOMETRY_FORMAT "%d,%d,%d,%d" -#define GEOMETRY_GROUP_NAME "geometry" - -static gchar *geometry_get_filename (void); - -static gchar * -geometry_get_filename (void) -{ - gchar *dir; - gchar *filename; - - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); - if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - DEBUG ("Creating directory:'%s'", dir); - g_mkdir_with_parents (dir, GEOMETRY_DIR_CREATE_MODE); - } - - filename = g_build_filename (dir, GEOMETRY_KEY_FILENAME, NULL); - g_free (dir); - - return filename; -} - -void -empathy_geometry_save (const gchar *name, - gint x, - gint y, - gint w, - gint h) -{ - GError *error = NULL; - GKeyFile *key_file; - gchar *filename; - GdkScreen *screen; - gint max_width; - gint max_height; - gchar *content; - gsize length; - gchar *str; - - DEBUG ("Saving window geometry: x:%d, y:%d, w:%d, h:%d\n", - x, y, w, h); - - screen = gdk_screen_get_default (); - max_width = gdk_screen_get_width (screen); - max_height = gdk_screen_get_height (screen); - - w = CLAMP (w, 100, max_width); - h = CLAMP (h, 100, max_height); - - x = CLAMP (x, 0, max_width - w); - y = CLAMP (y, 0, max_height - h); - - str = g_strdup_printf (GEOMETRY_FORMAT, x, y, w, h); - - key_file = g_key_file_new (); - - filename = geometry_get_filename (); - - g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL); - g_key_file_set_string (key_file, GEOMETRY_GROUP_NAME, name, str); - - g_free (str); - - content = g_key_file_to_data (key_file, &length, NULL); - if (!g_file_set_contents (filename, content, length, &error)) { - g_warning ("Couldn't save window geometry, error:%d->'%s'", - error->code, error->message); - g_error_free (error); - } - - g_free (content); - g_free (filename); - g_key_file_free (key_file); -} - -void -empathy_geometry_load (const gchar *name, - gint *x, - gint *y, - gint *w, - gint *h) -{ - GKeyFile *key_file; - gchar *filename; - gchar *str = NULL; - - if (x) { - *x = -1; - } - - if (y) { - *y = -1; - } - - if (w) { - *w = -1; - } - - if (h) { - *h = -1; - } - - key_file = g_key_file_new (); - - filename = geometry_get_filename (); - - if (g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL)) { - str = g_key_file_get_string (key_file, GEOMETRY_GROUP_NAME, name, NULL); - } - - if (str) { - gint tmp_x, tmp_y, tmp_w, tmp_h; - - sscanf (str, GEOMETRY_FORMAT, &tmp_x, &tmp_y, &tmp_w, &tmp_h); - - if (x) { - *x = tmp_x; - } - - if (y) { - *y = tmp_y; - } - - if (w) { - *w = tmp_w; - } - - if (h) { - *h = tmp_h; - } - - g_free (str); - } - - DEBUG ("Loading window geometry: x:%d, y:%d, w:%d, h:%d\n", - x ? *x : -1, y ? *y : -1, w ? *w : -1, h ? *h : -1); - - g_free (filename); - g_key_file_free (key_file); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-geometry.h b/gnome-2-26/libempathy-gtk/empathy-geometry.h deleted file mode 100644 index 1b711c2ec..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-geometry.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_GEOMETRY_H__ -#define __EMPATHY_GEOMETRY_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -void empathy_geometry_save (const gchar *name, - gint x, - gint y, - gint w, - gint h); -void empathy_geometry_load (const gchar *name, - gint *x, - gint *y, - gint *w, - gint *h); - -G_END_DECLS - -#endif /* __EMPATHY_GEOMETRY_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-images.h b/gnome-2-26/libempathy-gtk/empathy-images.h deleted file mode 100644 index 6abd2e8ad..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-images.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_IMAGES_H__ -#define __EMPATHY_IMAGES_H__ - -G_BEGIN_DECLS - -#define EMPATHY_IMAGE_OFFLINE "empathy-offline" -#define EMPATHY_IMAGE_HIDDEN "empathy-offline" -#define EMPATHY_IMAGE_AVAILABLE "empathy-available" -#define EMPATHY_IMAGE_BUSY "empathy-busy" -#define EMPATHY_IMAGE_AWAY "empathy-away" -#define EMPATHY_IMAGE_EXT_AWAY "empathy-extended-away" -#define EMPATHY_IMAGE_UNKNOWN "empathy-pending" - -#define EMPATHY_IMAGE_MESSAGE "im-message" -#define EMPATHY_IMAGE_NEW_MESSAGE "im-message-new" -#define EMPATHY_IMAGE_TYPING "user-typing" -#define EMPATHY_IMAGE_CONTACT_INFORMATION "gtk-info" -#define EMPATHY_IMAGE_GROUP_MESSAGE "system-users" -#define EMPATHY_IMAGE_VOIP "audio-input-microphone" -#define EMPATHY_IMAGE_LOG "document-open-recent" -#define EMPATHY_IMAGE_DOCUMENT_SEND "document-send" - -G_END_DECLS - -#endif /* __EMPATHY_IMAGES_ICONS_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.c b/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.c deleted file mode 100644 index b4ec2ff4c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.c +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" - -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mc-protocol.h> - -#include <libempathy/empathy-utils.h> - -#include <libempathy/empathy-irc-network-manager.h> -#include "empathy-ui-utils.h" -#include "totem-subtitle-encoding.h" - -#include "empathy-irc-network-dialog.h" - -typedef struct { - EmpathyIrcNetwork *network; - - GtkWidget *dialog; - GtkWidget *button_close; - - GtkWidget *entry_network; - GtkWidget *combobox_charset; - - GtkWidget *treeview_servers; - GtkWidget *button_add; - GtkWidget *button_remove; - GtkWidget *button_up; - GtkWidget *button_down; -} EmpathyIrcNetworkDialog; - -static void -irc_network_dialog_destroy_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - g_object_unref (dialog->network); - - g_slice_free (EmpathyIrcNetworkDialog, dialog); -} - -static void -irc_network_dialog_close_clicked_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - gtk_widget_destroy (dialog->dialog); -} - -enum { - COL_SRV_OBJ, - COL_ADR, - COL_PORT, - COL_SSL -}; - -static void -add_server_to_store (GtkListStore *store, - EmpathyIrcServer *server, - GtkTreeIter *iter) -{ - gchar *address; - guint port; - gboolean ssl; - - g_object_get (server, - "address", &address, - "port", &port, - "ssl", &ssl, - NULL); - - gtk_list_store_insert_with_values (store, iter, -1, - COL_SRV_OBJ, server, - COL_ADR, address, - COL_PORT, port, - COL_SSL, ssl, - -1); - - g_free (address); -} - -static void -irc_network_dialog_setup (EmpathyIrcNetworkDialog *dialog) -{ - gchar *name, *charset; - GSList *servers, *l; - GtkListStore *store; - - g_object_get (dialog->network, - "name", &name, - "charset", &charset, - NULL); - gtk_entry_set_text (GTK_ENTRY (dialog->entry_network), name); - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - - servers = empathy_irc_network_get_servers (dialog->network); - for (l = servers; l != NULL; l = g_slist_next (l)) - { - EmpathyIrcServer *server = l->data; - GtkTreeIter iter; - - add_server_to_store (store, server, &iter); - } - - totem_subtitle_encoding_set (GTK_COMBO_BOX (dialog->combobox_charset), - charset); - - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); - g_free (name); - g_free (charset); -} - -static void -irc_network_dialog_address_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - EmpathyIrcNetworkDialog *dialog) -{ - EmpathyIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - -1); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ADR, new_text, - -1); - - g_object_set (server, "address", new_text, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static void -irc_network_dialog_port_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - EmpathyIrcNetworkDialog *dialog) -{ - EmpathyIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - guint port; - - port = strtoul (new_text, NULL, 10); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - -1); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_PORT, port, - -1); - - g_object_set (server, "port", port, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static void -irc_network_dialog_ssl_toggled_cb (GtkCellRendererText *renderer, - gchar *path, - EmpathyIrcNetworkDialog *dialog) -{ - EmpathyIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - gboolean ssl; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - COL_SSL, &ssl, - -1); - ssl = !ssl; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_SSL, ssl, - -1); - - g_object_set (server, "ssl", ssl, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static gboolean -irc_network_dialog_network_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - EmpathyIrcNetworkDialog *dialog) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (widget)); - - g_object_set (dialog->network, "name", str, NULL); - - return FALSE; -} - -static void -irc_network_dialog_network_update_buttons (EmpathyIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gboolean can_remove = FALSE, can_move_up = FALSE, can_move_down = FALSE; - int selected; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW ( - dialog->treeview_servers)); - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - path = gtk_tree_model_get_path (model, &iter); - - selected = gtk_tree_path_get_indices (path)[0]; - - can_remove = TRUE; - can_move_up = selected > 0; - can_move_down = - selected < gtk_tree_model_iter_n_children (model, NULL) - 1; - - gtk_tree_path_free (path); - } - - gtk_widget_set_sensitive (dialog->button_remove, can_remove); - gtk_widget_set_sensitive (dialog->button_up, can_move_up); - gtk_widget_set_sensitive (dialog->button_down, can_move_down); -} - -static void -irc_network_dialog_button_add_clicked_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - EmpathyIrcServer *server; - GtkListStore *store; - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeViewColumn *column; - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - - server = empathy_irc_server_new (_("new server"), 6667, FALSE); - empathy_irc_network_append_server (dialog->network, server); - add_server_to_store (store, server, &iter); - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 0); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->treeview_servers), path, - column, TRUE); - - irc_network_dialog_network_update_buttons (dialog); - - gtk_tree_path_free (path); - g_object_unref (server); -} - -static void -irc_network_dialog_button_remove_clicked_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - EmpathyIrcServer *server; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - empathy_irc_network_remove_server (dialog->network, server); - - irc_network_dialog_network_update_buttons (dialog); - - g_object_unref (server); -} - -static void -irc_network_dialog_button_up_clicked_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter, iter_prev; - GtkTreePath *path; - gint *pos; - EmpathyIrcServer *server; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - path = gtk_tree_model_get_path (model, &iter); - - if (!gtk_tree_path_prev (path)) - { - gtk_tree_path_free (path); - return; - } - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_tree_model_get_iter (model, &iter_prev, path); - gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter); - - pos = gtk_tree_path_get_indices (path); - empathy_irc_network_set_server_position (dialog->network, server, *pos); - - irc_network_dialog_network_update_buttons (dialog); - - g_object_unref (server); - gtk_tree_path_free (path); -} - -static void -irc_network_dialog_button_down_clicked_cb (GtkWidget *widget, - EmpathyIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter, iter_prev; - GtkTreePath *path; - EmpathyIrcServer *server; - gint *pos; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - path = gtk_tree_model_get_path (model, &iter); - - gtk_tree_path_next (path); - if (!gtk_tree_model_get_iter (model, &iter_prev, path)) - { - gtk_tree_path_free (path); - return; - } - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter); - - pos = gtk_tree_path_get_indices (path); - empathy_irc_network_set_server_position (dialog->network, server, *pos); - - irc_network_dialog_network_update_buttons (dialog); - - gtk_tree_path_free (path); -} - -static void -irc_network_dialog_selection_changed_cb (GtkTreeSelection *treeselection, - EmpathyIrcNetworkDialog *dialog) -{ - irc_network_dialog_network_update_buttons (dialog); -} - -static void -irc_network_dialog_combobox_charset_changed_cb (GtkWidget *combobox, - EmpathyIrcNetworkDialog *dialog) -{ - const gchar *charset; - - charset = totem_subtitle_encoding_get_selected (GTK_COMBO_BOX (combobox)); - g_object_set (dialog->network, "charset", charset, NULL); -} - -static void -change_network (EmpathyIrcNetworkDialog *dialog, - EmpathyIrcNetwork *network) -{ - GtkListStore *store; - - if (dialog->network == network) - /* No need to change */ - return; - - if (dialog->network != NULL) - { - g_object_unref (dialog->network); - } - - dialog->network = network; - g_object_ref (network); - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - gtk_list_store_clear (store); - - irc_network_dialog_setup (dialog); -} - -/** - * empathy_irc_network_dialog_show: - * @network: the #EmpathyIrcNetwork to configure - * @parent: the parent of this dialog - * - * Display a dialog to configure a given #EmpathyIrcNetwork. - * This function is a singleton so if a configuration dialog already - * exists we use this one to edit the network. - * - * Returns: The displayed #GtkDialog - */ -GtkWidget * -empathy_irc_network_dialog_show (EmpathyIrcNetwork *network, - GtkWidget *parent) -{ - static EmpathyIrcNetworkDialog *dialog = NULL; - GladeXML *glade; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkAdjustment *adjustment; - GtkTreeSelection *selection; - GtkTreeViewColumn *column; - gchar *filename; - - g_return_val_if_fail (network != NULL, NULL); - - if (dialog != NULL) - { - change_network (dialog, network); - gtk_window_present (GTK_WINDOW (dialog->dialog)); - - return dialog->dialog; - } - - dialog = g_slice_new0 (EmpathyIrcNetworkDialog); - - dialog->network = network; - g_object_ref (dialog->network); - - filename = empathy_file_lookup ("empathy-account-widget-irc.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "irc_network_dialog", - NULL, - "irc_network_dialog", &dialog->dialog, - "button_close", &dialog->button_close, - "entry_network", &dialog->entry_network, - "combobox_charset", &dialog->combobox_charset, - "treeview_servers", &dialog->treeview_servers, - "button_add", &dialog->button_add, - "button_remove", &dialog->button_remove, - "button_up", &dialog->button_up, - "button_down", &dialog->button_down, - NULL); - g_free (filename); - - store = gtk_list_store_new (4, G_TYPE_OBJECT, G_TYPE_STRING, - G_TYPE_UINT, G_TYPE_BOOLEAN); - gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview_servers), - GTK_TREE_MODEL (store)); - g_object_unref (store); - - /* address */ - renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "editable", TRUE, NULL); - g_signal_connect (renderer, "edited", - G_CALLBACK (irc_network_dialog_address_edited_cb), dialog); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("Server"), renderer, "text", COL_ADR, - NULL); - - /* port */ - adjustment = (GtkAdjustment *) gtk_adjustment_new (6667, 1, G_MAXUINT16, - 1, 10, 0); - renderer = gtk_cell_renderer_spin_new (); - g_object_set (renderer, - "editable", TRUE, - "adjustment", adjustment, - NULL); - g_signal_connect (renderer, "edited", - G_CALLBACK (irc_network_dialog_port_edited_cb), dialog); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("Port"), renderer, "text", COL_PORT, - NULL); - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 1); - gtk_tree_view_column_set_expand (column, TRUE); - - /* SSL */ - renderer = gtk_cell_renderer_toggle_new (); - g_object_set (renderer, "activatable", TRUE, NULL); - g_signal_connect (renderer, "toggled", - G_CALLBACK (irc_network_dialog_ssl_toggled_cb), dialog); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("SSL"), renderer, "active", COL_SSL, - NULL); - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - /* charset */ - totem_subtitle_encoding_init (GTK_COMBO_BOX (dialog->combobox_charset)); - - irc_network_dialog_setup (dialog); - - empathy_glade_connect (glade, dialog, - "irc_network_dialog", "destroy", irc_network_dialog_destroy_cb, - "button_close", "clicked", irc_network_dialog_close_clicked_cb, - "entry_network", "focus-out-event", irc_network_dialog_network_focus_cb, - "button_add", "clicked", irc_network_dialog_button_add_clicked_cb, - "button_remove", "clicked", irc_network_dialog_button_remove_clicked_cb, - "button_up", "clicked", irc_network_dialog_button_up_clicked_cb, - "button_down", "clicked", irc_network_dialog_button_down_clicked_cb, - "combobox_charset", "changed", irc_network_dialog_combobox_charset_changed_cb, - NULL); - - g_object_unref (glade); - - g_object_add_weak_pointer (G_OBJECT (dialog->dialog), - (gpointer) &dialog); - - g_signal_connect (selection, "changed", - G_CALLBACK (irc_network_dialog_selection_changed_cb), - dialog); - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW (parent)); - gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); - - irc_network_dialog_network_update_buttons (dialog); - - return dialog->dialog; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.h b/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.h deleted file mode 100644 index 985849696..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-irc-network-dialog.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __EMPATHY_IRC_NETWORK_DIALOG_H__ -#define __EMPATHY_IRC_NETWORK_DIALOG_H__ - -#include <gtk/gtkwidget.h> - -#include <libempathy/empathy-irc-network.h> - -G_BEGIN_DECLS - -GtkWidget * empathy_irc_network_dialog_show (EmpathyIrcNetwork *network, - GtkWidget *parent); - -G_END_DECLS - -#endif /* __EMPATHY_IRC_NETWORK_DIALOG_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-log-window.c b/gnome-2-26/libempathy-gtk/empathy-log-window.c deleted file mode 100644 index 24633e565..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-log-window.c +++ /dev/null @@ -1,1093 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> -#include <stdlib.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <libempathy/empathy-log-manager.h> -#include <libempathy/empathy-chatroom-manager.h> -#include <libempathy/empathy-chatroom.h> -#include <libempathy/empathy-message.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-time.h> - -#include "empathy-log-window.h" -#include "empathy-account-chooser.h" -#include "empathy-chat-view.h" -#include "empathy-theme-manager.h" -#include "empathy-ui-utils.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -typedef struct { - GtkWidget *window; - - GtkWidget *notebook; - - GtkWidget *entry_find; - GtkWidget *button_find; - GtkWidget *treeview_find; - GtkWidget *scrolledwindow_find; - EmpathyChatView *chatview_find; - GtkWidget *button_previous; - GtkWidget *button_next; - - GtkWidget *vbox_chats; - GtkWidget *account_chooser_chats; - GtkWidget *entry_chats; - GtkWidget *calendar_chats; - GtkWidget *treeview_chats; - GtkWidget *scrolledwindow_chats; - EmpathyChatView *chatview_chats; - - gchar *last_find; - - EmpathyLogManager *log_manager; -} EmpathyLogWindow; - -static void log_window_destroy_cb (GtkWidget *widget, - EmpathyLogWindow *window); -static void log_window_entry_find_changed_cb (GtkWidget *entry, - EmpathyLogWindow *window); -static void log_window_find_changed_cb (GtkTreeSelection *selection, - EmpathyLogWindow *window); -static void log_window_find_populate (EmpathyLogWindow *window, - const gchar *search_criteria); -static void log_window_find_setup (EmpathyLogWindow *window); -static void log_window_button_find_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window); -static void log_window_button_next_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window); -static void log_window_button_previous_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window); -static void log_window_chats_changed_cb (GtkTreeSelection *selection, - EmpathyLogWindow *window); -static void log_window_chats_populate (EmpathyLogWindow *window); -static void log_window_chats_setup (EmpathyLogWindow *window); -static void log_window_chats_accounts_changed_cb (GtkWidget *combobox, - EmpathyLogWindow *window); -static void log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, - const gchar *chat_id, - gboolean is_chatroom); -static gboolean log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, - gchar **chat_id, - gboolean *is_chatroom); -static void log_window_chats_get_messages (EmpathyLogWindow *window, - const gchar *date_to_show); -static void log_window_calendar_chats_day_selected_cb (GtkWidget *calendar, - EmpathyLogWindow *window); -static void log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, - EmpathyLogWindow *window); -static void log_window_entry_chats_changed_cb (GtkWidget *entry, - EmpathyLogWindow *window); -static void log_window_entry_chats_activate_cb (GtkWidget *entry, - EmpathyLogWindow *window); - -enum { - COL_FIND_ACCOUNT_ICON, - COL_FIND_ACCOUNT_NAME, - COL_FIND_ACCOUNT, - COL_FIND_CHAT_NAME, - COL_FIND_CHAT_ID, - COL_FIND_IS_CHATROOM, - COL_FIND_DATE, - COL_FIND_DATE_READABLE, - COL_FIND_COUNT -}; - -enum { - COL_CHAT_ICON, - COL_CHAT_NAME, - COL_CHAT_ACCOUNT, - COL_CHAT_ID, - COL_CHAT_IS_CHATROOM, - COL_CHAT_COUNT -}; - -GtkWidget * -empathy_log_window_show (McAccount *account, - const gchar *chat_id, - gboolean is_chatroom, - GtkWindow *parent) -{ - static EmpathyLogWindow *window = NULL; - EmpathyAccountChooser *account_chooser; - GList *accounts; - gint account_num; - GladeXML *glade; - gchar *filename; - - if (window) { - gtk_window_present (GTK_WINDOW (window->window)); - - if (account && chat_id) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); - log_window_chats_set_selected (window, account, - chat_id, is_chatroom); - } - - return window->window; - } - - window = g_new0 (EmpathyLogWindow, 1); - window->log_manager = empathy_log_manager_dup_singleton (); - - filename = empathy_file_lookup ("empathy-log-window.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "log_window", - NULL, - "log_window", &window->window, - "notebook", &window->notebook, - "entry_find", &window->entry_find, - "button_find", &window->button_find, - "treeview_find", &window->treeview_find, - "scrolledwindow_find", &window->scrolledwindow_find, - "button_previous", &window->button_previous, - "button_next", &window->button_next, - "entry_chats", &window->entry_chats, - "calendar_chats", &window->calendar_chats, - "vbox_chats", &window->vbox_chats, - "treeview_chats", &window->treeview_chats, - "scrolledwindow_chats", &window->scrolledwindow_chats, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - window, - "log_window", "destroy", log_window_destroy_cb, - "entry_find", "changed", log_window_entry_find_changed_cb, - "button_previous", "clicked", log_window_button_previous_clicked_cb, - "button_next", "clicked", log_window_button_next_clicked_cb, - "button_find", "clicked", log_window_button_find_clicked_cb, - "entry_chats", "changed", log_window_entry_chats_changed_cb, - "entry_chats", "activate", log_window_entry_chats_activate_cb, - NULL); - - g_object_unref (glade); - - g_object_add_weak_pointer (G_OBJECT (window->window), - (gpointer) &window); - - /* We set this up here so we can block it when needed. */ - g_signal_connect (window->calendar_chats, "day-selected", - G_CALLBACK (log_window_calendar_chats_day_selected_cb), - window); - g_signal_connect (window->calendar_chats, "month-changed", - G_CALLBACK (log_window_calendar_chats_month_changed_cb), - window); - - /* Configure Search EmpathyChatView */ - window->chatview_find = empathy_theme_manager_create_view (empathy_theme_manager_get ()); - gtk_container_add (GTK_CONTAINER (window->scrolledwindow_find), - GTK_WIDGET (window->chatview_find)); - gtk_widget_show (GTK_WIDGET (window->chatview_find)); - - /* Configure Contacts EmpathyChatView */ - window->chatview_chats = empathy_theme_manager_create_view (empathy_theme_manager_get ()); - gtk_container_add (GTK_CONTAINER (window->scrolledwindow_chats), - GTK_WIDGET (window->chatview_chats)); - gtk_widget_show (GTK_WIDGET (window->chatview_chats)); - - /* Account chooser for chats */ - window->account_chooser_chats = empathy_account_chooser_new (); - account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); - - gtk_box_pack_start (GTK_BOX (window->vbox_chats), - window->account_chooser_chats, - FALSE, TRUE, 0); - - g_signal_connect (window->account_chooser_chats, "changed", - G_CALLBACK (log_window_chats_accounts_changed_cb), - window); - - /* Populate */ - accounts = mc_accounts_list (); - account_num = g_list_length (accounts); - mc_accounts_list_free (accounts); - - if (account_num > 1) { - gtk_widget_show (window->vbox_chats); - gtk_widget_show (window->account_chooser_chats); - } else { - gtk_widget_hide (window->vbox_chats); - gtk_widget_hide (window->account_chooser_chats); - } - - /* Search List */ - log_window_find_setup (window); - - /* Contacts */ - log_window_chats_setup (window); - log_window_chats_populate (window); - - /* Select chat */ - if (account && chat_id) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); - log_window_chats_set_selected (window, account, - chat_id, is_chatroom); - } - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (window->window), - GTK_WINDOW (parent)); - } - - gtk_widget_show (window->window); - - return window->window; -} - -static void -log_window_destroy_cb (GtkWidget *widget, - EmpathyLogWindow *window) -{ - g_free (window->last_find); - g_object_unref (window->log_manager); - - g_free (window); -} - -/* - * Search code. - */ -static void -log_window_entry_find_changed_cb (GtkWidget *entry, - EmpathyLogWindow *window) -{ - const gchar *str; - gboolean is_sensitive = TRUE; - - str = gtk_entry_get_text (GTK_ENTRY (window->entry_find)); - - is_sensitive &= !EMP_STR_EMPTY (str); - is_sensitive &= - !window->last_find || - (window->last_find && strcmp (window->last_find, str) != 0); - - gtk_widget_set_sensitive (window->button_find, is_sensitive); -} - -static void -log_window_find_changed_cb (GtkTreeSelection *selection, - EmpathyLogWindow *window) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeIter iter; - McAccount *account; - gchar *chat_id; - gboolean is_chatroom; - gchar *date; - EmpathyMessage *message; - GList *messages; - GList *l; - gboolean can_do_previous; - gboolean can_do_next; - - /* Get selected information */ - view = GTK_TREE_VIEW (window->treeview_find); - model = gtk_tree_view_get_model (view); - - if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) { - gtk_widget_set_sensitive (window->button_previous, FALSE); - gtk_widget_set_sensitive (window->button_next, FALSE); - - empathy_chat_view_clear (window->chatview_find); - - return; - } - - gtk_widget_set_sensitive (window->button_previous, TRUE); - gtk_widget_set_sensitive (window->button_next, TRUE); - - gtk_tree_model_get (model, &iter, - COL_FIND_ACCOUNT, &account, - COL_FIND_CHAT_ID, &chat_id, - COL_FIND_IS_CHATROOM, &is_chatroom, - COL_FIND_DATE, &date, - -1); - - /* Clear all current messages shown in the textview */ - empathy_chat_view_clear (window->chatview_find); - - /* Turn off scrolling temporarily */ - empathy_chat_view_scroll (window->chatview_find, FALSE); - - /* Get messages */ - messages = empathy_log_manager_get_messages_for_date (window->log_manager, - account, - chat_id, - is_chatroom, - date); - g_object_unref (account); - g_free (date); - g_free (chat_id); - - for (l = messages; l; l = l->next) { - message = l->data; - empathy_chat_view_append_message (window->chatview_find, message); - g_object_unref (message); - } - g_list_free (messages); - - /* Scroll to the most recent messages */ - empathy_chat_view_scroll (window->chatview_find, TRUE); - - /* Highlight and find messages */ - empathy_chat_view_highlight (window->chatview_find, - window->last_find); - empathy_chat_view_find_next (window->chatview_find, - window->last_find, - TRUE); - empathy_chat_view_find_abilities (window->chatview_find, - window->last_find, - &can_do_previous, - &can_do_next); - gtk_widget_set_sensitive (window->button_previous, can_do_previous); - gtk_widget_set_sensitive (window->button_next, can_do_next); - gtk_widget_set_sensitive (window->button_find, FALSE); -} - -static void -log_window_find_populate (EmpathyLogWindow *window, - const gchar *search_criteria) -{ - GList *hits, *l; - - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkListStore *store; - GtkTreeIter iter; - - view = GTK_TREE_VIEW (window->treeview_find); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - store = GTK_LIST_STORE (model); - - empathy_chat_view_clear (window->chatview_find); - - gtk_list_store_clear (store); - - if (EMP_STR_EMPTY (search_criteria)) { - /* Just clear the search. */ - return; - } - - hits = empathy_log_manager_search_new (window->log_manager, search_criteria); - - for (l = hits; l; l = l->next) { - EmpathyLogSearchHit *hit; - const gchar *account_name; - const gchar *account_icon; - gchar *date_readable; - - hit = l->data; - - /* Protect against invalid data (corrupt or old log files. */ - if (!hit->account || !hit->chat_id) { - continue; - } - - date_readable = empathy_log_manager_get_date_readable (hit->date); - account_name = mc_account_get_display_name (hit->account); - account_icon = empathy_icon_name_from_account (hit->account); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_FIND_ACCOUNT_ICON, account_icon, - COL_FIND_ACCOUNT_NAME, account_name, - COL_FIND_ACCOUNT, hit->account, - COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */ - COL_FIND_CHAT_ID, hit->chat_id, - COL_FIND_IS_CHATROOM, hit->is_chatroom, - COL_FIND_DATE, hit->date, - COL_FIND_DATE_READABLE, date_readable, - -1); - - g_free (date_readable); - - /* FIXME: Update COL_FIND_CHAT_NAME */ - if (hit->is_chatroom) { - } else { - } - } - - if (hits) { - empathy_log_manager_search_free (hits); - } -} - -static void -log_window_find_setup (EmpathyLogWindow *window) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeSortable *sortable; - GtkTreeViewColumn *column; - GtkListStore *store; - GtkCellRenderer *cell; - gint offset; - - view = GTK_TREE_VIEW (window->treeview_find); - selection = gtk_tree_view_get_selection (view); - - /* New store */ - store = gtk_list_store_new (COL_FIND_COUNT, - G_TYPE_STRING, /* account icon name */ - G_TYPE_STRING, /* account name */ - MC_TYPE_ACCOUNT, /* account */ - G_TYPE_STRING, /* chat name */ - G_TYPE_STRING, /* chat id */ - G_TYPE_BOOLEAN, /* is chatroom */ - G_TYPE_STRING, /* date */ - G_TYPE_STRING); /* date_readable */ - - model = GTK_TREE_MODEL (store); - sortable = GTK_TREE_SORTABLE (store); - - gtk_tree_view_set_model (view, model); - - /* New column */ - column = gtk_tree_view_column_new (); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - gtk_tree_view_column_add_attribute (column, cell, - "icon-name", - COL_FIND_ACCOUNT_ICON); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "text", - COL_FIND_ACCOUNT_NAME); - - gtk_tree_view_column_set_title (column, _("Account")); - gtk_tree_view_append_column (view, column); - - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_clickable (column, TRUE); - - cell = gtk_cell_renderer_text_new (); - offset = gtk_tree_view_insert_column_with_attributes (view, -1, _("Conversation"), - cell, "text", COL_FIND_CHAT_NAME, - NULL); - - column = gtk_tree_view_get_column (view, offset - 1); - gtk_tree_view_column_set_sort_column_id (column, COL_FIND_CHAT_NAME); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_clickable (column, TRUE); - - cell = gtk_cell_renderer_text_new (); - offset = gtk_tree_view_insert_column_with_attributes (view, -1, _("Date"), - cell, "text", COL_FIND_DATE_READABLE, - NULL); - - column = gtk_tree_view_get_column (view, offset - 1); - gtk_tree_view_column_set_sort_column_id (column, COL_FIND_DATE); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_clickable (column, TRUE); - - /* Set up treeview properties */ - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - gtk_tree_sortable_set_sort_column_id (sortable, - COL_FIND_DATE, - GTK_SORT_ASCENDING); - - /* Set up signals */ - g_signal_connect (selection, "changed", - G_CALLBACK (log_window_find_changed_cb), - window); - - g_object_unref (store); -} - -static void -log_window_button_find_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (window->entry_find)); - - /* Don't find the same crap again */ - if (window->last_find && strcmp (window->last_find, str) == 0) { - return; - } - - g_free (window->last_find); - window->last_find = g_strdup (str); - - log_window_find_populate (window, str); -} - -static void -log_window_button_next_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window) -{ - if (window->last_find) { - gboolean can_do_previous; - gboolean can_do_next; - - empathy_chat_view_find_next (window->chatview_find, - window->last_find, - FALSE); - empathy_chat_view_find_abilities (window->chatview_find, - window->last_find, - &can_do_previous, - &can_do_next); - gtk_widget_set_sensitive (window->button_previous, can_do_previous); - gtk_widget_set_sensitive (window->button_next, can_do_next); - } -} - -static void -log_window_button_previous_clicked_cb (GtkWidget *widget, - EmpathyLogWindow *window) -{ - if (window->last_find) { - gboolean can_do_previous; - gboolean can_do_next; - - empathy_chat_view_find_previous (window->chatview_find, - window->last_find, - FALSE); - empathy_chat_view_find_abilities (window->chatview_find, - window->last_find, - &can_do_previous, - &can_do_next); - gtk_widget_set_sensitive (window->button_previous, can_do_previous); - gtk_widget_set_sensitive (window->button_next, can_do_next); - } -} - -/* - * Chats Code - */ - -static void -log_window_chats_changed_cb (GtkTreeSelection *selection, - EmpathyLogWindow *window) -{ - /* Use last date by default */ - gtk_calendar_clear_marks (GTK_CALENDAR (window->calendar_chats)); - - log_window_chats_get_messages (window, NULL); -} - -static void -log_window_chats_populate (EmpathyLogWindow *window) -{ - EmpathyAccountChooser *account_chooser; - McAccount *account; - GList *chats, *l; - - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkListStore *store; - GtkTreeIter iter; - - account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); - account = empathy_account_chooser_get_account (account_chooser); - - view = GTK_TREE_VIEW (window->treeview_chats); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - store = GTK_LIST_STORE (model); - - if (account == NULL) { - gtk_list_store_clear (store); - return; - } - - /* Block signals to stop the logs being retrieved prematurely */ - g_signal_handlers_block_by_func (selection, - log_window_chats_changed_cb, - window); - - gtk_list_store_clear (store); - - chats = empathy_log_manager_get_chats (window->log_manager, account); - for (l = chats; l; l = l->next) { - EmpathyLogSearchHit *hit; - - hit = l->data; - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_CHAT_ICON, "empathy-available", /* FIXME */ - COL_CHAT_NAME, hit->chat_id, - COL_CHAT_ACCOUNT, account, - COL_CHAT_ID, hit->chat_id, - COL_CHAT_IS_CHATROOM, hit->is_chatroom, - -1); - - /* FIXME: Update COL_CHAT_ICON/NAME */ - if (hit->is_chatroom) { - } else { - } - } - empathy_log_manager_search_free (chats); - - /* Unblock signals */ - g_signal_handlers_unblock_by_func (selection, - log_window_chats_changed_cb, - window); - - - g_object_unref (account); -} - -static void -log_window_chats_setup (EmpathyLogWindow *window) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeSortable *sortable; - GtkTreeViewColumn *column; - GtkListStore *store; - GtkCellRenderer *cell; - - view = GTK_TREE_VIEW (window->treeview_chats); - selection = gtk_tree_view_get_selection (view); - - /* new store */ - store = gtk_list_store_new (COL_CHAT_COUNT, - G_TYPE_STRING, /* icon */ - G_TYPE_STRING, /* name */ - MC_TYPE_ACCOUNT, /* account */ - G_TYPE_STRING, /* id */ - G_TYPE_BOOLEAN); /* is chatroom */ - - model = GTK_TREE_MODEL (store); - sortable = GTK_TREE_SORTABLE (store); - - gtk_tree_view_set_model (view, model); - - /* new column */ - column = gtk_tree_view_column_new (); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - gtk_tree_view_column_add_attribute (column, cell, - "icon-name", - COL_CHAT_ICON); - - cell = gtk_cell_renderer_text_new (); - g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - gtk_tree_view_column_pack_start (column, cell, TRUE); - gtk_tree_view_column_add_attribute (column, cell, - "text", - COL_CHAT_NAME); - - gtk_tree_view_append_column (view, column); - - /* set up treeview properties */ - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - gtk_tree_sortable_set_sort_column_id (sortable, - COL_CHAT_NAME, - GTK_SORT_ASCENDING); - - /* set up signals */ - g_signal_connect (selection, "changed", - G_CALLBACK (log_window_chats_changed_cb), - window); - - g_object_unref (store); -} - -static void -log_window_chats_accounts_changed_cb (GtkWidget *combobox, - EmpathyLogWindow *window) -{ - /* Clear all current messages shown in the textview */ - empathy_chat_view_clear (window->chatview_chats); - - log_window_chats_populate (window); -} - -static void -log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, - const gchar *chat_id, - gboolean is_chatroom) -{ - EmpathyAccountChooser *account_chooser; - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreePath *path; - gboolean ok; - - account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); - empathy_account_chooser_set_account (account_chooser, account); - - view = GTK_TREE_VIEW (window->treeview_chats); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_model_get_iter_first (model, &iter)) { - return; - } - - for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; - gchar *this_chat_id; - gboolean this_is_chatroom; - - gtk_tree_model_get (model, &iter, - COL_CHAT_ACCOUNT, &this_account, - COL_CHAT_ID, &this_chat_id, - COL_CHAT_IS_CHATROOM, &this_is_chatroom, - -1); - - if (empathy_account_equal (this_account, account) && - strcmp (this_chat_id, chat_id) == 0 && - this_is_chatroom == is_chatroom) { - gtk_tree_selection_select_iter (selection, &iter); - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 0.5, 0.0); - gtk_tree_path_free (path); - g_object_unref (this_account); - g_free (this_chat_id); - break; - } - - g_object_unref (this_account); - g_free (this_chat_id); - } -} - -static gboolean -log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, - gchar **chat_id, - gboolean *is_chatroom) -{ - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - gchar *id = NULL; - McAccount *acc = NULL; - gboolean room = FALSE; - - view = GTK_TREE_VIEW (window->treeview_chats); - model = gtk_tree_view_get_model (view); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) { - return FALSE; - } - - gtk_tree_model_get (model, &iter, - COL_CHAT_ACCOUNT, &acc, - COL_CHAT_ID, &id, - COL_CHAT_IS_CHATROOM, &room, - -1); - - if (chat_id) { - *chat_id = id; - } else { - g_free (id); - } - if (account) { - *account = acc; - } else { - g_object_unref (acc); - } - if (is_chatroom) { - *is_chatroom = room; - } - - return TRUE; -} - -static void -log_window_chats_get_messages (EmpathyLogWindow *window, - const gchar *date_to_show) -{ - McAccount *account; - gchar *chat_id; - gboolean is_chatroom; - EmpathyMessage *message; - GList *messages; - GList *dates = NULL; - GList *l; - const gchar *date; - guint year_selected; - guint year; - guint month; - guint month_selected; - guint day; - - if (!log_window_chats_get_selected (window, &account, - &chat_id, &is_chatroom)) { - return; - } - - g_signal_handlers_block_by_func (window->calendar_chats, - log_window_calendar_chats_day_selected_cb, - window); - - /* Either use the supplied date or get the last */ - date = date_to_show; - if (!date) { - gboolean day_selected = FALSE; - - /* Get a list of dates and show them on the calendar */ - dates = empathy_log_manager_get_dates (window->log_manager, - account, chat_id, - is_chatroom); - - for (l = dates; l; l = l->next) { - const gchar *str; - - str = l->data; - if (!str) { - continue; - } - - sscanf (str, "%4d%2d%2d", &year, &month, &day); - gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats), - &year_selected, - &month_selected, - NULL); - - month_selected++; - - if (!l->next) { - date = str; - } - - if (year != year_selected || month != month_selected) { - continue; - } - - - DEBUG ("Marking date:'%s'", str); - gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day); - - if (l->next) { - continue; - } - - day_selected = TRUE; - - gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day); - } - - if (!day_selected) { - /* Unselect the day in the calendar */ - gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), 0); - } - } else { - sscanf (date, "%4d%2d%2d", &year, &month, &day); - gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats), - &year_selected, - &month_selected, - NULL); - - month_selected++; - - if (year != year_selected && month != month_selected) { - day = 0; - } - - gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day); - } - - g_signal_handlers_unblock_by_func (window->calendar_chats, - log_window_calendar_chats_day_selected_cb, - window); - - if (!date) { - goto OUT; - } - - /* Clear all current messages shown in the textview */ - empathy_chat_view_clear (window->chatview_chats); - - /* Turn off scrolling temporarily */ - empathy_chat_view_scroll (window->chatview_find, FALSE); - - /* Get messages */ - messages = empathy_log_manager_get_messages_for_date (window->log_manager, - account, chat_id, - is_chatroom, - date); - - for (l = messages; l; l = l->next) { - message = l->data; - - empathy_chat_view_append_message (window->chatview_chats, - message); - g_object_unref (message); - } - g_list_free (messages); - - /* Turn back on scrolling */ - empathy_chat_view_scroll (window->chatview_find, TRUE); - - /* Give the search entry main focus */ - gtk_widget_grab_focus (window->entry_chats); - -OUT: - g_list_foreach (dates, (GFunc) g_free, NULL); - g_list_free (dates); - g_object_unref (account); - g_free (chat_id); -} - -static void -log_window_calendar_chats_day_selected_cb (GtkWidget *calendar, - EmpathyLogWindow *window) -{ - guint year; - guint month; - guint day; - - gchar *date; - - gtk_calendar_get_date (GTK_CALENDAR (calendar), &year, &month, &day); - - /* We need this hear because it appears that the months start from 0 */ - month++; - - date = g_strdup_printf ("%4.4d%2.2d%2.2d", year, month, day); - - DEBUG ("Currently selected date is:'%s'", date); - - log_window_chats_get_messages (window, date); - - g_free (date); -} - -static void -log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, - EmpathyLogWindow *window) -{ - McAccount *account; - gchar *chat_id; - gboolean is_chatroom; - guint year_selected; - guint month_selected; - - GList *dates; - GList *l; - - gtk_calendar_clear_marks (GTK_CALENDAR (calendar)); - - if (!log_window_chats_get_selected (window, &account, - &chat_id, &is_chatroom)) { - DEBUG ("No chat selected to get dates for..."); - return; - } - - g_object_get (calendar, - "month", &month_selected, - "year", &year_selected, - NULL); - - /* We need this hear because it appears that the months start from 0 */ - month_selected++; - - /* Get the log object for this contact */ - dates = empathy_log_manager_get_dates (window->log_manager, account, - chat_id, is_chatroom); - g_object_unref (account); - g_free (chat_id); - - for (l = dates; l; l = l->next) { - const gchar *str; - guint year; - guint month; - guint day; - - str = l->data; - if (!str) { - continue; - } - - sscanf (str, "%4d%2d%2d", &year, &month, &day); - - if (year == year_selected && month == month_selected) { - DEBUG ("Marking date:'%s'", str); - gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day); - } - } - - g_list_foreach (dates, (GFunc) g_free, NULL); - g_list_free (dates); - - DEBUG ("Currently showing month %d and year %d", month_selected, - year_selected); -} - -static void -log_window_entry_chats_changed_cb (GtkWidget *entry, - EmpathyLogWindow *window) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (window->entry_chats)); - empathy_chat_view_highlight (window->chatview_chats, str); - - if (str) { - empathy_chat_view_find_next (window->chatview_chats, - str, - TRUE); - } -} - -static void -log_window_entry_chats_activate_cb (GtkWidget *entry, - EmpathyLogWindow *window) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (window->entry_chats)); - - if (str) { - empathy_chat_view_find_next (window->chatview_chats, - str, - FALSE); - } -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-log-window.glade b/gnome-2-26/libempathy-gtk/empathy-log-window.glade deleted file mode 100644 index 4f0c55d35..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-log-window.glade +++ /dev/null @@ -1,311 +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="log_window"> - <property name="title" translatable="yes">Previous Conversations</property> - <property name="role">log</property> - <property name="default_width">640</property> - <property name="default_height">450</property> - <property name="icon_name">document-open-recent</property> - <child> - <widget class="GtkNotebook" id="notebook"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="border_width">2</property> - <child> - <widget class="GtkVBox" id="vbox192"> - <property name="visible">True</property> - <property name="border_width">12</property> - <property name="spacing">6</property> - <child> - <widget class="GtkHBox" id="hbox144"> - <property name="visible">True</property> - <property name="spacing">12</property> - <child> - <widget class="GtkLabel" id="label628"> - <property name="visible">True</property> - <property name="label" translatable="yes" comments="Searching *for* something">_For:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_find</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_find"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="activates_default">True</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_find"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="label">gtk-find</property> - <property name="use_stock">True</property> - <property name="focus_on_click">False</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkVPaned" id="vpaned1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="position">120</property> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow14"> - <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> - <widget class="GtkTreeView" id="treeview_find"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="enable_search">False</property> - </widget> - </child> - </widget> - <packing> - <property name="resize">False</property> - <property name="shrink">True</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox215"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow_find"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <placeholder/> - </child> - </widget> - </child> - <child> - <widget class="GtkHBox" id="hbox171"> - <property name="visible">True</property> - <property name="spacing">12</property> - <child> - <placeholder/> - </child> - <child> - <widget class="GtkButton" id="button_previous"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="label">gtk-go-back</property> - <property name="use_stock">True</property> - <property name="focus_on_click">False</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">GTK_PACK_END</property> - <property name="position">2</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_next"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="label">gtk-go-forward</property> - <property name="use_stock">True</property> - <property name="focus_on_click">False</property> - <property name="response_id">0</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">GTK_PACK_END</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </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> - <child> - <widget class="GtkLabel" id="label595"> - <property name="visible">True</property> - <property name="label" translatable="yes" comments="Tab Label">Search</property> - </widget> - <packing> - <property name="type">tab</property> - <property name="tab_fill">False</property> - </packing> - </child> - <child> - <widget class="GtkTable" id="table7"> - <property name="visible">True</property> - <property name="border_width">12</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkVBox" id="vbox_chats"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow_chats"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox191"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow13"> - <property name="width_request">150</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> - <widget class="GtkTreeView" id="treeview_chats"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">False</property> - </widget> - </child> - </widget> - </child> - <child> - <widget class="GtkCalendar" id="calendar_chats"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox143"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <widget class="GtkImage" id="image247"> - <property name="visible">True</property> - <property name="stock">gtk-find</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_chats"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="activates_default">True</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label596"> - <property name="visible">True</property> - <property name="label" translatable="yes" comments="Tab Label">Conversations</property> - </widget> - <packing> - <property name="type">tab</property> - <property name="position">1</property> - <property name="tab_fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-log-window.h b/gnome-2-26/libempathy-gtk/empathy-log-window.h deleted file mode 100644 index 266e0c30c..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-log-window.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-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: Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_LOG_WINDOW_H__ -#define __EMPATHY_LOG_WINDOW_H__ - -#include <libmissioncontrol/mc-account.h> - -G_BEGIN_DECLS - -GtkWidget * empathy_log_window_show (McAccount *account, - const gchar *chat_id, - gboolean chatroom, - GtkWindow *parent); - -G_END_DECLS - -#endif /* __EMPATHY_LOG_WINDOW_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.c b/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.c deleted file mode 100644 index 93f679e66..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.c +++ /dev/null @@ -1,313 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> -#include <stdlib.h> - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <glib/gi18n-lib.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mission-control.h> - -#include <libempathy/empathy-call-factory.h> -#include <libempathy/empathy-contact-factory.h> -#include <libempathy/empathy-contact-manager.h> -#include <libempathy/empathy-dispatcher.h> -#include <libempathy/empathy-utils.h> - -#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT -#include <libempathy/empathy-debug.h> - -#include <libempathy-gtk/empathy-ui-utils.h> - -#include "empathy-new-message-dialog.h" -#include "empathy-account-chooser.h" - -typedef struct { - GtkWidget *dialog; - GtkWidget *table_contact; - GtkWidget *account_chooser; - GtkWidget *entry_id; - GtkWidget *button_chat; - GtkWidget *button_call; - EmpathyContactManager *contact_manager; -} EmpathyNewMessageDialog; - -enum { - COMPLETION_COL_TEXT, - COMPLETION_COL_ID, - COMPLETION_COL_NAME, -} CompletionCol; - -static void -new_message_dialog_account_changed_cb (GtkWidget *widget, - EmpathyNewMessageDialog *dialog) -{ - EmpathyAccountChooser *chooser; - McAccount *account; - EmpathyTpContactList *contact_list; - GList *members, *l; - GtkListStore *store; - GtkEntryCompletion *completion; - GtkTreeIter iter; - gchar *tmpstr; - - chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); - account = empathy_account_chooser_get_account (chooser); - contact_list = empathy_contact_manager_get_list (dialog->contact_manager, - account); - members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (contact_list)); - completion = gtk_entry_get_completion (GTK_ENTRY (dialog->entry_id)); - store = GTK_LIST_STORE (gtk_entry_completion_get_model (completion)); - gtk_list_store_clear (store); - - for (l = members; l; l = l->next) { - EmpathyContact *contact = l->data; - - if (!empathy_contact_is_online (contact)) { - continue; - } - - DEBUG ("Adding contact ID %s, Name %s", - empathy_contact_get_id (contact), - empathy_contact_get_name (contact)); - - tmpstr = g_strdup_printf ("%s (%s)", - empathy_contact_get_name (contact), - empathy_contact_get_id (contact)); - - gtk_list_store_insert_with_values (store, &iter, -1, - COMPLETION_COL_TEXT, tmpstr, - COMPLETION_COL_ID, empathy_contact_get_id (contact), - COMPLETION_COL_NAME, empathy_contact_get_name (contact), - -1); - - g_free (tmpstr); - } - - g_object_unref (account); -} - -static gboolean -new_message_dialog_match_selected_cb (GtkEntryCompletion *widget, - GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyNewMessageDialog *dialog) -{ - gchar *id; - - if (!iter || !model) { - return FALSE; - } - - gtk_tree_model_get (model, iter, COMPLETION_COL_ID, &id, -1); - gtk_entry_set_text (GTK_ENTRY (dialog->entry_id), id); - - DEBUG ("Got selected match **%s**", id); - - g_free (id); - - return TRUE; -} - -static gboolean -new_message_dialog_match_func (GtkEntryCompletion *completion, - const gchar *key, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkTreeModel *model; - gchar *id; - gchar *name; - - model = gtk_entry_completion_get_model (completion); - if (!model || !iter) { - return FALSE; - } - - gtk_tree_model_get (model, iter, COMPLETION_COL_NAME, &name, -1); - if (strstr (name, key)) { - DEBUG ("Key %s is matching name **%s**", key, name); - g_free (name); - return TRUE; - } - g_free (name); - - gtk_tree_model_get (model, iter, COMPLETION_COL_ID, &id, -1); - if (strstr (id, key)) { - DEBUG ("Key %s is matching ID **%s**", key, id); - g_free (id); - return TRUE; - } - g_free (id); - - return FALSE; -} - -static void -new_message_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyNewMessageDialog *dialog) -{ - McAccount *account; - const gchar *id; - - account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser)); - id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id)); - if (!account || EMP_STR_EMPTY (id)) { - if (account) { - g_object_unref (account); - } - gtk_widget_destroy (widget); - return; - } - - if (response == 1) { - EmpathyContactFactory *factory; - EmpathyContact *contact; - EmpathyCallFactory *call_factory; - - factory = empathy_contact_factory_dup_singleton (); - contact = empathy_contact_factory_get_from_id (factory, account, id); - - call_factory = empathy_call_factory_get(); - empathy_call_factory_new_call (call_factory, contact); - - g_object_unref (contact); - g_object_unref (factory); - } else if (response == 2) { - empathy_dispatcher_chat_with_contact_id (account, id, NULL, NULL); - } - - g_object_unref (account); - gtk_widget_destroy (widget); -} - -static void -new_message_change_state_button_cb (GtkEditable *editable, - EmpathyNewMessageDialog *dialog) -{ - const gchar *id; - gboolean sensitive; - - id = gtk_entry_get_text (GTK_ENTRY (editable)); - sensitive = !EMP_STR_EMPTY (id); - - gtk_widget_set_sensitive (dialog->button_chat, sensitive); - gtk_widget_set_sensitive (dialog->button_call, sensitive); -} - -static void -new_message_dialog_destroy_cb (GtkWidget *widget, - EmpathyNewMessageDialog *dialog) -{ - g_object_unref (dialog->contact_manager); - g_free (dialog); -} - -GtkWidget * -empathy_new_message_dialog_show (GtkWindow *parent) -{ - static EmpathyNewMessageDialog *dialog = NULL; - GladeXML *glade; - gchar *filename; - GtkEntryCompletion *completion; - GtkListStore *model; - - if (dialog) { - gtk_window_present (GTK_WINDOW (dialog->dialog)); - return dialog->dialog; - } - - dialog = g_new0 (EmpathyNewMessageDialog, 1); - - /* create a contact manager */ - dialog->contact_manager = empathy_contact_manager_dup_singleton (); - - filename = empathy_file_lookup ("empathy-new-message-dialog.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "new_message_dialog", - NULL, - "new_message_dialog", &dialog->dialog, - "table_contact", &dialog->table_contact, - "entry_id", &dialog->entry_id, - "button_chat", &dialog->button_chat, - "button_call",&dialog->button_call, - NULL); - g_free (filename); - - /* text completion */ - completion = gtk_entry_completion_new (); - model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - gtk_entry_completion_set_text_column (completion, COMPLETION_COL_TEXT); - gtk_entry_completion_set_match_func (completion, - new_message_dialog_match_func, - NULL, NULL); - gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (model)); - gtk_entry_set_completion (GTK_ENTRY (dialog->entry_id), completion); - g_signal_connect (completion, "match-selected", - G_CALLBACK (new_message_dialog_match_selected_cb), - dialog); - g_object_unref(completion); - g_object_unref(model); - - empathy_glade_connect (glade, dialog, - "new_message_dialog", "destroy", new_message_dialog_destroy_cb, - "new_message_dialog", "response", new_message_dialog_response_cb, - "entry_id", "changed", new_message_change_state_button_cb, - NULL); - - g_object_add_weak_pointer (G_OBJECT (dialog->dialog), (gpointer) &dialog); - - g_object_unref (glade); - - /* Create account chooser */ - dialog->account_chooser = empathy_account_chooser_new (); - gtk_table_attach_defaults (GTK_TABLE (dialog->table_contact), - dialog->account_chooser, - 1, 2, 0, 1); - empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser), - empathy_account_chooser_filter_is_connected, - NULL); - gtk_widget_show (dialog->account_chooser); - - new_message_dialog_account_changed_cb (dialog->account_chooser, dialog); - g_signal_connect (dialog->account_chooser, "changed", - G_CALLBACK (new_message_dialog_account_changed_cb), - dialog); - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW (parent)); - } - - gtk_widget_set_sensitive (dialog->button_chat, FALSE); - gtk_widget_set_sensitive (dialog->button_call, FALSE); - - gtk_widget_show (dialog->dialog); - - return dialog->dialog; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.glade b/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.glade deleted file mode 100644 index d6317f8d4..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.glade +++ /dev/null @@ -1,184 +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="GtkDialog" id="new_message_dialog"> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">New Conversation</property> - <property name="resizable">False</property> - <property name="role">new_message</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkTable" id="table_contact"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <placeholder/> - </child> - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Account:</property> - </widget> - <packing> - <property name="x_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Contact ID:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="activates_default">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="response_id">-6</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_call"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="response_id">1</property> - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="icon_name">audio-input-microphone</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">C_all</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_chat"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="response_id">2</property> - <child> - <widget class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkImage" id="image2"> - <property name="visible">True</property> - <property name="icon_name">im-message-new</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="label" translatable="yes">C_hat</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="position">2</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.h b/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.h deleted file mode 100644 index c1781d0cf..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-new-message-dialog.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_NEW_MESSAGE_DIALOG_H__ -#define __EMPATHY_NEW_MESSAGE_DIALOG_H__ - -#include <gtk/gtkwidget.h> - -G_BEGIN_DECLS - -GtkWidget *empathy_new_message_dialog_show (GtkWindow *parent); - -G_END_DECLS - -#endif /* __EMPATHY_NEW_MESSAGE_DIALOG_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.c b/gnome-2-26/libempathy-gtk/empathy-presence-chooser.c deleted file mode 100644 index ff735e520..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.c +++ /dev/null @@ -1,974 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * - * 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: Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> -#include <stdlib.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-enum-types.h> - -#include <libempathy/empathy-idle.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-status-presets.h> - -#include "empathy-ui-utils.h" -#include "empathy-images.h" -#include "empathy-presence-chooser.h" - -/* Flashing delay for icons (milliseconds). */ -#define FLASH_TIMEOUT 500 - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyPresenceChooser) -typedef struct { - EmpathyIdle *idle; - - GtkWidget *hbox; - GtkWidget *image; - GtkWidget *label; - GtkWidget *menu; - - McPresence last_state; - - McPresence flash_state_1; - McPresence flash_state_2; - guint flash_timeout_id; - - /* The handle the kind of unnessecary scroll support. */ - guint scroll_timeout_id; - McPresence scroll_state; - gchar *scroll_status; -} EmpathyPresenceChooserPriv; - -typedef struct { - GtkWidget *dialog; - GtkWidget *checkbutton_save; - GtkWidget *comboboxentry_message; - GtkWidget *entry_message; - GtkWidget *combobox_status; - GtkTreeModel *model_status; -} CustomMessageDialog; - -enum { - COL_ICON, - COL_LABEL, - COL_PRESENCE, - COL_COUNT -}; - -typedef struct { - McPresence state; - const gchar *status; -} StateAndStatus; - -static CustomMessageDialog *message_dialog = NULL; -/* States to be listed in the menu. - * Each state has a boolean telling if it can have custom message */ -static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE, - MC_PRESENCE_DO_NOT_DISTURB, TRUE, - MC_PRESENCE_AWAY, TRUE, - MC_PRESENCE_HIDDEN, FALSE, - MC_PRESENCE_OFFLINE, FALSE}; - -static void presence_chooser_finalize (GObject *object); -static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser); -static void presence_chooser_reset_scroll_timeout (EmpathyPresenceChooser *chooser); -static gboolean presence_chooser_scroll_timeout_cb (EmpathyPresenceChooser *chooser); -static gboolean presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser, - GdkEventScroll *event, - gpointer user_data); -static GList * presence_chooser_get_presets (EmpathyPresenceChooser *chooser); -static StateAndStatus *presence_chooser_state_and_status_new (McPresence state, - const gchar *status); -static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser); -static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser, - McPresence state_1, - McPresence state_2); -static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, - McPresence state); -static gboolean presence_chooser_button_press_event_cb (GtkWidget *chooser, - GdkEventButton *event, - gpointer user_data); -static void presence_chooser_toggled_cb (GtkWidget *chooser, - gpointer user_data); -static void presence_chooser_menu_popup (EmpathyPresenceChooser *chooser); -static void presence_chooser_menu_popdown (EmpathyPresenceChooser *chooser); -static void presence_chooser_menu_selection_done_cb (GtkMenuShell *menushell, - EmpathyPresenceChooser *chooser); -static void presence_chooser_menu_destroy_cb (GtkWidget *menu, - EmpathyPresenceChooser *chooser); -static void presence_chooser_menu_detach (GtkWidget *attach_widget, - GtkMenu *menu); -static void presence_chooser_menu_align_func (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - GtkWidget *widget); -static void presence_chooser_menu_add_item (GtkWidget *menu, - const gchar *str, - McPresence state); -static void presence_chooser_noncustom_activate_cb (GtkWidget *item, - gpointer user_data); -static void presence_chooser_set_state (McPresence state, - const gchar *status); -static void presence_chooser_custom_activate_cb (GtkWidget *item, - gpointer user_data); -static void presence_chooser_dialog_show (void); - -G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_TOGGLE_BUTTON); - -static void -empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = presence_chooser_finalize; - - g_type_class_add_private (object_class, sizeof (EmpathyPresenceChooserPriv)); -} - -static void -empathy_presence_chooser_init (EmpathyPresenceChooser *chooser) -{ - GtkWidget *arrow; - GtkWidget *alignment; - EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser, - EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv); - - chooser->priv = priv; - gtk_button_set_relief (GTK_BUTTON (chooser), GTK_RELIEF_NONE); - gtk_button_set_focus_on_click (GTK_BUTTON (chooser), FALSE); - - alignment = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment); - gtk_container_add (GTK_CONTAINER (chooser), alignment); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 1, 0); - - priv->hbox = gtk_hbox_new (FALSE, 1); - gtk_widget_show (priv->hbox); - gtk_container_add (GTK_CONTAINER (alignment), priv->hbox); - - priv->image = gtk_image_new (); - gtk_widget_show (priv->image); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->image, FALSE, TRUE, 0); - - priv->label = gtk_label_new (NULL); - gtk_widget_show (priv->label); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 0); - gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (priv->label), 0, 0.5); - gtk_misc_set_padding (GTK_MISC (priv->label), 4, 1); - - alignment = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment); - gtk_box_pack_start (GTK_BOX (priv->hbox), alignment, FALSE, FALSE, 0); - - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT); - gtk_widget_show (arrow); - gtk_container_add (GTK_CONTAINER (alignment), arrow); - - g_signal_connect (chooser, "toggled", - G_CALLBACK (presence_chooser_toggled_cb), - NULL); - g_signal_connect (chooser, "button-press-event", - G_CALLBACK (presence_chooser_button_press_event_cb), - NULL); - g_signal_connect (chooser, "scroll-event", - G_CALLBACK (presence_chooser_scroll_event_cb), - NULL); - - priv->idle = empathy_idle_dup_singleton (); - presence_chooser_presence_changed_cb (chooser); - g_signal_connect_swapped (priv->idle, "notify", - G_CALLBACK (presence_chooser_presence_changed_cb), - chooser); -} - -static void -presence_chooser_finalize (GObject *object) -{ - EmpathyPresenceChooserPriv *priv; - - priv = GET_PRIV (object); - - if (priv->flash_timeout_id) { - g_source_remove (priv->flash_timeout_id); - } - - if (priv->scroll_timeout_id) { - g_source_remove (priv->scroll_timeout_id); - } - - g_signal_handlers_disconnect_by_func (priv->idle, - presence_chooser_presence_changed_cb, - object); - g_object_unref (priv->idle); - - G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object); -} - -GtkWidget * -empathy_presence_chooser_new (void) -{ - GtkWidget *chooser; - - chooser = g_object_new (EMPATHY_TYPE_PRESENCE_CHOOSER, NULL); - - return chooser; -} - -static void -presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - McPresence state; - McPresence flash_state; - const gchar *status; - - priv = GET_PRIV (chooser); - - state = empathy_idle_get_state (priv->idle); - status = empathy_idle_get_status (priv->idle); - flash_state = empathy_idle_get_flash_state (priv->idle); - - presence_chooser_reset_scroll_timeout (chooser); - gtk_label_set_text (GTK_LABEL (priv->label), status); - - if (flash_state != MC_PRESENCE_UNSET) { - presence_chooser_flash_start (chooser, state, flash_state); - } else { - presence_chooser_flash_stop (chooser, state); - } -} - -static void -presence_chooser_reset_scroll_timeout (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - - priv = GET_PRIV (chooser); - - if (priv->scroll_timeout_id) { - g_source_remove (priv->scroll_timeout_id); - priv->scroll_timeout_id = 0; - } - - g_free (priv->scroll_status); - priv->scroll_status = NULL; -} - -static gboolean -presence_chooser_scroll_timeout_cb (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - - priv = GET_PRIV (chooser); - - priv->scroll_timeout_id = 0; - - empathy_idle_set_presence (priv->idle, - priv->scroll_state, - priv->scroll_status); - - g_free (priv->scroll_status); - priv->scroll_status = NULL; - - return FALSE; -} - -static gboolean -presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser, - GdkEventScroll *event, - gpointer user_data) -{ - EmpathyPresenceChooserPriv *priv; - GList *list, *l; - const gchar *current_status; - StateAndStatus *sas; - gboolean match; - - priv = GET_PRIV (chooser); - - switch (event->direction) { - case GDK_SCROLL_UP: - break; - case GDK_SCROLL_DOWN: - break; - default: - return FALSE; - } - - current_status = gtk_label_get_text (GTK_LABEL (priv->label)); - - /* Get the list of presets, which in this context means all the items - * without a trailing "...". - */ - list = presence_chooser_get_presets (chooser); - sas = NULL; - match = FALSE; - for (l = list; l; l = l->next) { - sas = l->data; - - if (sas->state == priv->last_state && - strcmp (sas->status, current_status) == 0) { - sas = NULL; - match = TRUE; - if (event->direction == GDK_SCROLL_UP) { - if (l->prev) { - sas = l->prev->data; - } - } - else if (event->direction == GDK_SCROLL_DOWN) { - if (l->next) { - sas = l->next->data; - } - } - break; - } - - sas = NULL; - } - - if (sas) { - presence_chooser_reset_scroll_timeout (chooser); - - priv->scroll_status = g_strdup (sas->status); - priv->scroll_state = sas->state; - - priv->scroll_timeout_id = - g_timeout_add_seconds (1, - (GSourceFunc) presence_chooser_scroll_timeout_cb, - chooser); - - presence_chooser_flash_stop (chooser, sas->state); - gtk_label_set_text (GTK_LABEL (priv->label), sas->status); - } - else if (!match) { - const gchar *status; - /* If we didn't get any match at all, it means the last state - * was a custom one. Just switch to the first one. - */ - status = empathy_presence_get_default_message (states[0]); - - presence_chooser_reset_scroll_timeout (chooser); - empathy_idle_set_presence (priv->idle, states[0], status); - } - - g_list_foreach (list, (GFunc) g_free, NULL); - g_list_free (list); - - return TRUE; -} - -static GList * -presence_chooser_get_presets (EmpathyPresenceChooser *chooser) -{ - GList *list = NULL; - guint i; - - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { - GList *presets, *p; - StateAndStatus *sas; - const gchar *status; - - status = empathy_presence_get_default_message (states[i]); - sas = presence_chooser_state_and_status_new (states[i], status); - list = g_list_prepend (list, sas); - - /* Go to next state if we don't want messages for that state */ - if (!states[i+1]) { - continue; - } - - presets = empathy_status_presets_get (states[i], 5); - for (p = presets; p; p = p->next) { - sas = presence_chooser_state_and_status_new (states[i], p->data); - list = g_list_prepend (list, sas); - } - g_list_free (presets); - } - list = g_list_reverse (list); - - return list; -} - -static StateAndStatus * -presence_chooser_state_and_status_new (McPresence state, - const gchar *status) -{ - StateAndStatus *sas; - - sas = g_new0 (StateAndStatus, 1); - - sas->state = state; - sas->status = status; - - return sas; -} - -static gboolean -presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - McPresence state; - static gboolean on = FALSE; - - priv = GET_PRIV (chooser); - - if (on) { - state = priv->flash_state_1; - } else { - state = priv->flash_state_2; - } - - gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence (state), - GTK_ICON_SIZE_MENU); - - on = !on; - - return TRUE; -} - -static void -presence_chooser_flash_start (EmpathyPresenceChooser *chooser, - McPresence state_1, - McPresence state_2) -{ - EmpathyPresenceChooserPriv *priv; - - g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser)); - - priv = GET_PRIV (chooser); - - priv->flash_state_1 = state_1; - priv->flash_state_2 = state_2; - - if (!priv->flash_timeout_id) { - priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT, - (GSourceFunc) presence_chooser_flash_timeout_cb, - chooser); - } -} - -static void -presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, - McPresence state) -{ - EmpathyPresenceChooserPriv *priv; - - g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser)); - - priv = GET_PRIV (chooser); - - if (priv->flash_timeout_id) { - g_source_remove (priv->flash_timeout_id); - priv->flash_timeout_id = 0; - } - - gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence (state), - GTK_ICON_SIZE_MENU); - - priv->last_state = state; -} - -static gboolean -presence_chooser_button_press_event_cb (GtkWidget *chooser, - GdkEventButton *event, - gpointer user_data) -{ - if (event->button != 1 || event->type != GDK_BUTTON_PRESS) { - return FALSE; - } - - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser))) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser), TRUE); - return TRUE; - } - - return FALSE; -} - -static void -presence_chooser_toggled_cb (GtkWidget *chooser, - gpointer user_data) -{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chooser))) { - presence_chooser_menu_popup (EMPATHY_PRESENCE_CHOOSER (chooser)); - } else { - presence_chooser_menu_popdown (EMPATHY_PRESENCE_CHOOSER (chooser)); - } -} - -static void -presence_chooser_menu_popup (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - GtkWidget *menu; - - priv = GET_PRIV (chooser); - - if (priv->menu) { - return; - } - - menu = empathy_presence_chooser_create_menu (); - - g_signal_connect_after (menu, "selection-done", - G_CALLBACK (presence_chooser_menu_selection_done_cb), - chooser); - - g_signal_connect (menu, "destroy", - G_CALLBACK (presence_chooser_menu_destroy_cb), - chooser); - - gtk_menu_attach_to_widget (GTK_MENU (menu), - GTK_WIDGET (chooser), - presence_chooser_menu_detach); - - gtk_menu_popup (GTK_MENU (menu), - NULL, NULL, - (GtkMenuPositionFunc) presence_chooser_menu_align_func, - chooser, - 1, - gtk_get_current_event_time ()); - - priv->menu = menu; -} - -static void -presence_chooser_menu_popdown (EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - - priv = GET_PRIV (chooser); - - if (priv->menu) { - gtk_widget_destroy (priv->menu); - } -} - -static void -presence_chooser_menu_selection_done_cb (GtkMenuShell *menushell, - EmpathyPresenceChooser *chooser) -{ - gtk_widget_destroy (GTK_WIDGET (menushell)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser), FALSE); -} - -static void -presence_chooser_menu_destroy_cb (GtkWidget *menu, - EmpathyPresenceChooser *chooser) -{ - EmpathyPresenceChooserPriv *priv; - - priv = GET_PRIV (chooser); - - priv->menu = NULL; -} - -static void -presence_chooser_menu_detach (GtkWidget *attach_widget, - GtkMenu *menu) -{ - /* We don't need to do anything, but attaching the menu means - * we don't own the ref count and it is cleaned up properly. - */ -} - -static void -presence_chooser_menu_align_func (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - GtkWidget *widget) -{ - GtkRequisition req; - GdkScreen *screen; - gint screen_height; - - gtk_widget_size_request (GTK_WIDGET (menu), &req); - - gdk_window_get_origin (widget->window, x, y); - - *x += widget->allocation.x + 1; - *y += widget->allocation.y; - - screen = gtk_widget_get_screen (GTK_WIDGET (menu)); - screen_height = gdk_screen_get_height (screen); - - if (req.height > screen_height) { - /* Too big for screen height anyway. */ - *y = 0; - return; - } - - if ((*y + req.height + widget->allocation.height) > screen_height) { - /* Can't put it below the button. */ - *y -= req.height; - *y += 1; - } else { - /* Put menu below button. */ - *y += widget->allocation.height; - *y -= 1; - } - - *push_in = FALSE; -} - -GtkWidget * -empathy_presence_chooser_create_menu (void) -{ - const gchar *status; - GtkWidget *menu; - GtkWidget *item; - GtkWidget *image; - guint i; - - menu = gtk_menu_new (); - - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { - GList *list, *l; - - status = empathy_presence_get_default_message (states[i]); - presence_chooser_menu_add_item (menu, - status, - states[i]); - - if (states[i+1]) { - /* Set custom messages if wanted */ - list = empathy_status_presets_get (states[i], 5); - for (l = list; l; l = l->next) { - presence_chooser_menu_add_item (menu, - l->data, - states[i]); - } - g_list_free (list); - } - - } - - /* Separator. */ - item = gtk_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (item); - - /* Custom messages */ - item = gtk_image_menu_item_new_with_label (_("Custom messages...")); - image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - gtk_widget_show (image); - gtk_widget_show (item); - - g_signal_connect (item, - "activate", - G_CALLBACK (presence_chooser_custom_activate_cb), - NULL); - - return menu; -} - -static void -presence_chooser_menu_add_item (GtkWidget *menu, - const gchar *str, - McPresence state) -{ - GtkWidget *item; - GtkWidget *image; - const gchar *icon_name; - - item = gtk_image_menu_item_new_with_label (str); - icon_name = empathy_icon_name_for_presence (state); - - g_signal_connect (item, "activate", - G_CALLBACK (presence_chooser_noncustom_activate_cb), - NULL); - - image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); - gtk_widget_show (image); - - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - gtk_widget_show (item); - - g_object_set_data_full (G_OBJECT (item), - "status", g_strdup (str), - (GDestroyNotify) g_free); - - g_object_set_data (G_OBJECT (item), "state", GINT_TO_POINTER (state)); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); -} - -static void -presence_chooser_noncustom_activate_cb (GtkWidget *item, - gpointer user_data) -{ - McPresence state; - const gchar *status; - - status = g_object_get_data (G_OBJECT (item), "status"); - state = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "state")); - - presence_chooser_set_state (state, status); -} - -static void -presence_chooser_set_state (McPresence state, - const gchar *status) -{ - EmpathyIdle *idle; - - idle = empathy_idle_dup_singleton (); - empathy_idle_set_presence (idle, state, status); - g_object_unref (idle); -} - -static void -presence_chooser_custom_activate_cb (GtkWidget *item, - gpointer user_data) -{ - presence_chooser_dialog_show (); -} - -static McPresence -presence_chooser_dialog_get_selected (CustomMessageDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeIter iter; - McPresence presence = LAST_MC_PRESENCE; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->combobox_status)); - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->combobox_status), &iter)) { - gtk_tree_model_get (model, &iter, - COL_PRESENCE, &presence, - -1); - } - - return presence; -} - -static void -presence_chooser_dialog_status_changed_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - GtkListStore *store; - GtkTreeIter iter; - McPresence presence = LAST_MC_PRESENCE; - GList *messages, *l; - - presence = presence_chooser_dialog_get_selected (dialog); - - store = gtk_list_store_new (1, G_TYPE_STRING); - messages = empathy_status_presets_get (presence, -1); - for (l = messages; l; l = l->next) { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, l->data, -1); - } - - gtk_entry_set_text (GTK_ENTRY (dialog->entry_message), - messages ? messages->data : ""); - - g_list_free (messages); - - gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message), - GTK_TREE_MODEL (store)); - - g_object_unref (store); -} - -static void -presence_chooser_dialog_message_changed_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - McPresence presence; - GList *messages, *l; - const gchar *text; - gboolean found = FALSE; - - presence = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - - messages = empathy_status_presets_get (presence, -1); - for (l = messages; l; l = l->next) { - if (!tp_strdiff (text, l->data)) { - found = TRUE; - break; - } - } - g_list_free (messages); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save), - found); -} - -static void -presence_chooser_dialog_save_toggled_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - gboolean active; - McPresence state; - const gchar *text; - - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save)); - state = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - - if (active) { - empathy_status_presets_set_last (state, text); - } else { - empathy_status_presets_remove (state, text); - } -} - -static void -presence_chooser_dialog_setup (CustomMessageDialog *dialog) -{ - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeIter iter; - guint i; - - store = gtk_list_store_new (COL_COUNT, - G_TYPE_STRING, /* Icon name */ - G_TYPE_STRING, /* Label */ - MC_TYPE_PRESENCE); /* Presence */ - gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status), - GTK_TREE_MODEL (store)); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, - "icon-name", COL_ICON, - NULL); - g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, - "text", COL_LABEL, - NULL); - - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { - if (!states[i+1]) { - continue; - } - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_ICON, empathy_icon_name_for_presence (states[i]), - COL_LABEL, empathy_presence_get_default_message (states[i]), - COL_PRESENCE, states[i], - -1); - } - - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0); -} - -static void -presence_chooser_dialog_response_cb (GtkWidget *widget, - gint response, - CustomMessageDialog *dialog) -{ - if (response == GTK_RESPONSE_APPLY) { - McPresence state; - const gchar *text; - - state = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - - presence_chooser_set_state (state, text); - } - - gtk_widget_destroy (widget); -} - -static void -presence_chooser_dialog_destroy_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - - g_free (dialog); - message_dialog = NULL; -} - -static void -presence_chooser_dialog_show (void) -{ - GladeXML *glade; - gchar *filename; - - if (message_dialog) { - gtk_window_present (GTK_WINDOW (message_dialog->dialog)); - return; - } - - message_dialog = g_new0 (CustomMessageDialog, 1); - - filename = empathy_file_lookup ("empathy-presence-chooser.glade", - "libempathy-gtk"); - glade = empathy_glade_get_file (filename, - "custom_message_dialog", - NULL, - "custom_message_dialog", &message_dialog->dialog, - "checkbutton_save", &message_dialog->checkbutton_save, - "comboboxentry_message", &message_dialog->comboboxentry_message, - "combobox_status", &message_dialog->combobox_status, - NULL); - g_free (filename); - - empathy_glade_connect (glade, - message_dialog, - "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb, - "custom_message_dialog", "response", presence_chooser_dialog_response_cb, - "combobox_status", "changed", presence_chooser_dialog_status_changed_cb, - "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb, - NULL); - - g_object_unref (glade); - - /* Setup the message combobox */ - message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child; - gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE); - gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25); - g_signal_connect (message_dialog->entry_message, "changed", - G_CALLBACK (presence_chooser_dialog_message_changed_cb), - message_dialog); - - presence_chooser_dialog_setup (message_dialog); - - gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0); - - /* FIXME: Set transian for a window ? */ - - gtk_widget_show_all (message_dialog->dialog); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.glade b/gnome-2-26/libempathy-gtk/empathy-presence-chooser.glade deleted file mode 100644 index ba79529f6..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.glade +++ /dev/null @@ -1,132 +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="GtkDialog" id="custom_message_dialog"> - <property name="visible">True</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">Custom message</property> - <property name="resizable">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox6"> - <property name="visible">True</property> - <child> - <widget class="GtkTable" id="table1"> - <property name="visible">True</property> - <property name="border_width">5</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <widget class="GtkComboBox" id="combobox_status"> - <property name="visible">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkComboBoxEntry" id="comboboxentry_message"> - <property name="visible">True</property> - <child internal-child="entry"> - <widget class="GtkEntry" id="comboboxentry-entry1"> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkCheckButton" id="checkbutton_save"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Save message</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label472"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Message:</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label471"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Status:</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area6"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="closebutton1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="response_id">-6</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-apply</property> - <property name="use_stock">True</property> - <property name="response_id">-10</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.h b/gnome-2-26/libempathy-gtk/empathy-presence-chooser.h deleted file mode 100644 index 8bf8de5b5..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-presence-chooser.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * - * 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: Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_PRESENCE_CHOOSER_H__ -#define __EMPATHY_PRESENCE_CHOOSER_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_PRESENCE_CHOOSER (empathy_presence_chooser_get_type ()) -#define EMPATHY_PRESENCE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooser)) -#define EMPATHY_PRESENCE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserClass)) -#define EMPATHY_IS_PRESENCE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_PRESENCE_CHOOSER)) -#define EMPATHY_IS_PRESENCE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_PRESENCE_CHOOSER)) -#define EMPATHY_PRESENCE_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserClass)) - -typedef struct _EmpathyPresenceChooser EmpathyPresenceChooser; -typedef struct _EmpathyPresenceChooserClass EmpathyPresenceChooserClass; - -struct _EmpathyPresenceChooser { - GtkToggleButton parent; - gpointer priv; -}; - -struct _EmpathyPresenceChooserClass { - GtkToggleButtonClass parent_class; -}; - -GType empathy_presence_chooser_get_type (void) G_GNUC_CONST; -GtkWidget *empathy_presence_chooser_new (void); -GtkWidget *empathy_presence_chooser_create_menu (void); - -G_END_DECLS - -#endif /* __EMPATHY_PRESENCE_CHOOSER_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-profile-chooser.c b/gnome-2-26/libempathy-gtk/empathy-profile-chooser.c deleted file mode 100644 index fd68dd8b0..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-profile-chooser.c +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> - -#include <gtk/gtk.h> -#include <libmissioncontrol/mc-profile.h> -#include <libmissioncontrol/mc-protocol.h> - -#include "empathy-profile-chooser.h" -#include "empathy-ui-utils.h" - -enum { - COL_ICON, - COL_LABEL, - COL_PROFILE, - COL_COUNT -}; - -McProfile* -empathy_profile_chooser_get_selected (GtkWidget *widget) -{ - GtkTreeModel *model; - GtkTreeIter iter; - McProfile *profile = NULL; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { - gtk_tree_model_get (model, &iter, - COL_PROFILE, &profile, - -1); - } - - return profile; -} - -gint -empathy_profile_chooser_n_profiles (GtkWidget *widget) -{ - GtkTreeModel *model; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - - return gtk_tree_model_iter_n_children (model, NULL); -} - -static gint -profile_chooser_sort_profile_value (McProfile *profile) -{ - guint i; - const gchar *profile_name; - const gchar *names[] = {"jabber", - "salut", - "gtalk", - NULL}; - - profile_name = mc_profile_get_unique_name (profile); - - for (i = 0 ; names[i]; i++) { - if (strcmp (profile_name, names[i]) == 0) { - return i; - } - } - - return i; -} - -static gint -profile_chooser_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data) -{ - McProfile *profile_a; - McProfile *profile_b; - gint cmp; - - gtk_tree_model_get (model, iter_a, - COL_PROFILE, &profile_a, - -1); - gtk_tree_model_get (model, iter_b, - COL_PROFILE, &profile_b, - -1); - - cmp = profile_chooser_sort_profile_value (profile_a); - cmp -= profile_chooser_sort_profile_value (profile_b); - if (cmp == 0) { - cmp = strcmp (mc_profile_get_display_name (profile_a), - mc_profile_get_display_name (profile_b)); - } - - g_object_unref (profile_a); - g_object_unref (profile_b); - - return cmp; -} - -GtkWidget * -empathy_profile_chooser_new (void) -{ - GList *profiles, *l, *seen; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkWidget *combo_box; - GtkTreeIter iter; - gboolean iter_set = FALSE; - McManager *btf_cm; - - /* set up combo box with new store */ - store = gtk_list_store_new (COL_COUNT, - G_TYPE_STRING, /* Icon name */ - G_TYPE_STRING, /* Label */ - MC_TYPE_PROFILE); /* Profile */ - combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "icon-name", COL_ICON, - NULL); - g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "text", COL_LABEL, - NULL); - - btf_cm = mc_manager_lookup ("butterfly"); - profiles = mc_profiles_list (); - seen = NULL; - for (l = profiles; l; l = l->next) { - McProfile *profile; - McProtocol *protocol; - const gchar *unique_name; - - profile = l->data; - - /* Check if the CM is installed, otherwise skip that profile. - * Workaround SF bug #1688779 */ - protocol = mc_profile_get_protocol (profile); - if (!protocol) { - continue; - } - g_object_unref (protocol); - - /* Skip MSN-Haze if we have butterfly */ - unique_name = mc_profile_get_unique_name (profile); - if (btf_cm && strcmp (unique_name, "msn-haze") == 0) { - continue; - } - - if (g_list_find_custom (seen, unique_name, (GCompareFunc) strcmp)) { - continue; - } - seen = g_list_append (seen, (char*) unique_name); - - gtk_list_store_insert_with_values (store, &iter, 0, - COL_ICON, mc_profile_get_icon_name (profile), - COL_LABEL, mc_profile_get_display_name (profile), - COL_PROFILE, profile, - -1); - iter_set = TRUE; - } - - g_list_free (seen); - - if (btf_cm) { - g_object_unref (btf_cm); - } - - /* Set the profile sort function */ - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), - COL_PROFILE, - profile_chooser_sort_func, - NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COL_PROFILE, - GTK_SORT_ASCENDING); - - if (iter_set) { - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); - } - - mc_profiles_free_list (profiles); - g_object_unref (store); - - return combo_box; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-profile-chooser.h b/gnome-2-26/libempathy-gtk/empathy-profile-chooser.h deleted file mode 100644 index 8cdc33d67..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-profile-chooser.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_PROTOCOL_CHOOSER_H__ -#define __EMPATHY_PROTOCOL_CHOOSER_H__ - -#include <libmissioncontrol/mc-profile.h> - -G_BEGIN_DECLS - -GtkWidget * empathy_profile_chooser_new (void); -McProfile * empathy_profile_chooser_get_selected (GtkWidget *widget); -gint empathy_profile_chooser_n_profiles (GtkWidget *widget); - -G_END_DECLS -#endif /* __EMPATHY_PROTOCOL_CHOOSER_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-smiley-manager.c b/gnome-2-26/libempathy-gtk/empathy-smiley-manager.c deleted file mode 100644 index 9f7dd73c8..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-smiley-manager.c +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Dafydd Harrie <dafydd.harries@collabora.co.uk> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-smiley-manager.h" -#include "empathy-ui-utils.h" - -typedef struct _SmileyManagerTree SmileyManagerTree; - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathySmileyManager) -typedef struct { - SmileyManagerTree *tree; - GSList *smileys; -} EmpathySmileyManagerPriv; - -struct _SmileyManagerTree { - gunichar c; - GdkPixbuf *pixbuf; - GSList *childrens; -}; - -G_DEFINE_TYPE (EmpathySmileyManager, empathy_smiley_manager, G_TYPE_OBJECT); - -static EmpathySmileyManager *manager_singleton = NULL; - -static SmileyManagerTree * -smiley_manager_tree_new (gunichar c) -{ - SmileyManagerTree *tree; - - tree = g_slice_new0 (SmileyManagerTree); - tree->c = c; - tree->pixbuf = NULL; - tree->childrens = NULL; - - return tree; -} - -static void -smiley_manager_tree_free (SmileyManagerTree *tree) -{ - GSList *l; - - if (!tree) { - return; - } - - for (l = tree->childrens; l; l = l->next) { - smiley_manager_tree_free (l->data); - } - - if (tree->pixbuf) { - g_object_unref (tree->pixbuf); - } - g_slist_free (tree->childrens); - g_slice_free (SmileyManagerTree, tree); -} - -static EmpathySmiley * -smiley_new (GdkPixbuf *pixbuf, const gchar *str) -{ - EmpathySmiley *smiley; - - smiley = g_slice_new0 (EmpathySmiley); - if (pixbuf) { - smiley->pixbuf = g_object_ref (pixbuf); - } - smiley->str = g_strdup (str); - - return smiley; -} - -void -empathy_smiley_free (EmpathySmiley *smiley) -{ - if (!smiley) { - return; - } - - if (smiley->pixbuf) { - g_object_unref (smiley->pixbuf); - } - g_free (smiley->str); - g_slice_free (EmpathySmiley, smiley); -} - -static void -smiley_manager_finalize (GObject *object) -{ - EmpathySmileyManagerPriv *priv = GET_PRIV (object); - - smiley_manager_tree_free (priv->tree); - g_slist_foreach (priv->smileys, (GFunc) empathy_smiley_free, NULL); - g_slist_free (priv->smileys); -} - -static GObject * -smiley_manager_constructor (GType type, - guint n_props, - GObjectConstructParam *props) -{ - GObject *retval; - - if (manager_singleton) { - retval = g_object_ref (manager_singleton); - } else { - retval = G_OBJECT_CLASS (empathy_smiley_manager_parent_class)->constructor - (type, n_props, props); - - manager_singleton = EMPATHY_SMILEY_MANAGER (retval); - g_object_add_weak_pointer (retval, (gpointer) &manager_singleton); - } - - return retval; -} - -static void -empathy_smiley_manager_class_init (EmpathySmileyManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = smiley_manager_finalize; - object_class->constructor = smiley_manager_constructor; - - g_type_class_add_private (object_class, sizeof (EmpathySmileyManagerPriv)); -} - -static void -empathy_smiley_manager_init (EmpathySmileyManager *manager) -{ - EmpathySmileyManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, - EMPATHY_TYPE_SMILEY_MANAGER, EmpathySmileyManagerPriv); - - manager->priv = priv; - priv->tree = smiley_manager_tree_new ('\0'); - priv->smileys = NULL; - - empathy_smiley_manager_load (manager); -} - -EmpathySmileyManager * -empathy_smiley_manager_dup_singleton (void) -{ - return g_object_new (EMPATHY_TYPE_SMILEY_MANAGER, NULL); -} - -static SmileyManagerTree * -smiley_manager_tree_find_child (SmileyManagerTree *tree, gunichar c) -{ - GSList *l; - - for (l = tree->childrens; l; l = l->next) { - SmileyManagerTree *child = l->data; - - if (child->c == c) { - return child; - } - } - - return NULL; -} - -static SmileyManagerTree * -smiley_manager_tree_find_or_insert_child (SmileyManagerTree *tree, gunichar c) -{ - SmileyManagerTree *child; - - child = smiley_manager_tree_find_child (tree, c); - - if (!child) { - child = smiley_manager_tree_new (c); - tree->childrens = g_slist_prepend (tree->childrens, child); - } - - return child; -} - -static void -smiley_manager_tree_insert (SmileyManagerTree *tree, - GdkPixbuf *smiley, - const gchar *str) -{ - SmileyManagerTree *child; - - child = smiley_manager_tree_find_or_insert_child (tree, g_utf8_get_char (str)); - - str = g_utf8_next_char (str); - if (*str) { - smiley_manager_tree_insert (child, smiley, str); - return; - } - - child->pixbuf = g_object_ref (smiley); -} - -static void -smiley_manager_add_valist (EmpathySmileyManager *manager, - GdkPixbuf *smiley, - const gchar *first_str, - va_list var_args) -{ - EmpathySmileyManagerPriv *priv = GET_PRIV (manager); - const gchar *str; - - for (str = first_str; str; str = va_arg (var_args, gchar*)) { - smiley_manager_tree_insert (priv->tree, smiley, str); - } - - priv->smileys = g_slist_prepend (priv->smileys, smiley_new (smiley, first_str)); -} - -void -empathy_smiley_manager_add (EmpathySmileyManager *manager, - const gchar *icon_name, - const gchar *first_str, - ...) -{ - GdkPixbuf *smiley; - va_list var_args; - - g_return_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager)); - g_return_if_fail (!EMP_STR_EMPTY (icon_name)); - g_return_if_fail (!EMP_STR_EMPTY (first_str)); - - smiley = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); - if (smiley) { - va_start (var_args, first_str); - smiley_manager_add_valist (manager, smiley, first_str, var_args); - va_end (var_args); - g_object_unref (smiley); - } -} - -void -empathy_smiley_manager_add_from_pixbuf (EmpathySmileyManager *manager, - GdkPixbuf *smiley, - const gchar *first_str, - ...) -{ - va_list var_args; - - g_return_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager)); - g_return_if_fail (GDK_IS_PIXBUF (smiley)); - g_return_if_fail (!EMP_STR_EMPTY (first_str)); - - va_start (var_args, first_str); - smiley_manager_add_valist (manager, smiley, first_str, var_args); - va_end (var_args); -} - -void -empathy_smiley_manager_load (EmpathySmileyManager *manager) -{ - g_return_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager)); - - /* From fd.o icon-naming spec */ - empathy_smiley_manager_add (manager, "face-angel", "O:-)", "O:)", NULL); - empathy_smiley_manager_add (manager, "face-cool", "B-)", "B)", NULL); - empathy_smiley_manager_add (manager, "face-crying", ":'(", NULL); - empathy_smiley_manager_add (manager, "face-devilish", ">:-)", ">:)", NULL); - empathy_smiley_manager_add (manager, "face-embarrassed",":-[", ":[", ":-$", ":$", NULL); - empathy_smiley_manager_add (manager, "face-kiss", ":-*", ":*", NULL); - empathy_smiley_manager_add (manager, "face-monkey", ":-(|)", ":(|)", NULL); - empathy_smiley_manager_add (manager, "face-plain", ":-|", ":|", NULL); - empathy_smiley_manager_add (manager, "face-raspberry", ":-P", ":P", ":-p", ":p", NULL); - empathy_smiley_manager_add (manager, "face-sad", ":-(", ":(", NULL); - empathy_smiley_manager_add (manager, "face-smile", ":-)", ":)", NULL); - empathy_smiley_manager_add (manager, "face-smile-big", ":-D", ":D", ":-d", ":d", NULL); - empathy_smiley_manager_add (manager, "face-smirk", ":-!", ":!", NULL); - empathy_smiley_manager_add (manager, "face-surprise", ":-O", ":O", NULL); - empathy_smiley_manager_add (manager, "face-wink", ";-)", ";)", NULL); -} - -GSList * -empathy_smiley_manager_parse (EmpathySmileyManager *manager, - const gchar *text) -{ - EmpathySmileyManagerPriv *priv = GET_PRIV (manager); - EmpathySmiley *smiley; - SmileyManagerTree *cur_tree = priv->tree; - const gchar *t; - const gchar *cur_str = text; - GSList *smileys = NULL; - - g_return_val_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager), NULL); - g_return_val_if_fail (text != NULL, NULL); - - for (t = text; *t; t = g_utf8_next_char (t)) { - SmileyManagerTree *child; - gunichar c; - - c = g_utf8_get_char (t); - child = smiley_manager_tree_find_child (cur_tree, c); - - if (cur_tree == priv->tree) { - if (child) { - if (t > cur_str) { - smiley = smiley_new (NULL, g_strndup (cur_str, t - cur_str)); - smileys = g_slist_prepend (smileys, smiley); - } - cur_str = t; - cur_tree = child; - } - - continue; - } - - if (child) { - cur_tree = child; - continue; - } - - smiley = smiley_new (cur_tree->pixbuf, g_strndup (cur_str, t - cur_str)); - smileys = g_slist_prepend (smileys, smiley); - if (cur_tree->pixbuf) { - cur_str = t; - cur_tree = smiley_manager_tree_find_child (priv->tree, c); - - if (!cur_tree) { - cur_tree = priv->tree; - } - } else { - cur_str = t; - cur_tree = priv->tree; - } - } - - smiley = smiley_new (cur_tree->pixbuf, g_strndup (cur_str, t - cur_str)); - smileys = g_slist_prepend (smileys, smiley); - - return g_slist_reverse (smileys); -} - -GSList * -empathy_smiley_manager_get_all (EmpathySmileyManager *manager) -{ - EmpathySmileyManagerPriv *priv = GET_PRIV (manager); - - return priv->smileys; -} - -typedef struct { - EmpathySmileyManager *manager; - EmpathySmiley *smiley; - EmpathySmileyMenuFunc func; - gpointer user_data; -} ActivateData; - -static void -smiley_menu_data_free (gpointer user_data, - GClosure *closure) -{ - ActivateData *data = (ActivateData*) user_data; - - g_object_unref (data->manager); - g_slice_free (ActivateData, data); -} - -static void -smiley_menu_activate_cb (GtkMenuItem *menuitem, - gpointer user_data) -{ - ActivateData *data = (ActivateData*) user_data; - - data->func (data->manager, data->smiley, data->user_data); -} - -GtkWidget * -empathy_smiley_menu_new (EmpathySmileyManager *manager, - EmpathySmileyMenuFunc func, - gpointer user_data) -{ - EmpathySmileyManagerPriv *priv = GET_PRIV (manager); - GSList *l; - GtkWidget *menu; - gint x = 0; - gint y = 0; - - g_return_val_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager), NULL); - g_return_val_if_fail (func != NULL, NULL); - - menu = gtk_menu_new (); - - for (l = priv->smileys; l; l = l->next) { - EmpathySmiley *smiley; - GtkWidget *item; - GtkWidget *image; - ActivateData *data; - - smiley = l->data; - image = gtk_image_new_from_pixbuf (smiley->pixbuf); - - item = gtk_image_menu_item_new_with_label (""); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - - gtk_menu_attach (GTK_MENU (menu), item, - x, x + 1, y, y + 1); - - gtk_widget_set_tooltip_text (item, smiley->str); - - data = g_slice_new (ActivateData); - data->manager = g_object_ref (manager); - data->smiley = smiley; - data->func = func; - data->user_data = user_data; - - g_signal_connect_data (item, "activate", - G_CALLBACK (smiley_menu_activate_cb), - data, - smiley_menu_data_free, - 0); - - if (x > 3) { - y++; - x = 0; - } else { - x++; - } - } - - gtk_widget_show_all (menu); - - return menu; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-smiley-manager.h b/gnome-2-26/libempathy-gtk/empathy-smiley-manager.h deleted file mode 100644 index dae022dfa..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-smiley-manager.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Dafydd Harrie <dafydd.harries@collabora.co.uk> - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_SMILEY_MANAGER__H__ -#define __EMPATHY_SMILEY_MANAGER_H__ - -#include <glib-object.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_SMILEY_MANAGER (empathy_smiley_manager_get_type ()) -#define EMPATHY_SMILEY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_SMILEY_MANAGER, EmpathySmileyManager)) -#define EMPATHY_SMILEY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_SMILEY_MANAGER, EmpathySmileyManagerClass)) -#define EMPATHY_IS_SMILEY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_SMILEY_MANAGER)) -#define EMPATHY_IS_SMILEY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_SMILEY_MANAGER)) -#define EMPATHY_SMILEY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_SMILEY_MANAGER, EmpathySmileyManagerClass)) - -typedef struct _EmpathySmileyManager EmpathySmileyManager; -typedef struct _EmpathySmileyManagerClass EmpathySmileyManagerClass; - -struct _EmpathySmileyManager { - GObject parent; - gpointer priv; -}; - -struct _EmpathySmileyManagerClass { - GObjectClass parent_class; -}; - -typedef struct { - GdkPixbuf *pixbuf; - gchar *str; -} EmpathySmiley; - -typedef void (*EmpathySmileyMenuFunc) (EmpathySmileyManager *manager, - EmpathySmiley *smiley, - gpointer user_data); - -GType empathy_smiley_manager_get_type (void) G_GNUC_CONST; -EmpathySmileyManager *empathy_smiley_manager_dup_singleton (void); -void empathy_smiley_manager_load (EmpathySmileyManager *manager); -void empathy_smiley_manager_add (EmpathySmileyManager *manager, - const gchar *icon_name, - const gchar *first_str, - ...); -void empathy_smiley_manager_add_from_pixbuf (EmpathySmileyManager *manager, - GdkPixbuf *smiley, - const gchar *first_str, - ...); -GSList * empathy_smiley_manager_get_all (EmpathySmileyManager *manager); -GSList * empathy_smiley_manager_parse (EmpathySmileyManager *manager, - const gchar *text); -GtkWidget * empathy_smiley_menu_new (EmpathySmileyManager *manager, - EmpathySmileyMenuFunc func, - gpointer user_data); -void empathy_smiley_free (EmpathySmiley *smiley); - -G_END_DECLS - -#endif /* __EMPATHY_SMILEY_MANAGER_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.c b/gnome-2-26/libempathy-gtk/empathy-spell-dialog.c deleted file mode 100644 index c5914ce94..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.c +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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. - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtksizegroup.h> -#include <glade/glade.h> - -#include <libempathy/empathy-utils.h> - -#include "empathy-chat.h" -#include "empathy-spell.h" -#include "empathy-spell-dialog.h" -#include "empathy-ui-utils.h" - -typedef struct { - GtkWidget *window; - GtkWidget *button_replace; - GtkWidget *label_word; - GtkWidget *treeview_words; - - EmpathyChat *chat; - - gchar *word; - GtkTextIter start; - GtkTextIter end; -} EmpathySpellDialog; - -enum { - COL_SPELL_WORD, - COL_SPELL_COUNT -}; - -static void spell_dialog_model_populate_columns (EmpathySpellDialog *dialog); -static void spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog); -static void spell_dialog_model_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathySpellDialog *dialog); -static void spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection, - EmpathySpellDialog *dialog); -static void spell_dialog_model_setup (EmpathySpellDialog *dialog); -static void spell_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathySpellDialog *dialog); -static void spell_dialog_destroy_cb (GtkWidget *widget, - EmpathySpellDialog *dialog); - -static void -spell_dialog_model_populate_columns (EmpathySpellDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - guint col_offset; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words)); - - renderer = gtk_cell_renderer_text_new (); - col_offset = gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_words), - -1, _("Word"), - renderer, - "text", COL_SPELL_WORD, - NULL); - - g_object_set_data (G_OBJECT (renderer), - "column", GINT_TO_POINTER (COL_SPELL_WORD)); - - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_words), col_offset - 1); - gtk_tree_view_column_set_sort_column_id (column, COL_SPELL_WORD); - gtk_tree_view_column_set_resizable (column, FALSE); - gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); -} - -static void -spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog) -{ - GtkTreeModel *model; - GtkListStore *store; - GList *suggestions, *l; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words)); - store = GTK_LIST_STORE (model); - - suggestions = empathy_spell_get_suggestions (dialog->word); - for (l = suggestions; l; l=l->next) { - GtkTreeIter iter; - gchar *word; - - word = l->data; - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_SPELL_WORD, word, - -1); - } - - empathy_spell_free_suggestions (suggestions); -} - -static void -spell_dialog_model_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathySpellDialog *dialog) -{ - spell_dialog_response_cb (dialog->window, GTK_RESPONSE_OK, dialog); -} - -static void -spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection, - EmpathySpellDialog *dialog) -{ - gint count; - - count = gtk_tree_selection_count_selected_rows (treeselection); - gtk_widget_set_sensitive (dialog->button_replace, (count == 1)); -} - -static void -spell_dialog_model_setup (EmpathySpellDialog *dialog) -{ - GtkTreeView *view; - GtkListStore *store; - GtkTreeSelection *selection; - - view = GTK_TREE_VIEW (dialog->treeview_words); - - g_signal_connect (view, "row-activated", - G_CALLBACK (spell_dialog_model_row_activated_cb), - dialog); - - store = gtk_list_store_new (COL_SPELL_COUNT, - G_TYPE_STRING); /* word */ - - gtk_tree_view_set_model (view, GTK_TREE_MODEL (store)); - - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - g_signal_connect (selection, "changed", - G_CALLBACK (spell_dialog_model_selection_changed_cb), - dialog); - - spell_dialog_model_populate_columns (dialog); - spell_dialog_model_populate_suggestions (dialog); - - g_object_unref (store); -} - -static void -spell_dialog_destroy_cb (GtkWidget *widget, - EmpathySpellDialog *dialog) -{ - g_object_unref (dialog->chat); - g_free (dialog->word); - - g_free (dialog); -} - -static void -spell_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathySpellDialog *dialog) -{ - if (response == GTK_RESPONSE_OK) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - - gchar *new_word; - - view = GTK_TREE_VIEW (dialog->treeview_words); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return; - } - - gtk_tree_model_get (model, &iter, COL_SPELL_WORD, &new_word, -1); - - empathy_chat_correct_word (dialog->chat, - &dialog->start, - &dialog->end, - new_word); - - g_free (new_word); - } - - gtk_widget_destroy (dialog->window); -} - -void -empathy_spell_dialog_show (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *word) -{ - EmpathySpellDialog *dialog; - GladeXML *gui; - gchar *str; - gchar *filename; - - g_return_if_fail (chat != NULL); - g_return_if_fail (word != NULL); - - dialog = g_new0 (EmpathySpellDialog, 1); - - dialog->chat = g_object_ref (chat); - - dialog->word = g_strdup (word); - - dialog->start = *start; - dialog->end = *end; - - filename = empathy_file_lookup ("empathy-spell-dialog.glade", - "libempathy-gtk"); - gui = empathy_glade_get_file (filename, - "spell_dialog", - NULL, - "spell_dialog", &dialog->window, - "button_replace", &dialog->button_replace, - "label_word", &dialog->label_word, - "treeview_words", &dialog->treeview_words, - NULL); - g_free (filename); - - empathy_glade_connect (gui, - dialog, - "spell_dialog", "response", spell_dialog_response_cb, - "spell_dialog", "destroy", spell_dialog_destroy_cb, - NULL); - - g_object_unref (gui); - - str = g_markup_printf_escaped ("%s:\n<b>%s</b>", - _("Suggestions for the word"), - word); - - gtk_label_set_markup (GTK_LABEL (dialog->label_word), str); - g_free (str); - - spell_dialog_model_setup (dialog); - - gtk_widget_show (dialog->window); -} diff --git a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.glade b/gnome-2-26/libempathy-gtk/empathy-spell-dialog.glade deleted file mode 100644 index 3ce1d5b56..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.glade +++ /dev/null @@ -1,130 +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="GtkDialog" id="spell_dialog"> - <property name="border_width">5</property> - <property name="title" translatable="yes">Spell Checker</property> - <property name="modal">True</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="default_width">275</property> - <property name="default_height">225</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox7"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkVBox" id="vbox128"> - <property name="visible">True</property> - <property name="border_width">5</property> - <property name="spacing">6</property> - <child> - <widget class="GtkLabel" id="label_word"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Suggestions for the word:</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow9"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <widget class="GtkTreeView" id="treeview_words"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">False</property> - </widget> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area7"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <child> - <widget class="GtkButton" id="button_cancel"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="response_id">-6</property> - </widget> - </child> - <child> - <widget class="GtkButton" id="button_replace"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="response_id">-5</property> - <child> - <widget class="GtkAlignment" id="alignment6"> - <property name="visible">True</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <child> - <widget class="GtkHBox" id="hbox135"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <widget class="GtkImage" id="image245"> - <property name="visible">True</property> - <property name="stock">gtk-convert</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label594"> - <property name="visible">True</property> - <property name="label">_Replace</property> - <property name="use_underline">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.h b/gnome-2-26/libempathy-gtk/empathy-spell-dialog.h deleted file mode 100644 index ce0218812..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-spell-dialog.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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: Martyn Russell <martyn@imendio.com> - * Richard Hult <richard@imendio.com> - */ - -#ifndef __EMPATHY_SPELL_DIALOG_H__ -#define __EMPATHY_SPELL_DIALOG_H__ - -#include <gtk/gtktextiter.h> -#include "empathy-chat.h" - -G_BEGIN_DECLS - -void empathy_spell_dialog_show (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *word); - -G_END_DECLS - -#endif /* __EMPATHY_SPELL_DIALOG_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-spell.c b/gnome-2-26/libempathy-gtk/empathy-spell.c deleted file mode 100644 index 914c0c78d..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-spell.c +++ /dev/null @@ -1,445 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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: Martyn Russell <martyn@imendio.com> - * Richard Hult <richard@imendio.com> - */ - -#include "config.h" - -#include <string.h> -#include <stdlib.h> - -#include <glib/gi18n-lib.h> - -#ifdef HAVE_ENCHANT -#include <enchant.h> -#endif - -#include "empathy-spell.h" -#include "empathy-conf.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#ifdef HAVE_ENCHANT - -typedef struct { - EnchantBroker *config; - EnchantDict *speller; -} SpellLanguage; - -#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes" -#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale" - -static GHashTable *iso_code_names = NULL; -static GList *languages = NULL; -static gboolean empathy_conf_notify_inited = FALSE; - -static void -spell_iso_codes_parse_start_tag (GMarkupParseContext *ctx, - const gchar *element_name, - const gchar **attr_names, - const gchar **attr_values, - gpointer data, - GError **error) -{ - const gchar *ccode_longB, *ccode_longT, *ccode; - const gchar *lang_name; - - if (!g_str_equal (element_name, "iso_639_entry") || - attr_names == NULL || attr_values == NULL) { - return; - } - - ccode = NULL; - ccode_longB = NULL; - ccode_longT = NULL; - lang_name = NULL; - - while (*attr_names && *attr_values) { - if (g_str_equal (*attr_names, "iso_639_1_code")) { - if (**attr_values) { - ccode = *attr_values; - } - } - else if (g_str_equal (*attr_names, "iso_639_2B_code")) { - if (**attr_values) { - ccode_longB = *attr_values; - } - } - else if (g_str_equal (*attr_names, "iso_639_2T_code")) { - if (**attr_values) { - ccode_longT = *attr_values; - } - } - else if (g_str_equal (*attr_names, "name")) { - lang_name = *attr_values; - } - - attr_names++; - attr_values++; - } - - if (!lang_name) { - return; - } - - if (ccode) { - g_hash_table_insert (iso_code_names, - g_strdup (ccode), - g_strdup (lang_name)); - } - - if (ccode_longB) { - g_hash_table_insert (iso_code_names, - g_strdup (ccode_longB), - g_strdup (lang_name)); - } - - if (ccode_longT) { - g_hash_table_insert (iso_code_names, - g_strdup (ccode_longT), - g_strdup (lang_name)); - } -} - -static void -spell_iso_code_names_init (void) -{ - GError *err = NULL; - gchar *buf; - gsize buf_len; - - iso_code_names = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, g_free); - - bindtextdomain ("iso_639", ISO_CODES_LOCALESDIR); - bind_textdomain_codeset ("iso_639", "UTF-8"); - - /* FIXME: We should read this in chunks and pass to the parser. */ - if (g_file_get_contents (ISO_CODES_DATADIR "/iso_639.xml", &buf, &buf_len, &err)) { - GMarkupParseContext *ctx; - GMarkupParser parser = { - spell_iso_codes_parse_start_tag, - NULL, NULL, NULL, NULL - }; - - ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL); - if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err)) { - g_warning ("Failed to parse '%s': %s", - ISO_CODES_DATADIR"/iso_639.xml", - err->message); - g_error_free (err); - } - - g_markup_parse_context_free (ctx); - g_free (buf); - } else { - g_warning ("Failed to load '%s': %s", - ISO_CODES_DATADIR"/iso_639.xml", err->message); - g_error_free (err); - } -} - -static void -spell_notify_languages_cb (EmpathyConf *conf, - const gchar *key, - gpointer user_data) -{ - GList *l; - - DEBUG ("Resetting languages due to config change"); - - /* We just reset the languages list. */ - for (l = languages; l; l = l->next) { - SpellLanguage *lang; - - lang = l->data; - - enchant_broker_free_dict (lang->config, lang->speller); - enchant_broker_free (lang->config); - - g_slice_free (SpellLanguage, lang); - } - - g_list_free (languages); - languages = NULL; -} - -static void -spell_setup_languages (void) -{ - gchar *str; - - if (!empathy_conf_notify_inited) { - empathy_conf_notify_add (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES, - spell_notify_languages_cb, NULL); - - empathy_conf_notify_inited = TRUE; - } - - if (languages) { - return; - } - - if (empathy_conf_get_string (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES, - &str) && str) { - gchar **strv; - gint i; - - strv = g_strsplit (str, ",", -1); - - i = 0; - while (strv && strv[i]) { - SpellLanguage *lang; - - DEBUG ("Setting up language:'%s'", strv[i]); - - lang = g_slice_new0 (SpellLanguage); - - lang->config = enchant_broker_init (); - lang->speller = enchant_broker_request_dict (lang->config, strv[i]); - - languages = g_list_append (languages, lang); - i++; - } - - if (strv) { - g_strfreev (strv); - } - - g_free (str); - } -} - -const gchar * -empathy_spell_get_language_name (const gchar *code) -{ - const gchar *name; - - g_return_val_if_fail (code != NULL, NULL); - - if (!iso_code_names) { - spell_iso_code_names_init (); - } - - name = g_hash_table_lookup (iso_code_names, code); - if (!name) { - return NULL; - } - - return dgettext ("iso_639", name); -} - -static void -enumerate_dicts (const gchar * const lang_tag, - const gchar * const provider_name, - const gchar * const provider_desc, - const gchar * const provider_file, - gpointer user_data) -{ - GList **list = user_data; - gchar *lang = g_strdup (lang_tag); - - if (strchr (lang, '_')) { - /* cut country part out of language */ - strchr (lang, '_')[0] = '\0'; - } - - if (g_list_find_custom (*list, lang, (GCompareFunc) strcmp)) { - /* this language is already part of the list */ - g_free (lang); - return; - } - - *list = g_list_append (*list, g_strdup (lang)); -} - -GList * -empathy_spell_get_language_codes (void) -{ - EnchantBroker *broker; - GList *list_langs = NULL; - - broker = enchant_broker_init (); - enchant_broker_list_dicts (broker, enumerate_dicts, &list_langs); - enchant_broker_free (broker); - - return list_langs; -} - -void -empathy_spell_free_language_codes (GList *codes) -{ - g_list_foreach (codes, (GFunc) g_free, NULL); - g_list_free (codes); -} - -gboolean -empathy_spell_check (const gchar *word) -{ - gint enchant_result = 1; - const gchar *p; - gboolean digit; - gunichar c; - gint len; - GList *l; - - g_return_val_if_fail (word != NULL, FALSE); - - spell_setup_languages (); - - if (!languages) { - DEBUG ("No languages to check against"); - return TRUE; - } - - /* Ignore certain cases like numbers, etc. */ - for (p = word, digit = TRUE; *p && digit; p = g_utf8_next_char (p)) { - c = g_utf8_get_char (p); - digit = g_unichar_isdigit (c); - } - - if (digit) { - /* We don't spell check digits. */ - DEBUG ("Not spell checking word:'%s', it is all digits", word); - return TRUE; - } - - len = strlen (word); - for (l = languages; l; l = l->next) { - SpellLanguage *lang; - - lang = l->data; - - enchant_result = enchant_dict_check (lang->speller, word, len); - - if (enchant_result == 0) { - break; - } - } - - return (enchant_result == 0); -} - -GList * -empathy_spell_get_suggestions (const gchar *word) -{ - gint len; - GList *l1; - GList *suggestion_list = NULL; - - g_return_val_if_fail (word != NULL, NULL); - - spell_setup_languages (); - - len = strlen (word); - - for (l1 = languages; l1; l1 = l1->next) { - SpellLanguage *lang; - gchar **suggestions; - gsize i, number_of_suggestions; - - lang = l1->data; - - suggestions = enchant_dict_suggest (lang->speller, word, len, - &number_of_suggestions); - - for (i = 0; i < number_of_suggestions; i++) { - suggestion_list = g_list_append (suggestion_list, - g_strdup (suggestions[i])); - } - - if (suggestions) { - enchant_dict_free_string_list (lang->speller, suggestions); - } - } - - return suggestion_list; -} - -gboolean -empathy_spell_supported (void) -{ - if (g_getenv ("EMPATHY_SPELL_DISABLED")) { - DEBUG ("EMPATHY_SPELL_DISABLE env variable defined"); - return FALSE; - } - - return TRUE; -} - -#else /* not HAVE_ENCHANT */ - -gboolean -empathy_spell_supported (void) -{ - return FALSE; -} - -GList * -empathy_spell_get_suggestions (const gchar *word) -{ - DEBUG ("Support disabled, could not get suggestions"); - - return NULL; -} - -gboolean -empathy_spell_check (const gchar *word) -{ - DEBUG ("Support disabled, could not check spelling"); - - return TRUE; -} - -const gchar * -empathy_spell_get_language_name (const gchar *lang) -{ - DEBUG ("Support disabled, could not get language name"); - - return NULL; -} - -GList * -empathy_spell_get_language_codes (void) -{ - DEBUG ("Support disabled, could not get language codes"); - - return NULL; -} - -void -empathy_spell_free_language_codes (GList *codes) -{ -} - -#endif /* HAVE_ENCHANT */ - - -void -empathy_spell_free_suggestions (GList *suggestions) -{ - g_list_foreach (suggestions, (GFunc) g_free, NULL); - g_list_free (suggestions); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-spell.h b/gnome-2-26/libempathy-gtk/empathy-spell.h deleted file mode 100644 index 797997c0a..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-spell.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * 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: Martyn Russell <martyn@imendio.com> - * Richard Hult <richard@imendio.com> - */ - -#ifndef __EMPATHY_SPELL_H__ -#define __EMPATHY_SPELL_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -gboolean empathy_spell_supported (void); -const gchar *empathy_spell_get_language_name (const gchar *code); -GList *empathy_spell_get_language_codes (void); -void empathy_spell_free_language_codes (GList *codes); -gboolean empathy_spell_check (const gchar *word); -GList * empathy_spell_get_suggestions (const gchar *word); -void empathy_spell_free_suggestions (GList *suggestions); - -G_END_DECLS - -#endif /* __EMPATHY_SPELL_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-boxes.c b/gnome-2-26/libempathy-gtk/empathy-theme-boxes.c deleted file mode 100644 index 458543fa4..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-boxes.c +++ /dev/null @@ -1,414 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> - -#include <telepathy-glib/util.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-theme-boxes.h" -#include "empathy-ui-utils.h" -#include "empathy-conf.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#define MARGIN 4 -#define HEADER_PADDING 2 - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeBoxes) -typedef struct { - gboolean show_avatars; - guint notify_show_avatars_id; -} EmpathyThemeBoxesPriv; - -G_DEFINE_TYPE (EmpathyThemeBoxes, empathy_theme_boxes, EMPATHY_TYPE_CHAT_TEXT_VIEW); - -static void -theme_boxes_create_tags (EmpathyThemeBoxes *theme) -{ - GtkTextBuffer *buffer; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme)); - - gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_BOXES_TAG_HEADER, - "pixels-above-lines", HEADER_PADDING, - "pixels-below-lines", HEADER_PADDING, - NULL); - - gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_BOXES_TAG_HEADER_LINE, NULL); -} - -/* Pads a pixbuf to the specified size, by centering it in a larger transparent - * pixbuf. Returns a new ref. - */ -static GdkPixbuf * -theme_boxes_pad_to_size (GdkPixbuf *pixbuf, - gint width, - gint height, - gint extra_padding_right) -{ - gint src_width, src_height; - GdkPixbuf *padded; - gint x_offset, y_offset; - - src_width = gdk_pixbuf_get_width (pixbuf); - src_height = gdk_pixbuf_get_height (pixbuf); - - x_offset = (width - src_width) / 2; - y_offset = (height - src_height) / 2; - - padded = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf), - TRUE, /* alpha */ - gdk_pixbuf_get_bits_per_sample (pixbuf), - width + extra_padding_right, - height); - - gdk_pixbuf_fill (padded, 0); - - gdk_pixbuf_copy_area (pixbuf, - 0, /* source coords */ - 0, - src_width, - src_height, - padded, - x_offset, /* dest coords */ - y_offset); - - return padded; -} - -typedef struct { - GdkPixbuf *pixbuf; - gchar *token; -} AvatarData; - -static void -theme_boxes_avatar_cache_data_free (gpointer ptr) -{ - AvatarData *data = ptr; - - g_object_unref (data->pixbuf); - g_free (data->token); - g_slice_free (AvatarData, data); -} - -static GdkPixbuf * -theme_boxes_get_avatar_pixbuf_with_cache (EmpathyContact *contact) -{ - AvatarData *data; - EmpathyAvatar *avatar; - GdkPixbuf *tmp_pixbuf; - GdkPixbuf *pixbuf = NULL; - - /* Check if avatar is in cache and if it's up to date */ - avatar = empathy_contact_get_avatar (contact); - data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache"); - if (data) { - if (avatar && !tp_strdiff (avatar->token, data->token)) { - /* We have the avatar in cache */ - return data->pixbuf; - } - } - - /* Avatar not in cache, create pixbuf */ - tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32); - if (tmp_pixbuf) { - pixbuf = theme_boxes_pad_to_size (tmp_pixbuf, 32, 32, 6); - g_object_unref (tmp_pixbuf); - } - if (!pixbuf) { - return NULL; - } - - /* Insert new pixbuf in cache */ - data = g_slice_new0 (AvatarData); - data->token = g_strdup (avatar->token); - data->pixbuf = pixbuf; - - g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache", - data, theme_boxes_avatar_cache_data_free); - - return data->pixbuf; -} - -static void -table_size_allocate_cb (GtkWidget *view, - GtkAllocation *allocation, - GtkWidget *box) -{ - gint width, height; - - gtk_widget_get_size_request (box, NULL, &height); - - width = allocation->width; - - width -= \ - gtk_text_view_get_right_margin (GTK_TEXT_VIEW (view)) - \ - gtk_text_view_get_left_margin (GTK_TEXT_VIEW (view)); - width -= 2 * MARGIN; - width -= 2 * HEADER_PADDING; - - gtk_widget_set_size_request (box, width, height); -} - -static void -theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme, - EmpathyMessage *msg) -{ - EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme); - EmpathyThemeBoxesPriv*priv = GET_PRIV (theme); - EmpathyContact *contact; - EmpathyContact *last_contact; - GdkPixbuf *avatar = NULL; - GtkTextBuffer *buffer; - const gchar *name; - GtkTextIter iter; - GtkWidget *label1, *label2; - GtkTextChildAnchor *anchor; - GtkWidget *box; - gchar *str; - time_t time; - gchar *tmp; - GtkTextIter start; - gboolean color_set; - GtkTextTagTable *table; - GtkTextTag *tag; - - contact = empathy_message_get_sender (msg); - name = empathy_contact_get_name (contact); - last_contact = empathy_chat_text_view_get_last_contact (view); - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme)); - - DEBUG ("Maybe add fancy header"); - - /* Only insert a header if the previously inserted block is not the same - * as this one. This catches all the different cases: - */ - if (last_contact && empathy_contact_equal (last_contact, contact)) { - return; - } - - empathy_chat_text_view_append_spacing (view); - - /* Insert header line */ - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, - &iter, - "\n", - -1, - EMPATHY_THEME_BOXES_TAG_HEADER_LINE, - NULL); - - gtk_text_buffer_get_end_iter (buffer, &iter); - anchor = gtk_text_buffer_create_child_anchor (buffer, &iter); - - /* Create a hbox for the header and resize it when the view allocation - * changes */ - box = gtk_hbox_new (FALSE, 0); - g_signal_connect_object (view, "size-allocate", - G_CALLBACK (table_size_allocate_cb), - box, 0); - - /* Add avatar to the box if needed */ - if (priv->show_avatars) { - avatar = theme_boxes_get_avatar_pixbuf_with_cache (contact); - if (avatar) { - GtkWidget *image; - - image = gtk_image_new_from_pixbuf (avatar); - - gtk_box_pack_start (GTK_BOX (box), image, - FALSE, TRUE, 2); - } - } - - /* Add contact alias */ - str = g_markup_printf_escaped ("<b>%s</b>", name); - label1 = g_object_new (GTK_TYPE_LABEL, - "label", str, - "use-markup", TRUE, - "xalign", 0.0, - NULL); - g_free (str); - - /* Add the message receive time */ - time = empathy_message_get_timestamp (msg); - tmp = empathy_time_to_string_local (time, - EMPATHY_TIME_FORMAT_DISPLAY_SHORT); - str = g_strdup_printf ("<i>%s</i>", tmp); - label2 = g_object_new (GTK_TYPE_LABEL, - "label", str, - "use-markup", TRUE, - "xalign", 1.0, - NULL); - g_free (tmp); - g_free (str); - - /* Set foreground color of labels to the same color than the header tag. */ - table = gtk_text_buffer_get_tag_table (buffer); - tag = gtk_text_tag_table_lookup (table, EMPATHY_THEME_BOXES_TAG_HEADER); - g_object_get (tag, "foreground-set", &color_set, NULL); - if (color_set) { - GdkColor color; - g_object_get (tag, "foreground-gdk", &color, NULL); - gtk_widget_modify_fg (label1, GTK_STATE_NORMAL, &color); - gtk_widget_modify_fg (label2, GTK_STATE_NORMAL, &color); - } - - /* Pack labels into the box */ - gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.5); - gtk_misc_set_alignment (GTK_MISC (label2), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (box), label1, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box), label2, TRUE, TRUE, 0); - - /* Add the header box to the text view */ - gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (view), - box, - anchor); - gtk_widget_show_all (box); - - /* Insert a header line */ - gtk_text_buffer_get_end_iter (buffer, &iter); - start = iter; - gtk_text_iter_backward_char (&start); - gtk_text_buffer_apply_tag_by_name (buffer, - EMPATHY_THEME_BOXES_TAG_HEADER, - &start, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, - &iter, - "\n", - -1, - EMPATHY_THEME_BOXES_TAG_HEADER, - NULL); - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert_with_tags_by_name (buffer, - &iter, - "\n", - -1, - EMPATHY_THEME_BOXES_TAG_HEADER_LINE, - NULL); -} - -static void -theme_boxes_append_message (EmpathyChatTextView *view, - EmpathyMessage *message) -{ - EmpathyContact *sender; - - theme_boxes_maybe_append_header (EMPATHY_THEME_BOXES (view), message); - - sender = empathy_message_get_sender (message); - if (empathy_message_get_tptype (message) == - TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) { - gchar *body; - - body = g_strdup_printf (" * %s %s", - empathy_contact_get_name (sender), - empathy_message_get_body (message)); - empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view), - body, - EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION); - } else { - empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view), - empathy_message_get_body (message), - EMPATHY_CHAT_TEXT_VIEW_TAG_BODY); - } -} - -static void -theme_boxes_notify_show_avatars_cb (EmpathyConf *conf, - const gchar *key, - gpointer user_data) -{ - EmpathyThemeBoxesPriv *priv = GET_PRIV (user_data); - - empathy_conf_get_bool (conf, key, &priv->show_avatars); -} - -static void -theme_boxes_finalize (GObject *object) -{ - EmpathyThemeBoxesPriv *priv = GET_PRIV (object); - - empathy_conf_notify_remove (empathy_conf_get (), - priv->notify_show_avatars_id); - - G_OBJECT_CLASS (empathy_theme_boxes_parent_class)->finalize (object); -} - -static void -empathy_theme_boxes_class_init (EmpathyThemeBoxesClass *class) -{ - GObjectClass *object_class; - EmpathyChatTextViewClass *chat_text_view_class; - - object_class = G_OBJECT_CLASS (class); - chat_text_view_class = EMPATHY_CHAT_TEXT_VIEW_CLASS (class); - - object_class->finalize = theme_boxes_finalize; - chat_text_view_class->append_message = theme_boxes_append_message; - - g_type_class_add_private (object_class, sizeof (EmpathyThemeBoxesPriv)); -} - -static void -empathy_theme_boxes_init (EmpathyThemeBoxes *theme) -{ - EmpathyThemeBoxesPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme, - EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesPriv); - - theme->priv = priv; - - theme_boxes_create_tags (theme); - - priv->notify_show_avatars_id = - empathy_conf_notify_add (empathy_conf_get (), - EMPATHY_PREFS_UI_SHOW_AVATARS, - theme_boxes_notify_show_avatars_cb, - theme); - - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_UI_SHOW_AVATARS, - &priv->show_avatars); - - /* Define margin */ - g_object_set (theme, - "left-margin", MARGIN, - "right-margin", MARGIN, - NULL); -} - -EmpathyThemeBoxes * -empathy_theme_boxes_new (void) -{ - return g_object_new (EMPATHY_TYPE_THEME_BOXES, - "only-if-date", TRUE, - NULL); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-boxes.h b/gnome-2-26/libempathy-gtk/empathy-theme-boxes.h deleted file mode 100644 index fed7ceea0..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-boxes.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_THEME_BOXES_H__ -#define __EMPATHY_THEME_BOXES_H__ - -#include <glib-object.h> - -#include "empathy-chat-text-view.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_THEME_BOXES (empathy_theme_boxes_get_type ()) -#define EMPATHY_THEME_BOXES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxes)) -#define EMPATHY_THEME_BOXES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesClass)) -#define EMPATHY_IS_THEME_BOXES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_THEME_BOXES)) -#define EMPATHY_IS_THEME_BOXES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_THEME_BOXES)) -#define EMPATHY_THEME_BOXES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesClass)) - -typedef struct _EmpathyThemeBoxes EmpathyThemeBoxes; -typedef struct _EmpathyThemeBoxesClass EmpathyThemeBoxesClass; - -struct _EmpathyThemeBoxes { - EmpathyChatTextView parent; - gpointer priv; -}; - -struct _EmpathyThemeBoxesClass { - EmpathyChatTextViewClass parent_class; -}; - -#define EMPATHY_THEME_BOXES_TAG_HEADER "fancy-header" -#define EMPATHY_THEME_BOXES_TAG_HEADER_LINE "fancy-header-line" - -GType empathy_theme_boxes_get_type (void) G_GNUC_CONST; -EmpathyThemeBoxes *empathy_theme_boxes_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_THEME_BOXES_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-irc.c b/gnome-2-26/libempathy-gtk/empathy-theme-irc.c deleted file mode 100644 index 479108ce3..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-irc.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <glib/gi18n-lib.h> - -#include <libempathy/empathy-utils.h> -#include "empathy-theme-irc.h" -#include "empathy-ui-utils.h" - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeIrc) -typedef struct { - gpointer dummy; -} EmpathyThemeIrcPriv; - -G_DEFINE_TYPE (EmpathyThemeIrc, empathy_theme_irc, EMPATHY_TYPE_CHAT_TEXT_VIEW); - -static void -theme_irc_create_tags (EmpathyThemeIrc *theme) -{ - GtkTextBuffer *buffer; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme)); - - gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_SELF, NULL); - gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_OTHER, NULL); - gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT, NULL); -} - -static void -theme_irc_append_message (EmpathyChatTextView *view, - EmpathyMessage *message) -{ - GtkTextBuffer *buffer; - const gchar *name; - const gchar *nick_tag; - GtkTextIter iter; - gchar *tmp; - EmpathyContact *contact; - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - contact = empathy_message_get_sender (message); - name = empathy_contact_get_name (contact); - - if (empathy_message_get_tptype (message) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) { - tmp = g_strdup_printf (" * %s %s", - empathy_contact_get_name (contact), - empathy_message_get_body (message)); - empathy_chat_text_view_append_body (view, tmp, - EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION); - g_free (tmp); - return; - } - - if (empathy_contact_is_user (contact)) { - nick_tag = EMPATHY_THEME_IRC_TAG_NICK_SELF; - } else { - if (empathy_message_should_highlight (message)) { - nick_tag = EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT; - } else { - nick_tag = EMPATHY_THEME_IRC_TAG_NICK_OTHER; - } - } - - gtk_text_buffer_get_end_iter (buffer, &iter); - - /* The nickname. */ - tmp = g_strdup_printf ("%s: ", name); - gtk_text_buffer_insert_with_tags_by_name (buffer, - &iter, - tmp, - -1, - "cut", - nick_tag, - NULL); - g_free (tmp); - - /* The text body. */ - empathy_chat_text_view_append_body (view, - empathy_message_get_body (message), - EMPATHY_CHAT_TEXT_VIEW_TAG_BODY); -} - -static void -empathy_theme_irc_class_init (EmpathyThemeIrcClass *class) -{ - GObjectClass *object_class; - EmpathyChatTextViewClass *chat_text_view_class; - - object_class = G_OBJECT_CLASS (class); - chat_text_view_class = EMPATHY_CHAT_TEXT_VIEW_CLASS (class); - - chat_text_view_class->append_message = theme_irc_append_message; - - g_type_class_add_private (object_class, sizeof (EmpathyThemeIrcPriv)); -} - -static void -empathy_theme_irc_init (EmpathyThemeIrc *theme) -{ - EmpathyThemeIrcPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme, - EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcPriv); - - theme->priv = priv; - - theme_irc_create_tags (theme); - - /* Define margin */ - g_object_set (theme, - "left-margin", 3, - "right-margin", 3, - NULL); -} - -EmpathyThemeIrc * -empathy_theme_irc_new (void) -{ - return g_object_new (EMPATHY_TYPE_THEME_IRC, NULL); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-irc.h b/gnome-2-26/libempathy-gtk/empathy-theme-irc.h deleted file mode 100644 index 58d82ac0e..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-irc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_THEME_IRC_H__ -#define __EMPATHY_THEME_IRC_H__ - -#include <glib-object.h> - -#include "empathy-chat-text-view.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_THEME_IRC (empathy_theme_irc_get_type ()) -#define EMPATHY_THEME_IRC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrc)) -#define EMPATHY_THEME_IRC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcClass)) -#define EMPATHY_IS_THEME_IRC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_THEME_IRC)) -#define EMPATHY_IS_THEME_IRC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_THEME_IRC)) -#define EMPATHY_THEME_IRC_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcClass)) - -typedef struct _EmpathyThemeIrc EmpathyThemeIrc; -typedef struct _EmpathyThemeIrcClass EmpathyThemeIrcClass; - -struct _EmpathyThemeIrc { - EmpathyChatTextView parent; - gpointer priv; -}; - -struct _EmpathyThemeIrcClass { - EmpathyChatTextViewClass parent_class; -}; - -#define EMPATHY_THEME_IRC_TAG_NICK_SELF "irc-nick-self" -#define EMPATHY_THEME_IRC_TAG_NICK_OTHER "irc-nick-other" -#define EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT "irc-nick-highlight" - -GType empathy_theme_irc_get_type (void) G_GNUC_CONST; -EmpathyThemeIrc *empathy_theme_irc_new (void); - -G_END_DECLS - -#endif /* __EMPATHY_THEME_IRC_H__ */ - diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-manager.c b/gnome-2-26/libempathy-gtk/empathy-theme-manager.c deleted file mode 100644 index a67536fb4..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-manager.c +++ /dev/null @@ -1,490 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" - -#include <string.h> - -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> - -#include <telepathy-glib/util.h> -#include <libempathy/empathy-utils.h> - -#include "empathy-theme-manager.h" -#include "empathy-chat-view.h" -#include "empathy-conf.h" -#include "empathy-chat-text-view.h" -#include "empathy-theme-boxes.h" -#include "empathy-theme-irc.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeManager) -typedef struct { - gchar *name; - guint name_notify_id; - GtkSettings *settings; - GList *boxes_views; -} EmpathyThemeManagerPriv; - -enum { - THEME_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static const gchar *themes[] = { - "classic", N_("Classic"), - "simple", N_("Simple"), - "clean", N_("Clean"), - "blue", N_("Blue"), - NULL -}; - -G_DEFINE_TYPE (EmpathyThemeManager, empathy_theme_manager, G_TYPE_OBJECT); - -static void -theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color) -{ - g_snprintf (str_color, 10, - "#%02x%02x%02x", - gdk_color->red >> 8, - gdk_color->green >> 8, - gdk_color->blue >> 8); -} - -static EmpathyThemeIrc * -theme_manager_create_irc_view (EmpathyThemeManager *manager) -{ - EmpathyChatTextView *view; - EmpathyThemeIrc *theme; - - theme = empathy_theme_irc_new (); - view = EMPATHY_CHAT_TEXT_VIEW (theme); - - /* Define base tags */ - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING, - "size", 2000, - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME, - "foreground", "darkgrey", - "justification", GTK_JUSTIFY_CENTER, - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION, - "foreground", "brown4", - "style", PANGO_STYLE_ITALIC, - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY, - "foreground-set", FALSE, - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT, - "foreground", "PeachPuff4", - "justification", GTK_JUSTIFY_LEFT, - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK, - "foreground", "steelblue", - "underline", PANGO_UNDERLINE_SINGLE, - NULL); - - /* Define IRC tags */ - empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_SELF, - "foreground", "sea green", - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_OTHER, - "foreground", "skyblue4", - NULL); - empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT, - "foreground", "indian red", - "weight", PANGO_WEIGHT_BOLD, - NULL); - - return theme; -} - -static void -theme_manager_boxes_weak_notify_cb (gpointer data, - GObject *where_the_object_was) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (data); - - priv->boxes_views = g_list_remove (priv->boxes_views, where_the_object_was); -} - -static EmpathyThemeBoxes * -theme_manager_create_boxes_view (EmpathyThemeManager *manager) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (manager); - EmpathyThemeBoxes *theme; - - theme = empathy_theme_boxes_new (); - priv->boxes_views = g_list_prepend (priv->boxes_views, theme); - g_object_weak_ref (G_OBJECT (theme), - theme_manager_boxes_weak_notify_cb, - manager); - - return theme; -} - -static void -theme_manager_update_boxes_tags (EmpathyThemeBoxes *theme, - const gchar *header_foreground, - const gchar *header_background, - const gchar *header_line_background, - const gchar *action_foreground, - const gchar *time_foreground, - const gchar *event_foreground, - const gchar *link_foreground, - const gchar *text_foreground, - const gchar *text_background, - const gchar *highlight_foreground) - -{ - EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme); - GtkTextTag *tag; - - DEBUG ("Update view with new colors:\n" - "header_foreground = %s\n" - "header_background = %s\n" - "header_line_background = %s\n" - "action_foreground = %s\n" - "time_foreground = %s\n" - "event_foreground = %s\n" - "link_foreground = %s\n" - "text_foreground = %s\n" - "text_background = %s\n" - "highlight_foreground = %s\n", - header_foreground, header_background, header_line_background, - action_foreground, time_foreground, event_foreground, - link_foreground, text_foreground, text_background, - highlight_foreground); - - - /* FIXME: GtkTextTag don't support to set color properties to NULL. - * See bug #542523 */ - - #define TAG_SET(prop, prop_set, value) \ - if (value != NULL) { \ - g_object_set (tag, prop, value, NULL); \ - } else { \ - g_object_set (tag, prop_set, FALSE, NULL); \ - } - - /* Define base tags */ - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT, - "weight", PANGO_WEIGHT_BOLD, - "pixels-above-lines", 4, - NULL); - TAG_SET ("paragraph-background", "paragraph-background-set", text_background); - TAG_SET ("foreground", "foreground-set",highlight_foreground); - - empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING, - "size", 3000, - "pixels-above-lines", 8, - NULL); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME, - "justification", GTK_JUSTIFY_CENTER, - NULL); - TAG_SET ("foreground", "foreground-set", time_foreground); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION, - "style", PANGO_STYLE_ITALIC, - "pixels-above-lines", 4, - NULL); - TAG_SET ("paragraph-background", "paragraph-background-set", text_background); - TAG_SET ("foreground", "foreground-set", action_foreground); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY, - "pixels-above-lines", 4, - NULL); - TAG_SET ("paragraph-background", "paragraph-background-set", text_background); - TAG_SET ("foreground", "foreground-set", text_foreground); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT, - "justification", GTK_JUSTIFY_LEFT, - NULL); - TAG_SET ("foreground", "foreground-set", event_foreground); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK, - "underline", PANGO_UNDERLINE_SINGLE, - NULL); - TAG_SET ("foreground", "foreground-set", link_foreground); - - /* Define BOXES tags */ - tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER, - "weight", PANGO_WEIGHT_BOLD, - "foreground", header_foreground, - "paragraph-background", header_background, - NULL); - TAG_SET ("foreground", "foreground-set", header_foreground); - TAG_SET ("paragraph-background", "paragraph-background-set", header_background); - tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER_LINE, - "size", 1, - "paragraph-background", header_line_background, - NULL); - TAG_SET ("paragraph-background", "paragraph-background-set", header_line_background); - - #undef TAG_SET -} - -static void -theme_manager_update_simple_tags (EmpathyThemeBoxes *theme) -{ - GtkStyle *style; - gchar color1[10]; - gchar color2[10]; - gchar color3[10]; - gchar color4[10]; - - style = gtk_widget_get_default_style (); - - theme_manager_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color1); - theme_manager_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color2); - theme_manager_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color3); - theme_manager_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color4); - - theme_manager_update_boxes_tags (theme, - color4, /* header_foreground */ - color2, /* header_background */ - color3, /* header_line_background */ - color1, /* action_foreground */ - "darkgrey", /* time_foreground */ - "darkgrey", /* event_foreground */ - color1, /* link_foreground */ - NULL, /* text_foreground */ - NULL, /* text_background */ - NULL); /* highlight_foreground */ -} - -static void -theme_manager_update_boxes_theme (EmpathyThemeManager *manager, - EmpathyThemeBoxes *theme) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (manager); - - if (strcmp (priv->name, "simple") == 0) { - theme_manager_update_simple_tags (theme); - } - else if (strcmp (priv->name, "clean") == 0) { - theme_manager_update_boxes_tags (theme, - "black", /* header_foreground */ - "#efefdf", /* header_background */ - "#e3e3d3", /* header_line_background */ - "brown4", /* action_foreground */ - "darkgrey", /* time_foreground */ - "darkgrey", /* event_foreground */ - "#49789e", /* link_foreground */ - NULL, /* text_foreground */ - NULL, /* text_background */ - NULL); /* highlight_foreground */ - } - else if (strcmp (priv->name, "blue") == 0) { - theme_manager_update_boxes_tags (theme, - "black", /* header_foreground */ - "#88a2b4", /* header_background */ - "#7f96a4", /* header_line_background */ - "brown4", /* action_foreground */ - "darkgrey", /* time_foreground */ - "#7f96a4", /* event_foreground */ - "#49789e", /* link_foreground */ - "black", /* text_foreground */ - "#adbdc8", /* text_background */ - "black"); /* highlight_foreground */ - } -} - -EmpathyChatView * -empathy_theme_manager_create_view (EmpathyThemeManager *manager) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (manager); - EmpathyThemeBoxes *theme; - - g_return_val_if_fail (EMPATHY_IS_THEME_MANAGER (manager), NULL); - - DEBUG ("Using theme %s", priv->name); - - if (strcmp (priv->name, "classic") == 0) { - return EMPATHY_CHAT_VIEW (theme_manager_create_irc_view (manager)); - } - - theme = theme_manager_create_boxes_view (manager); - theme_manager_update_boxes_theme (manager, theme); - - return EMPATHY_CHAT_VIEW (theme); -} - -static void -theme_manager_color_hash_notify_cb (EmpathyThemeManager *manager) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (manager); - - /* FIXME: Make that work, it should update color when theme changes but - * it doesnt seems to work with all themes. */ - - if (strcmp (priv->name, "simple") == 0) { - GList *l; - - /* We are using the simple theme which use the GTK theme color, - * Update views to use the new color. */ - for (l = priv->boxes_views; l; l = l->next) { - theme_manager_update_simple_tags (EMPATHY_THEME_BOXES (l->data)); - } - } -} - -static gboolean -theme_manager_ensure_theme_exists (const gchar *name) -{ - gint i; - - if (EMP_STR_EMPTY (name)) { - return FALSE; - } - - for (i = 0; themes[i]; i += 2) { - if (strcmp (themes[i], name) == 0) { - return TRUE; - } - } - - return FALSE; -} - -static void -theme_manager_notify_name_cb (EmpathyConf *conf, - const gchar *key, - gpointer user_data) -{ - EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data); - EmpathyThemeManagerPriv *priv = GET_PRIV (manager); - gchar *name = NULL; - - if (!empathy_conf_get_string (conf, key, &name) || - !theme_manager_ensure_theme_exists (name) || - !tp_strdiff (priv->name, name)) { - if (!priv->name) { - priv->name = g_strdup ("classic"); - } - - g_free (name); - return; - } - - g_free (priv->name); - priv->name = name; - - if (!tp_strdiff (priv->name, "simple") || - !tp_strdiff (priv->name, "clean") || - !tp_strdiff (priv->name, "blue")) { - GList *l; - - /* The theme changes to a boxed one, we can update boxed views */ - for (l = priv->boxes_views; l; l = l->next) { - theme_manager_update_boxes_theme (manager, - EMPATHY_THEME_BOXES (l->data)); - } - } - - g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL); -} - -static void -theme_manager_finalize (GObject *object) -{ - EmpathyThemeManagerPriv *priv = GET_PRIV (object); - GList *l; - - empathy_conf_notify_remove (empathy_conf_get (), priv->name_notify_id); - g_free (priv->name); - - for (l = priv->boxes_views; l; l = l->next) { - g_object_weak_unref (G_OBJECT (l->data), - theme_manager_boxes_weak_notify_cb, - object); - } - g_list_free (priv->boxes_views); - - G_OBJECT_CLASS (empathy_theme_manager_parent_class)->finalize (object); -} - -static void -empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - signals[THEME_CHANGED] = - g_signal_new ("theme-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - g_type_class_add_private (object_class, sizeof (EmpathyThemeManagerPriv)); - - object_class->finalize = theme_manager_finalize; -} - -static void -empathy_theme_manager_init (EmpathyThemeManager *manager) -{ - EmpathyThemeManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, - EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerPriv); - - manager->priv = priv; - - /* Take the theme name and track changes */ - priv->name_notify_id = - empathy_conf_notify_add (empathy_conf_get (), - EMPATHY_PREFS_CHAT_THEME, - theme_manager_notify_name_cb, - manager); - theme_manager_notify_name_cb (empathy_conf_get (), - EMPATHY_PREFS_CHAT_THEME, - manager); - - /* Track GTK color changes */ - priv->settings = gtk_settings_get_default (); - g_signal_connect_swapped (priv->settings, "notify::color-hash", - G_CALLBACK (theme_manager_color_hash_notify_cb), - manager); -} - -EmpathyThemeManager * -empathy_theme_manager_get (void) -{ - static EmpathyThemeManager *manager = NULL; - - if (!manager) { - manager = g_object_new (EMPATHY_TYPE_THEME_MANAGER, NULL); - } - - return manager; -} - -const gchar ** -empathy_theme_manager_get_themes (void) -{ - return themes; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-theme-manager.h b/gnome-2-26/libempathy-gtk/empathy-theme-manager.h deleted file mode 100644 index 05661d306..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme-manager.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2005-2007 Imendio AB - * Copyright (C) 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: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_THEME_MANAGER_H__ -#define __EMPATHY_THEME_MANAGER_H__ - -#include <glib-object.h> -#include "empathy-chat-view.h" - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_THEME_MANAGER (empathy_theme_manager_get_type ()) -#define EMPATHY_THEME_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManager)) -#define EMPATHY_THEME_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerClass)) -#define EMPATHY_IS_THEME_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_THEME_MANAGER)) -#define EMPATHY_IS_THEME_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_THEME_MANAGER)) -#define EMPATHY_THEME_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerClass)) - -typedef struct _EmpathyThemeManager EmpathyThemeManager; -typedef struct _EmpathyThemeManagerClass EmpathyThemeManagerClass; - -struct _EmpathyThemeManager { - GObject parent; - gpointer priv; -}; - -struct _EmpathyThemeManagerClass { - GObjectClass parent_class; -}; - -GType empathy_theme_manager_get_type (void) G_GNUC_CONST; -EmpathyThemeManager * empathy_theme_manager_get (void); -const gchar ** empathy_theme_manager_get_themes (void); -EmpathyChatView * empathy_theme_manager_create_view (EmpathyThemeManager *manager); - -G_END_DECLS - -#endif /* __EMPATHY_THEME_MANAGER_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-theme.c b/gnome-2-26/libempathy-gtk/empathy-theme.c deleted file mode 100644 index ca4f66663..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-theme.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Imendio AB - * - * 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. - */ - -#include <config.h> - -#include <string.h> -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> - -#include <libempathy/empathy-utils.h> - -#include "empathy-chat.h" -#include "empathy-conf.h" -#include "empathy-theme.h" -#include "empathy-smiley-manager.h" - -/* Number of seconds between timestamps when using normal mode, 5 minutes. */ -#define TIMESTAMP_INTERVAL 300 - -#define SCHEMES "(https?|ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\ - "file|webcal|mailto)" -#define BODY "([^\\ ]+)" -#define END_BODY "([^\\ ]*[^,;\?><()\\ \"\\.])" -#define URI_REGEX "("SCHEMES"://"END_BODY")" \ - "|((mailto:)?"BODY"@"BODY"\\."END_BODY")"\ - "|((www|ftp)\\."END_BODY")" -static GRegex *uri_regex = NULL; - -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTheme) - -typedef struct { - EmpathySmileyManager *smiley_manager; - gboolean show_avatars; -} EmpathyThemePriv; - -static void theme_finalize (GObject *object); -static void theme_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void theme_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); - - -G_DEFINE_TYPE (EmpathyTheme, empathy_theme, G_TYPE_OBJECT); - -enum { - PROP_0, - PROP_SHOW_AVATARS -}; - -static void -empathy_theme_class_init (EmpathyThemeClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - - object_class->finalize = theme_finalize; - object_class->get_property = theme_get_property; - object_class->set_property = theme_set_property; - - class->update_view = NULL; - class->append_message = NULL; - class->append_event = NULL; - class->append_timestamp = NULL; - class->append_spacing = NULL; - - g_object_class_install_property (object_class, - PROP_SHOW_AVATARS, - g_param_spec_boolean ("show-avatars", - "", "", - TRUE, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (EmpathyThemePriv)); -} - -static void -empathy_theme_init (EmpathyTheme *theme) -{ - EmpathyThemePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme, - EMPATHY_TYPE_THEME, EmpathyThemePriv); - - theme->priv = priv; - priv->smiley_manager = empathy_smiley_manager_dup_singleton (); -} - -static void -theme_finalize (GObject *object) -{ - EmpathyThemePriv *priv; - - priv = GET_PRIV (object); - - if (priv->smiley_manager) { - g_object_unref (priv->smiley_manager); - } - - (G_OBJECT_CLASS (empathy_theme_parent_class)->finalize) (object); -} - -static void -theme_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - EmpathyThemePriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_SHOW_AVATARS: - g_value_set_boolean (value, priv->show_avatars); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -theme_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - EmpathyThemePriv *priv; - - priv = GET_PRIV (object); - - switch (param_id) { - case PROP_SHOW_AVATARS: - empathy_theme_set_show_avatars (EMPATHY_THEME (object), - g_value_get_boolean (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -void -empathy_theme_maybe_append_date_and_time (EmpathyTheme *theme, - EmpathyChatView *view, - EmpathyMessage *message) -{ - time_t timestamp; - GDate *date, *last_date; - gboolean append_date, append_time; - - date = empathy_message_get_date_and_time (message, ×tamp); - - last_date = g_date_new (); - g_date_set_time_t (last_date, empathy_chat_view_get_last_timestamp (view)); - - append_date = FALSE; - append_time = FALSE; - - if (g_date_compare (date, last_date) > 0) { - append_date = TRUE; - append_time = TRUE; - } - - g_date_free (last_date); - g_date_free (date); - - if (empathy_chat_view_get_last_timestamp (view) + TIMESTAMP_INTERVAL < timestamp) { - append_time = TRUE; - } - - if (append_time || append_date) { - empathy_theme_append_timestamp (theme, view, message, - append_date, append_time); - } -} - -void -empathy_theme_update_view (EmpathyTheme *theme, - EmpathyChatView *view) -{ - if (!EMPATHY_THEME_GET_CLASS(theme)->update_view) { - g_error ("Theme must override update_view"); - } - - EMPATHY_THEME_GET_CLASS(theme)->update_view (theme, view); -} - -void -empathy_theme_append_message (EmpathyTheme *theme, - EmpathyChatView *view, - EmpathyMessage *message) -{ - if (!EMPATHY_THEME_GET_CLASS(theme)->append_message) { - g_warning ("Theme should override append_message"); - return; - } - - EMPATHY_THEME_GET_CLASS(theme)->append_message (theme, view, message); -} - -static void -theme_insert_text_with_emoticons (GtkTextBuffer *buf, - GtkTextIter *iter, - const gchar *str, - EmpathySmileyManager *smiley_manager) -{ - gboolean use_smileys = FALSE; - GSList *smileys, *l; - - empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SHOW_SMILEYS, - &use_smileys); - - if (!use_smileys) { - gtk_text_buffer_insert (buf, iter, str, -1); - return; - } - - smileys = empathy_smiley_manager_parse (smiley_manager, str); - for (l = smileys; l; l = l->next) { - EmpathySmiley *smiley; - - smiley = l->data; - if (smiley->pixbuf) { - gtk_text_buffer_insert_pixbuf (buf, iter, smiley->pixbuf); - } else { - gtk_text_buffer_insert (buf, iter, smiley->str, -1); - } - empathy_smiley_free (smiley); - } - g_slist_free (smileys); -} - -void -empathy_theme_append_text (EmpathyTheme *theme, - EmpathyChatView *view, - const gchar *body, - const gchar *tag, - const gchar *link_tag) -{ - EmpathyThemePriv *priv; - GtkTextBuffer *buffer; - GtkTextIter start_iter, end_iter; - GtkTextMark *mark; - GtkTextIter iter; - GMatchInfo *match_info; - gboolean match; - gint last = 0; - gint s = 0, e = 0; - gchar *tmp; - - priv = GET_PRIV (theme); - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - gtk_text_buffer_get_end_iter (buffer, &start_iter); - mark = gtk_text_buffer_create_mark (buffer, NULL, &start_iter, TRUE); - - if (!uri_regex) { - uri_regex = g_regex_new (URI_REGEX, 0, 0, NULL); - } - - for (match = g_regex_match (uri_regex, body, 0, &match_info); match; - match = g_match_info_next (match_info, NULL)) { - if (!g_match_info_fetch_pos (match_info, 0, &s, &e)) - continue; - - if (s > last) { - tmp = empathy_substring (body, last, s); - - gtk_text_buffer_get_end_iter (buffer, &iter); - theme_insert_text_with_emoticons (buffer, - &iter, - tmp, - priv->smiley_manager); - g_free (tmp); - } - - tmp = empathy_substring (body, s, e); - - gtk_text_buffer_get_end_iter (buffer, &iter); - if (!link_tag) { - gtk_text_buffer_insert (buffer, &iter, - tmp, -1); - } else { - gtk_text_buffer_insert_with_tags_by_name (buffer, - &iter, - tmp, - -1, - link_tag, - "link", - NULL); - } - - g_free (tmp); - last = e; - } - g_match_info_free (match_info); - - if (last < strlen (body)) { - gtk_text_buffer_get_end_iter (buffer, &iter); - theme_insert_text_with_emoticons (buffer, - &iter, - body + last, - priv->smiley_manager); - } - - gtk_text_buffer_get_end_iter (buffer, &iter); - gtk_text_buffer_insert (buffer, &iter, "\n", 1); - - /* Apply the style to the inserted text. */ - gtk_text_buffer_get_iter_at_mark (buffer, &start_iter, mark); - gtk_text_buffer_get_end_iter (buffer, &end_iter); - - gtk_text_buffer_apply_tag_by_name (buffer, - tag, - &start_iter, - &end_iter); - - gtk_text_buffer_delete_mark (buffer, mark); -} - -void -empathy_theme_append_event (EmpathyTheme *theme, - EmpathyChatView *view, - const gchar *str) -{ - if (!EMPATHY_THEME_GET_CLASS(theme)->append_event) { - return; - } - - EMPATHY_THEME_GET_CLASS(theme)->append_event (theme, view, str); -} - -void -empathy_theme_append_spacing (EmpathyTheme *theme, - EmpathyChatView *view) -{ - if (!EMPATHY_THEME_GET_CLASS(theme)->append_spacing) { - return; - } - - EMPATHY_THEME_GET_CLASS(theme)->append_spacing (theme, view); -} - - -void -empathy_theme_append_timestamp (EmpathyTheme *theme, - EmpathyChatView *view, - EmpathyMessage *message, - gboolean show_date, - gboolean show_time) -{ - if (!EMPATHY_THEME_GET_CLASS(theme)->append_timestamp) { - return; - } - - EMPATHY_THEME_GET_CLASS(theme)->append_timestamp (theme, view, - message, show_date, - show_time); -} - -gboolean -empathy_theme_get_show_avatars (EmpathyTheme *theme) -{ - EmpathyThemePriv *priv; - - g_return_val_if_fail (EMPATHY_IS_THEME (theme), FALSE); - - priv = GET_PRIV (theme); - - return priv->show_avatars; -} - -void -empathy_theme_set_show_avatars (EmpathyTheme *theme, gboolean show) -{ - EmpathyThemePriv *priv; - - g_return_if_fail (EMPATHY_IS_THEME (theme)); - - priv = GET_PRIV (theme); - - priv->show_avatars = show; - - g_object_notify (G_OBJECT (theme), "show-avatars"); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-ui-utils.c b/gnome-2-26/libempathy-gtk/empathy-ui-utils.c deleted file mode 100644 index 9e8928e8e..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-ui-utils.c +++ /dev/null @@ -1,1711 +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> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - * - * Part of this file is copied from GtkSourceView (gtksourceiter.c): - * Paolo Maggi - * Jeroen Zwartepoorte - */ - -#include <config.h> - -#include <string.h> -#include <X11/Xatom.h> -#include <gdk/gdkx.h> -#include <glib/gi18n-lib.h> -#include <gtk/gtk.h> -#include <gio/gio.h> -#include <glade/glade.h> -#include <canberra-gtk.h> - -#include <libmissioncontrol/mc-profile.h> - -#include "empathy-ui-utils.h" -#include "empathy-images.h" -#include "empathy-conf.h" - -#define DEBUG_FLAG EMPATHY_DEBUG_OTHER -#include <libempathy/empathy-debug.h> -#include <libempathy/empathy-utils.h> -#include <libempathy/empathy-dispatcher.h> -#include <libempathy/empathy-idle.h> -#include <libempathy/empathy-tp-file.h> - -#define SCHEMES "(https?|s?ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\ - "file|webcal|mailto)" -#define BODY "([^\\ \\n]+)" -#define END_BODY "([^\\ \\n]*[^,;\?><()\\ \"\\.\\n])" -#define URI_REGEX "("SCHEMES"://"END_BODY")" \ - "|((mailto:)?"BODY"@"BODY"\\."END_BODY")"\ - "|((www|ftp)\\."END_BODY")" - -void -empathy_gtk_init (void) -{ - static gboolean initialized = FALSE; - - if (initialized) - return; - - empathy_init (); - gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), - PKGDATADIR G_DIR_SEPARATOR_S "icons"); - - initialized = TRUE; -} - -GRegex * -empathy_uri_regex_dup_singleton (void) -{ - static GRegex *uri_regex = NULL; - - /* We intentionally leak the regex so it's not recomputed */ - if (!uri_regex) { - uri_regex = g_regex_new (URI_REGEX, 0, 0, NULL); - } - - return g_regex_ref (uri_regex); -} - -struct SizeData { - gint width; - gint height; - gboolean preserve_aspect_ratio; -}; - -static GladeXML * -get_glade_file (const gchar *filename, - const gchar *root, - const gchar *domain, - const gchar *first_required_widget, - va_list args) -{ - GladeXML *gui; - const char *name; - GtkWidget **widget_ptr; - - DEBUG ("Loading glade file %s", filename); - - gui = glade_xml_new (filename, root, domain); - - if (!gui) { - g_warning ("Couldn't find necessary glade file '%s'", filename); - } - - for (name = first_required_widget; name; name = va_arg (args, char *)) { - widget_ptr = va_arg (args, void *); - - *widget_ptr = glade_xml_get_widget (gui, name); - - if (!*widget_ptr) { - g_warning ("Glade file '%s' is missing widget '%s'.", - filename, name); - continue; - } - } - - return gui; -} - -void -empathy_glade_get_file_simple (const gchar *filename, - const gchar *root, - const gchar *domain, - const gchar *first_required_widget, ...) -{ - va_list args; - GladeXML *gui; - - va_start (args, first_required_widget); - - gui = get_glade_file (filename, - root, - domain, - first_required_widget, - args); - - va_end (args); - - if (gui) { - g_object_unref (gui); - } -} - -GladeXML * -empathy_glade_get_file (const gchar *filename, - const gchar *root, - const gchar *domain, - const gchar *first_required_widget, ...) -{ - va_list args; - GladeXML *gui; - - va_start (args, first_required_widget); - - gui = get_glade_file (filename, - root, - domain, - first_required_widget, - args); - - va_end (args); - - if (!gui) { - return NULL; - } - - return gui; -} - -void -empathy_glade_connect (GladeXML *gui, - gpointer user_data, - gchar *first_widget, ...) -{ - va_list args; - const gchar *name; - const gchar *signal; - GtkWidget *widget; - gpointer *callback; - - va_start (args, first_widget); - - for (name = first_widget; name; name = va_arg (args, char *)) { - signal = va_arg (args, void *); - callback = va_arg (args, void *); - - widget = glade_xml_get_widget (gui, name); - if (!widget) { - g_warning ("Glade file is missing widget '%s', aborting", - name); - continue; - } - - g_signal_connect (widget, - signal, - G_CALLBACK (callback), - user_data); - } - - va_end (args); -} - -void -empathy_glade_setup_size_group (GladeXML *gui, - GtkSizeGroupMode mode, - gchar *first_widget, ...) -{ - va_list args; - GtkWidget *widget; - GtkSizeGroup *size_group; - const gchar *name; - - va_start (args, first_widget); - - size_group = gtk_size_group_new (mode); - - for (name = first_widget; name; name = va_arg (args, char *)) { - widget = glade_xml_get_widget (gui, name); - if (!widget) { - g_warning ("Glade file is missing widget '%s'", name); - continue; - } - - gtk_size_group_add_widget (size_group, widget); - } - - g_object_unref (size_group); - - va_end (args); -} - -const gchar * -empathy_icon_name_from_account (McAccount *account) -{ - McProfile *profile; - - profile = mc_account_get_profile (account); - - return mc_profile_get_icon_name (profile); -} - -const gchar * -empathy_icon_name_for_presence (McPresence presence) -{ - switch (presence) { - case MC_PRESENCE_AVAILABLE: - return EMPATHY_IMAGE_AVAILABLE; - case MC_PRESENCE_DO_NOT_DISTURB: - return EMPATHY_IMAGE_BUSY; - case MC_PRESENCE_AWAY: - return EMPATHY_IMAGE_AWAY; - case MC_PRESENCE_EXTENDED_AWAY: - return EMPATHY_IMAGE_EXT_AWAY; - case MC_PRESENCE_HIDDEN: - return EMPATHY_IMAGE_HIDDEN; - case MC_PRESENCE_OFFLINE: - case MC_PRESENCE_UNSET: - return EMPATHY_IMAGE_OFFLINE; - default: - g_assert_not_reached (); - } - - return NULL; -} - -const gchar * -empathy_icon_name_for_contact (EmpathyContact *contact) -{ - McPresence presence; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), - EMPATHY_IMAGE_OFFLINE); - - presence = empathy_contact_get_presence (contact); - return empathy_icon_name_for_presence (presence); -} - -GdkPixbuf * -empathy_pixbuf_from_data (gchar *data, - gsize data_size) -{ - return empathy_pixbuf_from_data_and_mime (data, data_size, NULL); -} - -GdkPixbuf * -empathy_pixbuf_from_data_and_mime (gchar *data, - gsize data_size, - gchar **mime_type) -{ - GdkPixbufLoader *loader; - GdkPixbufFormat *format; - GdkPixbuf *pixbuf = NULL; - gchar **mime_types; - GError *error = NULL; - - if (!data) { - return NULL; - } - - loader = gdk_pixbuf_loader_new (); - if (!gdk_pixbuf_loader_write (loader, data, data_size, &error)) { - DEBUG ("Failed to write to pixbuf loader: %s", - error ? error->message : "No error given"); - goto out; - } - if (!gdk_pixbuf_loader_close (loader, &error)) { - DEBUG ("Failed to close pixbuf loader: %s", - error ? error->message : "No error given"); - goto out; - } - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) { - g_object_ref (pixbuf); - - if (mime_type != NULL) { - format = gdk_pixbuf_loader_get_format (loader); - mime_types = gdk_pixbuf_format_get_mime_types (format); - - *mime_type = g_strdup (*mime_types); - if (mime_types[1] != NULL) { - DEBUG ("Loader supports more than one mime " - "type! Picking the first one, %s", - *mime_type); - } - g_strfreev (mime_types); - } - } - -out: - g_clear_error (&error); - g_object_unref (loader); - - return pixbuf; -} - -static void -pixbuf_from_avatar_size_prepared_cb (GdkPixbufLoader *loader, - int width, - int height, - struct SizeData *data) -{ - g_return_if_fail (width > 0 && height > 0); - - if (data->preserve_aspect_ratio && (data->width > 0 || data->height > 0)) { - if (width < data->width && height < data->height) { - width = width; - height = height; - } - - if (data->width < 0) { - width = width * (double) data->height / (gdouble) height; - height = data->height; - } else if (data->height < 0) { - height = height * (double) data->width / (double) width; - width = data->width; - } else if ((double) height * (double) data->width > - (double) width * (double) data->height) { - width = 0.5 + (double) width * (double) data->height / (double) height; - height = data->height; - } else { - height = 0.5 + (double) height * (double) data->width / (double) width; - width = data->width; - } - } else { - if (data->width > 0) { - width = data->width; - } - - if (data->height > 0) { - height = data->height; - } - } - - gdk_pixbuf_loader_set_size (loader, width, height); -} - -static void -empathy_avatar_pixbuf_roundify (GdkPixbuf *pixbuf) -{ - gint width, height, rowstride; - guchar *pixels; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - pixels = gdk_pixbuf_get_pixels (pixbuf); - - if (width < 6 || height < 6) { - return; - } - - /* Top left */ - pixels[3] = 0; - pixels[7] = 0x80; - pixels[11] = 0xC0; - pixels[rowstride + 3] = 0x80; - pixels[rowstride * 2 + 3] = 0xC0; - - /* Top right */ - pixels[width * 4 - 1] = 0; - pixels[width * 4 - 5] = 0x80; - pixels[width * 4 - 9] = 0xC0; - pixels[rowstride + (width * 4) - 1] = 0x80; - pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; - - /* Bottom left */ - pixels[(height - 1) * rowstride + 3] = 0; - pixels[(height - 1) * rowstride + 7] = 0x80; - pixels[(height - 1) * rowstride + 11] = 0xC0; - pixels[(height - 2) * rowstride + 3] = 0x80; - pixels[(height - 3) * rowstride + 3] = 0xC0; - - /* Bottom right */ - pixels[height * rowstride - 1] = 0; - pixels[(height - 1) * rowstride - 1] = 0x80; - pixels[(height - 2) * rowstride - 1] = 0xC0; - pixels[height * rowstride - 5] = 0x80; - pixels[height * rowstride - 9] = 0xC0; -} - -static gboolean -empathy_gdk_pixbuf_is_opaque (GdkPixbuf *pixbuf) -{ - gint width, height, rowstride, i; - guchar *pixels; - guchar *row; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - pixels = gdk_pixbuf_get_pixels (pixbuf); - - row = pixels; - for (i = 3; i < rowstride; i+=4) { - if (row[i] < 0xfe) { - return FALSE; - } - } - - for (i = 1; i < height - 1; i++) { - row = pixels + (i*rowstride); - if (row[3] < 0xfe || row[rowstride-1] < 0xfe) { - return FALSE; - } - } - - row = pixels + ((height-1) * rowstride); - for (i = 3; i < rowstride; i+=4) { - if (row[i] < 0xfe) { - return FALSE; - } - } - - return TRUE; -} - -GdkPixbuf * -empathy_pixbuf_from_avatar_scaled (EmpathyAvatar *avatar, - gint width, - gint height) -{ - GdkPixbuf *pixbuf; - GdkPixbufLoader *loader; - struct SizeData data; - GError *error = NULL; - - if (!avatar) { - return NULL; - } - - data.width = width; - data.height = height; - data.preserve_aspect_ratio = TRUE; - - loader = gdk_pixbuf_loader_new (); - - g_signal_connect (loader, "size-prepared", - G_CALLBACK (pixbuf_from_avatar_size_prepared_cb), - &data); - - if (!gdk_pixbuf_loader_write (loader, avatar->data, avatar->len, &error)) { - g_warning ("Couldn't write avatar image:%p with " - "length:%" G_GSIZE_FORMAT " to pixbuf loader: %s", - avatar->data, avatar->len, error->message); - g_error_free (error); - return NULL; - } - - gdk_pixbuf_loader_close (loader, NULL); - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (!gdk_pixbuf_get_has_alpha (pixbuf)) { - GdkPixbuf *rounded_pixbuf; - - rounded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf)); - gdk_pixbuf_copy_area (pixbuf, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - rounded_pixbuf, - 0, 0); - pixbuf = rounded_pixbuf; - } else { - g_object_ref (pixbuf); - } - - if (empathy_gdk_pixbuf_is_opaque (pixbuf)) { - empathy_avatar_pixbuf_roundify (pixbuf); - } - - g_object_unref (loader); - - return pixbuf; -} - -GdkPixbuf * -empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact *contact, - gint width, - gint height) -{ - EmpathyAvatar *avatar; - - g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); - - avatar = empathy_contact_get_avatar (contact); - - return empathy_pixbuf_from_avatar_scaled (avatar, width, height); -} - -GdkPixbuf * -empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, gint max_size) -{ - gint width, height; - gdouble factor; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - - if (width > 0 && (width > max_size || height > max_size)) { - factor = (gdouble) max_size / MAX (width, height); - - width = width * factor; - height = height * factor; - - return gdk_pixbuf_scale_simple (pixbuf, - width, height, - GDK_INTERP_HYPER); - } - - return g_object_ref (pixbuf); -} - -GdkPixbuf * -empathy_pixbuf_from_icon_name_sized (const gchar *icon_name, - gint size) -{ - GtkIconTheme *theme; - GdkPixbuf *pixbuf; - GError *error = NULL; - - if (!icon_name) { - return NULL; - } - - theme = gtk_icon_theme_get_default (); - - pixbuf = gtk_icon_theme_load_icon (theme, - icon_name, - size, - 0, - &error); - if (error) { - DEBUG ("Error loading icon: %s", error->message); - g_clear_error (&error); - } - - return pixbuf; -} - -GdkPixbuf * -empathy_pixbuf_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size) -{ - gint w, h; - gint size = 48; - - if (!icon_name) { - return NULL; - } - - if (gtk_icon_size_lookup (icon_size, &w, &h)) { - size = (w + h) / 2; - } - - return empathy_pixbuf_from_icon_name_sized (icon_name, size); -} - -/* Stolen from GtkSourceView, hence the weird intendation. Please keep it like - * that to make it easier to apply changes from the original code. - */ -#define GTK_TEXT_UNKNOWN_CHAR 0xFFFC - -/* this function acts like g_utf8_offset_to_pointer() except that if it finds a - * decomposable character it consumes the decomposition length from the given - * offset. So it's useful when the offset was calculated for the normalized - * version of str, but we need a pointer to str itself. */ -static const gchar * -pointer_from_offset_skipping_decomp (const gchar *str, gint offset) -{ - gchar *casefold, *normal; - const gchar *p, *q; - - p = str; - while (offset > 0) - { - q = g_utf8_next_char (p); - casefold = g_utf8_casefold (p, q - p); - normal = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - offset -= g_utf8_strlen (normal, -1); - g_free (casefold); - g_free (normal); - p = q; - } - return p; -} - -static const gchar * -g_utf8_strcasestr (const gchar *haystack, const gchar *needle) -{ - gsize needle_len; - gsize haystack_len; - const gchar *ret = NULL; - gchar *p; - gchar *casefold; - gchar *caseless_haystack; - gint i; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - casefold = g_utf8_casefold (haystack, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - needle_len = g_utf8_strlen (needle, -1); - haystack_len = g_utf8_strlen (caseless_haystack, -1); - - if (needle_len == 0) - { - ret = (gchar *)haystack; - goto finally_1; - } - - if (haystack_len < needle_len) - { - ret = NULL; - goto finally_1; - } - - p = (gchar*)caseless_haystack; - needle_len = strlen (needle); - i = 0; - - while (*p) - { - if ((strncmp (p, needle, needle_len) == 0)) - { - ret = pointer_from_offset_skipping_decomp (haystack, i); - goto finally_1; - } - - p = g_utf8_next_char (p); - i++; - } - -finally_1: - g_free (caseless_haystack); - - return ret; -} - -static gboolean -g_utf8_caselessnmatch (const char *s1, const char *s2, - gssize n1, gssize n2) -{ - gchar *casefold; - gchar *normalized_s1; - gchar *normalized_s2; - gint len_s1; - gint len_s2; - gboolean ret = FALSE; - - g_return_val_if_fail (s1 != NULL, FALSE); - g_return_val_if_fail (s2 != NULL, FALSE); - g_return_val_if_fail (n1 > 0, FALSE); - g_return_val_if_fail (n2 > 0, FALSE); - - casefold = g_utf8_casefold (s1, n1); - normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - casefold = g_utf8_casefold (s2, n2); - normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - len_s1 = strlen (normalized_s1); - len_s2 = strlen (normalized_s2); - - if (len_s1 < len_s2) - goto finally_2; - - ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0); - -finally_2: - g_free (normalized_s1); - g_free (normalized_s2); - - return ret; -} - -static void -forward_chars_with_skipping (GtkTextIter *iter, - gint count, - gboolean skip_invisible, - gboolean skip_nontext, - gboolean skip_decomp) -{ - gint i; - - g_return_if_fail (count >= 0); - - i = count; - - while (i > 0) - { - gboolean ignored = FALSE; - - /* minimal workaround to avoid the infinite loop of bug #168247. - * It doesn't fix the problemjust the symptom... - */ - if (gtk_text_iter_is_end (iter)) - return; - - if (skip_nontext && gtk_text_iter_get_char (iter) == GTK_TEXT_UNKNOWN_CHAR) - ignored = TRUE; - - if (!ignored && skip_invisible && - /* _gtk_text_btree_char_is_invisible (iter)*/ FALSE) - ignored = TRUE; - - if (!ignored && skip_decomp) - { - /* being UTF8 correct sucks; this accounts for extra - offsets coming from canonical decompositions of - UTF8 characters (e.g. accented characters) which - g_utf8_normalize() performs */ - gchar *normal; - gchar buffer[6]; - gint buffer_len; - - buffer_len = g_unichar_to_utf8 (gtk_text_iter_get_char (iter), buffer); - normal = g_utf8_normalize (buffer, buffer_len, G_NORMALIZE_NFD); - i -= (g_utf8_strlen (normal, -1) - 1); - g_free (normal); - } - - gtk_text_iter_forward_char (iter); - - if (!ignored) - --i; - } -} - -static gboolean -lines_match (const GtkTextIter *start, - const gchar **lines, - gboolean visible_only, - gboolean slice, - GtkTextIter *match_start, - GtkTextIter *match_end) -{ - GtkTextIter next; - gchar *line_text; - const gchar *found; - gint offset; - - if (*lines == NULL || **lines == '\0') - { - if (match_start) - *match_start = *start; - if (match_end) - *match_end = *start; - return TRUE; - } - - next = *start; - gtk_text_iter_forward_line (&next); - - /* No more text in buffer, but *lines is nonempty */ - if (gtk_text_iter_equal (start, &next)) - return FALSE; - - if (slice) - { - if (visible_only) - line_text = gtk_text_iter_get_visible_slice (start, &next); - else - line_text = gtk_text_iter_get_slice (start, &next); - } - else - { - if (visible_only) - line_text = gtk_text_iter_get_visible_text (start, &next); - else - line_text = gtk_text_iter_get_text (start, &next); - } - - if (match_start) /* if this is the first line we're matching */ - { - found = g_utf8_strcasestr (line_text, *lines); - } - else - { - /* If it's not the first line, we have to match from the - * start of the line. - */ - if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), - strlen (*lines))) - found = line_text; - else - found = NULL; - } - - if (found == NULL) - { - g_free (line_text); - return FALSE; - } - - /* Get offset to start of search string */ - offset = g_utf8_strlen (line_text, found - line_text); - - next = *start; - - /* If match start needs to be returned, set it to the - * start of the search string. - */ - forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); - if (match_start) - { - *match_start = next; - } - - /* Go to end of search string */ - forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); - - g_free (line_text); - - ++lines; - - if (match_end) - *match_end = next; - - /* pass NULL for match_start, since we don't need to find the - * start again. - */ - return lines_match (&next, lines, visible_only, slice, NULL, match_end); -} - -/* strsplit () that retains the delimiter as part of the string. */ -static gchar ** -strbreakup (const char *string, - const char *delimiter, - gint max_tokens) -{ - GSList *string_list = NULL, *slist; - gchar **str_array, *s, *casefold, *new_string; - guint i, n = 1; - - g_return_val_if_fail (string != NULL, NULL); - g_return_val_if_fail (delimiter != NULL, NULL); - - if (max_tokens < 1) - max_tokens = G_MAXINT; - - s = strstr (string, delimiter); - if (s) - { - guint delimiter_len = strlen (delimiter); - - do - { - guint len; - - len = s - string + delimiter_len; - new_string = g_new (gchar, len + 1); - strncpy (new_string, string, len); - new_string[len] = 0; - casefold = g_utf8_casefold (new_string, -1); - g_free (new_string); - new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - string_list = g_slist_prepend (string_list, new_string); - n++; - string = s + delimiter_len; - s = strstr (string, delimiter); - } while (--max_tokens && s); - } - - if (*string) - { - n++; - casefold = g_utf8_casefold (string, -1); - new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - string_list = g_slist_prepend (string_list, new_string); - } - - str_array = g_new (gchar*, n); - - i = n - 1; - - str_array[i--] = NULL; - for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; - - g_slist_free (string_list); - - return str_array; -} - -gboolean -empathy_text_iter_forward_search (const GtkTextIter *iter, - const gchar *str, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit) -{ - gchar **lines = NULL; - GtkTextIter match; - gboolean retval = FALSE; - GtkTextIter search; - gboolean visible_only; - gboolean slice; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - if (limit && gtk_text_iter_compare (iter, limit) >= 0) - return FALSE; - - if (*str == '\0') { - /* If we can move one char, return the empty string there */ - match = *iter; - - if (gtk_text_iter_forward_char (&match)) { - if (limit && gtk_text_iter_equal (&match, limit)) { - return FALSE; - } - - if (match_start) { - *match_start = match; - } - if (match_end) { - *match_end = match; - } - return TRUE; - } else { - return FALSE; - } - } - - visible_only = TRUE; - slice = FALSE; - - /* locate all lines */ - lines = strbreakup (str, "\n", -1); - - search = *iter; - - do { - /* This loop has an inefficient worst-case, where - * gtk_text_iter_get_text () is called repeatedly on - * a single line. - */ - GtkTextIter end; - - if (limit && gtk_text_iter_compare (&search, limit) >= 0) { - break; - } - - if (lines_match (&search, (const gchar**)lines, - visible_only, slice, &match, &end)) { - if (limit == NULL || - (limit && gtk_text_iter_compare (&end, limit) <= 0)) { - retval = TRUE; - - if (match_start) { - *match_start = match; - } - if (match_end) { - *match_end = end; - } - } - break; - } - } while (gtk_text_iter_forward_line (&search)); - - g_strfreev ((gchar**)lines); - - return retval; -} - -static const gchar * -g_utf8_strrcasestr (const gchar *haystack, const gchar *needle) -{ - gsize needle_len; - gsize haystack_len; - const gchar *ret = NULL; - gchar *p; - gchar *casefold; - gchar *caseless_haystack; - gint i; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - casefold = g_utf8_casefold (haystack, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); - g_free (casefold); - - needle_len = g_utf8_strlen (needle, -1); - haystack_len = g_utf8_strlen (caseless_haystack, -1); - - if (needle_len == 0) - { - ret = (gchar *)haystack; - goto finally_1; - } - - if (haystack_len < needle_len) - { - ret = NULL; - goto finally_1; - } - - i = haystack_len - needle_len; - p = g_utf8_offset_to_pointer (caseless_haystack, i); - needle_len = strlen (needle); - - while (p >= caseless_haystack) - { - if (strncmp (p, needle, needle_len) == 0) - { - ret = pointer_from_offset_skipping_decomp (haystack, i); - goto finally_1; - } - - p = g_utf8_prev_char (p); - i--; - } - -finally_1: - g_free (caseless_haystack); - - return ret; -} - -static gboolean -backward_lines_match (const GtkTextIter *start, - const gchar **lines, - gboolean visible_only, - gboolean slice, - GtkTextIter *match_start, - GtkTextIter *match_end) -{ - GtkTextIter line, next; - gchar *line_text; - const gchar *found; - gint offset; - - if (*lines == NULL || **lines == '\0') - { - if (match_start) - *match_start = *start; - if (match_end) - *match_end = *start; - return TRUE; - } - - line = next = *start; - if (gtk_text_iter_get_line_offset (&next) == 0) - { - if (!gtk_text_iter_backward_line (&next)) - return FALSE; - } - else - gtk_text_iter_set_line_offset (&next, 0); - - if (slice) - { - if (visible_only) - line_text = gtk_text_iter_get_visible_slice (&next, &line); - else - line_text = gtk_text_iter_get_slice (&next, &line); - } - else - { - if (visible_only) - line_text = gtk_text_iter_get_visible_text (&next, &line); - else - line_text = gtk_text_iter_get_text (&next, &line); - } - - if (match_start) /* if this is the first line we're matching */ - { - found = g_utf8_strrcasestr (line_text, *lines); - } - else - { - /* If it's not the first line, we have to match from the - * start of the line. - */ - if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), - strlen (*lines))) - found = line_text; - else - found = NULL; - } - - if (found == NULL) - { - g_free (line_text); - return FALSE; - } - - /* Get offset to start of search string */ - offset = g_utf8_strlen (line_text, found - line_text); - - forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); - - /* If match start needs to be returned, set it to the - * start of the search string. - */ - if (match_start) - { - *match_start = next; - } - - /* Go to end of search string */ - forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); - - g_free (line_text); - - ++lines; - - if (match_end) - *match_end = next; - - /* try to match the rest of the lines forward, passing NULL - * for match_start so lines_match will try to match the entire - * line */ - return lines_match (&next, lines, visible_only, - slice, NULL, match_end); -} - -gboolean -empathy_text_iter_backward_search (const GtkTextIter *iter, - const gchar *str, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit) -{ - gchar **lines = NULL; - GtkTextIter match; - gboolean retval = FALSE; - GtkTextIter search; - gboolean visible_only; - gboolean slice; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - if (limit && gtk_text_iter_compare (iter, limit) <= 0) - return FALSE; - - if (*str == '\0') - { - /* If we can move one char, return the empty string there */ - match = *iter; - - if (gtk_text_iter_backward_char (&match)) - { - if (limit && gtk_text_iter_equal (&match, limit)) - return FALSE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = match; - return TRUE; - } - else - { - return FALSE; - } - } - - visible_only = TRUE; - slice = TRUE; - - /* locate all lines */ - lines = strbreakup (str, "\n", -1); - - search = *iter; - - while (TRUE) - { - /* This loop has an inefficient worst-case, where - * gtk_text_iter_get_text () is called repeatedly on - * a single line. - */ - GtkTextIter end; - - if (limit && gtk_text_iter_compare (&search, limit) <= 0) - break; - - if (backward_lines_match (&search, (const gchar**)lines, - visible_only, slice, &match, &end)) - { - if (limit == NULL || (limit && - gtk_text_iter_compare (&end, limit) > 0)) - { - retval = TRUE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = end; - } - break; - } - - if (gtk_text_iter_get_line_offset (&search) == 0) - { - if (!gtk_text_iter_backward_line (&search)) - break; - } - else - { - gtk_text_iter_set_line_offset (&search, 0); - } - } - - g_strfreev ((gchar**)lines); - - return retval; -} - -gboolean -empathy_window_get_is_visible (GtkWindow *window) -{ - GdkWindowState state; - GdkWindow *gdk_window; - - g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); - - gdk_window = GTK_WIDGET (window)->window; - if (!gdk_window) { - return FALSE; - } - - state = gdk_window_get_state (gdk_window); - if (state & (GDK_WINDOW_STATE_WITHDRAWN | GDK_WINDOW_STATE_ICONIFIED)) { - return FALSE; - } - - return TRUE; -} - -void -empathy_window_iconify (GtkWindow *window, GtkStatusIcon *status_icon) -{ - GdkRectangle icon_location; - gulong data[4]; - Display *dpy; - GdkWindow *gdk_window; - - gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL); - gdk_window = GTK_WIDGET (window)->window; - dpy = gdk_x11_drawable_get_xdisplay (gdk_window); - - data[0] = icon_location.x; - data[1] = icon_location.y; - data[2] = icon_location.width; - data[3] = icon_location.height; - - XChangeProperty (dpy, - GDK_WINDOW_XID (gdk_window), - gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (gdk_window), - "_NET_WM_ICON_GEOMETRY"), - XA_CARDINAL, 32, PropModeReplace, - (guchar *)&data, 4); - - gtk_window_set_skip_taskbar_hint (window, TRUE); - gtk_window_iconify (window); -} - -/* Takes care of moving the window to the current workspace. */ -void -empathy_window_present (GtkWindow *window, - gboolean steal_focus) -{ - guint32 timestamp; - - g_return_if_fail (GTK_IS_WINDOW (window)); - - /* There are three cases: hidden, visible, visible on another - * workspace. - */ - - if (!empathy_window_get_is_visible (window)) { - /* Hide it so present brings it to the current workspace. */ - gtk_widget_hide (GTK_WIDGET (window)); - } - - timestamp = gtk_get_current_event_time (); - gtk_window_set_skip_taskbar_hint (window, FALSE); - gtk_window_present_with_time (window, timestamp); - /* FIXME: This shouldn't be required as gtk_window_present's doc says - * it deiconify automatically. */ - gtk_window_deiconify (window); -} - -GtkWindow * -empathy_get_toplevel_window (GtkWidget *widget) -{ - GtkWidget *toplevel; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - toplevel = gtk_widget_get_toplevel (widget); - if (GTK_IS_WINDOW (toplevel) && - GTK_WIDGET_TOPLEVEL (toplevel)) { - return GTK_WINDOW (toplevel); - } - - return NULL; -} - -/* The URL opening code can't handle schemeless strings, so we try to be - * smart and add http if there is no scheme or doesn't look like a mail - * address. This should work in most cases, and let us click on strings - * like "www.gnome.org". - */ -static gchar * -fixup_url (const gchar *url) -{ - if (g_str_has_prefix (url, "ghelp:") || - g_str_has_prefix (url, "mailto:") || - strstr (url, ":/")) { - return NULL; - } - - if (strstr (url, "@")) { - return g_strdup_printf ("mailto:%s", url); - } - - return g_strdup_printf ("http://%s", url); -} - -void -empathy_url_show (GtkWidget *parent, - const char *url) -{ - gchar *real_url; - GError *error = NULL; - - real_url = fixup_url (url); - if (real_url) { - url = real_url; - } - - gtk_show_uri (gtk_widget_get_screen (parent), url, - gtk_get_current_event_time (), &error); - - if (error) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (NULL, 0, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("Unable to open URI")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", error->message); - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - gtk_window_present (GTK_WINDOW (dialog)); - - g_clear_error (&error); - } - - g_free (real_url); -} - -static void -link_button_hook (GtkLinkButton *button, - const gchar *link, - gpointer user_data) -{ - empathy_url_show (GTK_WIDGET (button), link); -} - -GtkWidget * -empathy_link_button_new (const gchar *url, - const gchar *title) -{ - static gboolean hook = FALSE; - - if (!hook) { - hook = TRUE; - gtk_link_button_set_uri_hook (link_button_hook, NULL, NULL); - } - - return gtk_link_button_new_with_label (url, title); -} - -void -empathy_toggle_button_set_state_quietly (GtkWidget *widget, - GCallback callback, - gpointer user_data, - gboolean active) -{ - g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget)); - - g_signal_handlers_block_by_func (widget, callback, user_data); - g_object_set (widget, "active", active, NULL); - g_signal_handlers_unblock_by_func (widget, callback, user_data); -} - -/* Sending files with the file chooser */ - -static void -file_manager_send_file_request_cb (EmpathyDispatchOperation *operation, - const GError *error, gpointer user_data) -{ - GFile *file = (GFile *)user_data; - EmpathyTpFile *tp_file; - - if (error != NULL) { - DEBUG ("Couldn't request channel: %s", error->message); - g_object_unref (file); - return; - } - - DEBUG ("Starting to send file"); - - tp_file = EMPATHY_TP_FILE ( - empathy_dispatch_operation_get_channel_wrapper (operation)); - - empathy_tp_file_offer (tp_file, file, NULL); - - g_object_unref (file); -} - -static void -file_manager_send_file_response_cb (GtkDialog *widget, - gint response_id, - EmpathyContact *contact) -{ - if (response_id == GTK_RESPONSE_OK) { - GSList *list; - GSList *l; - - list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (widget)); - - DEBUG ("File chooser selected files:"); - - for (l = list; l; l = l->next) { - gchar *uri; - GFile *gfile; - GFileInfo *info; - GtkRecentManager *manager; - gchar *filename; - GTimeVal mtime; - GError *error = NULL; - - uri = l->data; - gfile = g_file_new_for_uri (uri); - info = g_file_query_info (gfile, - G_FILE_ATTRIBUTE_STANDARD_SIZE "," - G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," - G_FILE_ATTRIBUTE_TIME_MODIFIED, - 0, NULL, &error); - - if (error) { - DEBUG ("Can't get info about the file: %s", error->message); - g_clear_error (&error); - g_object_unref (gfile); - continue; - } - - DEBUG ("\t%s", uri); - filename = g_file_get_basename (gfile); - g_file_info_get_modification_time (info, &mtime); - - empathy_dispatcher_send_file_to_contact (contact, - filename, g_file_info_get_size (info), mtime.tv_sec, - g_file_info_get_content_type (info), - file_manager_send_file_request_cb, gfile); - - g_free (filename); - g_object_unref (info); - - manager = gtk_recent_manager_get_default (); - gtk_recent_manager_add_item (manager, uri); - - g_free (uri); - } - g_slist_free (list); - } - - gtk_widget_destroy (GTK_WIDGET (widget)); -} - -void -empathy_send_file_with_file_chooser (EmpathyContact *contact) -{ - GtkWidget *widget; - GtkWidget *button; - - g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - - DEBUG ("Creating selection file chooser"); - - widget = gtk_file_chooser_dialog_new (_("Select a file"), - NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - NULL); - - /* send button */ - button = gtk_button_new_with_mnemonic (_("_Send")); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_icon_name (EMPATHY_IMAGE_DOCUMENT_SEND, - GTK_ICON_SIZE_BUTTON)); - gtk_widget_show (button); - gtk_dialog_add_action_widget (GTK_DIALOG (widget), button, - GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_dialog_set_default_response (GTK_DIALOG (widget), - GTK_RESPONSE_OK); - - g_signal_connect (widget, "response", - G_CALLBACK (file_manager_send_file_response_cb), - contact); - - gtk_widget_show (widget); -} - -typedef struct { - EmpathySound sound_id; - const char * event_ca_id; - const char * event_ca_description; - const char * gconf_key; -} EmpathySoundEntry; - -/* NOTE: these entries MUST be in the same order than EmpathySound enum */ -static EmpathySoundEntry sound_entries[LAST_EMPATHY_SOUND] = { - { EMPATHY_SOUND_MESSAGE_INCOMING, "message-new-instant", - N_("Received an instant message"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE } , - { EMPATHY_SOUND_MESSAGE_OUTGOING, "message-sent-instant", - N_("Sent an instant message"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE } , - { EMPATHY_SOUND_CONVERSATION_NEW, "message-new-instant", - N_("Incoming chat request"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION }, - { EMPATHY_SOUND_CONTACT_CONNECTED, "service-login", - N_("Contact connected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN }, - { EMPATHY_SOUND_CONTACT_DISCONNECTED, "service-logout", - N_("Contact disconnected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT }, - { EMPATHY_SOUND_ACCOUNT_CONNECTED, "service-login", - N_("Connected to server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN }, - { EMPATHY_SOUND_ACCOUNT_DISCONNECTED, "service-logout", - N_("Disconnected from server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }, - { EMPATHY_SOUND_PHONE_INCOMING, "phone-incoming-call", - N_("Incoming voice call"), NULL }, - { EMPATHY_SOUND_PHONE_OUTGOING, "phone-outgoing-calling", - N_("Outgoing voice call"), NULL }, - { EMPATHY_SOUND_PHONE_HANGUP, "phone-hangup", - N_("Voice call ended"), NULL }, -}; - - -static gboolean -empathy_sound_pref_is_enabled (const char *key) -{ - EmpathyConf *conf; - gboolean res; - - conf = empathy_conf_get (); - res = FALSE; - - empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_ENABLED, &res); - - if (!res) { - return FALSE; - } - - if (!empathy_check_available_state ()) { - empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY, - &res); - if (res) { - return FALSE; - } - } - - empathy_conf_get_bool (conf, key, &res); - - return res; -} - -void -empathy_sound_stop (EmpathySound sound_id) -{ - EmpathySoundEntry *entry; - - g_return_if_fail (sound_id < LAST_EMPATHY_SOUND); - - entry = &(sound_entries[sound_id]); - g_return_if_fail (entry->sound_id == sound_id); - - ca_context_cancel (ca_gtk_context_get (), entry->sound_id); -} - - -gboolean -empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, - ca_finish_callback_t callback, gpointer user_data) -{ - EmpathySoundEntry *entry; - gboolean should_play = TRUE; - ca_proplist *p = NULL; - ca_context *c; - - g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); - - entry = &(sound_entries[sound_id]); - g_return_val_if_fail (entry->sound_id == sound_id, FALSE); - - if (entry->gconf_key != NULL) { - should_play = empathy_sound_pref_is_enabled (entry->gconf_key); - } - - if (!should_play) - return FALSE; - - c = ca_gtk_context_get (); - ca_context_cancel (c, entry->sound_id); - - DEBUG ("Play sound \"%s\" (%s)", - entry->event_ca_id, - entry->event_ca_description); - - if (ca_proplist_create(&p) < 0) - goto failed; - - if (ca_proplist_sets (p, CA_PROP_EVENT_ID, entry->event_ca_id) < 0) - goto failed; - - if (ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, - gettext (entry->event_ca_id)) < 0) - goto failed; - - if (ca_gtk_proplist_set_for_widget (p, widget) < 0) - goto failed; - - ca_context_play_full (ca_gtk_context_get (), entry->sound_id, - p, callback, user_data); - - ca_proplist_destroy (p); - - return TRUE; - -failed: - if (p != NULL) - ca_proplist_destroy (p); - - return FALSE; -} - -void -empathy_sound_play (GtkWidget *widget, EmpathySound sound_id) -{ - empathy_sound_play_full (widget, sound_id, NULL, NULL); -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-ui-utils.h b/gnome-2-26/libempathy-gtk/empathy-ui-utils.h deleted file mode 100644 index 64c1f1a14..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-ui-utils.h +++ /dev/null @@ -1,148 +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> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - * - * Part of this file is copied from GtkSourceView (gtksourceiter.c): - * Paolo Maggi - * Jeroen Zwartepoorte - */ - -#ifndef __EMPATHY_UI_UTILS_H__ -#define __EMPATHY_UI_UTILS_H__ - -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include <canberra-gtk.h> - -#include <libmissioncontrol/mc-account.h> -#include <libmissioncontrol/mc-profile.h> - - -#include <libempathy/empathy-contact.h> - -#include "empathy-chat-view.h" - -G_BEGIN_DECLS - -/* NOTE: Keep this sync with sound_entries in empathy-ui-utils.c */ -typedef enum { - EMPATHY_SOUND_MESSAGE_INCOMING = 0, - EMPATHY_SOUND_MESSAGE_OUTGOING, - EMPATHY_SOUND_CONVERSATION_NEW, - EMPATHY_SOUND_CONTACT_CONNECTED, - EMPATHY_SOUND_CONTACT_DISCONNECTED, - EMPATHY_SOUND_ACCOUNT_CONNECTED, - EMPATHY_SOUND_ACCOUNT_DISCONNECTED, - EMPATHY_SOUND_PHONE_INCOMING, - EMPATHY_SOUND_PHONE_OUTGOING, - EMPATHY_SOUND_PHONE_HANGUP, - LAST_EMPATHY_SOUND, -} EmpathySound; - -void empathy_gtk_init (void); -GRegex * empathy_uri_regex_dup_singleton (void); - -/* Glade */ -void empathy_glade_get_file_simple (const gchar *filename, - const gchar *root, - const gchar *domain, - const gchar *first_required_widget, - ...); -GladeXML * empathy_glade_get_file (const gchar *filename, - const gchar *root, - const gchar *domain, - const gchar *first_required_widget, - ...); -void empathy_glade_connect (GladeXML *gui, - gpointer user_data, - gchar *first_widget, - ...); -void empathy_glade_setup_size_group (GladeXML *gui, - GtkSizeGroupMode mode, - gchar *first_widget, - ...); -/* Pixbufs */ -const gchar * empathy_icon_name_from_account (McAccount *account); -const gchar * empathy_icon_name_for_presence (McPresence presence); -const gchar * empathy_icon_name_for_contact (EmpathyContact *contact); -GdkPixbuf * empathy_pixbuf_from_data (gchar *data, - gsize data_size); -GdkPixbuf * empathy_pixbuf_from_data_and_mime (gchar *data, - gsize data_size, - gchar **mime_type); -GdkPixbuf * empathy_pixbuf_from_avatar_scaled (EmpathyAvatar *avatar, - gint width, - gint height); -GdkPixbuf * empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact *contact, - gint width, - gint height); -GdkPixbuf * empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, - gint max_size); -GdkPixbuf * empathy_pixbuf_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size); -GdkPixbuf * empathy_pixbuf_from_icon_name_sized (const gchar *icon_name, - gint size); -/* Text view */ -gboolean empathy_text_iter_forward_search (const GtkTextIter*iter, - const gchar *str, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter*limit); -gboolean empathy_text_iter_backward_search (const GtkTextIter*iter, - const gchar *str, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter*limit); -/* Windows */ -gboolean empathy_window_get_is_visible (GtkWindow *window); -void empathy_window_present (GtkWindow *window, - gboolean steal_focus); -void empathy_window_iconify (GtkWindow *window, - GtkStatusIcon *status_icon); -GtkWindow * empathy_get_toplevel_window (GtkWidget *widget); -void empathy_url_show (GtkWidget *parent, - const char *url); -void empathy_toggle_button_set_state_quietly (GtkWidget *widget, - GCallback callback, - gpointer user_data, - gboolean active); -GtkWidget * empathy_link_button_new (const gchar *url, - const gchar *title); - -void empathy_send_file_with_file_chooser (EmpathyContact *contact); - -/* Sounds */ -void empathy_sound_play (GtkWidget *widget, - EmpathySound sound_id); -gboolean empathy_sound_play_full (GtkWidget *widget, - EmpathySound sound_id, - ca_finish_callback_t callback, - gpointer user_data); -void empathy_sound_stop (EmpathySound sound_id); - -G_END_DECLS - -#endif /* __EMPATHY_UI_UTILS_H__ */ diff --git a/gnome-2-26/libempathy-gtk/empathy-video-src.c b/gnome-2-26/libempathy-gtk/empathy-video-src.c deleted file mode 100644 index d2d03026b..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-video-src.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * empathy-gst-video-src.c - Source for EmpathyGstVideoSrc - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <stdio.h> -#include <stdlib.h> - -#include <gst/interfaces/colorbalance.h> - -#include "empathy-video-src.h" - -G_DEFINE_TYPE(EmpathyGstVideoSrc, empathy_video_src, GST_TYPE_BIN) - -/* Keep in sync with EmpathyGstVideoSrcChannel */ -static gchar *channel_names[NR_EMPATHY_GST_VIDEO_SRC_CHANNELS] = { "contrast", - "brightness", "gamma" }; - -/* signal enum */ -#if 0 -enum -{ - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; -#endif - -/* private structure */ -typedef struct _EmpathyGstVideoSrcPrivate EmpathyGstVideoSrcPrivate; - -struct _EmpathyGstVideoSrcPrivate -{ - gboolean dispose_has_run; - GstElement *src; - /* Element implementing a ColorBalance interface */ - GstElement *balance; -}; - -#define EMPATHY_GST_VIDEO_SRC_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_VIDEO_SRC, \ - EmpathyGstVideoSrcPrivate)) - -static void -empathy_video_src_init (EmpathyGstVideoSrc *obj) -{ - EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (obj); - GstElement *scale, *colorspace, *capsfilter; - GstPad *ghost, *src; - GstCaps *caps; - - /* allocate any data required by the object here */ - scale = gst_element_factory_make ("videoscale", NULL); - colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL); - - capsfilter = gst_element_factory_make ("capsfilter", NULL); - caps = gst_caps_new_simple ("video/x-raw-yuv", - "width", G_TYPE_INT, 320, - "height", G_TYPE_INT, 240, - NULL); - - g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL); - - priv->src = gst_element_factory_make ("gconfvideosrc", NULL); - - gst_bin_add_many (GST_BIN (obj), priv->src, scale, colorspace, capsfilter, - NULL); - gst_element_link_many (priv->src, scale, colorspace, capsfilter, NULL); - - src = gst_element_get_static_pad (capsfilter, "src"); - - ghost = gst_ghost_pad_new ("src", src); - gst_element_add_pad (GST_ELEMENT (obj), ghost); - - gst_object_unref (G_OBJECT (src)); -} - -static void empathy_video_src_dispose (GObject *object); -static void empathy_video_src_finalize (GObject *object); - -static void -empathy_video_src_class_init (EmpathyGstVideoSrcClass *empathy_video_src_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (empathy_video_src_class); - - g_type_class_add_private (empathy_video_src_class, - sizeof (EmpathyGstVideoSrcPrivate)); - - object_class->dispose = empathy_video_src_dispose; - object_class->finalize = empathy_video_src_finalize; -} - -void -empathy_video_src_dispose (GObject *object) -{ - EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object); - EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose) - G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose (object); -} - -void -empathy_video_src_finalize (GObject *object) -{ - //EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object); - //EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self); - - /* free any data held directly by the object here */ - - G_OBJECT_CLASS (empathy_video_src_parent_class)->finalize (object); -} - -GstElement * -empathy_video_src_new (void) -{ - return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_VIDEO_SRC, NULL)); -} - -void -empathy_video_src_set_channel (GstElement *src, - EmpathyGstVideoSrcChannel channel, guint percent) -{ - GstElement *color; - GstColorBalance *balance; - const GList *channels; - GList *l; - - /* Find something supporting GstColorBalance */ - color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); - - if (color == NULL) - return; - - balance = GST_COLOR_BALANCE (color); - - channels = gst_color_balance_list_channels (balance); - - for (l = (GList *)channels; l != NULL; l = g_list_next (l)) - { - GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data); - - if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0) - { - gst_color_balance_set_value (balance, c, - ((c->max_value - c->min_value) * percent)/100 - + c->min_value); - break; - } - } - - g_object_unref (color); -} - -guint -empathy_video_src_get_channel (GstElement *src, - EmpathyGstVideoSrcChannel channel) -{ - GstElement *color; - GstColorBalance *balance; - const GList *channels; - GList *l; - guint percent = 0; - - /* Find something supporting GstColorBalance */ - color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); - - if (color == NULL) - return percent; - - balance = GST_COLOR_BALANCE (color); - - channels = gst_color_balance_list_channels (balance); - - for (l = (GList *)channels; l != NULL; l = g_list_next (l)) - { - GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data); - - if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0) - { - percent = - ((gst_color_balance_get_value (balance, c) - - c->min_value) * 100) / - (c->max_value - c->min_value); - - break; - } - } - - g_object_unref (color); - - return percent; -} - - -guint -empathy_video_src_get_supported_channels (GstElement *src) -{ - GstElement *color; - GstColorBalance *balance; - const GList *channels; - GList *l; - guint result = 0; - - /* Find something supporting GstColorBalance */ - color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); - - if (color == NULL) - goto out; - - balance = GST_COLOR_BALANCE (color); - - channels = gst_color_balance_list_channels (balance); - - for (l = (GList *)channels; l != NULL; l = g_list_next (l)) - { - GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (l->data); - int i; - - for (i = 0; i < NR_EMPATHY_GST_VIDEO_SRC_CHANNELS; i++) - { - if (g_ascii_strcasecmp (channel->label, channel_names[i]) == 0) - { - result |= (1 << i); - break; - } - } - } - - g_object_unref (color); - -out: - return result; -} - diff --git a/gnome-2-26/libempathy-gtk/empathy-video-src.h b/gnome-2-26/libempathy-gtk/empathy-video-src.h deleted file mode 100644 index fef0b84dd..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-video-src.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * empathy-gst-video-src.h - Header for EmpathyGstVideoSrc - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __EMPATHY_GST_VIDEO_SRC_H__ -#define __EMPATHY_GST_VIDEO_SRC_H__ - -#include <glib-object.h> -#include <gst/gst.h> - -G_BEGIN_DECLS - -typedef struct _EmpathyGstVideoSrc EmpathyGstVideoSrc; -typedef struct _EmpathyGstVideoSrcClass EmpathyGstVideoSrcClass; - -typedef enum { - EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST = 0, - EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS = 1, - EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA = 2, - NR_EMPATHY_GST_VIDEO_SRC_CHANNELS -} EmpathyGstVideoSrcChannel; - -#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_CONTRAST \ - (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_CONTRAST) -#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_BRIGHTNESS \ - (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_BRIGHTNESS) -#define EMPATHY_GST_VIDEO_SRC_SUPPORTS_GAMMA \ - (1 << EMPATHY_GST_VIDEO_SRC_CHANNEL_GAMMA) - -struct _EmpathyGstVideoSrcClass { - GstBinClass parent_class; -}; - -struct _EmpathyGstVideoSrc { - GstBin parent; -}; - -GType empathy_video_src_get_type (void); - -/* TYPE MACROS */ -#define EMPATHY_TYPE_GST_VIDEO_SRC \ - (empathy_video_src_get_type()) -#define EMPATHY_GST_VIDEO_SRC(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_GST_VIDEO_SRC, \ - EmpathyGstVideoSrc)) -#define EMPATHY_GST_VIDEO_SRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_GST_VIDEO_SRC, \ - EmpathyGstVideoSrcClass)) -#define EMPATHY_IS_GST_VIDEO_SRC(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_GST_VIDEO_SRC)) -#define EMPATHY_IS_GST_VIDEO_SRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_GST_VIDEO_SRC)) -#define EMPATHY_GST_VIDEO_SRC_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_GST_VIDEO_SRC, \ - EmpathyGstVideoSrcClass)) - -GstElement *empathy_video_src_new (void); - -guint -empathy_video_src_get_supported_channels (GstElement *src); - -void empathy_video_src_set_channel (GstElement *src, - EmpathyGstVideoSrcChannel channel, guint percent); - -guint empathy_video_src_get_channel (GstElement *src, - EmpathyGstVideoSrcChannel channel); - - -G_END_DECLS - -#endif /* #ifndef __EMPATHY_GST_VIDEO_SRC_H__*/ diff --git a/gnome-2-26/libempathy-gtk/empathy-video-widget.c b/gnome-2-26/libempathy-gtk/empathy-video-widget.c deleted file mode 100644 index 5b76257f4..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-video-widget.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * empathy-gst-gtk-widget.c - Source for EmpathyVideoWidget - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <stdio.h> -#include <stdlib.h> - -#include <gdk/gdkx.h> -#include <gst/interfaces/xoverlay.h> -#include <gst/farsight/fs-element-added-notifier.h> - -#include "empathy-video-widget.h" - -G_DEFINE_TYPE(EmpathyVideoWidget, empathy_video_widget, - GTK_TYPE_DRAWING_AREA) - -static void empathy_video_widget_element_added_cb ( - FsElementAddedNotifier *notifier, GstBin *bin, GstElement *element, - EmpathyVideoWidget *self); - -static void empathy_video_widget_sync_message_cb ( - GstBus *bus, GstMessage *message, EmpathyVideoWidget *self); - -/* signal enum */ -#if 0 -enum -{ - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; -#endif - -enum { - PROP_GST_ELEMENT = 1, - PROP_GST_BUS, - PROP_MIN_WIDTH, - PROP_MIN_HEIGHT, - PROP_SYNC, - PROP_ASYNC, -}; - -/* private structure */ -typedef struct _EmpathyVideoWidgetPriv EmpathyVideoWidgetPriv; - -struct _EmpathyVideoWidgetPriv -{ - gboolean dispose_has_run; - GstBus *bus; - GstElement *videosink; - GstPad *sink_pad; - GstElement *overlay; - FsElementAddedNotifier *notifier; - gint min_width; - gint min_height; - gboolean sync; - gboolean async; - - GMutex *lock; -}; - -#define GET_PRIV(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - EMPATHY_TYPE_VIDEO_WIDGET, EmpathyVideoWidgetPriv)) - -static void -empathy_video_widget_init (EmpathyVideoWidget *obj) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (obj); - GdkColor black; - - priv->lock = g_mutex_new (); - - priv->notifier = fs_element_added_notifier_new (); - g_signal_connect (priv->notifier, "element-added", - G_CALLBACK (empathy_video_widget_element_added_cb), - obj); - - if (gdk_color_parse ("Black", &black)) - gtk_widget_modify_bg (GTK_WIDGET (obj), GTK_STATE_NORMAL, - &black); - - GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (obj), GTK_DOUBLE_BUFFERED); -} - -static void -empathy_video_widget_constructed (GObject *object) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (object); - - priv->videosink = gst_element_factory_make ("gconfvideosink", NULL); - gst_object_ref (priv->videosink); - gst_object_sink (priv->videosink); - - priv->sink_pad = gst_element_get_static_pad (priv->videosink, "sink"); - - fs_element_added_notifier_add (priv->notifier, GST_BIN (priv->videosink)); - gst_bus_enable_sync_message_emission (priv->bus); - - g_signal_connect (priv->bus, "sync-message", - G_CALLBACK (empathy_video_widget_sync_message_cb), object); - - gtk_widget_set_size_request (GTK_WIDGET (object), priv->min_width, - priv->min_height); -} - -static void empathy_video_widget_dispose (GObject *object); -static void empathy_video_widget_finalize (GObject *object); - -static gboolean empathy_video_widget_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static void -empathy_video_widget_element_set_sink_properties (EmpathyVideoWidget *self); - -static void -empathy_video_widget_set_property (GObject *object, - guint property_id, const GValue *value, GParamSpec *pspec) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (object); - - switch (property_id) - { - case PROP_GST_BUS: - priv->bus = g_value_dup_object (value); - break; - case PROP_MIN_WIDTH: - priv->min_width = g_value_get_int (value); - break; - case PROP_MIN_HEIGHT: - priv->min_height = g_value_get_int (value); - break; - case PROP_SYNC: - priv->sync = g_value_get_boolean (value); - empathy_video_widget_element_set_sink_properties ( - EMPATHY_VIDEO_WIDGET (object)); - break; - case PROP_ASYNC: - priv->async = g_value_get_boolean (value); - empathy_video_widget_element_set_sink_properties ( - EMPATHY_VIDEO_WIDGET (object)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -empathy_video_widget_get_property (GObject *object, - guint property_id, GValue *value, GParamSpec *pspec) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (object); - - switch (property_id) - { - case PROP_GST_ELEMENT: - g_value_set_object (value, priv->videosink); - break; - case PROP_GST_BUS: - g_value_set_object (value, priv->bus); - break; - case PROP_MIN_WIDTH: - g_value_set_int (value, priv->min_width); - break; - case PROP_MIN_HEIGHT: - g_value_set_int (value, priv->min_height); - break; - case PROP_SYNC: - g_value_set_boolean (value, priv->sync); - break; - case PROP_ASYNC: - g_value_set_boolean (value, priv->async); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - - -static void -empathy_video_widget_class_init ( - EmpathyVideoWidgetClass *empathy_video_widget_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (empathy_video_widget_class); - GtkWidgetClass *widget_class = - GTK_WIDGET_CLASS (empathy_video_widget_class); - GParamSpec *param_spec; - - g_type_class_add_private (empathy_video_widget_class, - sizeof (EmpathyVideoWidgetPriv)); - - object_class->dispose = empathy_video_widget_dispose; - object_class->finalize = empathy_video_widget_finalize; - object_class->constructed = empathy_video_widget_constructed; - - object_class->set_property = empathy_video_widget_set_property; - object_class->get_property = empathy_video_widget_get_property; - - widget_class->expose_event = empathy_video_widget_expose_event; - - param_spec = g_param_spec_object ("gst-element", - "gst-element", "The underlaying gstreamer element", - GST_TYPE_ELEMENT, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_GST_ELEMENT, param_spec); - - param_spec = g_param_spec_object ("gst-bus", - "gst-bus", - "The toplevel bus from the pipeline in which this bin will be added", - GST_TYPE_BUS, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_GST_BUS, param_spec); - - param_spec = g_param_spec_int ("min-width", - "min-width", - "Minimal width of the widget", - 0, G_MAXINT, 320, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_MIN_WIDTH, param_spec); - - param_spec = g_param_spec_int ("min-height", - "min-height", - "Minimal height of the widget", - 0, G_MAXINT, 240, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_MIN_HEIGHT, param_spec); - - param_spec = g_param_spec_boolean ("sync", - "sync", - "Whether the underlying sink should be sync or not", - TRUE, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_SYNC, param_spec); - - param_spec = g_param_spec_boolean ("async", - "async", - "Whether the underlying sink should be async or not", - TRUE, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_ASYNC, param_spec); -} - -void -empathy_video_widget_dispose (GObject *object) -{ - EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (object); - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - if (priv->dispose_has_run) - return; - - priv->dispose_has_run = TRUE; - - if (priv->bus != NULL) - g_object_unref (priv->bus); - - priv->bus = NULL; - - if (priv->videosink != NULL) - g_object_unref (priv->videosink); - - priv->videosink = NULL; - - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (empathy_video_widget_parent_class)->dispose) - G_OBJECT_CLASS (empathy_video_widget_parent_class)->dispose (object); -} - -void -empathy_video_widget_finalize (GObject *object) -{ - EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (object); - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - /* free any data held directly by the object here */ - g_mutex_free (priv->lock); - - G_OBJECT_CLASS (empathy_video_widget_parent_class)->finalize (object); -} - - -static void -empathy_video_widget_element_set_sink_properties_unlocked ( - EmpathyVideoWidget *self) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - if (priv->overlay == NULL) - return; - - if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay), - "force-aspect-ratio")) - g_object_set (G_OBJECT (priv->overlay), "force-aspect-ratio", TRUE, NULL); - - if (g_object_class_find_property ( - G_OBJECT_GET_CLASS (priv->overlay), "sync")) - g_object_set (G_OBJECT (priv->overlay), "sync", priv->sync, NULL); - - if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay), - "async")) - g_object_set (G_OBJECT (priv->overlay), "async", priv->async, NULL); -} - -static void -empathy_video_widget_element_set_sink_properties (EmpathyVideoWidget *self) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - g_mutex_lock (priv->lock); - empathy_video_widget_element_set_sink_properties_unlocked (self); - g_mutex_unlock (priv->lock); -} - -static void -empathy_video_widget_element_added_cb (FsElementAddedNotifier *notifier, - GstBin *bin, GstElement *element, EmpathyVideoWidget *self) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - /* We assume the overlay is the sink */ - g_mutex_lock (priv->lock); - if (priv->overlay == NULL && GST_IS_X_OVERLAY (element)) - { - priv->overlay = element; - g_object_add_weak_pointer (G_OBJECT (element), - (gpointer) &priv->overlay); - empathy_video_widget_element_set_sink_properties_unlocked (self); - gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay)); - } - g_mutex_unlock (priv->lock); -} - -static void -empathy_video_widget_sync_message_cb (GstBus *bus, GstMessage *message, - EmpathyVideoWidget *self) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - const GstStructure *s; - - if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) - return; - - if (GST_MESSAGE_SRC (message) != (GstObject *) priv->overlay) - return; - - s = gst_message_get_structure (message); - - if (gst_structure_has_name (s, "prepare-xwindow-id")) - { - g_assert (GTK_WIDGET_REALIZED (GTK_WIDGET (self))); - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (priv->overlay), - GDK_WINDOW_XID (GTK_WIDGET (self)->window)); - } -} - -static gboolean -empathy_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event) -{ - EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (widget); - EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - - if (event != NULL && event->count > 0) - return TRUE; - - if (priv->overlay == NULL) - { - gdk_window_clear_area (widget->window, 0, 0, - widget->allocation.width, widget->allocation.height); - return TRUE; - } - - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (priv->overlay), - GDK_WINDOW_XID (widget->window)); - - gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay)); - - return TRUE; -} - -GtkWidget * -empathy_video_widget_new_with_size (GstBus *bus, gint width, gint height) -{ - g_return_val_if_fail (bus != NULL, NULL); - - return GTK_WIDGET (g_object_new (EMPATHY_TYPE_VIDEO_WIDGET, - "gst-bus", bus, - "min-width", width, - "min-height", height, - NULL)); -} - -GtkWidget * -empathy_video_widget_new (GstBus *bus) -{ - g_return_val_if_fail (bus != NULL, NULL); - - return GTK_WIDGET (g_object_new (EMPATHY_TYPE_VIDEO_WIDGET, - "gst-bus", bus, - NULL)); -} - -GstPad * -empathy_video_widget_get_sink (EmpathyVideoWidget *widget) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (widget); - - return priv->sink_pad; -} - -GstElement * -empathy_video_widget_get_element (EmpathyVideoWidget *widget) -{ - EmpathyVideoWidgetPriv *priv = GET_PRIV (widget); - - return priv->videosink; -} diff --git a/gnome-2-26/libempathy-gtk/empathy-video-widget.h b/gnome-2-26/libempathy-gtk/empathy-video-widget.h deleted file mode 100644 index 08acdaa71..000000000 --- a/gnome-2-26/libempathy-gtk/empathy-video-widget.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * empathy-gst-gtk-widget.h - Header for EmpathyVideoWidget - * Copyright (C) 2008 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __EMPATHY_VIDEO_WIDGET_H__ -#define __EMPATHY_VIDEO_WIDGET_H__ - -#include <glib-object.h> -#include <gst/gst.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -typedef struct _EmpathyVideoWidget EmpathyVideoWidget; -typedef struct _EmpathyVideoWidgetClass EmpathyVideoWidgetClass; - -struct _EmpathyVideoWidgetClass { - GtkDrawingAreaClass parent_class; -}; - -struct _EmpathyVideoWidget { - GtkDrawingArea parent; -}; - -GType empathy_video_widget_get_type (void); - -/* TYPE MACROS */ -#define EMPATHY_TYPE_VIDEO_WIDGET \ - (empathy_video_widget_get_type()) -#define EMPATHY_VIDEO_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_VIDEO_WIDGET, \ - EmpathyVideoWidget)) -#define EMPATHY_VIDEO_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_VIDEO_WIDGET, \ - EmpathyVideoWidgetClass)) -#define EMPATHY_IS_VIDEO_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_VIDEO_WIDGET)) -#define EMPATHY_IS_VIDEO_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_VIDEO_WIDGET)) -#define EMPATHY_VIDEO_WIDGET_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_VIDEO_WIDGET, \ - EmpathyVideoWidgetClass)) - -GtkWidget *empathy_video_widget_new (GstBus *bus); -GtkWidget *empathy_video_widget_new_with_size (GstBus *bus, - gint width, gint height); - -GstElement *empathy_video_widget_get_element (EmpathyVideoWidget *widget); -GstPad *empathy_video_widget_get_sink (EmpathyVideoWidget *widget); - -G_END_DECLS - -#endif /* #ifndef __EMPATHY_VIDEO_WIDGET_H__*/ diff --git a/gnome-2-26/libempathy-gtk/libempathy-gtk.pc.in b/gnome-2-26/libempathy-gtk/libempathy-gtk.pc.in deleted file mode 100644 index c83979338..000000000 --- a/gnome-2-26/libempathy-gtk/libempathy-gtk.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libempathy-gtk -Description: Empathy interface library -Requires: pkg-config >= 0.21 -Requires.private: glib-2.0, gobject-2.0, gtk+-2.0, libglade-2.0, libmissioncontrol, libempathy, telepathy-glib -Version: @VERSION@ -Libs: -L${libdir} -lempathy-gtk -Cflags: -I${includedir} diff --git a/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.c b/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.c deleted file mode 100644 index 112f169fd..000000000 --- a/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.c +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net> - * - * encoding list copied from gnome-terminal/encoding.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add exception clause. - * See license_change file for details. - * - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "totem-subtitle-encoding.h" -#include <string.h> - -typedef enum -{ - SUBTITLE_ENCODING_CURRENT_LOCALE, - - SUBTITLE_ENCODING_ISO_8859_6, - SUBTITLE_ENCODING_IBM_864, - SUBTITLE_ENCODING_MAC_ARABIC, - SUBTITLE_ENCODING_WINDOWS_1256, - - SUBTITLE_ENCODING_ARMSCII_8, - - SUBTITLE_ENCODING_ISO_8859_4, - SUBTITLE_ENCODING_ISO_8859_13, - SUBTITLE_ENCODING_WINDOWS_1257, - - SUBTITLE_ENCODING_ISO_8859_14, - - SUBTITLE_ENCODING_ISO_8859_2, - SUBTITLE_ENCODING_IBM_852, - SUBTITLE_ENCODING_MAC_CE, - SUBTITLE_ENCODING_WINDOWS_1250, - - SUBTITLE_ENCODING_GB18030, - SUBTITLE_ENCODING_GB2312, - SUBTITLE_ENCODING_GBK, - SUBTITLE_ENCODING_HZ, - - SUBTITLE_ENCODING_BIG5, - SUBTITLE_ENCODING_BIG5_HKSCS, - SUBTITLE_ENCODING_EUC_TW, - - SUBTITLE_ENCODING_MAC_CROATIAN, - - SUBTITLE_ENCODING_ISO_8859_5, - SUBTITLE_ENCODING_IBM_855, - SUBTITLE_ENCODING_ISO_IR_111, - SUBTITLE_ENCODING_KOI8_R, - SUBTITLE_ENCODING_MAC_CYRILLIC, - SUBTITLE_ENCODING_WINDOWS_1251, - - SUBTITLE_ENCODING_CP_866, - - SUBTITLE_ENCODING_MAC_UKRAINIAN, - SUBTITLE_ENCODING_KOI8_U, - - SUBTITLE_ENCODING_GEOSTD8, - - SUBTITLE_ENCODING_ISO_8859_7, - SUBTITLE_ENCODING_MAC_GREEK, - SUBTITLE_ENCODING_WINDOWS_1253, - - SUBTITLE_ENCODING_MAC_GUJARATI, - - SUBTITLE_ENCODING_MAC_GURMUKHI, - - SUBTITLE_ENCODING_ISO_8859_8_I, - SUBTITLE_ENCODING_IBM_862, - SUBTITLE_ENCODING_MAC_HEBREW, - SUBTITLE_ENCODING_WINDOWS_1255, - - SUBTITLE_ENCODING_ISO_8859_8, - - SUBTITLE_ENCODING_MAC_DEVANAGARI, - - SUBTITLE_ENCODING_MAC_ICELANDIC, - - SUBTITLE_ENCODING_EUC_JP, - SUBTITLE_ENCODING_ISO_2022_JP, - SUBTITLE_ENCODING_SHIFT_JIS, - - SUBTITLE_ENCODING_EUC_KR, - SUBTITLE_ENCODING_ISO_2022_KR, - SUBTITLE_ENCODING_JOHAB, - SUBTITLE_ENCODING_UHC, - - SUBTITLE_ENCODING_ISO_8859_10, - - SUBTITLE_ENCODING_MAC_FARSI, - - SUBTITLE_ENCODING_ISO_8859_16, - SUBTITLE_ENCODING_MAC_ROMANIAN, - - SUBTITLE_ENCODING_ISO_8859_3, - - SUBTITLE_ENCODING_TIS_620, - - SUBTITLE_ENCODING_ISO_8859_9, - SUBTITLE_ENCODING_IBM_857, - SUBTITLE_ENCODING_MAC_TURKISH, - SUBTITLE_ENCODING_WINDOWS_1254, - - SUBTITLE_ENCODING_UTF_7, - SUBTITLE_ENCODING_UTF_8, - SUBTITLE_ENCODING_UTF_16, - SUBTITLE_ENCODING_UCS_2, - SUBTITLE_ENCODING_UCS_4, - - SUBTITLE_ENCODING_ISO_8859_1, - SUBTITLE_ENCODING_ISO_8859_15, - SUBTITLE_ENCODING_IBM_850, - SUBTITLE_ENCODING_MAC_ROMAN, - SUBTITLE_ENCODING_WINDOWS_1252, - - SUBTITLE_ENCODING_TCVN, - SUBTITLE_ENCODING_VISCII, - SUBTITLE_ENCODING_WINDOWS_1258, - - SUBTITLE_ENCODING_LAST -} SubtitleEncodingIndex; - - -typedef struct -{ - int index; - gboolean valid; - char *charset; - char *name; -} SubtitleEncoding; - - -static SubtitleEncoding encodings[] = { - - {SUBTITLE_ENCODING_CURRENT_LOCALE, TRUE, - NULL, N_("Current Locale")}, - - {SUBTITLE_ENCODING_ISO_8859_6, FALSE, - "ISO-8859-6", N_("Arabic")}, - {SUBTITLE_ENCODING_IBM_864, FALSE, - "IBM864", N_("Arabic")}, - {SUBTITLE_ENCODING_MAC_ARABIC, FALSE, - "MAC_ARABIC", N_("Arabic")}, - {SUBTITLE_ENCODING_WINDOWS_1256, FALSE, - "WINDOWS-1256", N_("Arabic")}, - - {SUBTITLE_ENCODING_ARMSCII_8, FALSE, - "ARMSCII-8", N_("Armenian")}, - - {SUBTITLE_ENCODING_ISO_8859_4, FALSE, - "ISO-8859-4", N_("Baltic")}, - {SUBTITLE_ENCODING_ISO_8859_13, FALSE, - "ISO-8859-13", N_("Baltic")}, - {SUBTITLE_ENCODING_WINDOWS_1257, FALSE, - "WINDOWS-1257", N_("Baltic")}, - - {SUBTITLE_ENCODING_ISO_8859_14, FALSE, - "ISO-8859-14", N_("Celtic")}, - - {SUBTITLE_ENCODING_ISO_8859_2, FALSE, - "ISO-8859-2", N_("Central European")}, - {SUBTITLE_ENCODING_IBM_852, FALSE, - "IBM852", N_("Central European")}, - {SUBTITLE_ENCODING_MAC_CE, FALSE, - "MAC_CE", N_("Central European")}, - {SUBTITLE_ENCODING_WINDOWS_1250, FALSE, - "WINDOWS-1250", N_("Central European")}, - - {SUBTITLE_ENCODING_GB18030, FALSE, - "GB18030", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_GB2312, FALSE, - "GB2312", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_GBK, FALSE, - "GBK", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_HZ, FALSE, - "HZ", N_("Chinese Simplified")}, - - {SUBTITLE_ENCODING_BIG5, FALSE, - "BIG5", N_("Chinese Traditional")}, - {SUBTITLE_ENCODING_BIG5_HKSCS, FALSE, - "BIG5-HKSCS", N_("Chinese Traditional")}, - {SUBTITLE_ENCODING_EUC_TW, FALSE, - "EUC-TW", N_("Chinese Traditional")}, - - {SUBTITLE_ENCODING_MAC_CROATIAN, FALSE, - "MAC_CROATIAN", N_("Croatian")}, - - {SUBTITLE_ENCODING_ISO_8859_5, FALSE, - "ISO-8859-5", N_("Cyrillic")}, - {SUBTITLE_ENCODING_IBM_855, FALSE, - "IBM855", N_("Cyrillic")}, - {SUBTITLE_ENCODING_ISO_IR_111, FALSE, - "ISO-IR-111", N_("Cyrillic")}, - {SUBTITLE_ENCODING_KOI8_R, FALSE, - "KOI8-R", N_("Cyrillic")}, - {SUBTITLE_ENCODING_MAC_CYRILLIC, FALSE, - "MAC-CYRILLIC", N_("Cyrillic")}, - {SUBTITLE_ENCODING_WINDOWS_1251, FALSE, - "WINDOWS-1251", N_("Cyrillic")}, - - {SUBTITLE_ENCODING_CP_866, FALSE, - "CP866", N_("Cyrillic/Russian")}, - - {SUBTITLE_ENCODING_MAC_UKRAINIAN, FALSE, - "MAC_UKRAINIAN", N_("Cyrillic/Ukrainian")}, - {SUBTITLE_ENCODING_KOI8_U, FALSE, - "KOI8-U", N_("Cyrillic/Ukrainian")}, - - {SUBTITLE_ENCODING_GEOSTD8, FALSE, - "GEORGIAN-PS", N_("Georgian")}, - - {SUBTITLE_ENCODING_ISO_8859_7, FALSE, - "ISO-8859-7", N_("Greek")}, - {SUBTITLE_ENCODING_MAC_GREEK, FALSE, - "MAC_GREEK", N_("Greek")}, - {SUBTITLE_ENCODING_WINDOWS_1253, FALSE, - "WINDOWS-1253", N_("Greek")}, - - {SUBTITLE_ENCODING_MAC_GUJARATI, FALSE, - "MAC_GUJARATI", N_("Gujarati")}, - - {SUBTITLE_ENCODING_MAC_GURMUKHI, FALSE, - "MAC_GURMUKHI", N_("Gurmukhi")}, - - {SUBTITLE_ENCODING_ISO_8859_8_I, FALSE, - "ISO-8859-8-I", N_("Hebrew")}, - {SUBTITLE_ENCODING_IBM_862, FALSE, - "IBM862", N_("Hebrew")}, - {SUBTITLE_ENCODING_MAC_HEBREW, FALSE, - "MAC_HEBREW", N_("Hebrew")}, - {SUBTITLE_ENCODING_WINDOWS_1255, FALSE, - "WINDOWS-1255", N_("Hebrew")}, - - {SUBTITLE_ENCODING_ISO_8859_8, FALSE, - "ISO-8859-8", N_("Hebrew Visual")}, - - {SUBTITLE_ENCODING_MAC_DEVANAGARI, FALSE, - "MAC_DEVANAGARI", N_("Hindi")}, - - {SUBTITLE_ENCODING_MAC_ICELANDIC, FALSE, - "MAC_ICELANDIC", N_("Icelandic")}, - - {SUBTITLE_ENCODING_EUC_JP, FALSE, - "EUC-JP", N_("Japanese")}, - {SUBTITLE_ENCODING_ISO_2022_JP, FALSE, - "ISO2022JP", N_("Japanese")}, - {SUBTITLE_ENCODING_SHIFT_JIS, FALSE, - "SHIFT-JIS", N_("Japanese")}, - - {SUBTITLE_ENCODING_EUC_KR, FALSE, - "EUC-KR", N_("Korean")}, - {SUBTITLE_ENCODING_ISO_2022_KR, FALSE, - "ISO2022KR", N_("Korean")}, - {SUBTITLE_ENCODING_JOHAB, FALSE, - "JOHAB", N_("Korean")}, - {SUBTITLE_ENCODING_UHC, FALSE, - "UHC", N_("Korean")}, - - {SUBTITLE_ENCODING_ISO_8859_10, FALSE, - "ISO-8859-10", N_("Nordic")}, - - {SUBTITLE_ENCODING_MAC_FARSI, FALSE, - "MAC_FARSI", N_("Persian")}, - - {SUBTITLE_ENCODING_ISO_8859_16, FALSE, - "ISO-8859-16", N_("Romanian")}, - {SUBTITLE_ENCODING_MAC_ROMANIAN, FALSE, - "MAC_ROMANIAN", N_("Romanian")}, - - {SUBTITLE_ENCODING_ISO_8859_3, FALSE, - "ISO-8859-3", N_("South European")}, - - {SUBTITLE_ENCODING_TIS_620, FALSE, - "TIS-620", N_("Thai")}, - - {SUBTITLE_ENCODING_ISO_8859_9, FALSE, - "ISO-8859-9", N_("Turkish")}, - {SUBTITLE_ENCODING_IBM_857, FALSE, - "IBM857", N_("Turkish")}, - {SUBTITLE_ENCODING_MAC_TURKISH, FALSE, - "MAC_TURKISH", N_("Turkish")}, - {SUBTITLE_ENCODING_WINDOWS_1254, FALSE, - "WINDOWS-1254", N_("Turkish")}, - - {SUBTITLE_ENCODING_UTF_7, FALSE, - "UTF-7", N_("Unicode")}, - {SUBTITLE_ENCODING_UTF_8, FALSE, - "UTF-8", N_("Unicode")}, - {SUBTITLE_ENCODING_UTF_16, FALSE, - "UTF-16", N_("Unicode")}, - {SUBTITLE_ENCODING_UCS_2, FALSE, - "UCS-2", N_("Unicode")}, - {SUBTITLE_ENCODING_UCS_4, FALSE, - "UCS-4", N_("Unicode")}, - - {SUBTITLE_ENCODING_ISO_8859_1, FALSE, - "ISO-8859-1", N_("Western")}, - {SUBTITLE_ENCODING_ISO_8859_15, FALSE, - "ISO-8859-15", N_("Western")}, - {SUBTITLE_ENCODING_IBM_850, FALSE, - "IBM850", N_("Western")}, - {SUBTITLE_ENCODING_MAC_ROMAN, FALSE, - "MAC_ROMAN", N_("Western")}, - {SUBTITLE_ENCODING_WINDOWS_1252, FALSE, - "WINDOWS-1252", N_("Western")}, - - {SUBTITLE_ENCODING_TCVN, FALSE, - "TCVN", N_("Vietnamese")}, - {SUBTITLE_ENCODING_VISCII, FALSE, - "VISCII", N_("Vietnamese")}, - {SUBTITLE_ENCODING_WINDOWS_1258, FALSE, - "WINDOWS-1258", N_("Vietnamese")} -}; - -static const SubtitleEncoding * -find_encoding_by_charset (const char *charset) -{ - int i; - - i = 1; /* skip current locale */ - while (i < SUBTITLE_ENCODING_LAST) { - if (strcasecmp (charset, encodings[i].charset) == 0) - return &encodings[i]; - - ++i; - } - - if (strcasecmp (charset, - encodings[SUBTITLE_ENCODING_CURRENT_LOCALE].charset) == 0) - return &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - - return NULL; -} - -static void -subtitle_encoding_init (void) -{ - int i; - gsize bytes_read, bytes_written; - gchar *converted; - gchar ascii_sample[96]; - - g_get_charset ((const char **) - &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE].charset); - - g_assert (G_N_ELEMENTS (encodings) == SUBTITLE_ENCODING_LAST); - - /* Initialize the sample text with all of the printing ASCII characters - * from space (32) to the tilde (126), 95 in all. */ - for (i = 0; i < (int) sizeof (ascii_sample); i++) - ascii_sample[i] = i + 32; - - ascii_sample[sizeof (ascii_sample) - 1] = '\0'; - - i = 0; - while (i < SUBTITLE_ENCODING_LAST) { - bytes_read = 0; - bytes_written = 0; - - g_assert (encodings[i].index == i); - - /* Translate the names */ - encodings[i].name = _(encodings[i].name); - - /* Test that the encoding is a proper superset of ASCII (which naive - * apps are going to use anyway) by attempting to validate the text - * using the current encoding. This also flushes out any encodings - * which the underlying GIConv implementation can't support. - */ - converted = g_convert (ascii_sample, sizeof (ascii_sample) - 1, - encodings[i].charset, encodings[i].charset, - &bytes_read, &bytes_written, NULL); - - /* The encoding is only valid if ASCII passes through cleanly. */ - if (i == SUBTITLE_ENCODING_CURRENT_LOCALE) - encodings[i].valid = TRUE; - else - encodings[i].valid = - (bytes_read == (sizeof (ascii_sample) - 1)) && - (converted != NULL) && (strcmp (converted, ascii_sample) == 0); - -#ifdef DEBUG_ENCODINGS - if (!encodings[i].valid) { - g_print ("Rejecting encoding %s as invalid:\n", encodings[i].charset); - g_print (" input \"%s\"\n", ascii_sample); - g_print (" output \"%s\"\n\n", converted ? converted : "(null)"); - } -#endif - - /* Discard the converted string. */ - g_free (converted); - - ++i; - } -} - -static int -subtitle_encoding_get_index (const char *charset) -{ - const SubtitleEncoding *e; - - e = find_encoding_by_charset (charset); - if (e != NULL) - return e->index; - else - return SUBTITLE_ENCODING_CURRENT_LOCALE; -} - -static const char * -subtitle_encoding_get_charset (int index) -{ - const SubtitleEncoding *e; - - if (index >= SUBTITLE_ENCODING_LAST) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else if (index < SUBTITLE_ENCODING_CURRENT_LOCALE) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else if (!encodings[index].valid) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else - e = &encodings[index]; - return e->charset; -} - -enum -{ - INDEX_COL, - NAME_COL -}; - -static gint -compare (GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b, gpointer data) -{ - gchar *str_a, *str_b; - gint result; - - gtk_tree_model_get (model, a, NAME_COL, &str_a, -1); - gtk_tree_model_get (model, b, NAME_COL, &str_b, -1); - - result = strcmp (str_a, str_b); - - g_free (str_a); - g_free (str_b); - - return result; -} - -static void -is_encoding_sensitive (GtkCellLayout * cell_layout, - GtkCellRenderer * cell, - GtkTreeModel * tree_model, GtkTreeIter * iter, gpointer data) -{ - - gboolean sensitive; - - sensitive = !gtk_tree_model_iter_has_child (tree_model, iter); - g_object_set (cell, "sensitive", sensitive, NULL); -} - -static GtkTreeModel * -subtitle_encoding_create_store (void) -{ - gchar *label; - gchar *lastlang = ""; - GtkTreeIter iter, iter2; - GtkTreeStore *store; - int i; - - store = gtk_tree_store_new (2, G_TYPE_INT, G_TYPE_STRING); - - for (i = 0; i < SUBTITLE_ENCODING_LAST; i++) { - if (encodings[i].valid) { - if (strcmp (lastlang, encodings[i].name)) { - lastlang = encodings[i].name; - gtk_tree_store_append (store, &iter, NULL); - gtk_tree_store_set (store, &iter, INDEX_COL, - -1, NAME_COL, lastlang, -1); - } - label = g_strdup_printf("%s (%s)", lastlang, encodings[i].charset); - gtk_tree_store_append (store, &iter2, &iter); - gtk_tree_store_set (store, &iter2, INDEX_COL, - encodings[i].index, NAME_COL, label, -1); - g_free(label); - } - } - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), - compare, NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - NAME_COL, GTK_SORT_ASCENDING); - return GTK_TREE_MODEL (store); -} - -static void -subtitle_encoding_combo_render (GtkComboBox * combo) -{ - GtkCellRenderer *renderer; - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, - "text", NAME_COL, NULL); - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), - renderer, is_encoding_sensitive, NULL, NULL); -} - -const char * -totem_subtitle_encoding_get_selected (GtkComboBox * combo) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gint index = -1; - - model = gtk_combo_box_get_model (combo); - if (gtk_combo_box_get_active_iter (combo, &iter)) { - gtk_tree_model_get (model, &iter, INDEX_COL, &index, -1); - } - if (index == -1) - return NULL; - return subtitle_encoding_get_charset (index); -} - -void -totem_subtitle_encoding_set (GtkComboBox * combo, const char *encoding) -{ - GtkTreeModel *model; - GtkTreeIter iter, iter2; - gint index, i; - - g_return_if_fail (encoding != NULL); - - model = gtk_combo_box_get_model (combo); - index = subtitle_encoding_get_index (encoding); - gtk_tree_model_get_iter_first (model, &iter); - do { - if (!gtk_tree_model_iter_has_child (model, &iter)) - continue; - if (!gtk_tree_model_iter_children (model, &iter2, &iter)) - continue; - do { - gtk_tree_model_get (model, &iter2, INDEX_COL, &i, -1); - if (i == index) - break; - } while (gtk_tree_model_iter_next (model, &iter2)); - if (i == index) - break; - } while (gtk_tree_model_iter_next (model, &iter)); - gtk_combo_box_set_active_iter (combo, &iter2); -} - -void -totem_subtitle_encoding_init (GtkComboBox *combo) -{ - GtkTreeModel *model; - subtitle_encoding_init (); - model = subtitle_encoding_create_store (); - gtk_combo_box_set_model (combo, model); - g_object_unref (model); - subtitle_encoding_combo_render (combo); -} - -/* - * vim: sw=2 ts=8 cindent noai bs=2 - */ diff --git a/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.h b/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.h deleted file mode 100644 index 656c0dec5..000000000 --- a/gnome-2-26/libempathy-gtk/totem-subtitle-encoding.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net> - * - * encoding list copied from gnome-terminal/encoding.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add exception clause. - * See license_change file for details. - * - */ - -/* Encoding stuff */ - -#ifndef TOTEM_SUBTITLE_ENCODING_H -#define TOTEM_SUBTITLE_ENCODING_H - -#include <gtk/gtk.h> - -void totem_subtitle_encoding_init (GtkComboBox *combo); -void totem_subtitle_encoding_set (GtkComboBox *combo, const char *encoding); -const char * totem_subtitle_encoding_get_selected (GtkComboBox *combo); - -#endif /* SUBTITLE_ENCODING_H */ |