Skip to content

Commit 424cf44

Browse files
committed
Fix indents, update docs to reflect ability to open URIs in tabs
1 parent 04f7e80 commit 424cf44

File tree

3 files changed

+70
-68
lines changed

3 files changed

+70
-68
lines changed

docs/caja.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ X display to use.
2626
\fB\-g, \-\-geometry=\fIGEOMETRY\fR
2727
Create the initial window with the given geometry.
2828
.TP
29+
\fB\-t, \-\-tabs\fR
30+
Open URIs in tabs.
31+
.TP
2932
\fB\-n, \-\-no\-default\-window\fR
3033
Only create windows for explicitly specified URIs.
3134
.TP

src/caja-application.c

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ caja_empty_callback_to_ensure_read() {
221221

222222
static void
223223
open_window (CajaApplication *application,
224-
GFile *location, GdkScreen *screen, const char *geometry, gboolean browser_window)
224+
GFile *location,
225+
GdkScreen *screen,
226+
const char *geometry,
227+
gboolean browser_window)
225228
{
226229
CajaApplication *self = CAJA_APPLICATION (application);
227230
CajaWindow *window;
@@ -239,9 +242,7 @@ open_window (CajaApplication *application,
239242
if (browser_window ||g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
240243
window = caja_application_create_navigation_window (application,
241244
screen);
242-
}
243-
244-
else {
245+
} else {
245246
window = caja_application_get_spatial_window (application,
246247
NULL,
247248
NULL,
@@ -254,8 +255,7 @@ open_window (CajaApplication *application,
254255

255256
if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window))) {
256257
/* never maximize windows opened from shell if a
257-
* custom geometry has been requested.
258-
*/
258+
* custom geometry has been requested. */
259259
gtk_window_unmaximize (GTK_WINDOW (window));
260260
eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
261261
geometry,
@@ -269,84 +269,86 @@ open_window (CajaApplication *application,
269269

270270
static void
271271
open_tabs (CajaApplication *application,
272-
GFile **locations, guint n_files, GdkScreen *screen, const char *geometry, gboolean browser_window)
272+
GFile **locations,
273+
guint n_files,
274+
GdkScreen *screen,
275+
const char *geometry,
276+
gboolean browser_window)
273277
{
274278
CajaApplication *self = CAJA_APPLICATION (application);
275279
CajaWindow *window;
276280
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);
281+
/* monitor the preference to use browser or spatial windows */
282+
/* connect before trying to read or this preference won't be read by root or after change */
283+
g_signal_connect_swapped (caja_preferences,
284+
"changed::"CAJA_PREFERENCES_ALWAYS_USE_BROWSER,
285+
G_CALLBACK (caja_empty_callback_to_ensure_read),
286+
self);
283287

284288
if (browser_window ||g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
285-
window = caja_application_create_navigation_window (application,
286-
screen);
289+
window = caja_application_create_navigation_window (application, screen);
287290
} else {
288291
window = caja_application_get_spatial_window (application,
289-
NULL,
290-
NULL,
291-
locations[0],
292-
screen,
293-
NULL);
292+
NULL,
293+
NULL,
294+
locations[0],
295+
screen,
296+
NULL);
294297
}
295298

296299
/* open all locations */
297300
uri = g_file_get_uri (locations[0]);
298-
g_debug("Opening new tab at uri %s\n", uri);
301+
g_debug ("Opening new tab at uri %s\n", uri);
299302
caja_window_go_to (window, locations[0]);
300-
for (int i = 1; i< n_files;i++){
303+
for (int i = 1; i< n_files;i++) {
301304
/* open tabs in reverse order because each
302305
* tab is opened before the previous one */
303306
guint tab = n_files-i;
304307
uri = g_file_get_uri (locations[tab]);
305-
g_debug("Opening new tab at uri %s\n", uri);
306-
if(i==0){
308+
g_debug ("Opening new tab at uri %s\n", uri);
309+
if (i == 0) {
307310
caja_window_go_to (window, locations[tab]);
308-
}else{
311+
} else {
309312
caja_window_go_to_tab (window, locations[tab]);
310313
}
311314
}
312315

313316
if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window))) {
314317
/* never maximize windows opened from shell if a
315-
* custom geometry has been requested.
316-
*/
318+
* custom geometry has been requested. */
317319
gtk_window_unmaximize (GTK_WINDOW (window));
318320
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);
321+
geometry,
322+
APPLICATION_WINDOW_MIN_WIDTH,
323+
APPLICATION_WINDOW_MIN_HEIGHT,
324+
FALSE);
323325
}
324326

325327
g_free (uri);
326328
}
327329

