mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
slot: ensure we're back from an active search when changing location
When search is turned off, we want to change the location of the slot to the search base folder. We used to keep track of the search active state using the state of the search toggle button; unfortunately, the button is per-window, so its active state will also be synchronized when switching tabs. This will cause a non-search slot that becomes active following a tab switch from a search slot to think its search just became inactive, and will then change its location to the default ($HOME). Fix the bug by keeping an additional state per-slot for whether there's an active search. https://bugzilla.gnome.org/show_bug.cgi?id=686893
This commit is contained in:
parent
f017a93b9b
commit
0b59aa2e04
2 changed files with 21 additions and 14 deletions
|
@ -101,6 +101,7 @@ struct NautilusWindowSlotDetails {
|
|||
gulong qe_changed_id;
|
||||
gulong qe_cancel_id;
|
||||
gulong qe_activated_id;
|
||||
gboolean search_active;
|
||||
|
||||
/* Load state */
|
||||
GCancellable *find_mount_cancellable;
|
||||
|
@ -142,11 +143,31 @@ toggle_toolbar_search_button (NautilusWindowSlot *slot,
|
|||
{
|
||||
GtkActionGroup *action_group;
|
||||
GtkAction *action;
|
||||
gboolean old_active;
|
||||
GFile *location;
|
||||
|
||||
action_group = nautilus_window_get_main_action_group (slot->details->window);
|
||||
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SEARCH);
|
||||
|
||||
old_active = slot->details->search_active;
|
||||
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
|
||||
slot->details->search_active = active;
|
||||
|
||||
/* If search was active on this slot and became inactive, change
|
||||
* the slot location to the real directory.
|
||||
*/
|
||||
if (!active && old_active) {
|
||||
/* Use the query editor search root if possible */
|
||||
location = nautilus_window_slot_get_query_editor_location (slot);
|
||||
|
||||
/* Use the home directory as a fallback */
|
||||
if (location == NULL) {
|
||||
location = g_file_new_for_path (g_get_home_dir ());
|
||||
}
|
||||
|
||||
nautilus_window_slot_open_location (slot, location, 0);
|
||||
g_object_unref (location);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -282,21 +282,7 @@ nautilus_window_set_search_visible (NautilusWindow *window,
|
|||
remember_focus_widget (window);
|
||||
nautilus_window_slot_set_query_editor_visible (slot, TRUE);
|
||||
} else {
|
||||
GFile *location = NULL;
|
||||
|
||||
restore_focus_widget (window);
|
||||
|
||||
/* Use the location bar as the return location */
|
||||
location = nautilus_window_slot_get_query_editor_location (slot);
|
||||
|
||||
/* Last try: use the home directory as the return location */
|
||||
if (location == NULL) {
|
||||
location = g_file_new_for_path (g_get_home_dir ());
|
||||
}
|
||||
|
||||
nautilus_window_go_to (window, location);
|
||||
g_object_unref (location);
|
||||
|
||||
nautilus_window_slot_set_query_editor_visible (slot, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue