summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnautilus-private/nautilus-icon-container.c50
-rw-r--r--libnautilus-private/nautilus-icon-container.h6
-rw-r--r--src/nautilus-icon-view.c50
-rw-r--r--src/nautilus-list-view.c13
-rw-r--r--src/nautilus-view.c17
-rw-r--r--src/nautilus-view.h3
6 files changed, 84 insertions, 55 deletions
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 3aa7d3239..a46f75d6c 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -239,10 +239,10 @@ enum {
ICON_POSITION_CHANGED,
GET_STORED_LAYOUT_TIMESTAMP,
STORE_LAYOUT_TIMESTAMP,
- ICON_TEXT_CHANGED,
+ ICON_RENAME_STARTED,
+ ICON_RENAME_ENDED,
ICON_STRETCH_STARTED,
ICON_STRETCH_ENDED,
- RENAMING_ICON,
LAYOUT_CHANGED,
MOVE_COPY_ITEMS,
HANDLE_NETSCAPE_URL,
@@ -5778,17 +5778,6 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
- signals[ICON_TEXT_CHANGED]
- = g_signal_new ("icon_text_changed",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusIconContainerClass,
- icon_text_changed),
- NULL, NULL,
- g_cclosure_marshal_generic,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER,
- G_TYPE_STRING);
signals[ICON_STRETCH_STARTED]
= g_signal_new ("icon_stretch_started",
G_TYPE_FROM_CLASS (class),
@@ -5809,16 +5798,27 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- signals[RENAMING_ICON]
- = g_signal_new ("renaming_icon",
+ signals[ICON_RENAME_STARTED]
+ = g_signal_new ("icon_rename_started",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusIconContainerClass,
- renaming_icon),
+ icon_rename_started),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+ signals[ICON_RENAME_ENDED]
+ = g_signal_new ("icon_rename_ended",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusIconContainerClass,
+ icon_rename_ended),
+ NULL, NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE, 2,
+ G_TYPE_POINTER,
+ G_TYPE_STRING);
signals[GET_ICON_URI]
= g_signal_new ("get_icon_uri",
G_TYPE_FROM_CLASS (class),
@@ -8325,7 +8325,7 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
end_offset);
g_signal_emit (container,
- signals[RENAMING_ICON], 0,
+ signals[ICON_RENAME_STARTED], 0,
GTK_EDITABLE (details->rename_widget));
nautilus_icon_container_update_icon (container, icon);
@@ -8339,7 +8339,7 @@ static void
end_renaming_mode (NautilusIconContainer *container, gboolean commit)
{
NautilusIcon *icon;
- const char *changed_text;
+ const char *changed_text = NULL;
set_pending_icon_to_rename (container, NULL);
@@ -8363,18 +8363,18 @@ end_renaming_mode (NautilusIconContainer *container, gboolean commit)
if (commit) {
/* Verify that text has been modified before signalling change. */
changed_text = eel_editable_label_get_text (EEL_EDITABLE_LABEL (container->details->rename_widget));
- if (strcmp (container->details->original_text, changed_text) != 0) {
- g_signal_emit (container,
- signals[ICON_TEXT_CHANGED], 0,
- icon->data,
- changed_text);
+ if (strcmp (container->details->original_text, changed_text) == 0) {
+ changed_text = NULL;
}
}
- gtk_widget_hide (container->details->rename_widget);
+ g_signal_emit (container,
+ signals[ICON_RENAME_ENDED], 0,
+ icon->data,
+ changed_text);
+ gtk_widget_hide (container->details->rename_widget);
g_free (container->details->original_text);
-
}
gboolean
diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h
index cdae0ca0b..ad6c92662 100644
--- a/libnautilus-private/nautilus-icon-container.h
+++ b/libnautilus-private/nautilus-icon-container.h
@@ -217,11 +217,11 @@ typedef struct {
void (* icon_position_changed) (NautilusIconContainer *container,
NautilusIconData *data,
const NautilusIconPosition *position);
- void (* icon_text_changed) (NautilusIconContainer *container,
+ void (* icon_rename_started) (NautilusIconContainer *container,
+ GtkWidget *renaming_widget);
+ void (* icon_rename_ended) (NautilusIconContainer *container,
NautilusIconData *data,
const char *text);
- void (* renaming_icon) (NautilusIconContainer *container,
- GtkWidget *renaming_widget);
void (* icon_stretch_started) (NautilusIconContainer *container,
NautilusIconData *data);
void (* icon_stretch_ended) (NautilusIconContainer *container,
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index 0a42e1403..aa00a901b 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -1772,20 +1772,6 @@ band_select_ended_callback (NautilusIconContainer *container,
nautilus_view_stop_batching_selection_changes (NAUTILUS_VIEW (icon_view));
}
-static void
-renaming_icon_callback (NautilusIconContainer *container,
- GtkWidget *widget,
- gpointer callback_data)
-{
- NautilusView *directory_view;
-
- directory_view = NAUTILUS_VIEW (callback_data);
- nautilus_clipboard_set_up_editable
- (GTK_EDITABLE (widget),
- nautilus_view_get_ui_manager (directory_view),
- FALSE);
-}
-
int
nautilus_icon_view_compare_files (NautilusIconView *icon_view,
NautilusFile *a,
@@ -1990,23 +1976,39 @@ icon_position_changed_callback (NautilusIconContainer *container,
/* Attempt to change the filename to the new text. Notify user if operation fails. */
static void
-nautilus_icon_view_icon_text_changed_callback (NautilusIconContainer *container,
- NautilusFile *file,
- char *new_name,
- NautilusIconView *icon_view)
+icon_rename_ended_cb (NautilusIconContainer *container,
+ NautilusFile *file,
+ const char *new_name,
+ NautilusIconView *icon_view)
{
g_assert (NAUTILUS_IS_FILE (file));
- g_assert (new_name != NULL);
+
+ nautilus_view_set_is_renaming (NAUTILUS_VIEW (icon_view), FALSE);
/* Don't allow a rename with an empty string. Revert to original
* without notifying the user.
*/
- if (new_name[0] == '\0') {
+ if ((new_name == NULL) || (new_name[0] == '\0')) {
return;
}
+
nautilus_rename_file (file, new_name, NULL, NULL);
}
+static void
+icon_rename_started_cb (NautilusIconContainer *container,
+ GtkWidget *widget,
+ gpointer callback_data)
+{
+ NautilusView *directory_view;
+
+ directory_view = NAUTILUS_VIEW (callback_data);
+ nautilus_clipboard_set_up_editable
+ (GTK_EDITABLE (widget),
+ nautilus_view_get_ui_manager (directory_view),
+ FALSE);
+}
+
static char *
get_icon_uri_callback (NautilusIconContainer *container,
NautilusFile *file,
@@ -2313,8 +2315,6 @@ create_icon_container (NautilusIconView *icon_view)
G_CALLBACK (icon_container_context_click_background_callback), icon_view, 0);
g_signal_connect_object (icon_container, "icon_position_changed",
G_CALLBACK (icon_position_changed_callback), icon_view, 0);
- g_signal_connect_object (icon_container, "icon_text_changed",
- G_CALLBACK (nautilus_icon_view_icon_text_changed_callback), icon_view, 0);
g_signal_connect_object (icon_container, "selection_changed",
G_CALLBACK (selection_changed_callback), icon_view, 0);
/* FIXME: many of these should move into fm-icon-container as virtual methods */
@@ -2332,8 +2332,10 @@ create_icon_container (NautilusIconView *icon_view)
G_CALLBACK (get_stored_icon_position_callback), icon_view, 0);
g_signal_connect_object (icon_container, "layout_changed",
G_CALLBACK (layout_changed_callback), icon_view, 0);
- g_signal_connect_object (icon_container, "renaming_icon",
- G_CALLBACK (renaming_icon_callback), icon_view, 0);
+ g_signal_connect_object (icon_container, "icon_rename_started",
+ G_CALLBACK (icon_rename_started_cb), icon_view, 0);
+ g_signal_connect_object (icon_container, "icon_rename_ended",
+ G_CALLBACK (icon_rename_ended_cb), icon_view, 0);
g_signal_connect_object (icon_container, "icon_stretch_started",
G_CALLBACK (nautilus_view_update_menus), icon_view,
G_CONNECT_SWAPPED);
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 2858af540..cf30a938a 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1205,8 +1205,10 @@ editable_focus_out_cb (GtkWidget *widget,
{
NautilusListView *view = user_data;
- nautilus_view_unfreeze_updates (NAUTILUS_VIEW (view));
view->details->editable_widget = NULL;
+
+ nautilus_view_set_is_renaming (NAUTILUS_VIEW (view), FALSE);
+ nautilus_view_unfreeze_updates (NAUTILUS_VIEW (view));
}
static void
@@ -1236,10 +1238,11 @@ cell_renderer_editing_started_cb (GtkCellRenderer *renderer,
static void
cell_renderer_editing_canceled (GtkCellRendererText *cell,
- NautilusListView *view)
+ NautilusListView *view)
{
view->details->editable_widget = NULL;
+ nautilus_view_set_is_renaming (NAUTILUS_VIEW (view), FALSE);
nautilus_view_unfreeze_updates (NAUTILUS_VIEW (view));
}
@@ -1247,13 +1250,14 @@ static void
cell_renderer_edited (GtkCellRendererText *cell,
const char *path_str,
const char *new_text,
- NautilusListView *view)
+ NautilusListView *view)
{
GtkTreePath *path;
NautilusFile *file;
GtkTreeIter iter;
view->details->editable_widget = NULL;
+ nautilus_view_set_is_renaming (NAUTILUS_VIEW (view), FALSE);
/* Don't allow a rename with an empty string. Revert to original
* without notifying the user.
@@ -2912,6 +2916,9 @@ nautilus_list_view_start_renaming_file (NautilusView *view,
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));
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 69379b0f2..399e8f650 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -231,6 +231,8 @@ struct NautilusViewDetails
guint updates_queued;
gboolean needs_reload;
+ gboolean is_renaming;
+
gboolean sort_directories_first;
gboolean show_foreign_files;
@@ -4090,11 +4092,26 @@ can_rename_file (NautilusView *view, NautilusFile *file)
return nautilus_file_can_rename (file);
}
+gboolean
+nautilus_view_get_is_renaming (NautilusView *view)
+{
+ return view->details->is_renaming;
+}
+
+void
+nautilus_view_set_is_renaming (NautilusView *view,
+ gboolean is_renaming)
+{
+ view->details->is_renaming = is_renaming;
+}
+
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);
}
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 8d2e12479..54f46509f 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -353,6 +353,9 @@ gboolean nautilus_view_handle_scroll_event (NautilusView
void nautilus_view_freeze_updates (NautilusView *view);
void nautilus_view_unfreeze_updates (NautilusView *view);
+gboolean nautilus_view_get_is_renaming (NautilusView *view);
+void nautilus_view_set_is_renaming (NautilusView *view,
+ gboolean renaming);
void nautilus_view_add_subdirectory (NautilusView *view,
NautilusDirectory*directory);
void nautilus_view_remove_subdirectory (NautilusView *view,