[nautilus] window: Add helper to open new tab from a back / forward selection
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window: Add helper to open new tab from a back / forward selection
- Date: Sat, 16 Jul 2022 15:38:11 +0000 (UTC)
commit 802a33b3e7f5cffd267065add44325d92341b2c7
Author: Corey Berla <corey berla me>
Date: Sat Jul 16 07:39:09 2022 -0700
window: Add helper to open new tab from a back / forward selection
Add function like nautilus_window_back_or_foward(), but instead
of acting on the current slot, open a new tab. This will be used
when middle clicking the navigation buttons in the toolbar.
src/nautilus-window.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/nautilus-window.h | 3 +++
2 files changed, 51 insertions(+)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 34f2aec72..d409d31ef 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2034,6 +2034,54 @@ nautilus_window_back_or_forward (NautilusWindow *window,
}
}
+void
+nautilus_window_back_or_forward_in_new_tab (NautilusWindow *window,
+ NautilusNavigationDirection direction)
+{
+ GFile *location;
+ NautilusWindowSlot *window_slot;
+ NautilusWindowSlot *new_slot;
+ NautilusNavigationState *state;
+
+ window_slot = nautilus_window_get_active_slot (window);
+ new_slot = nautilus_window_slot_new (window);
+ state = nautilus_window_slot_get_navigation_state (window_slot);
+
+ /* Manually fix up the back / forward lists and location.
+ * This way we don't have to unnecessary load the current location
+ * and then load back / forward */
+ switch (direction)
+ {
+ case NAUTILUS_NAVIGATION_DIRECTION_BACK:
+ {
+ state->forward_list = g_list_prepend (state->forward_list, state->current_location_bookmark);
+ state->current_location_bookmark = state->back_list->data;
+ state->back_list = state->back_list->next;
+ }
+ break;
+
+ case NAUTILUS_NAVIGATION_DIRECTION_FORWARD:
+ {
+ state->back_list = g_list_prepend (state->back_list, state->current_location_bookmark);
+ state->current_location_bookmark = state->forward_list->data;
+ state->forward_list = state->forward_list->next;
+ }
+ break;
+
+ default:
+ {
+ g_assert_not_reached ();
+ }
+ }
+
+ location = nautilus_bookmark_get_location (state->current_location_bookmark);
+ nautilus_window_initialize_slot (window, new_slot, NAUTILUS_OPEN_FLAG_NEW_TAB);
+ nautilus_window_slot_open_location_full (new_slot, location, 0, NULL);
+ nautilus_window_slot_restore_navigation_state (new_slot, state);
+
+ free_navigation_state (state);
+}
+
static void
on_click_gesture_pressed (GtkGestureClick *gesture,
gint n_press,
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 03fb00edd..71bf490e3 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -115,4 +115,7 @@ gboolean nautilus_window_export_handle (NautilusWindow *window,
gpointer user_data);
void nautilus_window_unexport_handle (NautilusWindow *window);
+void nautilus_window_back_or_forward_in_new_tab (NautilusWindow *window,
+ NautilusNavigationDirection back);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]