aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-accounts-dialog.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-03 01:08:27 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-03 22:04:37 +0800
commit24a3d8e3e4cee7272cc26d17ca3bdb8029581304 (patch)
treed913d7f9c044ac01e9bdfb9f29bb7482e45c23ca /src/empathy-accounts-dialog.c
parentf72e6ddce1c1fd2ac17e11b3fcd285d08ba787dd (diff)
downloadgsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar.gz
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar.bz2
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar.lz
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar.xz
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.tar.zst
gsoc2013-empathy-24a3d8e3e4cee7272cc26d17ca3bdb8029581304.zip
Allow accounts_dialog_has_pending_change to return a NULL TpAccount
That way we can warn user when he is about to lose his newly created account (#598550).
Diffstat (limited to 'src/empathy-accounts-dialog.c')
-rw-r--r--src/empathy-accounts-dialog.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 2a09e277b..f12c4513a 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -61,6 +61,10 @@
* unsaved changes */
#define PENDING_CHANGES_QUESTION_PRIMARY_TEXT \
_("There are unsaved modification regarding your %s account.")
+/* The primary text of the dialog shown to the user when he is about to lose
+ * an unsaved new account */
+#define UNSAVED_NEW_ACCOUNT_QUESTION_PRIMARY_TEXT \
+ _("Your new account has not been saved yet.")
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT);
@@ -363,7 +367,7 @@ accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog,
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, account, -1);
- return *account != NULL && priv->setting_widget_object != NULL
+ return priv->setting_widget_object != NULL
&& empathy_account_widget_contains_pending_changes (
priv->setting_widget_object);
}
@@ -495,6 +499,22 @@ accounts_dialog_add_pending_changes_response_cb (GtkDialog *message_dialog,
}
}
+static gchar *
+get_dialog_primary_text (TpAccount *account)
+{
+ if (account != NULL)
+ {
+ /* Existing account */
+ return g_strdup_printf (PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
+ tp_account_get_display_name (account));
+ }
+ else
+ {
+ /* Newly created account */
+ return g_strdup (UNSAVED_NEW_ACCOUNT_QUESTION_PRIMARY_TEXT);
+ }
+}
+
static void
accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
@@ -503,9 +523,7 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button,
if (accounts_dialog_has_pending_change (dialog, &account))
{
- gchar *question_dialog_primary_text = g_strdup_printf (
- PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- tp_account_get_display_name (account));
+ gchar *question_dialog_primary_text = get_dialog_primary_text (account);
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,
@@ -999,13 +1017,9 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
/* The currently selected account has some unsaved changes. We ask
* the user if he really wants to lose his changes and select another
* account */
- gchar *question_dialog_primary_text;
+ gchar *question_dialog_primary_text = get_dialog_primary_text (account);
priv->destination_row = gtk_tree_row_reference_new (model, path);
- question_dialog_primary_text = g_strdup_printf (
- PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- tp_account_get_display_name (account));
-
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,
_("You are about to select another account, which will discard\n"
@@ -1450,10 +1464,7 @@ accounts_dialog_response_cb (GtkWidget *widget,
if (accounts_dialog_has_pending_change (dialog, &account))
{
- gchar *question_dialog_primary_text;
- question_dialog_primary_text = g_strdup_printf (
- PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- tp_account_get_display_name (account));
+ gchar *question_dialog_primary_text = get_dialog_primary_text (account);
accounts_dialog_show_question_dialog (dialog,
question_dialog_primary_text,