aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2008-10-17 20:47:25 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-17 20:47:25 +0800
commit5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04 (patch)
tree3a9ee7d2b9abba1a987b138ee4db65b0c16f21e0
parent1dd22bde4598101ebac5c1fdefed743ff60d709d (diff)
downloadgsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar.gz
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar.bz2
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar.lz
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar.xz
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.tar.zst
gsoc2013-empathy-5a9c84a4fad2df9e4aee9f0dc6bd1b411560ba04.zip
Automatically tick "import" only for accounts which are not already present in MC. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=1623
-rw-r--r--src/empathy-import-dialog.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c
index c0d92f708..aa791b014 100644
--- a/src/empathy-import-dialog.c
+++ b/src/empathy-import-dialog.c
@@ -489,6 +489,27 @@ import_dialog_button_cancel_clicked_cb (GtkButton *button,
}
static gboolean
+import_dialog_filter_mc_accounts (McAccount *account,
+ gpointer user_data)
+{
+ gchar *value;
+ const gchar *username;
+ gboolean result;
+
+ username = (const gchar *) user_data;
+
+ if (mc_account_get_param_string (account, "account", &value)
+ == MC_ACCOUNT_SETTING_ABSENT)
+ return FALSE;
+
+ result = tp_strdiff (value, username);
+
+ g_free (value);
+
+ return !result;
+}
+
+static gboolean
import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog)
{
GtkTreeModel *model;
@@ -506,16 +527,39 @@ import_dialog_add_accounts_to_model (EmpathyImportDialog *dialog)
{
GValue *value, *account_data;
AccountData *data = (AccountData *) account->data;
+ gboolean import;
+ GList *accounts, *all_accounts;
+ McProfile *profile;
account_data = tp_g_value_slice_new (G_TYPE_POINTER);
g_value_set_pointer (account_data, data);
value = g_hash_table_lookup (data->settings, "account");
+ /* Get the profile of the account we're adding to get all current
+ * accounts in MC. */
+ profile = mc_profile_lookup (data->protocol);
+
+ all_accounts = profile ? mc_accounts_list_by_profile (profile) :
+ mc_accounts_list ();
+
+ /* Filter the list of all relevant accounts to remove ones which are NOT
+ * the same as the one we're now adding. */
+ accounts = mc_accounts_filter (all_accounts,
+ import_dialog_filter_mc_accounts,
+ (gpointer) g_value_get_string (value));
+
+ /* Make the checkbox ticked if there is *no* account already with the
+ * relevant details. */
+ import = (g_list_length (accounts) == 0);
+
+ mc_accounts_list_free (accounts);
+ g_object_unref (profile);
+
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_IMPORT, TRUE,
+ COL_IMPORT, import,
COL_PROTOCOL, data->protocol,
COL_NAME, g_value_get_string (value),
COL_SOURCE, "Pidgin",