window: set places sidebar to the previous location on error

Nautilus opens the location notified by GtkPlacesSidebar
without further interaction with it.

With that, when a location fails to open, Nautilus goes
back to the previous valid location but, because of we're
not interacting with the sidebar after the failure, the
sidebar was not updated to match these changes, i.e. kept
the old invalid row selected.

To fix it, set the previous valid location to the sidebar
as well if there's some error loading a location.

https://bugzilla.gnome.org/show_bug.cgi?id=734755
parent 10a96ee3
......@@ -656,10 +656,6 @@ static void got_file_info_for_view_selection_callback (NautilusFile
static gboolean create_content_view (NautilusWindowSlot *slot,
const char *view_id,
GError **error);
static void display_view_selection_failure (NautilusWindow *window,
NautilusFile *file,
GFile *location,
GError *error);
static void load_new_location (NautilusWindowSlot *slot,
GFile *location,
GList *selection,
......@@ -1278,8 +1274,10 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
_("Unable to load location"));
}
if (!report_callback (slot, error)) {
display_view_selection_failure (window, file,
location, error);
nautilus_window_slot_display_view_selection_failure (window,
file,
location,
error);
}
if (!gtk_widget_get_visible (GTK_WIDGET (window))) {
......@@ -1583,9 +1581,11 @@ cancel_location_change (NautilusWindowSlot *slot)
end_location_change (slot);
}
static void
display_view_selection_failure (NautilusWindow *window, NautilusFile *file,
GFile *location, GError *error)
void
nautilus_window_slot_display_view_selection_failure (NautilusWindow *window,
NautilusFile *file,
GFile *location,
GError *error)
{
char *error_message;
char *detail_message;
......
......@@ -125,4 +125,9 @@ void nautilus_window_slot_set_status (NautilusWindowSlot *slot,
const char *detail_status);
void nautilus_window_slot_sync_view_mode (NautilusWindowSlot *slot);
void nautilus_window_slot_display_view_selection_failure (NautilusWindow *window,
NautilusFile *file,
GFile *location,
GError *error);
#endif /* NAUTILUS_WINDOW_SLOT_H */
......@@ -988,6 +988,34 @@ setup_side_pane_width (NautilusWindow *window)
window->priv->side_pane_width);
}
static void
nautilus_window_location_opened (NautilusWindow *window,
GFile *location,
GError *error,
gpointer user_data)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
if (error) {
NautilusFile *old_file;
GFile *old_location;
old_file = nautilus_window_slot_get_file (window->priv->active_slot);
old_location = nautilus_file_get_location (old_file);
gtk_places_sidebar_set_location (GTK_PLACES_SIDEBAR (window->priv->places_sidebar), old_location);
g_warning ("error opening location: %s", error->message);
nautilus_window_slot_display_view_selection_failure (window,
old_file,
location,
error);
g_object_unref (old_location);
}
}
/* Callback used when the places sidebar changes location; we need to change the displayed folder */
static void
places_sidebar_open_location_cb (GtkPlacesSidebar *sidebar,
......@@ -1013,7 +1041,12 @@ places_sidebar_open_location_cb (GtkPlacesSidebar *sidebar,
break;
}
nautilus_window_slot_open_location (window->priv->active_slot, location, flags);
nautilus_window_slot_open_location_full (window->priv->active_slot,
location,
flags,
NULL,
(NautilusWindowGoToCallback) nautilus_window_location_opened,
NULL);
}
/* Callback used when the places sidebar needs us to present an error message */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment