File: 0005-Fix-822-The-image-rotation-keys-and-affect-the-wrong.patch

package info (click to toggle)
geeqie 1%3A1.6-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 17,112 kB
  • sloc: ansic: 103,819; xml: 12,121; cpp: 2,087; sh: 1,056; makefile: 601; awk: 160; perl: 140
file content (505 lines) | stat: -rw-r--r-- 14,650 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
From: Colin Clark <colin.clark@cclark.uk>
Date: Fri, 15 Jan 2021 12:43:54 +0000
Subject: Fix #822: The image rotation keys ([ and ]) affect the wrong image

https://github.com/BestImageViewer/geeqie/issues/822

If a call is of the format:
geeqie /<folder1>/*jpg
Geeqie opens folder1 with the listed files selected.

If a call is of the format:
geeqie /<folder1>/*jpg /<folder2>/*jpg
Geeqie opens folder1 and the listed files are displayed in an unnamed
collection.

The hidden command line collection feature of previous versions is
deleted.
---
 src/layout.c                   | 10 +++++
 src/layout.h                   |  1 +
 src/main.c                     | 97 ++++++++++++++++++++++++++++++++++--------
 src/remote.c                   | 86 ++++++++++++++++++++++++++++---------
 src/view_file.h                |  1 +
 src/view_file/view_file.c      |  9 ++++
 src/view_file/view_file_icon.c | 20 +++++++++
 src/view_file/view_file_icon.h |  1 +
 src/view_file/view_file_list.c | 25 +++++++++++
 src/view_file/view_file_list.h |  1 +
 10 files changed, 214 insertions(+), 37 deletions(-)

diff --git a/src/layout.c b/src/layout.c
index 7a0e1b8..0040057 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -1086,6 +1086,16 @@ void layout_select_invert(LayoutWindow *lw)
 	if (lw->vf) vf_select_invert(lw->vf);
 }
 
+void layout_select_list(LayoutWindow *lw, GList *list)
+{
+	if (!layout_valid(&lw)) return;
+
+	if (lw->vf)
+		{
+		vf_select_list(lw->vf, list);
+		}
+}
+
 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode)
 {
 	if (!layout_valid(&lw)) return;
diff --git a/src/layout.h b/src/layout.h
index 78bbfaf..ddb0d89 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -75,6 +75,7 @@ guint layout_selection_count(LayoutWindow *lw, gint64 *bytes);
 void layout_select_all(LayoutWindow *lw);
 void layout_select_none(LayoutWindow *lw);
 void layout_select_invert(LayoutWindow *lw);
+void layout_select_list(LayoutWindow *lw, GList *list);
 
 void layout_mark_to_selection(LayoutWindow *lw, gint mark, MarkToSelectionMode mode);
 void layout_selection_to_mark(LayoutWindow *lw, gint mark, SelectionToMarkMode mode);
diff --git a/src/main.c b/src/main.c
index 4af654f..1356f9a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -138,7 +138,7 @@ static void parse_command_line_add_file(const gchar *file_path, gchar **path, gc
 		{
 		if (!*path) *path = remove_level_from_path(path_parsed);
 		if (!*file) *file = g_strdup(path_parsed);
-		*list = g_list_prepend(*list, file_data_new_no_grouping(path_parsed));
+		*list = g_list_prepend(*list, path_parsed);
 		}
 }
 
@@ -452,7 +452,13 @@ static void parse_command_line(gint argc, gchar *argv[])
 				remote_list = g_list_prepend(remote_list, geometry);
 				}
 			remote_list = g_list_prepend(remote_list, "--new-window");
-		}
+			}
+		else if (!remote_server_exists(app_lock))
+			{
+			/* Geeqie started for first time but with --remote option
+			 */
+			remote_do = FALSE;
+			}
 		g_free(app_lock);
 		}
 
@@ -482,6 +488,8 @@ static void parse_command_line(gint argc, gchar *argv[])
 		remote_list = g_list_prepend(remote_list, pwd);
 
 		remote_control(argv[0], remote_list, command_line->path, list, command_line->collection_list);
+		/* There is no return to this point
+		 */
 		g_free(pwd);
 		g_free(current_dir);
 		}
