the same implementation (fixes NB#58817).
* src/modest-platform.h:
* New rename_folder_dialog method.
* src/modest-ui-actions.c:
* Now rename uses a dialog in modest platform, sharing the
implementation with new folder dialog. Also removed old
dialog implementation.
* src/maemo/modest-platform.c:
* New method rename_folder_dialog, and refactored
new_folder_dialog, creating name_folder_dialog
that implements the same logic and controls for
both UI actions.
pmo-trunk-r2367
/* Show WID-INF036 */
if (chars_length == 20) {
hildon_banner_show_information (gtk_widget_get_parent (GTK_WIDGET (data)), NULL,
- _("mcen_ib_maxchar_reached"));
+ dgettext("hildon-common-strings", "ckdg_ib_maximum_characters_reached"));
} else {
if (chars_length == 0) {
/* A blank space is not valid as first character */
g_list_free(cols);
}
-
-
-gint
-modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
- TnyFolderStore *parent_folder,
- gchar *suggested_name,
- gchar **folder_name)
+static gint
+modest_platform_run_folder_name_dialog (GtkWindow *parent_window,
+ const gchar *dialog_title,
+ const gchar *label_text,
+ const gchar *suggested_name,
+ gchar **folder_name)
{
GtkWidget *dialog, *entry, *label, *hbox;
gint result;
/* Ask the user for the folder name */
- dialog = gtk_dialog_new_with_buttons (_("mcen_ti_new_folder"),
+ dialog = gtk_dialog_new_with_buttons (dialog_title,
parent_window,
GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK,
NULL);
/* Create label and entry */
- label = gtk_label_new (_("mcen_fi_new_folder_name"));
+ label = gtk_label_new (label_text);
/* TODO: check that the suggested name does not exist */
/* We set 21 as maximum because we want to show WID-INF036
when the user inputs more that 20 */
}
gint
+modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
+ TnyFolderStore *parent_folder,
+ gchar *suggested_name,
+ gchar **folder_name)
+{
+ return modest_platform_run_folder_name_dialog (parent_window,
+ _("mcen_ti_new_folder"),
+ _("mcen_fi_new_folder_name"),
+ suggested_name,
+ folder_name);
+}
+
+gint
+modest_platform_run_rename_folder_dialog (GtkWindow *parent_window,
+ TnyFolderStore *parent_folder,
+ const gchar *suggested_name,
+ gchar **folder_name)
+{
+ return modest_platform_run_folder_name_dialog (parent_window,
+ _("New folder name"),
+ _("Enter new folder name:"),
+ suggested_name,
+ folder_name);
+}
+
+gint
modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
const gchar *message)
{
gchar **folder_name);
/**
+ * modest_platform_run_rename_folder_dialog:
+ * @parent_window: a #GtkWindow
+ * @parent: the parent of the folder
+ * @suggested_name: current name of the folder
+ * @folder_name: the new folder name selected by the user for the folder
+ *
+ * runs a "rename folder" confirmation dialog. If the user input a valid folder name it's
+ * returned in the #folder_name attribute.
+ *
+ * Returns: the #GtkResponseType returned by the dialog
+ **/
+gint modest_platform_run_rename_folder_dialog (GtkWindow *parent_window,
+ TnyFolderStore *parent,
+ const gchar *current_name,
+ gchar **folder_name);
+
+/**
* modest_platform_run_confirmation_dialog:
* @parent_window: the parent #GtkWindow of the dialog
* @message: the message to show to the user
static void reply_forward (ReplyForwardAction action, ModestWindow *win);
-static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title);
-
static void _on_send_receive_progress_changed (ModestMailOperation *mail_op,
ModestMailOperationState *state,
modest_msg_edit_window_remove_attachments (window, NULL);
}
-/*
- * Shows a dialog with an entry that asks for some text. The returned
- * value must be freed by the caller. The dialog window title will be
- * set to @title.
- */
-static gchar *
-ask_for_folder_name (GtkWindow *parent_window,
- const gchar *title)
-{
- GtkWidget *dialog, *entry;
- gchar *folder_name = NULL;
-
- /* Ask for folder name */
- dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
- parent_window,
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- gtk_label_new(title),
- FALSE, FALSE, 0);
-
- entry = gtk_entry_new_with_max_length (40);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- entry,
- TRUE, FALSE, 0);
-
- gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
-
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
- folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
-
- gtk_widget_destroy (dialog);
-
- return folder_name;
-}
-
void
modest_ui_actions_on_new_folder (GtkAction *action, ModestMainWindow *main_window)
{
if (folder && TNY_IS_FOLDER (folder)) {
gchar *folder_name;
- folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
- _("Please enter a new name for the folder"));
+ gint response;
+ const gchar *current_name;
+
+ current_name = tny_folder_get_name (TNY_FOLDER (folder));
+ response = modest_platform_run_rename_folder_dialog (GTK_WINDOW (main_window), NULL,
+ current_name, &folder_name);
- if (folder_name != NULL && strlen (folder_name) > 0) {
+ if (response == GTK_RESPONSE_OK && strlen (folder_name) > 0) {
ModestMailOperation *mail_op;
mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window));