---
 From: Luca Cavalli <luca.cavalli@gmail.com>
 Subject: allow nautilus to rename files with ctrl+double click

 http://bugzilla.gnome.org/attachment.cgi?id=82999&action=diff

 Can probably be enhanced to include a toolbar item.

 libnautilus-private/nautilus-icon-canvas-item.c |   24 +++++++++++++++
 libnautilus-private/nautilus-icon-canvas-item.h |    3 +
 libnautilus-private/nautilus-icon-container.c   |   37 +++++++++++++++++++++++-
 src/file-manager/fm-list-view.c                 |   14 ++++++++-
 4 files changed, 76 insertions(+), 2 deletions(-)

Index: b/src/file-manager/fm-list-view.c
===================================================================
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -157,7 +157,9 @@ static void   fm_list_view_iface_init   
 static void   fm_list_view_rename_callback                 (NautilusFile      *file,
 							    GnomeVFSResult     result,
 							    gpointer           callback_data);
-
+static void   fm_list_view_start_renaming_file             (FMDirectoryView   *view,
+							    NautilusFile      *file,
+							    gboolean           select_all);
 
 G_DEFINE_TYPE_WITH_CODE (FMListView, fm_list_view, FM_TYPE_DIRECTORY_VIEW, 
 			 G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_VIEW,
@@ -660,6 +662,16 @@ button_press_callback (GtkWidget *widget
 						activate_selected_items_alternate (view, file);
 						nautilus_file_unref (file);
 					}
+				} else if (event->button == 1 &&
+					   (event->state & GDK_CONTROL_MASK) != 0 &&
+					   gtk_tree_selection_count_selected_rows (selection) == 1) {
+					/* CTRL + double click click on the only selected row, start renaming */
+					NautilusFile *file;
+					file = fm_list_model_file_for_path (view->details->model, path);
+					if (file != NULL) {
+						fm_list_view_start_renaming_file (FM_DIRECTORY_VIEW (view), file, FALSE);
+						nautilus_file_unref (file);
+					}
 				}
 			}
 			tree_view_class->button_press_event (widget, event);
Index: b/libnautilus-private/nautilus-icon-container.c
===================================================================
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -5117,6 +5117,36 @@ handle_icon_button_press (NautilusIconCo
 		details->double_click_icon[1] = details->double_click_icon[0];
 		details->double_click_icon[0] = icon;
 	}
+
+	if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) &&
+	    event->type == GDK_BUTTON_PRESS &&
+	    (has_selection (container) && !has_multiple_selection (container))) {
+
+		GList *node;
+		GList *selection = nautilus_icon_container_get_selection (container);
+		NautilusIcon *icon;
+
+		/*g_message ("CLIK !!!, x:%f y:%f l:%d", event->x, event->y, g_list_length (selection));*/
+		/*set_pending_icon_to_rename*/
+
+		for (node = container->details->icons; node != NULL; node = node->next) {
+			icon = node->data;
+			if (icon->is_selected) {
+				g_message ("item: %p / %p / %p", selection, icon, icon->item);
+				g_message ("is selected: %d", icon->is_selected);
+
+				if (icon && nautilus_icon_canvas_item_hit_text (icon->item,
+				    ceil(event->x),
+				    ceil(event->y))) {
+					nautilus_icon_container_start_renaming_selected_item (container, FALSE);
+
+					/*set_pending_icon_to_rename (container, icon);*/
+					return TRUE;
+				}
+			}
+		}
+	}
+
 	if (event->type == GDK_2BUTTON_PRESS &&
 	    (event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON)) {
 		/* Double clicking does not trigger a D&D action. */
@@ -5133,6 +5163,11 @@ handle_icon_button_press (NautilusIconCo
 			} else if (event->button == DRAG_BUTTON &&
 				   (event->state & GDK_SHIFT_MASK) != 0) {
 				activate_selected_items_alternate (container, icon);
+			} else if (event->button == DRAG_BUTTON &&
+				   (event->state & GDK_CONTROL_MASK) != 0 &&
+				   !has_multiple_selection (container)) {
+				/* CTRL + double click click on the only selected icon, start renaming */
+				nautilus_icon_container_start_renaming_selected_item (container, FALSE);
 			}
 		}
 		return TRUE;
@@ -5160,7 +5195,7 @@ handle_icon_button_press (NautilusIconCo
 	 * the same way for contextual menu as it would be without. 
 	 */
 	details->icon_selected_on_button_down = icon->is_selected;
-	
+
 	if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) &&
 	    (event->state & GDK_CONTROL_MASK) == 0 &&
 	    (event->state & GDK_SHIFT_MASK) != 0) {
Index: b/libnautilus-private/nautilus-icon-canvas-item.c
===================================================================
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -2371,6 +2371,30 @@ nautilus_icon_canvas_item_hit_test_recta
 	return hit_test (item, canvas_rect);
 }
 
+/* nautilus_icon_canvas_item_hit_text
+ *
+ * Check and see if there is an intersection between the item and the p
+ */
+gboolean
+nautilus_icon_canvas_item_hit_text (NautilusIconCanvasItem *item, int x, int y)
+{
+	/* HACK ME */
+	GdkRegion *region;
+	GdkRectangle rectangle;
+
+	g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
+
+	rectangle.x = item->details->text_rect.x0;
+	rectangle.y = item->details->text_rect.y0;
+	rectangle.width = item->details->text_width;
+	rectangle.height = item->details->text_height;
+
+	region = gdk_region_rectangle (&rectangle);
+
+	return gdk_region_point_in (region, x, y);
+}
+
+
 const char *
 nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item)
 {
Index: b/libnautilus-private/nautilus-icon-canvas-item.h
===================================================================
--- a/libnautilus-private/nautilus-icon-canvas-item.h
+++ b/libnautilus-private/nautilus-icon-canvas-item.h
@@ -86,6 +86,9 @@ gboolean    nautilus_icon_canvas_item_hi
 gboolean    nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem       *item,
 								ArtPoint                      world_point,
 								GtkCornerType *corner);
+gboolean    nautilus_icon_canvas_item_hit_text                 (NautilusIconCanvasItem       *item,
+								int                           x,
+								int                           y);
 void        nautilus_icon_canvas_item_invalidate_label_size    (NautilusIconCanvasItem       *item);
 ArtDRect    nautilus_icon_canvas_item_get_icon_rectangle       (const NautilusIconCanvasItem *item);
 ArtDRect    nautilus_icon_canvas_item_get_text_rectangle       (NautilusIconCanvasItem       *item);
