/* The primary text of the dialog shown to the user when he is about to lose
* unsaved changes */
#define PENDING_CHANGES_QUESTION_PRIMARY_TEXT \
- "There are unsaved modification regarding your %s account."
+ _("There are unsaved modification regarding your %s account.")
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT);
* is retrieved asynchronously, we keep some information as member of the
* EmpathyAccountsDialog object. */
gboolean force_change_row;
- gchar *destination_path;
+ GtkTreeRowReference *destination_row;
} EmpathyAccountsDialogPriv;
/* To translators: The first parameter is the login id and the
* second one is the server. The resulting string will be something
- * like: "MyUserName on chat.freenode.net" */
- default_display_name =
- g_strdup_printf (_("%s on %s"), login_id, server);
+ * like: "MyUserName on chat.freenode.net".
+ * You should reverse the order of these arguments if the
+ * server should come before the login id in your locale.*/
+ default_display_name = g_strdup_printf (_("%1$s on %2$s"),
+ login_id, server);
}
else
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
gchar *icon_name;
- priv->settings_widget = empathy_account_widget_get_widget (widget_object);
+ priv->setting_widget_object =
+ empathy_account_widget_new_for_protocol (settings, FALSE);
+
+ priv->settings_widget =
+ empathy_account_widget_get_widget (priv->setting_widget_object);
+
+ priv->settings_widget =
+ empathy_account_widget_get_widget (priv->setting_widget_object);
g_signal_connect (priv->setting_widget_object, "account-created",
G_CALLBACK (empathy_account_dialog_account_created_cb), dialog);
g_signal_connect (priv->setting_widget_object, "cancelled",
accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog,
EmpathyAccount **account)
{
- gboolean has_pending_changes;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreeSelection *selection;
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, account, -1);
- has_pending_changes = account != NULL && priv->setting_widget_object != NULL
+ return *account != NULL && priv->setting_widget_object != NULL
&& empathy_account_widget_contains_pending_changes (
priv->setting_widget_object);
-
- return has_pending_changes;
}
static void
accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account;
+ EmpathyAccount *account = NULL;
if (accounts_dialog_has_pending_change (dialog, &account))
{
- gchar *question_dialog_primary_text = g_strdup_printf (
- PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
- empathy_account_get_display_name (account));
-
- accounts_dialog_show_question_dialog (dialog, question_dialog_primary_text,
- "You are about to create a new account, which will discard\n"
- "your changes. Are you sure you want to proceed?",
- G_CALLBACK (accounts_dialog_add_pending_changes_response_cb),
- dialog,
- GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
- GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
-
- g_free (question_dialog_primary_text);
+ gchar *question_dialog_primary_text = g_strdup_printf (
+ PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
+ empathy_account_get_display_name (account));
+
+ accounts_dialog_show_question_dialog (dialog,
+ question_dialog_primary_text,
+ _("You are about to create a new account, which will discard\n"
+ "your changes. Are you sure you want to proceed?"),
+ G_CALLBACK (accounts_dialog_add_pending_changes_response_cb),
+ dialog,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+ GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
+
+ g_free (question_dialog_primary_text);
}
else
{
accounts_dialog_account_display_name_changed_cb, account_dialog);
empathy_account_remove_async (account, NULL, NULL);
g_object_unref (account);
+ account = NULL;
}
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
g_free (question_dialog_primary_text);
if (account != NULL)
- g_object_unref (account);
+ {
+ g_object_unref (account);
+ account = NULL;
+ }
}
static void
gtk_widget_destroy (GTK_WIDGET (message_dialog));
- if (response_id == GTK_RESPONSE_YES)
+ if (response_id == GTK_RESPONSE_YES && priv->destination_row != NULL)
{
/* The user wants to lose unsaved changes to the currently selected
* account and select another account. We discard the changes and
* select the other account. */
- GtkTreeIter iter;
+ GtkTreePath *path;
GtkTreeSelection *selection;
- GtkTreeModel *model;
priv->force_change_row = TRUE;
empathy_account_widget_discard_pending_changes (
priv->setting_widget_object);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+ path = gtk_tree_row_reference_get_path (priv->destination_row);
selection = gtk_tree_view_get_selection (
GTK_TREE_VIEW (priv->treeview));
- if (gtk_tree_model_get_iter_from_string (model,
- &iter, priv->destination_path))
+ if (path != NULL)
{
/* This will trigger a call to
* accounts_dialog_account_selection_change() */
- gtk_tree_selection_select_iter (selection, &iter);
+ gtk_tree_selection_select_path (selection, path);
+ gtk_tree_path_free (path);
}
+
+ gtk_tree_row_reference_free (priv->destination_row);
}
else
{
gboolean path_currently_selected,
gpointer data)
{
- EmpathyAccount *account;
+ EmpathyAccount *account = NULL;
EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (data);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
* the user if he really wants to lose his changes and select another
* account */
gchar *question_dialog_primary_text;
- priv->destination_path = gtk_tree_path_to_string (path);
+ priv->destination_row = gtk_tree_row_reference_new (model, path);
question_dialog_primary_text = g_strdup_printf (
PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
empathy_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"
- "your changes. Are you sure you want to proceed?",
+ accounts_dialog_show_question_dialog (dialog,
+ question_dialog_primary_text,
+ _("You are about to select another account, which will discard\n"
+ "your changes. Are you sure you want to proceed?"),
G_CALLBACK (accounts_dialog_selection_change_response_cb),
dialog,
GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
gint response,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccount *account;
+ EmpathyAccount *account = NULL;
if (accounts_dialog_has_pending_change (dialog, &account))
{
PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
empathy_account_get_display_name (account));
- accounts_dialog_show_question_dialog (dialog, question_dialog_primary_text,
- "You are about to close the window, which will discard\n"
- "your changes. Are you sure you want to proceed?",
+ accounts_dialog_show_question_dialog (dialog,
+ question_dialog_primary_text,
+ _("You are about to close the window, which will discard\n"
+ "your changes. Are you sure you want to proceed?"),
G_CALLBACK (accounts_dialog_close_response_cb),
widget,
GTK_STOCK_CANCEL, GTK_RESPONSE_NO,