@@ -494,7 +502,7 @@ static void parse_command_line(gint argc, gchar *argv[])
 		}
 	else
 		{
-		filelist_free(list);
+		string_list_free(list);
 		command_line->cmd_list = NULL;
 		}
 
@@ -900,6 +908,8 @@ gint main(gint argc, gchar *argv[])
 	gchar *buf;
 	CollectionData *cd = NULL;
 	gboolean disable_clutter = FALSE;
+	gboolean single_dir = TRUE;
+	LayoutWindow *lw;
 
 #ifdef HAVE_GTHREAD
 #if !GLIB_CHECK_VERSION(2,32,0)
@@ -1037,6 +1047,9 @@ gint main(gint argc, gchar *argv[])
 
 	layout_editors_reload_start();
 
+	/* If no --list option, open a separate collection window for each
+	 * .gqv file on the command line
+	 */
 	if (command_line->collection_list && !command_line->startup_command_line_collection)
 		{
 		GList *work;
@@ -1064,34 +1077,59 @@ gint main(gint argc, gchar *argv[])
 		command_line->ssi = secure_open(pathl);
 		}
 
-	if (command_line->cmd_list ||
-	    (command_line->startup_command_line_collection && command_line->collection_list))
+	/* If there is a files list on the command line and no --list option,
+	 * check if they are all in the same folder
+	 */
+	if (command_line->cmd_list && !(command_line->startup_command_line_collection))
 		{
 		GList *work;
+		gchar *path = NULL;
 
-		if (command_line->startup_command_line_collection)
-			{
-			CollectWindow *cw;
+		work = command_line->cmd_list;
 
-			cw = collection_window_new("");
-			cd = cw->cd;
-			}
-		else
+		while (work && single_dir)
 			{
-			cd = collection_new("");	/* if we pass NULL, untitled counter is falsely increm. */
+			gchar *dirname;
+
+			dirname = g_path_get_dirname(work->data);
+			if (!path)
+				{
+				path = g_strdup(dirname);
+				}
+			else
+				{
+				if (g_strcmp0(path, dirname) != 0)
+					{
+					single_dir = FALSE;
+					}
+				}
+			g_free(dirname);
+			work = work->next;
 			}
+		g_free(path);
+		}
 
-		g_free(cd->path);
-		cd->path = NULL;
-		g_free(cd->name);
-		cd->name = g_strdup(_("Command line"));
+	/* Files from multiple folders, or --list option given
+	 * then open an unnamed collection and insert all files
+	 */
+	if ((command_line->cmd_list && !single_dir) || (command_line->startup_command_line_collection))
+		{
+		GList *work;
+		CollectWindow *cw;
+
+		cw = collection_window_new(NULL);
+		cd = cw->cd;
 
 		collection_path_changed(cd);
 
 		work = command_line->cmd_list;
 		while (work)
 			{
-			collection_add(cd, (FileData *)work->data, FALSE);
+			FileData *fd;
+
+			fd = file_data_new_simple(work->data);
+			collection_add(cd, fd, FALSE);
+			file_data_unref(fd);
 			work = work->next;
 			}
 
@@ -1119,6 +1157,29 @@ gint main(gint argc, gchar *argv[])
 					    collection_get_first(first_collection));
 		}
 
+	/* If the files on the command line are from one folder, select those files
+	 */
+	lw = NULL;
+	layout_valid(&lw);
+
+	if (single_dir && command_line->cmd_list)
+		{
+		GList *work;
+		GList *selected;
+		FileData *fd;
+
+		selected = NULL;
+		work = command_line->cmd_list;
+		while (work)
+			{
+			fd = file_data_new_simple((gchar *)work->data);
+			selected = g_list_append(selected, fd);
+			file_data_unref(fd);
+			work = work->next;
+			}
+		layout_select_list(lw, selected);
+		}
+
 	buf = g_build_filename(get_rc_dir(), ".command", NULL);
 	remote_connection = remote_server_init(buf, cd);
 	g_free(buf);
diff --git a/src/remote.c b/src/remote.c
index 78634cf..6f44424 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -38,6 +38,7 @@
 #include "slideshow.h"
 #include "ui_fileops.h"
 #include "rcfile.h"