328330
static void
329331
open_windows (CajaApplication *application,
330-
GFile **files,
331-
GdkScreen *screen,
332-
const char *geometry,
333-
guint n_files,
334-
gboolean browser_window,
335-
gboolean open_in_tabs)
332+
GFile **files,
333+
GdkScreen *screen,
334+
const char *geometry,
335+
guint n_files,
336+
gboolean browser_window,
337+
gboolean open_in_tabs)
336338
{
337339
guint i;
338340

339341
if (files == NULL || files[0] == NULL) {
340342
/* Open a window pointing at the default location. */
341343
open_window (application, NULL, screen, geometry, browser_window);
342344
} else {
343-
if(open_in_tabs){
345+
if (open_in_tabs) {
344346
/* Open one window with one tab at each requested location */
345347
open_tabs (application, files, n_files, screen, geometry, browser_window);
346-
}else{
348+
} else {
347349
/* Open windows at each requested location. */
348350
i = 0;
349-
while (i < n_files ){
351+
while (i < n_files) {
350352
open_window (application, files[i], screen, geometry, browser_window);
351353
i++ ;
352354
}
@@ -356,9 +358,9 @@ open_windows (CajaApplication *application,
356358

357359
static void
358360
caja_application_open (GApplication *app,
359-
GFile **files,
360-
gint n_files,
361-
const gchar *options)
361+
GFile **files,
362+
gint n_files,
363+
const gchar *options)
362364
{
363365
CajaApplication *self = CAJA_APPLICATION (app);
364366
gboolean browser_window = FALSE;
@@ -368,28 +370,27 @@ caja_application_open (GApplication *app,
368370

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

371-
/*Check if local command line passed --browser, --geometry or --tabs*/
372-
if (strlen(options) > 0){
373+
/* Check if local command line passed --browser, --geometry or --tabs */
374+
if (strlen (options) > 0) {
373375
gchar** splitedOptions = g_strsplit (options, &splitter, 3);
374-
sscanf(splitedOptions[0], "%d", &browser_window);
375-
if(strcmp(splitedOptions[1], "NULL")!=0){
376+
sscanf (splitedOptions[0], "%d", &browser_window);
377+
if (strcmp (splitedOptions[1], "NULL") != 0) {
376378
geometry = splitedOptions[1];
377379
}
378-
sscanf(splitedOptions[2], "%d", &open_in_tabs);
380+
sscanf (splitedOptions[2], "%d", &open_in_tabs);
379381

380-
/*Reset this or 3ed and later invocations will use same
381-
*geometry even if the user has resized open window
382-
*/
382+
/* Reset this or 3ed and later invocations will use same
383+
* geometry even if the user has resized open window */
383384
self->priv->geometry = NULL;
384-
g_strfreev(splitedOptions);
385+
g_strfreev (splitedOptions);
385386
}
386387

387-
open_windows (self, files,
388-
gdk_screen_get_default (),
389-
geometry,
390-
n_files,
391-
browser_window,
392-
open_in_tabs);
388+
open_windows (self, files,
389+
gdk_screen_get_default (),
390+
geometry,
391+
n_files,
392+
browser_window,
393+
open_in_tabs);
393394
}
394395

395396
void
@@ -425,7 +426,7 @@ caja_application_quit (CajaApplication *self)
425426

426427
windows = gtk_application_get_windows (GTK_APPLICATION (app));
427428
g_list_foreach (windows, (GFunc) gtk_widget_destroy, NULL);
428-
/* we have been asked to force quit */
429+
/* we have been asked to force quit */
429430
g_application_quit (G_APPLICATION (self));
430431
}
431432

@@ -2091,7 +2092,7 @@ caja_application_local_command_line (GApplication *application,
20912092
{ "force-desktop", '\0', 0, G_OPTION_ARG_NONE, &self->priv->force_desktop,
20922093
N_("Manage the desktop regardless of set preferences or environment (on new startup only)"), NULL },
20932094
{ "tabs", 't', 0, G_OPTION_ARG_NONE, &open_in_tabs,
2094-
N_("Open URI in tabs."), NULL },
2095+
N_("Open URIs in tabs."), NULL },
20952096
{ "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window,
20962097
N_("Open a browser window."), NULL },
20972098
{ "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell,
@@ -2216,15 +2217,14 @@ caja_application_local_command_line (GApplication *application,
22162217
/*Invoke "Open" to create new windows */
22172218
if (len > 0) {
22182219
gchar* concatOptions = g_malloc0(64);
2219-
if(self->priv->geometry==NULL){
2220-
g_snprintf(concatOptions, 64, "%d=NULL=%d", browser_window, open_in_tabs);
2221-
}else{
2222-
g_snprintf(concatOptions, 64, "%d=%s=%d", browser_window, self->priv->geometry, open_in_tabs);
2220+
if (self->priv->geometry == NULL) {
2221+
g_snprintf (concatOptions, 64, "%d=NULL=%d", browser_window, open_in_tabs);
2222+
} else {
2223+
g_snprintf (concatOptions, 64, "%d=%s=%d", browser_window, self->priv->geometry, open_in_tabs);
22232224
}
22242225
g_application_open (application, files, len, concatOptions);
2225-
g_free(concatOptions);
2226+
g_free (concatOptions);
22262227
} else {
2227-
g_print("non\n");
22282228
if (len > 0) {
22292229
g_application_open (application, files, len, "");
22302230
}
@@ -2238,7 +2238,6 @@ caja_application_local_command_line (GApplication *application,
22382238
out:
22392239
g_option_context_free (context);
22402240

2241-
22422241
return TRUE;
22432242
}
22442243

src/caja-window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void caja_window_disconnect_content_view (CajaWindow *window,
136136

137137
void caja_window_go_to (CajaWindow *window,
138138
GFile *location);
139-
void caja_window_go_to_tab (CajaWindow *window,
139+
void caja_window_go_to_tab (CajaWindow *window,
140140
GFile *location);
141141
void caja_window_go_to_full (CajaWindow *window,
142142
GFile *location,

0 commit comments

Comments
 (0)