Revert "view: show "New Folder" dialog"

This reverts commit 6f4fc647.
parent 1b513125
......@@ -6256,7 +6256,6 @@ void
nautilus_file_operations_new_folder (GtkWidget *parent_view,
GdkPoint *target_point,
const char *parent_dir,
const char *folder_name,
NautilusCreateCallback done_callback,
gpointer done_callback_data)
{
......@@ -6272,7 +6271,6 @@ nautilus_file_operations_new_folder (GtkWidget *parent_view,
job->done_callback = done_callback;
job->done_callback_data = done_callback_data;
job->dest_dir = g_file_new_for_uri (parent_dir);
job->filename = g_strdup (folder_name);
job->make_dir = TRUE;
if (target_point != NULL) {
job->position = *target_point;
......
......@@ -64,7 +64,6 @@ void nautilus_file_operations_empty_trash (GtkWidget *parent_vie
void nautilus_file_operations_new_folder (GtkWidget *parent_view,
GdkPoint *target_point,
const char *parent_dir_uri,
const char *folder_name,
NautilusCreateCallback done_callback,
gpointer done_callback_data);
void nautilus_file_operations_new_file (GtkWidget *parent_view,
......
......@@ -729,7 +729,7 @@ create_folder_redo_func (NautilusFileUndoInfoCreate *self,
parent = g_file_get_parent (self->priv->target_file);
parent_uri = g_file_get_uri (parent);
nautilus_file_operations_new_folder (NULL, NULL, parent_uri, NULL,
nautilus_file_operations_new_folder (NULL, NULL, parent_uri,
create_callback, self);
g_free (parent_uri);
......
......@@ -1404,6 +1404,22 @@ rename_file (NautilusView *view, NautilusFile *new_file)
nautilus_view_reveal_selection (view);
}
static void
reveal_newly_added_folder (NautilusView *view, NautilusFile *new_file,
NautilusDirectory *directory, GFile *target_location)
{
GFile *location;
location = nautilus_file_get_location (new_file);
if (g_file_equal (location, target_location)) {
g_signal_handlers_disconnect_by_func (view,
G_CALLBACK (reveal_newly_added_folder),
(void *) target_location);
rename_file (view, new_file);
}
g_object_unref (location);
}
typedef struct {
NautilusView *directory_view;
GHashTable *added_locations;
......@@ -1537,6 +1553,22 @@ new_folder_done (GFile *new_folder,
0, 0);
g_list_free_full (uris, g_free);
g_free (target_uri);
} else {
if (g_hash_table_lookup_extended (data->added_locations, new_folder, NULL, NULL)) {
/* The file was already added */
rename_file (directory_view, file);
} else {
/* We need to run after the default handler adds the folder we want to
* operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we
* must use connect_after.
*/
g_signal_connect_data (directory_view,
"add-file",
G_CALLBACK (reveal_newly_added_folder),
g_object_ref (new_folder),
(GClosureNotify)g_object_unref,
G_CONNECT_AFTER);
}
}
nautilus_file_unref (file);
......@@ -1591,134 +1623,31 @@ context_menu_to_file_operation_position (NautilusView *view)
}
}
static void
nautilus_view_add_file_dialog_validate_entry (GObject *object,
GParamSpec *params,
gpointer user_data)
{
const gchar *text;
g_assert (object && GTK_IS_ENTRY (object));
g_assert (user_data && GTK_IS_DIALOG (user_data));
text = gtk_entry_get_text (GTK_ENTRY (object));
gtk_dialog_set_response_sensitive (GTK_DIALOG (user_data),
GTK_RESPONSE_OK,
g_utf8_strlen (text, -1) > 0);
}
static void
nautilus_view_add_file_dialog_entry_activate (GtkWidget *entry,
gpointer user_data)
{
const gchar *text;
g_assert (entry && GTK_IS_ENTRY (entry));
g_assert (user_data && GTK_IS_DIALOG (user_data));
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (g_utf8_strlen (text, -1) > 0) {
gtk_dialog_response (GTK_DIALOG (user_data),
GTK_RESPONSE_OK);
}
}
static void
nautilus_view_new_folder (NautilusView *directory_view,
gboolean with_selection)
{
GtkWidget *dialog;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *box;
GtkWidget *window;
GtkWidget *area;
gint response;
// Dialog label
label = gtk_label_new (_("Name"));
gtk_style_context_add_class (gtk_widget_get_style_context (label),
"dim-label");
// Folder name entry
entry = gtk_entry_new ();
gtk_widget_set_hexpand (entry, TRUE);
// Dialog
window = gtk_widget_get_toplevel (GTK_WIDGET (directory_view));
dialog = gtk_dialog_new_with_buttons (_("New Folder"),
GTK_WINDOW (window),
GTK_DIALOG_MODAL | GTK_DIALOG_USE_HEADER_BAR | GTK_DIALOG_DESTROY_WITH_PARENT,
_("Cancel"),
GTK_RESPONSE_CANCEL,
_("Create"),
GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_OK);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog ),
GTK_RESPONSE_OK,
FALSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
// Main box
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (box), entry);
gtk_container_add (GTK_CONTAINER (area), box);
gtk_widget_show_all (box);
// Only allow non-null names
g_signal_connect (entry,
"notify::text",
G_CALLBACK (nautilus_view_add_file_dialog_validate_entry),
dialog);
g_signal_connect (entry,
"activate",
G_CALLBACK (nautilus_view_add_file_dialog_entry_activate),
dialog);
// Show the dialog and wait for user interaction
response = gtk_dialog_run (GTK_DIALOG (dialog));
// Perform the action on GTK_RESPONSE_OK response
if (response == GTK_RESPONSE_OK) {
char *parent_uri;
gchar *name;
NewFolderData *data;
GdkPoint *pos;
data = new_folder_data_new (directory_view, with_selection);
name = gtk_entry_get_text (GTK_ENTRY (entry));
char *parent_uri;
NewFolderData *data;
GdkPoint *pos;
g_signal_connect_data (directory_view,
"add-file",
G_CALLBACK (track_newly_added_locations),
data,
(GClosureNotify)NULL,
G_CONNECT_AFTER);
data = new_folder_data_new (directory_view, with_selection);
pos = context_menu_to_file_operation_position (directory_view);
g_signal_connect_data (directory_view,
"add-file",
G_CALLBACK (track_newly_added_locations),
data,
(GClosureNotify)NULL,
G_CONNECT_AFTER);
parent_uri = nautilus_view_get_backing_uri (directory_view);
nautilus_file_operations_new_folder (GTK_WIDGET (directory_view),
pos,
parent_uri,
name,
new_folder_done, data);
pos = context_menu_to_file_operation_position (directory_view);
g_free (parent_uri);
}
parent_uri = nautilus_view_get_backing_uri (directory_view);
nautilus_file_operations_new_folder (GTK_WIDGET (directory_view),
pos, parent_uri,
new_folder_done, data);
gtk_widget_destroy (dialog);
g_free (parent_uri);
}
static NewFolderData *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment