summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYetoo1 <[email protected]>2019-12-25 00:32:31 -0800
committerraveit65 <[email protected]>2022-07-20 21:40:42 +0200
commit3ad8d41776d40906f940bda52a86dc9300084828 (patch)
tree48e0b2f5a99c71464abf7838e6c3511f03afe1cd /src
parent73c4ab5f009e492d889b267ed18a5416ec81a6c9 (diff)
downloadcaja-3ad8d41776d40906f940bda52a86dc9300084828.tar.bz2
caja-3ad8d41776d40906f940bda52a86dc9300084828.tar.xz
Keep path same when opening new window from an existing one
solved https://github.com/mate-desktop/caja/issues/1335
Diffstat (limited to 'src')
-rw-r--r--src/caja-navigation-window-menus.c9
-rw-r--r--src/caja-window.c36
-rw-r--r--src/caja-window.h1
3 files changed, 40 insertions, 6 deletions
diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c
index 9976a6ca..6839ef6f 100644
--- a/src/caja-navigation-window-menus.c
+++ b/src/caja-navigation-window-menus.c
@@ -607,15 +607,12 @@ action_new_window_callback (GtkAction *action,
gpointer user_data)
{
CajaWindow *current_window;
- CajaWindow *new_window;
- current_window = CAJA_WINDOW (user_data);
- new_window = caja_application_create_navigation_window (
- current_window->application,
- gtk_window_get_screen (GTK_WINDOW (current_window)));
- caja_window_go_home (new_window);
+ current_window = CAJA_WINDOW (user_data);
+ caja_window_new_window (current_window);
}
+
static void
action_new_tab_callback (GtkAction *action,
gpointer user_data)
diff --git a/src/caja-window.c b/src/caja-window.c
index 064e5b92..809eeb26 100644
--- a/src/caja-window.c
+++ b/src/caja-window.c
@@ -308,6 +308,42 @@ caja_window_new_tab (CajaWindow *window)
}
}
+/*Opens a new window when called from an existing window and goes to the same location that's in the existing window.*/
+void
+caja_window_new_window (CajaWindow *window)
+{
+ CajaWindowSlot *current_slot;
+ GFile *location = NULL;
+ g_return_if_fail (CAJA_IS_WINDOW (window));
+
+ /*Get and set the directory location of current window (slot).*/
+ current_slot = window->details->active_pane->active_slot;
+ location = caja_window_slot_get_location (current_slot);
+
+ if (location != NULL)
+ {
+ CajaWindow *new_window;
+ CajaWindowSlot *new_slot;
+ CajaWindowOpenFlags flags;
+ flags = FALSE;
+
+ /*Create a new window*/
+ new_window = caja_application_create_navigation_window (
+ window->application,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+
+ /*Create a slot in the new window.*/
+ new_slot = new_window->details->active_pane->active_slot;
+ g_return_if_fail (CAJA_IS_WINDOW_SLOT (new_slot));
+
+ /*Open a directory at the set location in the new window (slot).*/
+ caja_window_slot_open_location_full (new_slot, location,
+ CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
+ flags, NULL, NULL, NULL);
+ g_object_unref (location);
+ }
+}
+
void
caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab)
{
diff --git a/src/caja-window.h b/src/caja-window.h
index 2de08b34..323a43aa 100644
--- a/src/caja-window.h
+++ b/src/caja-window.h
@@ -148,6 +148,7 @@ void caja_window_go_to_with_selection (CajaWindow *window,
GList *new_selection);
void caja_window_go_home (CajaWindow *window);
void caja_window_new_tab (CajaWindow *window);
+void caja_window_new_window (CajaWindow *window);
void caja_window_go_up (CajaWindow *window,
gboolean close_behind,
gboolean new_tab);