From 788470113896a3d6c7ff441b0ea031568029f83c Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 10 Mar 2009 11:20:01 +0000 Subject: [PATCH] Make the "Import Accounts" button insensitive if there's nothing to import. Signed-off-by: Jonny Lamb svn path=/trunk/; revision=2665 --- src/empathy-accounts-dialog.c | 16 +++++++++++----- src/empathy-import-dialog.c | 6 ++++++ src/empathy-import-dialog.h | 1 + src/empathy-import-pidgin.c | 16 ++++++++++++++++ src/empathy-import-pidgin.h | 1 + 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 892f2423..4d945668 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1153,11 +1153,17 @@ empathy_accounts_dialog_show (GtkWindow *parent, empathy_conf_get_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, &import_asked); - if (!import_asked) { - empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_IMPORT_ASKED, TRUE); - empathy_import_dialog_show (GTK_WINDOW (dialog->window), - FALSE); + + if (empathy_import_dialog_accounts_to_import ()) { + + if (!import_asked) { + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_IMPORT_ASKED, TRUE); + empathy_import_dialog_show (GTK_WINDOW (dialog->window), + FALSE); + } + } else { + gtk_widget_set_sensitive (dialog->button_import, FALSE); } return dialog->window; diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c index 80e2d747..955e07b9 100644 --- a/src/empathy-import-dialog.c +++ b/src/empathy-import-dialog.c @@ -347,6 +347,12 @@ import_dialog_destroy_cb (GtkWidget *widget, g_slice_free (EmpathyImportDialog, dialog); } +gboolean +empathy_import_dialog_accounts_to_import (void) +{ + return empathy_import_pidgin_accounts_to_import (); +} + void empathy_import_dialog_show (GtkWindow *parent, gboolean warning) diff --git a/src/empathy-import-dialog.h b/src/empathy-import-dialog.h index 1d616e38..278afc70 100644 --- a/src/empathy-import-dialog.h +++ b/src/empathy-import-dialog.h @@ -38,6 +38,7 @@ typedef struct EmpathyImportAccountData *empathy_import_account_data_new (const gchar *source); void empathy_import_account_data_free (EmpathyImportAccountData *data); +gboolean empathy_import_dialog_accounts_to_import (void); void empathy_import_dialog_show (GtkWindow *parent, gboolean warning); G_END_DECLS diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c index 6c40bccf..76295c70 100644 --- a/src/empathy-import-pidgin.c +++ b/src/empathy-import-pidgin.c @@ -303,3 +303,19 @@ FILENAME: return accounts; } +gboolean +empathy_import_pidgin_accounts_to_import (void) +{ + gchar *filename; + gboolean out; + GFile *file; + + filename = g_build_filename (g_get_home_dir (), ".purple", "accounts.xml", NULL); + file = g_file_new_for_path (filename); + out = g_file_query_exists (file, NULL); + + g_free (filename); + g_object_unref (file); + + return out; +} diff --git a/src/empathy-import-pidgin.h b/src/empathy-import-pidgin.h index 4f1bd5a3..fc7d2e49 100644 --- a/src/empathy-import-pidgin.h +++ b/src/empathy-import-pidgin.h @@ -27,6 +27,7 @@ G_BEGIN_DECLS GList *empathy_import_pidgin_load (void); +gboolean empathy_import_pidgin_accounts_to_import (void); G_END_DECLS -- 2.39.2