Skip to content

Commit

Permalink
Revert "add option to open multiple uri in tabs at startup"
Browse files Browse the repository at this point in the history
This reverts commit fd1f45f.
  • Loading branch information
raveit65 committed Sep 17, 2018
1 parent 0d7a79d commit fb9a3cf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 123 deletions.
157 changes: 50 additions & 107 deletions src/caja-application.c
Expand Up @@ -267,90 +267,26 @@ open_window (CajaApplication *application,
g_free (uri); g_free (uri);
} }


static void
open_tabs (CajaApplication *application,
GFile **locations, guint n_files, GdkScreen *screen, const char *geometry, gboolean browser_window)
{
CajaApplication *self = CAJA_APPLICATION (application);
CajaWindow *window;
gchar *uri = NULL;

/*monitor the preference to use browser or spatial windows */
/*connect before trying to read or this preference won't be read by root or after change*/
g_signal_connect_swapped(caja_preferences, "changed::"CAJA_PREFERENCES_ALWAYS_USE_BROWSER,
G_CALLBACK (caja_empty_callback_to_ensure_read),
self);

if (browser_window ||g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = caja_application_create_navigation_window (application,
screen);
} else {
window = caja_application_get_spatial_window (application,
NULL,
NULL,
locations[0],
screen,
NULL);
}

/* open all locations */
uri = g_file_get_uri (locations[0]);
g_debug("Opening new tab at uri %s\n", uri);
caja_window_go_to (window, locations[0]);
for (int i = 1; i< n_files;i++){
/* open tabs in reverse order because each
* tab is opened before the previous one */
guint tab = n_files-i;
uri = g_file_get_uri (locations[tab]);
g_debug("Opening new tab at uri %s\n", uri);
if(i==0){
caja_window_go_to (window, locations[tab]);
}else{
caja_window_go_to_tab (window, locations[tab]);
}
}

if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window))) {
/* never maximize windows opened from shell if a
* custom geometry has been requested.
*/
gtk_window_unmaximize (GTK_WINDOW (window));
eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
geometry,
APPLICATION_WINDOW_MIN_WIDTH,
APPLICATION_WINDOW_MIN_HEIGHT,
FALSE);
}

g_free (uri);
}

static void static void
open_windows (CajaApplication *application, open_windows (CajaApplication *application,
GFile **files, GFile **files,
GdkScreen *screen, GdkScreen *screen,
const char *geometry, const char *geometry,
guint n_files, guint len,
gboolean browser_window, gboolean browser_window)
gboolean open_in_tabs)
{ {
guint i; guint i;


if (files == NULL || files[0] == NULL) { if (files == NULL || files[0] == NULL) {
/* Open a window pointing at the default location. */ /* Open a window pointing at the default location. */
open_window (application, NULL, screen, geometry, browser_window); open_window (application, NULL, screen, geometry, browser_window );
} else { } else {
if(open_in_tabs){ /* Open windows at each requested location. */
/* Open one window with one tab at each requested location */ i = 0;
open_tabs (application, files, n_files, screen, geometry, browser_window); while (i < len ){
}else{ open_window (application, files[i], screen, geometry, browser_window);
/* Open windows at each requested location. */ i++ ;
i = 0; }
while (i < n_files ){
open_window (application, files[i], screen, geometry, browser_window);
i++ ;
}
}
} }
} }


