summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/caja-application.c174
-rw-r--r--src/caja-application.h15
2 files changed, 74 insertions, 115 deletions
diff --git a/src/caja-application.c b/src/caja-application.c
index 5881facd..a462524f 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -777,43 +777,34 @@ open_window (CajaApplication *application,
{
GFile *location;
CajaWindow *window;
+ gboolean existing;
+
+ if (uri == NULL) {
+ location = g_file_new_for_path (g_get_home_dir ());
+ } else {
+ location = g_file_new_for_uri (uri);
+ }
+
+ existing = FALSE;
if (browser_window ||
- g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
+ g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
startup_id,
screen);
- if (uri == NULL)
- {
- caja_window_go_home (window);
- }
- else
- {
- location = g_file_new_for_uri (uri);
- caja_window_go_to (window, location);
- g_object_unref (location);
- }
- }
- else
- {
- if (uri == NULL)
- {
- location = g_file_new_for_path (g_get_home_dir ());
- }
- else
- {
- location = g_file_new_for_uri (uri);
- }
-
- window = caja_application_present_spatial_window (application,
+ } else {
+ window = caja_application_get_spatial_window (application,
NULL,
startup_id,
location,
- screen);
- g_object_unref (location);
+ screen,
+ NULL);
}
+ caja_window_go_to (window, location);
+
+ g_object_unref (location);
+
if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window)))
{
/* never maximize windows opened from shell if a
@@ -1225,22 +1216,25 @@ caja_application_get_existing_spatial_window (GFile *location)
{
GList *l;
CajaWindowSlot *slot;
+ GFile *window_location;
for (l = caja_application_get_spatial_window_list ();
- l != NULL; l = l->next)
- {
- GFile *window_location;
-
+ l != NULL; l = l->next) {
slot = CAJA_WINDOW (l->data)->details->active_pane->active_slot;
- window_location = slot->location;
- if (window_location != NULL)
- {
- if (g_file_equal (location, window_location))
- {
- return CAJA_SPATIAL_WINDOW (l->data);
+
+ window_location = slot->pending_location;
+
+ if (window_location == NULL) {
+ window_location = slot->location;
+ }
+
+ if (window_location != NULL) {
+ if (g_file_equal (location, window_location)) {
+ return CAJA_SPATIAL_WINDOW (l->data);
}
}
}
+
return NULL;
}
@@ -1416,68 +1410,32 @@ spatial_window_destroyed_callback (void *user_data, GObject *window)
}
CajaWindow *
-caja_application_present_spatial_window (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GdkScreen *screen)
-{
- return caja_application_present_spatial_window_with_selection (application,
- requesting_window,
- startup_id,
- location,
- NULL,
- screen);
-}
-
-CajaWindow *
-caja_application_present_spatial_window_with_selection (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GList *new_selection,
- GdkScreen *screen)
+caja_application_get_spatial_window (CajaApplication *application,
+ CajaWindow *requesting_window,
+ const char *startup_id,
+ GFile *location,
+ GdkScreen *screen,
+ gboolean *existing)
{
CajaWindow *window;
- GList *l;
- char *uri;
+ gchar *uri;
g_return_val_if_fail (CAJA_IS_APPLICATION (application), NULL);
+ window = CAJA_WINDOW
+ (caja_application_get_existing_spatial_window (location));
- for (l = caja_application_get_spatial_window_list ();
- l != NULL; l = l->next)
- {
- CajaWindow *existing_window;
- CajaWindowSlot *slot;
- GFile *existing_location;
-
- existing_window = CAJA_WINDOW (l->data);
- slot = existing_window->details->active_pane->active_slot;
- existing_location = slot->pending_location;
-
- if (existing_location == NULL)
- {
- existing_location = slot->location;
+ if (window != NULL) {
+ if (existing != NULL) {
+ *existing = TRUE;
}
- if (g_file_equal (existing_location, location))
- {
- gtk_window_present (GTK_WINDOW (existing_window));
- if (new_selection &&
- slot->content_view != NULL)
- {
- caja_view_set_selection (slot->content_view, new_selection);
- }
-
- uri = g_file_get_uri (location);
- caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
- "present EXISTING spatial window=%p: %s",
- existing_window, uri);
- g_free (uri);
- return existing_window;
- }
+ return window;
}
+ if (existing != NULL) {
+ *existing = FALSE;
+ }
+
window = create_window (application, CAJA_TYPE_SPATIAL_WINDOW, startup_id, screen);
if (requesting_window)
{
@@ -1508,8 +1466,6 @@ caja_application_present_spatial_window_with_selection (CajaApplication *applica
g_object_weak_ref (G_OBJECT (window),
spatial_window_destroyed_callback, NULL);
- caja_window_go_to_with_selection (window, location, new_selection);
-
uri = g_file_get_uri (location);
caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"present NEW spatial window=%p: %s",
@@ -1704,27 +1660,30 @@ autorun_show_window (GMount *mount, gpointer user_data)
{
GFile *location;
CajaApplication *application = user_data;
+ CajaWindow *window;
+ gboolean existing;
location = g_mount_get_root (mount);
+ existing = FALSE;
/* There should probably be an easier way to do this */
- if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER))
- {
- CajaWindow *window;
+ if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
- NULL,
- gdk_screen_get_default ());
- caja_window_go_to (window, location);
-
+ NULL,
+ gdk_screen_get_default ());
}
else
{
- caja_application_present_spatial_window (application,
- NULL,
- NULL,
- location,
- gdk_screen_get_default ());
+ window = caja_application_get_spatial_window (application,
+ NULL,
+ NULL,
+ location,
+ gdk_screen_get_default (),
+ NULL);
}
+
+ caja_window_go_to (window, location);
+
g_object_unref (location);
}
@@ -2285,7 +2244,12 @@ caja_application_load_session (CajaApplication *application)
else if (!strcmp (type, "spatial"))
{
location = g_file_new_for_uri (location_uri);
- window = caja_application_present_spatial_window (application, NULL, NULL, location, gdk_screen_get_default ());
+ window = caja_application_get_spatial_window (application, NULL, NULL,
+ location, gdk_screen_get_default (),
+ NULL);
+
+ caja_window_go_to (window, location);
+
g_object_unref (location);
}
else
diff --git a/src/caja-application.h b/src/caja-application.h
index 5c5b94d0..426f2c09 100644
--- a/src/caja-application.h
+++ b/src/caja-application.h
@@ -88,17 +88,12 @@ GList * caja_application_get_window_list (void);
GList * caja_application_get_spatial_window_list (void);
unsigned int caja_application_get_n_windows (void);
-CajaWindow * caja_application_present_spatial_window (CajaApplication *application,
+CajaWindow * caja_application_get_spatial_window (CajaApplication *application,
CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GdkScreen *screen);
-CajaWindow * caja_application_present_spatial_window_with_selection (CajaApplication *application,
- CajaWindow *requesting_window,
- const char *startup_id,
- GFile *location,
- GList *new_selection,
- GdkScreen *screen);
+ const char *startup_id,
+ GFile *location,
+ GdkScreen *screen,
+ gboolean *existing);
CajaWindow * caja_application_create_navigation_window (CajaApplication *application,
const char *startup_id,