+#include "view_file.h"
 
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -72,6 +73,8 @@ struct _RemoteClient {
 typedef struct _RemoteData RemoteData;
 struct _RemoteData {
 	CollectionData *command_collection;
+	GList *file_list;
+	gboolean single_dir;
 };
 
 /* To enable file names containing newlines to be processed correctly,
@@ -1221,39 +1224,87 @@ static void gr_list_clear(const gchar *text, GIOChannel *channel, gpointer data)
 {
 	RemoteData *remote_data = data;
 
-	if (remote_data->command_collection)
-		{
-		collection_unref(remote_data->command_collection);
-		remote_data->command_collection = NULL;
-		}
+	remote_data->command_collection = NULL;
+	remote_data->file_list = NULL;
+	remote_data->single_dir = TRUE;
 }
 
 static void gr_list_add(const gchar *text, GIOChannel *channel, gpointer data)
 {
 	RemoteData *remote_data = data;
 	gboolean new = TRUE;
+	gchar *path = NULL;
+	FileData *fd;
+	FileData *first;
 
-	if (!remote_data->command_collection)
+	/* If there is a files list on the command line
+	 * check if they are all in the same folder
+	 */
+	if (remote_data->single_dir)
 		{
+		GList *work;
+		work = remote_data->file_list;
+		while (work && remote_data->single_dir)
+			{
+			gchar *dirname;
+			dirname = g_path_get_dirname(((FileData *)work->data)->path);
+			if (!path)
+				{
+				path = g_strdup(dirname);
+				}
+			else
+				{
+				if (g_strcmp0(path, dirname) != 0)
+					{
+					remote_data->single_dir = FALSE;
+					}
+				}
+			g_free(dirname);
+			work = work->next;
+			}
+		g_free(path);
+		}
+
+	gchar *pathname = g_path_get_dirname(text);
+	layout_set_path(lw_id, pathname);
+	g_free(pathname);
+
+	fd = file_data_new_simple(text);
+	remote_data->file_list = g_list_append(remote_data->file_list, fd);
+	file_data_unref(fd);
+
+	vf_select_none(lw_id->vf);
+	remote_data->file_list = g_list_reverse(remote_data->file_list);
+
+	layout_select_list(lw_id, remote_data->file_list);
+	layout_refresh(lw_id);
+	first = (FileData *)(g_list_first(vf_selection_get_list(lw_id->vf))->data);
+	layout_set_fd(lw_id, first);
+
 		CollectionData *cd;
+		CollectWindow *cw;
 
-		cd = collection_new("");
+	if (!remote_data->command_collection && !remote_data->single_dir)
+		{
+		cw = collection_window_new(NULL);
+		cd = cw->cd;
 
-		g_free(cd->path);
-		cd->path = NULL;
-		g_free(cd->name);
-		cd->name = g_strdup(_("Command line"));
+		collection_path_changed(cd);
 
 		remote_data->command_collection = cd;
 		}
-	else
+	else if (!remote_data->single_dir)
 		{
 		new = (!collection_get_first(remote_data->command_collection));
 		}
 
-	if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
+	if (!remote_data->single_dir)
 		{
 		layout_image_set_collection(lw_id, remote_data->command_collection, collection_get_first(remote_data->command_collection));
+		if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new)
+			{
+			layout_image_set_collection(lw_id, remote_data->command_collection, collection_get_first(remote_data->command_collection));
+			}
 		}
 }
 
@@ -1495,7 +1546,7 @@ GList *remote_build_list(GList *list, gint argc, gchar *argv[], GList **errors)
  * \param arg_exec Binary (argv0)
  * \param remote_list Evaluated and recognized remote commands
  * \param path The current path
- * \param cmd_list List of all non collections in Path
+ * \param cmd_list List of all non collections in Path (gchar *path)
  * \param collection_list List of all collections in argv
  */
 void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path,
@@ -1608,15 +1659,12 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
 		work = cmd_list;
 		while (work)
 			{
-			FileData *fd;
 			gchar *text;
 
-			fd = work->data;
-			work = work->next;
-
-			text = g_strconcat(prefix, fd->path, NULL);
+			text = g_strconcat(prefix, work->data, NULL);
 			remote_client_send(rc, text);
 			g_free(text);
+			work = work->next;
 
 			sent = TRUE;
 			}
