summaryrefslogtreecommitdiff
path: root/src/nautilus-view.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-04-21 11:30:34 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-04-22 13:18:05 +0200
commitc38a5dfdad01c4006563f552f601342f54ce7cb6 (patch)
tree13a586cacea6d567d67f3ff1c68e3aa81e4dab29 /src/nautilus-view.c
parentfa64cb2a828e9042111fa626dd7f66683cb13b19 (diff)
downloadnautilus-c38a5dfdad01c4006563f552f601342f54ce7cb6.tar.gz
view: extract the creation of new folder dialog
Diffstat (limited to 'src/nautilus-view.c')
-rw-r--r--src/nautilus-view.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index ea5c14edc..8f0384ca6 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -1750,30 +1750,34 @@ nautilus_view_new_folder_dialog_entry_activate (GtkWidget *entry,
}
}
-static void
-nautilus_view_new_folder (NautilusView *directory_view,
- gboolean with_selection)
+typedef struct {
+ gint response;
+ gchar *name;
+} FileNameDialogReturnData;
+
+static FileNameDialogReturnData*
+nautilus_view_new_file_name_dialog (NautilusView *view)
{
FileNameDialogData *dialog_data;
+ FileNameDialogReturnData *dialog_return_data;
GtkBuilder *builder;
GtkWindow *dialog;
GtkEntry *entry;
- gint response;
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-new-folder-dialog.ui");
dialog = GTK_WINDOW (gtk_builder_get_object (builder, "new_folder_dialog"));
entry = GTK_ENTRY (gtk_builder_get_object (builder, "name_entry"));
/* build up dialog fields */
- dialog_data = g_new0 (FileNameDialogData, 1);
- dialog_data->view = directory_view;
+ dialog_data = g_new (FileNameDialogData, 1);
+ dialog_data->view = view;
dialog_data->dialog = GTK_WIDGET (dialog);
dialog_data->error_label = GTK_WIDGET (gtk_builder_get_object (builder, "error_label"));
dialog_data->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
dialog_data->target_is_folder = TRUE;
gtk_window_set_transient_for (dialog,
- GTK_WINDOW (nautilus_view_get_window (directory_view)));
+ GTK_WINDOW (nautilus_view_get_window (view)));
/* Connect signals */
gtk_builder_add_callback_symbols (builder,
@@ -1785,17 +1789,33 @@ nautilus_view_new_folder (NautilusView *directory_view,
gtk_builder_connect_signals (builder, dialog_data);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ dialog_return_data = g_new (FileNameDialogReturnData, 1);
+ dialog_return_data->response = gtk_dialog_run (GTK_DIALOG (dialog));
+ dialog_return_data->name = g_strstrip (g_strdup (gtk_entry_get_text (entry)));
+
+ g_object_unref (builder);
+ g_free (dialog_data);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
- if (response == GTK_RESPONSE_OK) {
+ return dialog_return_data;
+}
+
+static void
+nautilus_view_new_folder (NautilusView *directory_view,
+ gboolean with_selection)
+{
+ FileNameDialogReturnData *dialog_return_data;
+
+ dialog_return_data = nautilus_view_new_file_name_dialog (directory_view);
+
+ if (dialog_return_data->response == GTK_RESPONSE_OK) {
NewFolderData *data;
GdkPoint *pos;
char *parent_uri;
gchar *name;
data = new_folder_data_new (directory_view, with_selection);
- name = g_strdup (gtk_entry_get_text (entry));
- g_strstrip (name);
+ name = dialog_return_data->name;
g_signal_connect_data (directory_view,
"add-file",
@@ -1824,9 +1844,7 @@ nautilus_view_new_folder (NautilusView *directory_view,
directory_view->details->dialog_duplicated_name_label_timeout_id = 0;
}
- g_free (dialog_data);
- g_object_unref (builder);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_free (dialog_return_data);
}
static NewFolderData *