summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-04-22 11:50:06 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-04-22 20:56:39 +0200
commit48136bb5e964b1f2d1439f913ee214061d4e5a8e (patch)
tree48d8542f8bb915df40b2848ab98a1e3529f2aae5 /src
parent94edb26627c21f53dbe5e7a59a188aedaca7a05b (diff)
downloadnautilus-48136bb5e964b1f2d1439f913ee214061d4e5a8e.tar.gz
canvas-container: remove in place renaming support
Now that we use a dialog, we can remove lot of hacks we had for in place renaming.
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-canvas-view.c37
-rw-r--r--src/nautilus-list-view.c70
-rw-r--r--src/nautilus-view.c130
-rw-r--r--src/nautilus-view.h6
4 files changed, 7 insertions, 236 deletions
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 543b71364..b71753ad9 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1009,19 +1009,6 @@ nautilus_canvas_view_can_rename_file (NautilusView *view, NautilusFile *file)
return NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->can_rename_file (view, file);
}
-static void
-nautilus_canvas_view_start_renaming_file (NautilusView *view,
- NautilusFile *file,
- gboolean select_all)
-{
- /* call parent class to make sure the right canvas is selected */
- NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->start_renaming_file (view, file, select_all);
-
- /* start renaming */
- nautilus_canvas_container_start_renaming_selected_item
- (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), select_all);
-}
-
const GActionEntry canvas_view_entries[] = {
{ "keep-aligned", NULL, NULL, "true", action_keep_aligned },
{ "reversed-order", NULL, NULL, "false", action_reversed_order },
@@ -1373,27 +1360,6 @@ icon_position_changed_callback (NautilusCanvasContainer *container,
"1.0", scale_string);
}
-/* Attempt to change the filename to the new text. Notify user if operation fails. */
-static void
-icon_rename_ended_cb (NautilusCanvasContainer *container,
- NautilusFile *file,
- const char *new_name,
- NautilusCanvasView *canvas_view)
-{
- g_assert (NAUTILUS_IS_FILE (file));
-
- nautilus_view_set_is_renaming (NAUTILUS_VIEW (canvas_view), FALSE);
-
- /* Don't allow a rename with an empty string. Revert to original
- * without notifying the user.
- */
- if ((new_name == NULL) || (new_name[0] == '\0')) {
- return;
- }
-
- nautilus_rename_file (file, new_name, NULL, NULL);
-}
-
static char *
get_icon_uri_callback (NautilusCanvasContainer *container,
NautilusFile *file,
@@ -1664,8 +1630,6 @@ create_canvas_container (NautilusCanvasView *canvas_view)
G_CALLBACK (get_stored_icon_position_callback), canvas_view, 0);
g_signal_connect_object (canvas_container, "layout-changed",
G_CALLBACK (layout_changed_callback), canvas_view, 0);
- g_signal_connect_object (canvas_container, "icon-rename-ended",
- G_CALLBACK (icon_rename_ended_cb), canvas_view, 0);
g_signal_connect_object (canvas_container, "icon-stretch-started",
G_CALLBACK (nautilus_view_update_context_menus), canvas_view,
G_CONNECT_SWAPPED);
@@ -1872,7 +1836,6 @@ nautilus_canvas_view_class_init (NautilusCanvasViewClass *klass)
nautilus_view_class->click_policy_changed = nautilus_canvas_view_click_policy_changed;
nautilus_view_class->update_actions_state = nautilus_canvas_view_update_actions_state;
nautilus_view_class->sort_directories_first_changed = nautilus_canvas_view_sort_directories_first_changed;
- nautilus_view_class->start_renaming_file = nautilus_canvas_view_start_renaming_file;
nautilus_view_class->using_manual_layout = nautilus_canvas_view_using_manual_layout;
nautilus_view_class->widget_to_file_operation_position = nautilus_canvas_view_widget_to_file_operation_position;
nautilus_view_class->get_view_id = nautilus_canvas_view_get_id;
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b7d39d591..09731abcc 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3147,69 +3147,6 @@ nautilus_list_view_can_zoom_out (NautilusView *view)
}
static void
-nautilus_list_view_start_renaming_file (NautilusView *view,
- NautilusFile *file,
- gboolean select_all)
-{
- NautilusListView *list_view;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- list_view = NAUTILUS_LIST_VIEW (view);
-
- /* Select all if we are in renaming mode already */
- if (list_view->details->file_name_column && list_view->details->editable_widget) {
- gtk_editable_select_region (GTK_EDITABLE (list_view->details->editable_widget),
- 0,
- -1);
- return;
- }
-
- if (!nautilus_list_model_get_first_iter_for_file (list_view->details->model, file, &iter)) {
- return;
- }
-
- /* call parent class to make sure the right icon is selected */
- NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->start_renaming_file (view, file, select_all);
-
- /* Freeze updates to the view to prevent losing rename focus when the tree view updates */
- nautilus_view_freeze_updates (NAUTILUS_VIEW (view));
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_view->details->model), &iter);
-
- /* Make filename-cells editable. */
- g_object_set (G_OBJECT (list_view->details->file_name_cell),
- "editable", TRUE,
- NULL);
-
- gtk_tree_view_scroll_to_cell (list_view->details->tree_view,
- NULL,
- list_view->details->file_name_column,
- TRUE, 0.0, 0.0);
- gtk_tree_view_set_cursor_on_cell (list_view->details->tree_view,
- path,
- list_view->details->file_name_column,
- GTK_CELL_RENDERER (list_view->details->file_name_cell),
- TRUE);
-
- /* set cursor also triggers editing-started, where we save the editable widget */
- if (list_view->details->editable_widget != NULL) {
- int start_offset = 0;
- int end_offset = -1;
-
- if (!select_all) {
- eel_filename_get_rename_region (list_view->details->original_name,
- &start_offset, &end_offset);
- }
-
- gtk_editable_select_region (GTK_EDITABLE (list_view->details->editable_widget),
- start_offset, end_offset);
- }
-
- gtk_tree_path_free (path);
-}
-
-static void
nautilus_list_view_click_policy_changed (NautilusView *directory_view)
{
GdkWindow *win;
@@ -3237,7 +3174,7 @@ nautilus_list_view_click_policy_changed (NautilusView *directory_view)
if (gtk_widget_get_realized (GTK_WIDGET (tree))) {
win = gtk_widget_get_window (GTK_WIDGET (tree));
gdk_window_set_cursor (win, NULL);
-
+
display = gtk_widget_get_display (GTK_WIDGET (view));
if (display != NULL) {
gdk_display_flush (display);
@@ -3266,10 +3203,10 @@ static void
default_visible_columns_changed_callback (gpointer callback_data)
{
NautilusListView *list_view;
-
+
list_view = NAUTILUS_LIST_VIEW (callback_data);
- set_columns_settings_from_metadata_and_preferences (list_view);
+ set_columns_settings_from_metadata_and_preferences (list_view);
}
static void
@@ -3531,7 +3468,6 @@ nautilus_list_view_class_init (NautilusListViewClass *class)
nautilus_view_class->invert_selection = nautilus_list_view_invert_selection;
nautilus_view_class->compare_files = nautilus_list_view_compare_files;
nautilus_view_class->sort_directories_first_changed = nautilus_list_view_sort_directories_first_changed;
- nautilus_view_class->start_renaming_file = nautilus_list_view_start_renaming_file;
nautilus_view_class->end_file_changes = nautilus_list_view_end_file_changes;
nautilus_view_class->using_manual_layout = nautilus_list_view_using_manual_layout;
nautilus_view_class->get_view_id = nautilus_list_view_get_id;
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index a59a93106..dbf499942 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -181,8 +181,6 @@ struct NautilusViewDetails
guint done_loading_handler_id;
guint file_changed_handler_id;
- guint delayed_rename_file_id;
-
GList *new_added_files;
GList *new_changed_files;
@@ -1339,77 +1337,6 @@ action_select_pattern (GSimpleAction *action,
select_pattern(user_data);
}
-typedef struct {
- NautilusView *view;
- NautilusFile *new_file;
-} RenameData;
-
-static gboolean
-delayed_rename_file_hack_callback (RenameData *data)
-{
- NautilusView *view;
- NautilusFile *new_file;
-
- view = data->view;
- new_file = data->new_file;
-
- if (view->details->slot != NULL &&
- view->details->active) {
- NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->start_renaming_file (view, new_file, FALSE);
- nautilus_view_reveal_selection (view);
- }
-
- return FALSE;
-}
-
-static void
-delayed_rename_file_hack_removed (RenameData *data)
-{
- g_object_unref (data->view);
- nautilus_file_unref (data->new_file);
- g_free (data);
-}
-
-
-static void
-rename_file (NautilusView *view, NautilusFile *new_file)
-{
- RenameData *data;
-
- /* HACK!!!!
- This is a work around bug in listview. After the rename is
- enabled we will get file changes due to info about the new
- file being read, which will cause the model to change. When
- the model changes GtkTreeView clears the editing. This hack just
- delays editing for some time to try to avoid this problem.
- A major problem is that the selection of the row causes us
- to load the slow mimetype for the file, which leads to a
- file_changed. So, before we delay we select the row.
- */
- if (NAUTILUS_IS_LIST_VIEW (view)) {
- nautilus_view_select_file (view, new_file);
-
- data = g_new (RenameData, 1);
- data->view = g_object_ref (view);
- data->new_file = nautilus_file_ref (new_file);
- if (view->details->delayed_rename_file_id != 0) {
- g_source_remove (view->details->delayed_rename_file_id);
- }
- view->details->delayed_rename_file_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT,
- 100, (GSourceFunc)delayed_rename_file_hack_callback,
- data, (GDestroyNotify) delayed_rename_file_hack_removed);
-
- return;
- }
-
- /* no need to select because start_renaming_file selects
- * nautilus_view_select_file (view, new_file);
- */
- NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->start_renaming_file (view, new_file, FALSE);
- nautilus_view_reveal_selection (view);
-}
-
static void
reveal_newly_added_folder (NautilusView *view, NautilusFile *new_file,
NautilusDirectory *directory, GFile *target_location)
@@ -1439,30 +1366,6 @@ typedef struct {
} NewFolderSelectionData;
static void
-rename_newly_added_folder (NautilusView *view, NautilusFile *removed_file,
- NautilusDirectory *directory, NewFolderSelectionData *data)
-{
- GFile *location;
-
- location = nautilus_file_get_location (removed_file);
- if (!g_hash_table_remove (data->to_remove_locations, location)) {
- g_assert_not_reached ();
- }
- g_object_unref (location);
- if (g_hash_table_size (data->to_remove_locations) == 0) {
- nautilus_view_set_selection (data->directory_view, NULL);
- g_signal_handlers_disconnect_by_func (data->directory_view,
- G_CALLBACK (rename_newly_added_folder),
- (void *) data);
-
- rename_file (data->directory_view, data->new_folder);
- g_object_unref (data->new_folder);
- g_hash_table_destroy (data->to_remove_locations);
- g_free (data);
- }
-}
-
-static void
track_newly_added_locations (NautilusView *view, NautilusFile *new_file,
NautilusDirectory *directory, gpointer user_data)
{
@@ -1474,7 +1377,7 @@ track_newly_added_locations (NautilusView *view, NautilusFile *new_file,
}
static void
-new_folder_done (GFile *new_folder,
+new_folder_done (GFile *new_folder,
gboolean success,
gpointer user_data)
{
@@ -1499,11 +1402,11 @@ new_folder_done (GFile *new_folder,
if (new_folder == NULL) {
goto fail;
}
-
+
screen = gtk_widget_get_screen (GTK_WIDGET (directory_view));
g_snprintf (screen_string, sizeof (screen_string), "%d", gdk_screen_get_number (screen));
-
+
file = nautilus_file_get (new_folder);
nautilus_file_set_metadata
(file, NAUTILUS_METADATA_KEY_SCREEN,
@@ -1540,13 +1443,6 @@ new_folder_done (GFile *new_folder,
target_uri = nautilus_file_get_uri (file);
- g_signal_connect_data (directory_view,
- "remove-file",
- G_CALLBACK (rename_newly_added_folder),
- sdata,
- (GClosureNotify)NULL,
- G_CONNECT_AFTER);
-
nautilus_view_move_copy_items (directory_view,
uris,
NULL,
@@ -2704,16 +2600,11 @@ nautilus_view_destroy (GtkWidget *object)
view->details->reveal_selection_idle_id = 0;
}
- if (view->details->delayed_rename_file_id != 0) {
- g_source_remove (view->details->delayed_rename_file_id);
- view->details->delayed_rename_file_id = 0;
- }
-
if (view->details->model) {
nautilus_directory_unref (view->details->model);
view->details->model = NULL;
}
-
+
if (view->details->directory_as_file) {
nautilus_file_unref (view->details->directory_as_file);
view->details->directory_as_file = NULL;
@@ -4015,18 +3906,6 @@ nautilus_view_set_is_renaming (NautilusView *view,
}
static void
-start_renaming_file (NautilusView *view,
- NautilusFile *file,
- gboolean select_all)
-{
- view->details->is_renaming = TRUE;
-
- if (file != NULL) {
- nautilus_view_select_file (view, file);
- }
-}
-
-static void
open_one_in_new_window (gpointer data, gpointer callback_data)
{
g_assert (NAUTILUS_IS_FILE (data));
@@ -7785,7 +7664,6 @@ nautilus_view_class_init (NautilusViewClass *klass)
klass->get_selected_icon_locations = real_get_selected_icon_locations;
klass->is_read_only = real_is_read_only;
klass->can_rename_file = can_rename_file;
- klass->start_renaming_file = start_renaming_file;
klass->get_backing_uri = real_get_backing_uri;
klass->using_manual_layout = real_using_manual_layout;
klass->get_window = nautilus_view_get_window;
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index c8e0c26bf..d3a08c77f 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -248,12 +248,6 @@ struct NautilusViewClass {
gboolean (* can_rename_file) (NautilusView *view,
NautilusFile *file);
- /* select_all specifies whether the whole filename should be selected
- * or only its basename (i.e. everything except the extension)
- * */
- void (* start_renaming_file) (NautilusView *view,
- NautilusFile *file,
- gboolean select_all);
/* convert *point from widget's coordinate system to a coordinate
* system used for specifying file operation positions, which is view-specific.