Expand All @@ -362,41 +298,40 @@ caja_application_open (GApplication *app,
{ {
CajaApplication *self = CAJA_APPLICATION (app); CajaApplication *self = CAJA_APPLICATION (app);
gboolean browser_window = FALSE; gboolean browser_window = FALSE;
gboolean open_in_tabs = FALSE;
const gchar *geometry = NULL; const gchar *geometry = NULL;
const char splitter = '='; const char splitter = '=';


g_debug ("Open called on the GApplication instance; %d files", n_files); g_debug ("Open called on the GApplication instance; %d files", n_files);


/*Check if local command line passed --browser, --geometry or --tabs*/ /*Check if local command line passed --browser or --geometry */
if (strlen(options) > 0){ if (strcmp(options,"") != 0 ){
gchar** splitedOptions = g_strsplit (options, &splitter, 3); if (g_str_match_string ("browser",
sscanf(splitedOptions[0], "%d", &browser_window); options,
if(strcmp(splitedOptions[1], "NULL")!=0){ FALSE) == TRUE){
geometry = splitedOptions[1]; browser_window = TRUE;
geometry = strchr(options, splitter);
}
else {
geometry = options;
} }
sscanf(splitedOptions[2], "%d", &open_in_tabs);

/*Reset this or 3ed and later invocations will use same /*Reset this or 3ed and later invocations will use same
*geometry even if the user has resized open window *geometry even if the user has resized open window
*/ */
self->priv->geometry = NULL; self->priv->geometry = NULL;
} }


open_windows (self, files, open_windows (self, files,
gdk_screen_get_default (), gdk_screen_get_default (),
geometry, geometry,
n_files, n_files,
browser_window, browser_window);
open_in_tabs);
} }


void void
caja_application_open_location (CajaApplication *application, caja_application_open_location (CajaApplication *application,
GFile *location, GFile *location,
GFile *selection, GFile *selection,
const char *startup_id, const char *startup_id)
const gboolean open_in_tabs)
{ {
CajaWindow *window; CajaWindow *window;
GList *sel_list = NULL; GList *sel_list = NULL;
Expand All @@ -408,8 +343,7 @@ caja_application_open_location (CajaApplication *application,
} }


caja_window_slot_open_location_full (caja_window_get_active_slot (window), location, caja_window_slot_open_location_full (caja_window_get_active_slot (window), location,
open_in_tabs, CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW, 0, CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW, sel_list, NULL, NULL);
sel_list, NULL, NULL);


if (sel_list != NULL) { if (sel_list != NULL) {
caja_file_list_free (sel_list); caja_file_list_free (sel_list);
Expand Down Expand Up @@ -2063,7 +1997,6 @@ caja_application_local_command_line (GApplication *application,
gboolean perform_self_check = FALSE; gboolean perform_self_check = FALSE;
gboolean version = FALSE; gboolean version = FALSE;
gboolean browser_window = FALSE; gboolean browser_window = FALSE;
gboolean open_in_tabs = FALSE;
gboolean kill_shell = FALSE; gboolean kill_shell = FALSE;
const gchar *autostart_id; const gchar *autostart_id;
gboolean no_default_window = FALSE; gboolean no_default_window = FALSE;
Expand All @@ -2089,8 +2022,6 @@ caja_application_local_command_line (GApplication *application,
N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL }, N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL },
{ "force-desktop", '\0', 0, G_OPTION_ARG_NONE, &self->priv->force_desktop, { "force-desktop", '\0', 0, G_OPTION_ARG_NONE, &self->priv->force_desktop,
N_("Manage the desktop regardless of set preferences or environment (on new startup only)"), NULL }, N_("Manage the desktop regardless of set preferences or environment (on new startup only)"), NULL },
{ "tabs", 't', 0, G_OPTION_ARG_NONE, &open_in_tabs,
N_("Open URI in tabs."), NULL },
{ "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window, { "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window,
N_("Open a browser window."), NULL }, N_("Open a browser window."), NULL },
{ "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell, { "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell,
Expand Down Expand Up @@ -2120,7 +2051,7 @@ caja_application_local_command_line (GApplication *application,
if (autostart_id != NULL && *autostart_id != '\0') { if (autostart_id != NULL && *autostart_id != '\0') {
no_default_window = TRUE; no_default_window = TRUE;
self->priv->autostart = TRUE; self->priv->autostart = TRUE;
} }




argv = *arguments; argv = *arguments;
Expand Down Expand Up @@ -2178,6 +2109,7 @@ caja_application_local_command_line (GApplication *application,
caja_application_load_session (self); caja_application_load_session (self);
} }



GFile **files; GFile **files;
gint idx, len; gint idx, len;


Expand Down Expand Up @@ -2211,19 +2143,30 @@ caja_application_local_command_line (GApplication *application,
files[1] = NULL; files[1] = NULL;
} }


/*Set up --geometry, --browser and --tabs options */ /*Set up geometry and --browser options */
/*Invoke "Open" to create new windows */ /*Invoke "Open" to create new windows */
if (len > 0) {
gchar* concatOptions = g_malloc0(64); if (browser_window == TRUE && self->priv->geometry == NULL){
if(self->priv->geometry==NULL){
g_snprintf(concatOptions, 64, "%d=NULL=%d", browser_window, open_in_tabs); if (len > 0) {
}else{ g_application_open (application, files, len, "browser");
g_snprintf(concatOptions, 64, "%d=%s=%d", browser_window, self->priv->geometry, open_in_tabs);
} }
g_application_open (application, files, len, concatOptions); }
g_free(concatOptions);
} else { else if (browser_window == FALSE && self->priv->geometry != NULL){
g_print("non\n"); if (len > 0) {
g_application_open (application, files, len, self->priv->geometry);
}
}

else if (browser_window == TRUE && self->priv->geometry != NULL){
if (len > 0) {
g_application_open (application, files, len, (g_strconcat("browser","=",
self->priv->geometry, NULL)));
}
}

else {
if (len > 0) { if (len > 0) {
g_application_open (application, files, len, ""); g_application_open (application, files, len, "");
} }
Expand Down Expand Up @@ -2477,11 +2420,11 @@ caja_application_quit_mainloop (GApplication *app)
static void static void
caja_application_class_init (CajaApplicationClass *class) caja_application_class_init (CajaApplicationClass *class)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GApplicationClass *application_class; GApplicationClass *application_class;


object_class = G_OBJECT_CLASS (class); object_class = G_OBJECT_CLASS (class);
object_class->finalize = caja_application_finalize; object_class->finalize = caja_application_finalize;


application_class = G_APPLICATION_CLASS (class); application_class = G_APPLICATION_CLASS (class);
application_class->startup = caja_application_startup; application_class->startup = caja_application_startup;
Expand Down
3 changes: 1 addition & 2 deletions src/caja-application.h
Expand Up @@ -100,7 +100,6 @@ void caja_application_close_all_spatial_windows (void);
void caja_application_open_location (CajaApplication *application, void caja_application_open_location (CajaApplication *application,
GFile *location, GFile *location,
GFile *selection, GFile *selection,
const char *startup_id, const char *startup_id);
const gboolean open_in_tabs);


#endif /* CAJA_APPLICATION_H */ #endif /* CAJA_APPLICATION_H */
6 changes: 3 additions & 3 deletions src/caja-freedesktop-dbus.c
Expand Up @@ -75,10 +75,10 @@ skeleton_handle_show_items_cb (CajaFreedesktopFileManager1 *object,
parent = g_file_get_parent (file); parent = g_file_get_parent (file);


if (parent != NULL) { if (parent != NULL) {
caja_application_open_location (application, parent, file, startup_id, 0); caja_application_open_location (application, parent, file, startup_id);
g_object_unref (parent); g_object_unref (parent);
} else { } else {
caja_application_open_location (application, file, NULL, startup_id, 0); caja_application_open_location (application, file, NULL, startup_id);
} }


g_object_unref (file); g_object_unref (file);
Expand All @@ -105,7 +105,7 @@ skeleton_handle_show_folders_cb (CajaFreedesktopFileManager1 *object,


file = g_file_new_for_uri (uris[i]); file = g_file_new_for_uri (uris[i]);


caja_application_open_location (application, file, NULL, startup_id, 0); caja_application_open_location (application, file, NULL, startup_id);


g_object_unref (file); g_object_unref (file);
} }
Expand Down
10 changes: 1 addition & 9 deletions src/caja-window.c
Expand Up @@ -234,14 +234,6 @@ caja_window_go_to (CajaWindow *window, GFile *location)
caja_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE); caja_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE);
} }


void
caja_window_go_to_tab (CajaWindow *window, GFile *location)
{
g_return_if_fail (CAJA_IS_WINDOW (window));

caja_window_slot_go_to (window->details->active_pane->active_slot, location, TRUE);
}

void void
caja_window_go_to_full (CajaWindow *window, caja_window_go_to_full (CajaWindow *window,
GFile *location, GFile *location,
Expand Down Expand Up @@ -274,7 +266,7 @@ caja_window_new_tab (CajaWindow *window)
CajaWindowSlot *current_slot; CajaWindowSlot *current_slot;
CajaWindowSlot *new_slot; CajaWindowSlot *new_slot;
CajaWindowOpenFlags flags; CajaWindowOpenFlags flags;
GFile *location = NULL; GFile *location;
int new_slot_position; int new_slot_position;
char *scheme; char *scheme;


Expand Down
2 changes: 0 additions & 2 deletions src/caja-window.h
Expand Up @@ -136,8 +136,6 @@ void caja_window_disconnect_content_view (CajaWindow *window,


void caja_window_go_to (CajaWindow *window, void caja_window_go_to (CajaWindow *window,
GFile *location); GFile *location);
void caja_window_go_to_tab (CajaWindow *window,
GFile *location);
void caja_window_go_to_full (CajaWindow *window, void caja_window_go_to_full (CajaWindow *window,
GFile *location, GFile *location,
CajaWindowGoToCallback callback, CajaWindowGoToCallback callback,
Expand Down

0 comments on commit fb9a3cf

Please sign in to comment.