@@ -267,90 +267,26 @@ open_window (CajaApplication *application,
267267 g_free (uri );
268268}
269269
270- static void
271- open_tabs (CajaApplication * application ,
272- GFile * * locations , guint n_files , GdkScreen * screen , const char * geometry , gboolean browser_window )
273- {
274- CajaApplication * self = CAJA_APPLICATION (application );
275- CajaWindow * window ;
276- gchar * uri = NULL ;
277-
278- /*monitor the preference to use browser or spatial windows */
279- /*connect before trying to read or this preference won't be read by root or after change*/
280- g_signal_connect_swapped (caja_preferences , "changed::" CAJA_PREFERENCES_ALWAYS_USE_BROWSER ,
281- G_CALLBACK (caja_empty_callback_to_ensure_read ),
282- self );
283-
284- if (browser_window || g_settings_get_boolean (caja_preferences , CAJA_PREFERENCES_ALWAYS_USE_BROWSER )) {
285- window = caja_application_create_navigation_window (application ,
286- screen );
287- } else {
288- window = caja_application_get_spatial_window (application ,
289- NULL ,
290- NULL ,
291- locations [0 ],
292- screen ,
293- NULL );
294- }
295-
296- /* open all locations */
297- uri = g_file_get_uri (locations [0 ]);
298- g_debug ("Opening new tab at uri %s\n" , uri );
299- caja_window_go_to (window , locations [0 ]);
300- for (int i = 1 ; i < n_files ;i ++ ){
301- /* open tabs in reverse order because each
302- * tab is opened before the previous one */
303- guint tab = n_files - i ;
304- uri = g_file_get_uri (locations [tab ]);
305- g_debug ("Opening new tab at uri %s\n" , uri );
306- if (i == 0 ){
307- caja_window_go_to (window , locations [tab ]);
308- }else {
309- caja_window_go_to_tab (window , locations [tab ]);
310- }
311- }
312-
313- if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window ))) {
314- /* never maximize windows opened from shell if a
315- * custom geometry has been requested.
316- */
317- gtk_window_unmaximize (GTK_WINDOW (window ));
318- eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window ),
319- geometry ,
320- APPLICATION_WINDOW_MIN_WIDTH ,
321- APPLICATION_WINDOW_MIN_HEIGHT ,
322- FALSE);
323- }
324-
325- g_free (uri );
326- }
327-
328270static void
329271open_windows (CajaApplication * application ,
330272 GFile * * files ,
331273 GdkScreen * screen ,
332274 const char * geometry ,
333- guint n_files ,
334- gboolean browser_window ,
335- gboolean open_in_tabs )
275+ guint len ,
276+ gboolean browser_window )
336277{
337278 guint i ;
338279
339280 if (files == NULL || files [0 ] == NULL ) {
340281 /* Open a window pointing at the default location. */
341- open_window (application , NULL , screen , geometry , browser_window );
282+ open_window (application , NULL , screen , geometry , browser_window );
342283 } else {
343- if (open_in_tabs ){
344- /* Open one window with one tab at each requested location */
345- open_tabs (application , files , n_files , screen , geometry , browser_window );
346- }else {
347- /* Open windows at each requested location. */
348- i = 0 ;
349- while (i < n_files ){
350- open_window (application , files [i ], screen , geometry , browser_window );
351- i ++ ;
352- }
353- }
284+ /* Open windows at each requested location. */
285+ i = 0 ;
286+ while (i < len ){
287+ open_window (application , files [i ], screen , geometry , browser_window );
288+ i ++ ;
289+ }
354290 }
355291}
356292
@@ -362,41 +298,40 @@ caja_application_open (GApplication *app,
362298{
363299 CajaApplication * self = CAJA_APPLICATION (app );
364300 gboolean browser_window = FALSE;
365- gboolean open_in_tabs = FALSE;
366301 const gchar * geometry = NULL ;
367302 const char splitter = '=' ;
368303
369304 g_debug ("Open called on the GApplication instance; %d files" , n_files );
370305
371- /*Check if local command line passed --browser, --geometry or --tabs*/
372- if (strlen (options ) > 0 ){
373- gchar * * splitedOptions = g_strsplit (options , & splitter , 3 );
374- sscanf (splitedOptions [0 ], "%d" , & browser_window );
375- if (strcmp (splitedOptions [1 ], "NULL" )!= 0 ){
376- geometry = splitedOptions [1 ];
306+ /*Check if local command line passed --browser or --geometry */
307+ if (strcmp (options ,"" ) != 0 ){
308+ if (g_str_match_string ("browser" ,
309+ options ,
310+ FALSE) == TRUE){
311+ browser_window = TRUE;
312+ geometry = strchr (options , splitter );
313+ }
314+ else {
315+ geometry = options ;
377316 }
378- sscanf (splitedOptions [2 ], "%d" , & open_in_tabs );
379-
380317 /*Reset this or 3ed and later invocations will use same
381318 *geometry even if the user has resized open window
382319 */
383320 self -> priv -> geometry = NULL ;
384321 }
385322
386- open_windows (self , files ,
323+ open_windows (self , files ,
387324 gdk_screen_get_default (),
388325 geometry ,
389326 n_files ,
390- browser_window ,
391- open_in_tabs );
327+ browser_window );
392328}
393329
394330void
395331caja_application_open_location (CajaApplication * application ,
396332 GFile * location ,
397333 GFile * selection ,
398- const char * startup_id ,
399- const gboolean open_in_tabs )
334+ const char * startup_id )
400335{
401336 CajaWindow * window ;
402337 GList * sel_list = NULL ;
@@ -408,8 +343,7 @@ caja_application_open_location (CajaApplication *application,
408343 }
409344
410345 caja_window_slot_open_location_full (caja_window_get_active_slot (window ), location ,
411- open_in_tabs , CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW ,
412- sel_list , NULL , NULL );
346+ 0 , CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW , sel_list , NULL , NULL );
413347
414348 if (sel_list != NULL ) {
415349 caja_file_list_free (sel_list );
@@ -2063,7 +1997,6 @@ caja_application_local_command_line (GApplication *application,
20631997 gboolean perform_self_check = FALSE;
20641998 gboolean version = FALSE;
20651999 gboolean browser_window = FALSE;
2066- gboolean open_in_tabs = FALSE;
20672000 gboolean kill_shell = FALSE;
20682001 const gchar * autostart_id ;
20692002 gboolean no_default_window = FALSE;
@@ -2089,8 +2022,6 @@ caja_application_local_command_line (GApplication *application,
20892022 N_ ("Do not manage the desktop (ignore the preference set in the preferences dialog)." ), NULL },
20902023 { "force-desktop" , '\0' , 0 , G_OPTION_ARG_NONE , & self -> priv -> force_desktop ,
20912024 N_ ("Manage the desktop regardless of set preferences or environment (on new startup only)" ), NULL },
2092- { "tabs" , 't' , 0 , G_OPTION_ARG_NONE , & open_in_tabs ,
2093- N_ ("Open URI in tabs." ), NULL },
20942025 { "browser" , '\0' , 0 , G_OPTION_ARG_NONE , & browser_window ,
20952026 N_ ("Open a browser window." ), NULL },
20962027 { "quit" , 'q' , 0 , G_OPTION_ARG_NONE , & kill_shell ,
@@ -2120,7 +2051,7 @@ caja_application_local_command_line (GApplication *application,
21202051 if (autostart_id != NULL && * autostart_id != '\0' ) {
21212052 no_default_window = TRUE;
21222053 self -> priv -> autostart = TRUE;
2123- }
2054+ }
21242055
21252056
21262057 argv = * arguments ;
@@ -2178,6 +2109,7 @@ caja_application_local_command_line (GApplication *application,
21782109 caja_application_load_session (self );
21792110 }
21802111
2112+
21812113 GFile * * files ;
21822114 gint idx , len ;
21832115
@@ -2211,19 +2143,30 @@ caja_application_local_command_line (GApplication *application,
22112143 files [1 ] = NULL ;
22122144 }
22132145
2214- /*Set up -- geometry, --browser and --tabs options */
2146+ /*Set up geometry and --browser options */
22152147 /*Invoke "Open" to create new windows */
2216- if (len > 0 ) {
2217- gchar * concatOptions = g_malloc0 (64 );
2218- if (self -> priv -> geometry == NULL ){
2219- g_snprintf (concatOptions , 64 , "%d=NULL=%d" , browser_window , open_in_tabs );
2220- }else {
2221- g_snprintf (concatOptions , 64 , "%d=%s=%d" , browser_window , self -> priv -> geometry , open_in_tabs );
2148+
2149+ if (browser_window == TRUE && self -> priv -> geometry == NULL ){
2150+
2151+ if (len > 0 ) {
2152+ g_application_open (application , files , len , "browser" );
22222153 }
2223- g_application_open (application , files , len , concatOptions );
2224- g_free (concatOptions );
2225- } else {
2226- g_print ("non\n" );
2154+ }
2155+
2156+ else if (browser_window == FALSE && self -> priv -> geometry != NULL ){
2157+ if (len > 0 ) {
2158+ g_application_open (application , files , len , self -> priv -> geometry );
2159+ }
2160+ }
2161+
2162+ else if (browser_window == TRUE && self -> priv -> geometry != NULL ){
2163+ if (len > 0 ) {
2164+ g_application_open (application , files , len , (g_strconcat ("browser" ,"=" ,
2165+ self -> priv -> geometry , NULL )));
2166+ }
2167+ }
2168+
2169+ else {
22272170 if (len > 0 ) {
22282171 g_application_open (application , files , len , "" );
22292172 }
@@ -2477,11 +2420,11 @@ caja_application_quit_mainloop (GApplication *app)
24772420static void
24782421caja_application_class_init (CajaApplicationClass * class )
24792422{
2480- GObjectClass * object_class ;
2423+ GObjectClass * object_class ;
24812424 GApplicationClass * application_class ;
24822425
2483- object_class = G_OBJECT_CLASS (class );
2484- object_class -> finalize = caja_application_finalize ;
2426+ object_class = G_OBJECT_CLASS (class );
2427+ object_class -> finalize = caja_application_finalize ;
24852428
24862429 application_class = G_APPLICATION_CLASS (class );
24872430 application_class -> startup = caja_application_startup ;
0 commit comments