Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to exit from file rename after pressing Enter key a 2nd time with modified key binding from F2 to Enter key #1794

Open
wmzart opened this issue Dec 3, 2024 · 2 comments

Comments

@wmzart
Copy link

wmzart commented Dec 3, 2024

Expected behaviour

With Cupertino Panel layout, the OSX key binding for file renaming can be matched to resemble that of OSX, which is the Enter key instead of F2. After changing the concerning line in the accels file and restarting caja, it is possible to press the Enter key in order to rename. One would expect that pressing the Enter key once more, would apply the text and exit the renaming mode.

In the function libcaja-private/caja-icon-container.c

key_press_event (GtkWidget *widget,
                 GdkEventKey *event)
...
    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);
...

I would expect that the function end_renaming_mode(container, TRUE) would be triggered here and rename the file accordingly and end the renaming mode.

Actual behaviour

When pressing the Enter key a second time, caja stays in the renaming mode and selects the whole filename including the extension if applicable. Applying the change is possible when pressing Shift Enter.

Steps to reproduce the behaviour

  1. Change F2 to Return in the accels file with:

caja -q; sed -i 's/.*DirViewActions\/Rename\".*/\(gtk_accel_path \"<Actions>\/DirViewActions\/Rename\" \"Return\"\)/g' ~/.config/caja/accels

  1. Open caja and select a file. Press the Enter key and observe that it enters in rename mode.
  2. Change the filename and press the Enter key once more.
  3. Observe that caja stays in rename mode.
  4. Pressing escape will revert the change. Pressing shift Enter or clicking somewhere with the mouse will effectuate the change.

To revert the F2 to Return change, use following command:

caja -q; sed -i 's/.*DirViewActions\/Rename\".*/; \(gtk_accel_path \"<Actions>\/DirViewActions\/Rename\" \"F2\"\)/g' ~/.config/caja/accels

MATE general version

Mate 1.26.2

Package version

Caja version 1.26.3

Linux Distribution

Ubuntu-Mate 24.04.1 LTS (Noble Numbat) 64-bit

Link to bugreport of your Distribution (requirement)

@wmzart
Copy link
Author

wmzart commented Dec 4, 2024

As an unwanted side-effect, when creating a new directory with keyboard shortcut Shift Control N followed by typing a name, it does not exit from the input field after pressing enter. Again, a workaround is to press Shift Enter

Also, the feature to press twice on the rename key (F2) in order to select the whole filename including the extension is not compatible with the OSX enter-key keybinding. Maybe with the enter key for renaming it should be made configurable: OSX style or press twice to select the whole filename including the extension.

@wmzart
Copy link
Author

wmzart commented Dec 4, 2024

I think nemo solved this with following addition in src/nemo-window.c:

static gboolean
nemo_window_key_press_event (GtkWidget *widget,
				 GdkEventKey *event)
{
    NemoWindow *window;
    NemoWindowSlot *active_slot;
    NemoView *view;
    GtkWidget *focus_widget;
    size_t i;

    window = NEMO_WINDOW (widget);

    active_slot = nemo_window_get_active_slot (window);
    view = active_slot->content_view;
    ...
    if (view != NULL && nemo_view_get_is_renaming (view)) {
            /* if we're renaming, just forward the event to the
             * focused widget and return. We don't want to process the window
             * accelerator bindings, as they might conflict with the
             * editable widget bindings.
             */
            if (gtk_window_propagate_key_event (GTK_WINDOW (window), event)) {
                    return TRUE;
            }

           /* Do not allow for other accelerator bindings to fire off while
            *  renaming is in progress
            */
           return FALSE;
    }
	...
}

In caja there is no similar function like nemo_view_get_is_renaming (view). The member is_renaming of the struct NemoView is in caja not implemented in the function in src/nemo-view.c

gboolean
nemo_view_get_is_renaming (NemoView *view)
{
        return view->details->is_renaming;
}

More information:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant