[nautilus/wip/csoriano/renaming: 10/10] canvas-container: remove in place renaming support



commit 50cd4df01d20547f20f3a0c130ac068a9479d8ee
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Apr 22 11:50:06 2015 +0200

    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.

 libnautilus-private/nautilus-canvas-container.c |  531 ++++-------------------
 src/nautilus-canvas-view.c                      |   37 --
 src/nautilus-list-view.c                        |   70 +---
 src/nautilus-view.c                             |  130 +------
 src/nautilus-view.h                             |    6 -
 5 files changed, 99 insertions(+), 675 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index 705db9d..1797b5c 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -148,9 +148,6 @@ static gboolean      all_selected                                   (NautilusCan
 static gboolean      has_selection                                  (NautilusCanvasContainer *container);
 static void          icon_destroy                                   (NautilusCanvasContainer *container,
                                                                       NautilusCanvasIcon          *icon);
-static void          end_renaming_mode                              (NautilusCanvasContainer *container,
-                                                                    gboolean               commit);
-static NautilusCanvasIcon *get_icon_being_renamed                         (NautilusCanvasContainer 
*container);
 static void          finish_adding_new_icons                        (NautilusCanvasContainer *container);
 static inline void   icon_get_bounding_box                          (NautilusCanvasIcon          *icon,
                                                                       int                   *x1_return,
@@ -158,9 +155,6 @@ static inline void   icon_get_bounding_box                          (NautilusCan
                                                                       int                   *x2_return,
                                                                       int                   *y2_return,
                                                                       NautilusCanvasItemBoundsUsage usage);
-static gboolean      is_renaming                                    (NautilusCanvasContainer *container);
-static gboolean      is_renaming_pending                            (NautilusCanvasContainer *container);
-static void          process_pending_icon_to_rename                 (NautilusCanvasContainer *container);
 static void          handle_hadjustment_changed                     (GtkAdjustment         *adjustment,
                                                                     NautilusCanvasContainer *container);
 static void          handle_vadjustment_changed                     (GtkAdjustment         *adjustment,
@@ -286,13 +280,9 @@ icon_set_position (NautilusCanvasIcon *icon,
 
        container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (icon->item)->canvas);
 
-       if (icon == get_icon_being_renamed (container)) {
-               end_renaming_mode (container, TRUE);
-       }
-
        if (nautilus_canvas_container_get_is_fixed_size (container)) {
                /*  FIXME: This should be:
-                   
+
                    container_x = GTK_WIDGET (container)->allocation.x;
                    container_y = GTK_WIDGET (container)->allocation.y;
                    container_width = GTK_WIDGET (container)->allocation.width;
@@ -440,8 +430,6 @@ static void
 icon_toggle_selected (NautilusCanvasContainer *container,
                      NautilusCanvasIcon *icon)
 {              
-       end_renaming_mode (container, TRUE);
-
        icon->is_selected = !icon->is_selected;
        if (icon->is_selected) {
                container->details->selection = g_list_prepend (container->details->selection, icon->data);
@@ -1921,7 +1909,6 @@ redo_layout_internal (NautilusCanvasContainer *container)
        nautilus_canvas_container_update_scroll_region (container);
 
        process_pending_icon_to_reveal (container);
-       process_pending_icon_to_rename (container);
        nautilus_canvas_container_update_visible_icons (container);
 }
 
@@ -2135,10 +2122,6 @@ nautilus_canvas_container_move_icon (NautilusCanvasContainer *container,
        
        emit_signal = FALSE;
        
-       if (icon == get_icon_being_renamed (container)) {
-               end_renaming_mode (container, TRUE);
-       }
-
        if (scale != icon->scale) {
                icon->scale = scale;
                nautilus_canvas_container_update_icon (container, icon);
@@ -3993,10 +3976,7 @@ button_press_event (GtkWidget *widget,
        /* Invoke the canvas event handler and see if an item picks up the event. */
        clicked_on_icon = GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->button_press_event 
(widget, event);
        
-       /* Move focus to canvas container, unless we're still renaming (to avoid exiting
-        * renaming mode)
-        */
-       if (!gtk_widget_has_focus (widget) && !(is_renaming (container) || is_renaming_pending (container))) {
+       if (!gtk_widget_has_focus (widget)) {
                gtk_widget_grab_focus (widget);
        }
 
@@ -4042,7 +4022,6 @@ button_press_event (GtkWidget *widget,
 
        /* Button 3 does a contextual menu. */
        if (event->button == CONTEXTUAL_MENU_BUTTON) {
-               end_renaming_mode (container, TRUE);
                selection_changed = unselect_all (container);
                if (selection_changed) {
                        g_signal_emit (container, signals[SELECTION_CHANGED], 0);
@@ -4470,8 +4449,6 @@ motion_notify_event (GtkWidget *widget,
                                details->drag_started = TRUE;
                                details->drag_state = DRAG_STATE_MOVE_OR_COPY;
 
-                               end_renaming_mode (container, TRUE);
-                       
                                eel_canvas_w2c (EEL_CANVAS (container),
                                                details->drag_x,
                                                details->drag_y,
@@ -4545,111 +4522,95 @@ key_press_event (GtkWidget *widget,
        container = NAUTILUS_CANVAS_CONTAINER (widget);
        handled = FALSE;
 
-       if (is_renaming (container) || is_renaming_pending (container)) {
-               switch (event->keyval) {
-               case GDK_KEY_Return:
-               case GDK_KEY_KP_Enter:
-                       end_renaming_mode (container, TRUE);    
-                       handled = TRUE;
-                       break;                  
-               case GDK_KEY_Escape:
-                       end_renaming_mode (container, FALSE);
+       switch (event->keyval) {
+       case GDK_KEY_Home:
+       case GDK_KEY_KP_Home:
+               keyboard_home (container, event);
+               handled = TRUE;
+               break;
+       case GDK_KEY_End:
+       case GDK_KEY_KP_End:
+               keyboard_end (container, event);
+               handled = TRUE;
+               break;
+       case GDK_KEY_Left:
+       case GDK_KEY_KP_Left:
+               /* Don't eat Alt-Left, as that is used for history browsing */
+               if ((event->state & GDK_MOD1_MASK) == 0) {
+                       keyboard_left (container, event);
                        handled = TRUE;
-                       break;
-               default:
-                       break;
                }
-       } else {
-               switch (event->keyval) {
-               case GDK_KEY_Home:
-               case GDK_KEY_KP_Home:
-                       keyboard_home (container, event);
+               break;
+       case GDK_KEY_Up:
+       case GDK_KEY_KP_Up:
+               /* Don't eat Alt-Up, as that is used for alt-shift-Up */
+               if ((event->state & GDK_MOD1_MASK) == 0) {
+                       keyboard_up (container, event);
                        handled = TRUE;
-                       break;
-               case GDK_KEY_End:
-               case GDK_KEY_KP_End:
-                       keyboard_end (container, event);
+               }
+               break;
+       case GDK_KEY_Right:
+       case GDK_KEY_KP_Right:
+               /* Don't eat Alt-Right, as that is used for history browsing */
+               if ((event->state & GDK_MOD1_MASK) == 0) {
+                       keyboard_right (container, event);
                        handled = TRUE;
-                       break;
-               case GDK_KEY_Left:
-               case GDK_KEY_KP_Left:
-                       /* Don't eat Alt-Left, as that is used for history browsing */
-                       if ((event->state & GDK_MOD1_MASK) == 0) {
-                               keyboard_left (container, event);
-                               handled = TRUE;
-                       }
-                       break;
-               case GDK_KEY_Up:
-               case GDK_KEY_KP_Up:
-                       /* Don't eat Alt-Up, as that is used for alt-shift-Up */
-                       if ((event->state & GDK_MOD1_MASK) == 0) {
-                               keyboard_up (container, event);
-                               handled = TRUE;
-                       }
-                       break;
-               case GDK_KEY_Right:
-               case GDK_KEY_KP_Right:
-                       /* Don't eat Alt-Right, as that is used for history browsing */
-                       if ((event->state & GDK_MOD1_MASK) == 0) {
-                               keyboard_right (container, event);
-                               handled = TRUE;
-                       }
-                       break;
-               case GDK_KEY_Down:
-               case GDK_KEY_KP_Down:
-                       /* Don't eat Alt-Down, as that is used for Open */
-                       if ((event->state & GDK_MOD1_MASK) == 0) {
-                               keyboard_down (container, event);
-                               handled = TRUE;
-                       }
-                       break;
-               case GDK_KEY_space:
-                       keyboard_space (container, event);
+               }
+               break;
+       case GDK_KEY_Down:
+       case GDK_KEY_KP_Down:
+               /* Don't eat Alt-Down, as that is used for Open */
+               if ((event->state & GDK_MOD1_MASK) == 0) {
+                       keyboard_down (container, event);
                        handled = TRUE;
-                       break;
-               case GDK_KEY_Return:
-               case GDK_KEY_KP_Enter:
-                       if ((event->state & GDK_SHIFT_MASK) != 0) {
-                               activate_selected_items_alternate (container, NULL);
-                       } else {
-                               activate_selected_items (container);
-                       }
-                       
+               }
+               break;
+       case GDK_KEY_space:
+               keyboard_space (container, event);
+               handled = TRUE;
+               break;
+       case GDK_KEY_Return:
+       case GDK_KEY_KP_Enter:
+               if ((event->state & GDK_SHIFT_MASK) != 0) {
+                       activate_selected_items_alternate (container, NULL);
+               } else {
+                       activate_selected_items (container);
+               }
+
+               handled = TRUE;
+               break;
+       case GDK_KEY_Escape:
+               handled = undo_stretching (container);
+               break;
+       case GDK_KEY_plus:
+       case GDK_KEY_minus:
+       case GDK_KEY_equal:
+       case GDK_KEY_KP_Add:
+       case GDK_KEY_KP_Subtract:
+       case GDK_KEY_0:
+       case GDK_KEY_KP_0:
+               if (event->state & GDK_CONTROL_MASK) {
+                       handled = keyboard_stretching (container, event);
+               }
+               break;
+       case GDK_KEY_F10:
+               /* handle Ctrl+F10 because we want to display the
+                * background popup even if something is selected.
+                * The other cases are handled by popup_menu().
+                */
+               if (event->state & GDK_CONTROL_MASK) {
+                       handled = handle_popups (container, event,
+                                                "context_click_background");
+               }
+               break;
+       case GDK_KEY_v:
+               /* Eat Control + v to not enable type ahead */
+               if ((event->state & GDK_CONTROL_MASK) != 0) {
                        handled = TRUE;
-                       break;
-               case GDK_KEY_Escape:
-                       handled = undo_stretching (container);
-                       break;
-               case GDK_KEY_plus:
-               case GDK_KEY_minus:
-               case GDK_KEY_equal:
-               case GDK_KEY_KP_Add:
-               case GDK_KEY_KP_Subtract:
-               case GDK_KEY_0:
-               case GDK_KEY_KP_0:
-                       if (event->state & GDK_CONTROL_MASK) {
-                               handled = keyboard_stretching (container, event);
-                       }
-                       break;
-               case GDK_KEY_F10:
-                       /* handle Ctrl+F10 because we want to display the
-                        * background popup even if something is selected.
-                        * The other cases are handled by popup_menu().
-                        */
-                       if (event->state & GDK_CONTROL_MASK) {
-                               handled = handle_popups (container, event,
-                                                        "context_click_background");
-                       }
-                       break;
-               case GDK_KEY_v:
-                       /* Eat Control + v to not enable type ahead */
-                       if ((event->state & GDK_CONTROL_MASK) != 0) {
-                               handled = TRUE;
-                       }
-                       break;
-               default:
-                       break;
                }
+               break;
+       default:
+               break;
        }
 
        if (!handled) {
@@ -4866,27 +4827,6 @@ nautilus_canvas_container_class_init (NautilusCanvasContainerClass *class)
                                g_cclosure_marshal_VOID__POINTER,
                                G_TYPE_NONE, 1,
                                G_TYPE_POINTER);
-       signals[ICON_RENAME_STARTED]
-               = g_signal_new ("icon-rename-started",
-                               G_TYPE_FROM_CLASS (class),
-                               G_SIGNAL_RUN_LAST,
-                               G_STRUCT_OFFSET (NautilusCanvasContainerClass,
-                                                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 (NautilusCanvasContainerClass,
-                                                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),
@@ -5165,8 +5105,6 @@ handle_focus_in_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_da
 static gboolean
 handle_focus_out_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
 {
-       /* End renaming and commit change. */
-       end_renaming_mode (NAUTILUS_CANVAS_CONTAINER (widget), TRUE);
        update_selected (NAUTILUS_CANVAS_CONTAINER (widget));
 
        return FALSE;
@@ -5493,8 +5431,6 @@ nautilus_canvas_container_clear (NautilusCanvasContainer *container)
                return;
        }
 
-       end_renaming_mode (container, TRUE);
-       
        clear_keyboard_focus (container);
        clear_keyboard_rubberband_start (container);
        unschedule_keyboard_icon_reveal (container);
@@ -5826,23 +5762,6 @@ activate_selected_items_alternate (NautilusCanvasContainer *container,
        g_list_free (selection);
 }
 
-static NautilusCanvasIcon *
-get_icon_being_renamed (NautilusCanvasContainer *container)
-{
-       NautilusCanvasIcon *rename_icon;
-
-       if (!is_renaming (container)) {
-               return NULL;
-       }
-
-       g_assert (!has_multiple_selection (container));
-
-       rename_icon = get_first_selected_icon (container);
-       g_assert (rename_icon != NULL);
-
-       return rename_icon;
-}                       
-
 static NautilusIconInfo *
 nautilus_canvas_container_get_icon_images (NautilusCanvasContainer *container,
                                             NautilusCanvasIconData      *data,
@@ -6018,17 +5937,6 @@ nautilus_canvas_container_update_icon (NautilusCanvasContainer *container,
                                                   &additional_text,
                                                   FALSE);
 
-       /* If name of icon being renamed was changed from elsewhere, end renaming mode. 
-        * Alternatively, we could replace the characters in the editable text widget
-        * with the new name, but that could cause timing problems if the user just
-        * happened to be typing at that moment.
-        */
-       if (icon == get_icon_being_renamed (container) &&
-           g_strcmp0 (editable_text,
-                      nautilus_canvas_item_get_editable_text (icon->item)) != 0) {
-               end_renaming_mode (container, FALSE);
-       }
-
        eel_canvas_item_set (EEL_CANVAS_ITEM (icon->item),
                             "editable_text", editable_text,
                             "additional_text", additional_text,
@@ -6299,8 +6207,6 @@ nautilus_canvas_container_remove (NautilusCanvasContainer *container,
        g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE);
        g_return_val_if_fail (data != NULL, FALSE);
 
-       end_renaming_mode (container, FALSE);
-               
        icon = g_hash_table_lookup (container->details->icon_set, data);
 
        if (icon == NULL) {
@@ -6357,8 +6263,6 @@ nautilus_canvas_container_set_zoom_level (NautilusCanvasContainer *container, in
        
        details = container->details;
 
-       end_renaming_mode (container, TRUE);
-               
        pinned_level = new_level;
        if (pinned_level < NAUTILUS_CANVAS_ZOOM_LEVEL_SMALL) {
                pinned_level = NAUTILUS_CANVAS_ZOOM_LEVEL_SMALL;
@@ -7136,245 +7040,6 @@ nautilus_canvas_container_is_auto_layout (NautilusCanvasContainer *container)
        return container->details->auto_layout;
 }
 
-static void
-pending_icon_to_rename_destroy_callback (NautilusCanvasItem *item, NautilusCanvasContainer *container)
-{
-       g_assert (container->details->pending_icon_to_rename != NULL);
-       g_assert (container->details->pending_icon_to_rename->item == item);
-       container->details->pending_icon_to_rename = NULL;
-}
-
-static NautilusCanvasIcon *
-get_pending_icon_to_rename (NautilusCanvasContainer *container)
-{
-       return container->details->pending_icon_to_rename;
-}
-
-static void
-set_pending_icon_to_rename (NautilusCanvasContainer *container, NautilusCanvasIcon *icon)
-{
-       NautilusCanvasIcon *old_icon;
-       
-       old_icon = container->details->pending_icon_to_rename;
-       
-       if (icon == old_icon) {
-               return;
-       }
-       
-       if (old_icon != NULL) {
-               g_signal_handlers_disconnect_by_func
-                       (old_icon->item,
-                        G_CALLBACK (pending_icon_to_rename_destroy_callback),
-                        container);
-       }
-       
-       if (icon != NULL) {
-               g_signal_connect (icon->item, "destroy",
-                                 G_CALLBACK (pending_icon_to_rename_destroy_callback), container);
-       }
-       
-       container->details->pending_icon_to_rename = icon;
-}
-
-static void
-process_pending_icon_to_rename (NautilusCanvasContainer *container)
-{
-       NautilusCanvasIcon *pending_icon_to_rename;
-       
-       pending_icon_to_rename = get_pending_icon_to_rename (container);
-       
-       if (pending_icon_to_rename != NULL) {
-               if (pending_icon_to_rename->is_selected && !has_multiple_selection (container)) {
-                       nautilus_canvas_container_start_renaming_selected_item (container, FALSE);
-               } else {
-                       set_pending_icon_to_rename (container, NULL);
-               }
-       }
-}
-
-static gboolean
-is_renaming_pending (NautilusCanvasContainer *container)
-{
-       return get_pending_icon_to_rename (container) != NULL;
-}
-
-static gboolean
-is_renaming (NautilusCanvasContainer *container)
-{
-       return container->details->renaming;
-}
-
-/**
- * nautilus_canvas_container_start_renaming_selected_item
- * @container: An canvas container widget.
- * @select_all: Whether the whole file should initially be selected, or
- *              only its basename (i.e. everything except its extension).
- * 
- * Displays the edit name widget on the first selected icon
- **/
-void
-nautilus_canvas_container_start_renaming_selected_item (NautilusCanvasContainer *container,
-                                                       gboolean select_all)
-{
-       NautilusCanvasContainerDetails *details;
-       NautilusCanvasIcon *icon;
-       EelDRect icon_rect;
-       PangoContext *context;
-       PangoFontDescription *desc;
-       const char *editable_text;
-       int x, y, width;
-       int start_offset, end_offset;
-
-       /* Check if it already in renaming mode, if so - select all */
-       details = container->details;
-       if (details->renaming) {
-               eel_editable_label_select_region (EEL_EDITABLE_LABEL (details->rename_widget),
-                                                 0,
-                                                 -1);
-               return;
-       }
-
-       /* Find selected icon */
-       icon = get_first_selected_icon (container);
-       if (icon == NULL) {
-               return;
-       }
-
-       g_assert (!has_multiple_selection (container));
-
-
-       if (!icon_is_positioned (icon)) {
-               set_pending_icon_to_rename (container, icon);
-               return;
-       }
-       
-       set_pending_icon_to_rename (container, NULL);
-
-       /* Make a copy of the original editable text for a later compare */
-       editable_text = nautilus_canvas_item_get_editable_text (icon->item);
-
-       /* This could conceivably be NULL if a rename was triggered really early. */
-       if (editable_text == NULL) {
-               return;
-       }
-
-       details->original_text = g_strdup (editable_text);
-       
-       /* Freeze updates so files added while renaming don't cause rename to loose focus, bug #318373 */
-       nautilus_canvas_container_freeze_updates (container);
-
-       /* Create text renaming widget, if it hasn't been created already.
-        * We deal with the broken canvas text item widget by keeping it around
-        * so its contents can still be cut and pasted as part of the clipboard
-        */
-       if (details->rename_widget == NULL) {
-               details->rename_widget = eel_editable_label_new ("Test text");
-               eel_editable_label_set_line_wrap (EEL_EDITABLE_LABEL (details->rename_widget), TRUE);
-               eel_editable_label_set_line_wrap_mode (EEL_EDITABLE_LABEL (details->rename_widget), 
PANGO_WRAP_WORD_CHAR);
-               eel_editable_label_set_draw_outline (EEL_EDITABLE_LABEL (details->rename_widget), TRUE);
-
-               eel_editable_label_set_justify (EEL_EDITABLE_LABEL (details->rename_widget), 
GTK_JUSTIFY_CENTER);
-
-               gtk_misc_set_padding (GTK_MISC (details->rename_widget), 1, 1);
-               gtk_layout_put (GTK_LAYOUT (container),
-                               details->rename_widget, 0, 0);
-       } 
-
-       /* Set the right font */
-       if (details->font) {
-               desc = pango_font_description_from_string (details->font);
-       } else {
-               context = gtk_widget_get_pango_context (GTK_WIDGET (container));
-               desc = pango_font_description_copy (pango_context_get_font_description (context));
-       }
-       eel_editable_label_set_font_description (EEL_EDITABLE_LABEL (details->rename_widget),
-                                                desc);
-       pango_font_description_free (desc);
-       
-       icon_rect = nautilus_canvas_item_get_icon_rectangle (icon->item);
-
-       width = nautilus_canvas_item_get_max_text_width (icon->item);
-
-       eel_canvas_w2c (EEL_CANVAS_ITEM (icon->item)->canvas,
-                       (icon_rect.x0 + icon_rect.x1) / 2,
-                       icon_rect.y1,
-                       &x, &y);
-       x = x - width / 2 - 1;
-
-       gtk_layout_move (GTK_LAYOUT (container),
-                        details->rename_widget,
-                        x, y);
-       
-       gtk_widget_set_size_request (details->rename_widget,
-                                    width, -1);
-       eel_editable_label_set_text (EEL_EDITABLE_LABEL (details->rename_widget),
-                                    editable_text);
-       if (select_all) {
-               start_offset = 0;
-               end_offset = -1;
-       } else {
-               eel_filename_get_rename_region (editable_text, &start_offset, &end_offset);
-       }
-
-       gtk_widget_show (details->rename_widget);
-       gtk_widget_grab_focus (details->rename_widget);
-
-       eel_editable_label_select_region (EEL_EDITABLE_LABEL (details->rename_widget),
-                                         start_offset,
-                                         end_offset);
-       
-       g_signal_emit (container,
-                      signals[ICON_RENAME_STARTED], 0,
-                      GTK_EDITABLE (details->rename_widget));
-       
-       nautilus_canvas_container_update_icon (container, icon);
-       
-       /* We are in renaming mode */
-       details->renaming = TRUE;
-       nautilus_canvas_item_set_renaming (icon->item, TRUE);
-}
-
-static void
-end_renaming_mode (NautilusCanvasContainer *container, gboolean commit)
-{
-       NautilusCanvasIcon *icon;
-       const char *changed_text = NULL;
-
-       set_pending_icon_to_rename (container, NULL);
-
-       icon = get_icon_being_renamed (container);
-       if (icon == NULL) {
-               return;
-       }
-
-       /* We are not in renaming mode */
-       container->details->renaming = FALSE;
-       nautilus_canvas_item_set_renaming (icon->item, FALSE);
-       
-       nautilus_canvas_container_unfreeze_updates (container);
-
-       if (commit) {
-               set_pending_icon_to_reveal (container, icon);
-       }
-
-       gtk_widget_grab_focus (GTK_WIDGET (container));
-       
-       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) {
-                       changed_text = NULL;
-               }
-       }
-
-       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
 nautilus_canvas_container_has_stored_icon_positions (NautilusCanvasContainer *container)
 {
@@ -7491,8 +7156,8 @@ nautilus_canvas_container_set_font (NautilusCanvasContainer *container,
 /**
  * nautilus_canvas_container_get_icon_description
  * @container: An canvas container widget.
- * @data: Icon data 
- * 
+ * @data: Icon data
+ *
  * Gets the description for the icon. This function may return NULL.
  **/
 char*
@@ -7561,7 +7226,7 @@ nautilus_canvas_container_accessible_do_action (AtkAction *accessible, int i)
        if (!widget) {
                return FALSE;
        }
-       
+
        container = NAUTILUS_CANVAS_CONTAINER (widget);
        switch (i) {
        case ACTION_ACTIVATE :
@@ -7589,15 +7254,15 @@ nautilus_canvas_container_accessible_get_n_actions (AtkAction *accessible)
 }
 
 static const char *
-nautilus_canvas_container_accessible_action_get_description (AtkAction *accessible, 
+nautilus_canvas_container_accessible_action_get_description (AtkAction *accessible,
                                                             int i)
 {
        NautilusCanvasContainerAccessiblePrivate *priv;
-       
+
        g_assert (i < LAST_ACTION);
 
        priv = GET_ACCESSIBLE_PRIV (accessible);
-       
+
        if (priv->action_descriptions[i]) {
                return priv->action_descriptions[i];
        } else {
@@ -7942,9 +7607,6 @@ nautilus_canvas_container_accessible_get_n_children (AtkObject *accessible)
        container = NAUTILUS_CANVAS_CONTAINER (widget);
 
        i = g_hash_table_size (container->details->icon_set);
-       if (container->details->rename_widget) {
-               i++;
-       }
 
        return i;
 }
@@ -7974,17 +7636,8 @@ nautilus_canvas_container_accessible_ref_child (AtkObject *accessible, int i)
                 g_object_ref (atk_object);
 
                 return atk_object;
-        } else {
-               if (i == g_list_length (container->details->icons)) {
-                       if (container->details->rename_widget) {
-                               atk_object = gtk_widget_get_accessible (container->details->rename_widget);
-                               g_object_ref (atk_object);
-
-                               return atk_object;
-                       }
-               }
-                return NULL;
         }
+        return NULL;
 }
 
 G_DEFINE_TYPE_WITH_CODE (NautilusCanvasContainerAccessible, nautilus_canvas_container_accessible,
@@ -7993,7 +7646,7 @@ G_DEFINE_TYPE_WITH_CODE (NautilusCanvasContainerAccessible, nautilus_canvas_cont
                         G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, 
nautilus_canvas_container_accessible_selection_interface_init))
 
 static void
-nautilus_canvas_container_accessible_initialize (AtkObject *accessible, 
+nautilus_canvas_container_accessible_initialize (AtkObject *accessible,
                                                 gpointer data)
 {
        NautilusCanvasContainer *container;
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 543b713..b71753a 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 b7d39d5..09731ab 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 bef1982..cca283b 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,
@@ -2696,16 +2592,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;
@@ -4007,18 +3898,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));
@@ -7777,7 +7656,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 c8e0c26..d3a08c7 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.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]