diff --git a/src/view_file.h b/src/view_file.h
index 6ec34f7..16297da 100644
--- a/src/view_file.h
+++ b/src/view_file.h
@@ -64,6 +64,7 @@ void vf_select_all(ViewFile *vf);
 void vf_select_none(ViewFile *vf);
 void vf_select_invert(ViewFile *vf);
 void vf_select_by_fd(ViewFile *vf, FileData *fd);
+void vf_select_list(ViewFile *vf, GList *list);
 
 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
 void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
diff --git a/src/view_file/view_file.c b/src/view_file/view_file.c
index e07670a..5e6674a 100644
--- a/src/view_file/view_file.c
+++ b/src/view_file/view_file.c
@@ -234,6 +234,15 @@ void vf_select_by_fd(ViewFile *vf, FileData *fd)
 	}
 }
 
+void vf_select_list(ViewFile *vf, GList *list)
+{
+	switch (vf->type)
+	{
+	case FILEVIEW_LIST: vflist_select_list(vf, list); break;
+	case FILEVIEW_ICON: vficon_select_list(vf, list); break;
+	}
+}
+
 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
 {
 	switch (vf->type)
diff --git a/src/view_file/view_file_icon.c b/src/view_file/view_file_icon.c
index 611f987..e1493c8 100644
--- a/src/view_file/view_file_icon.c
+++ b/src/view_file/view_file_icon.c
@@ -922,6 +922,26 @@ void vficon_select_by_fd(ViewFile *vf, FileData *fd)
 	vficon_set_focus(vf, fd);
 }
 
+void vficon_select_list(ViewFile *vf, GList *list)
+{
+	GList *work;
+	FileData *fd;
+
+	if (!list) return;
+
+	work = list;
+	while (work)
+		{
+		fd = work->data;
+		if (g_list_find(vf->list, fd))
+			{
+			VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
+			vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+			}
+		work = work->next;
+		}
+}
+
 void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
 {
 	GList *work;
diff --git a/src/view_file/view_file_icon.h b/src/view_file/view_file_icon.h
index 4f2d6c3..35e5855 100644
--- a/src/view_file/view_file_icon.h
+++ b/src/view_file/view_file_icon.h
@@ -64,6 +64,7 @@ void vficon_select_all(ViewFile *vf);
 void vficon_select_none(ViewFile *vf);
 void vficon_select_invert(ViewFile *vf);
 void vficon_select_by_fd(ViewFile *vf, FileData *fd);
+void vficon_select_list(ViewFile *vf, GList *list);
 
 void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
 void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
diff --git a/src/view_file/view_file_list.c b/src/view_file/view_file_list.c
index 2e2a092..6418b41 100644
--- a/src/view_file/view_file_list.c
+++ b/src/view_file/view_file_list.c
@@ -1673,6 +1673,31 @@ void vflist_select_by_fd(ViewFile *vf, FileData *fd)
 		}
 }
 
+void vflist_select_list(ViewFile *vf, GList *list)
+{
+	GtkTreeIter iter;
+	GList *work;
+
+	work = list;
+
+	while (work)
+		{
+		FileData *fd;
+
+		fd = work->data;
+
+		if (vflist_find_row(vf, fd, &iter) < 0) return;
+		if (!vflist_row_is_selected(vf, fd))
+			{
+			GtkTreeSelection *selection;
+
+			selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
+			gtk_tree_selection_select_iter(selection, &iter);
+			}
+		work = work->next;
+		}
+}
+
 static void vflist_select_closest(ViewFile *vf, FileData *sel_fd)
 {
 	GList *work;
diff --git a/src/view_file/view_file_list.h b/src/view_file/view_file_list.h
index a1df381..3bbf480 100644
--- a/src/view_file/view_file_list.h
+++ b/src/view_file/view_file_list.h
@@ -63,6 +63,7 @@ void vflist_select_all(ViewFile *vf);
 void vflist_select_none(ViewFile *vf);
 void vflist_select_invert(ViewFile *vf);
 void vflist_select_by_fd(ViewFile *vf, FileData *fd);
+void vflist_select_list(ViewFile *vf, GList *list);
 
 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
 void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);