diff options
author | Gary Li <gary.li1@uwaterloo.ca> | 2022-12-26 20:30:00 +0000 |
---|---|---|
committer | Corey Berla <corey@berla.me> | 2022-12-26 20:30:00 +0000 |
commit | 59e30b051613d4ecffebc886c0d76d463edd5492 (patch) | |
tree | dd02da3a73accaf0e4613a6e69f2dbedce803334 /src/nautilus-window.c | |
parent | 3b7ec5d5eafe4e4fb2b8dc527e0413fbef2d2fc4 (diff) | |
download | nautilus-59e30b051613d4ecffebc886c0d76d463edd5492.tar.gz |
nautilus-window: do not override last_location for root prompt
Currently, nautilus_location_entry_cancel uses the last_location GFile
to reset the location entry path if the user cancels.
However, the root prompt immediately overrides last_location
by setting the location to "/", which results in the user always seeing "/"
even if they cancel location bar entry then use CTRL-L to check current path.
To fix this, use the same logic as the home prompt, which only sets the entry text.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2249
Diffstat (limited to 'src/nautilus-window.c')
-rw-r--r-- | src/nautilus-window.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c index a3962230c..7cd980d98 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -383,19 +383,23 @@ action_go_to_tab (GSimpleAction *action, } static void -action_prompt_for_location_root (GSimpleAction *action, - GVariant *state, - gpointer user_data) +prompt_for_location (NautilusWindow *window, + const char *path) { - NautilusWindow *window = user_data; - GFile *location; GtkWidget *entry; - location = g_file_new_for_path ("/"); entry = nautilus_window_ensure_location_entry (window); - nautilus_location_entry_set_location (NAUTILUS_LOCATION_ENTRY (entry), location); + nautilus_location_entry_set_special_text (NAUTILUS_LOCATION_ENTRY (entry), + path); + gtk_editable_set_position (GTK_EDITABLE (entry), -1); +} - g_object_unref (location); +static void +action_prompt_for_location_root (GSimpleAction *action, + GVariant *state, + gpointer user_data) +{ + prompt_for_location (NAUTILUS_WINDOW (user_data), "/"); } static void @@ -403,12 +407,7 @@ action_prompt_for_location_home (GSimpleAction *action, GVariant *state, gpointer user_data) { - GtkWidget *entry; - - entry = nautilus_window_ensure_location_entry (NAUTILUS_WINDOW (user_data)); - nautilus_location_entry_set_special_text (NAUTILUS_LOCATION_ENTRY (entry), - "~"); - gtk_editable_set_position (GTK_EDITABLE (entry), -1); + prompt_for_location (NAUTILUS_WINDOW (user_data), "~"); } static void |