Mercurial > hg > forks > geeqie
annotate src/remote.c @ 2820:a58a176761eb
Bug fix #251: Crop simulation
https://github.com/BestImageViewer/geeqie/issues/251
If draw rectangle is not selected, return null.
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Sat, 18 Aug 2018 11:00:35 +0100 |
parents | 3e9ca298bb1d |
children | ed4e22060177 |
rev | line source |
---|---|
9 | 1 /* |
2350
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
2 * Copyright (C) 2004 John Ellis |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
3 * Copyright (C) 2008 - 2016 The Geeqie Team |
9 | 4 * |
5 * Author: John Ellis | |
6 * | |
2350
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
10 * (at your option) any later version. |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
11 * |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
15 * GNU General Public License for more details. |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
16 * |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
17 * You should have received a copy of the GNU General Public License along |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
18 * with this program; if not, write to the Free Software Foundation, Inc., |
95507e596256
Update copyright in all files
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2290
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
9 | 20 */ |
21 | |
281 | 22 #include "main.h" |
9 | 23 #include "remote.h" |
24 | |
2502
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
25 #include "cache_maint.h" |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
26 #include "collect.h" |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
27 #include "filedata.h" |
2418
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
28 #include "image.h" |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
29 #include "img-view.h" |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
30 #include "layout.h" |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
31 #include "layout_image.h" |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
32 #include "layout_util.h" |
1022
d09059a8b243
Move miscellaneous functions to their own files (new misc.[ch]).
Laurent Monin <geeqie@norz.org>
parents:
1000
diff
changeset
|
33 #include "misc.h" |
2731
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
34 #include "pixbuf-renderer.h" |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
35 #include "slideshow.h" |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
36 #include "ui_fileops.h" |
1467
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
37 #include "rcfile.h" |
9 | 38 |
39 #include <sys/socket.h> | |
40 #include <sys/un.h> | |
41 #include <signal.h> | |
42 #include <errno.h> | |
43 | |
2639
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
44 #include "glua.h" |
9 | 45 |
46 #define SERVER_MAX_CLIENTS 8 | |
47 | |
48 #define REMOTE_SERVER_BACKLOG 4 | |
49 | |
50 | |
51 #ifndef UNIX_PATH_MAX | |
52 #define UNIX_PATH_MAX 108 | |
53 #endif | |
54 | |
55 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
56 static RemoteConnection *remote_client_open(const gchar *path); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
57 static gint remote_client_send(RemoteConnection *rc, const gchar *text); |
2464
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
58 static void gr_raise(const gchar *text, GIOChannel *channel, gpointer data); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
59 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
60 static LayoutWindow *lw_id = NULL; /* points to the window set by the --id option */ |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
61 |
9 | 62 typedef struct _RemoteClient RemoteClient; |
63 struct _RemoteClient { | |
64 gint fd; | |
1523
e52aabe8fc7a
Fix up event source ids type: gint -> guint.
Laurent Monin <geeqie@norz.org>
parents:
1484
diff
changeset
|
65 guint channel_id; /* event source id */ |
9 | 66 RemoteConnection *rc; |
67 }; | |
68 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
69 typedef struct _RemoteData RemoteData; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
70 struct _RemoteData { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
71 CollectionData *command_collection; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
72 }; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
73 |
9 | 74 |
75 static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition condition, gpointer data) | |
76 { | |
77 RemoteClient *client = data; | |
78 RemoteConnection *rc; | |
1299
584b947dc5ed
hopefully fixed a freeze on solaris
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1291
diff
changeset
|
79 GIOStatus status = G_IO_STATUS_NORMAL; |
9 | 80 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
81 lw_id = NULL; |
9 | 82 rc = client->rc; |
83 | |
84 if (condition & G_IO_IN) | |
85 { | |
86 gchar *buffer = NULL; | |
87 GError *error = NULL; | |
1300
762f043c4ba2
fixed compiler warning
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1299
diff
changeset
|
88 gsize termpos; |
9 | 89 |
1299
584b947dc5ed
hopefully fixed a freeze on solaris
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1291
diff
changeset
|
90 while ((status = g_io_channel_read_line(source, &buffer, NULL, &termpos, &error)) == G_IO_STATUS_NORMAL) |
9 | 91 { |
92 if (buffer) | |
93 { | |
94 buffer[termpos] = '\0'; | |
95 | |
96 if (strlen(buffer) > 0) | |
97 { | |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
98 if (rc->read_func) rc->read_func(rc, buffer, source, rc->read_data); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
99 g_io_channel_write_chars(source, "\n", -1, NULL, NULL); /* empty line finishes the command */ |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
100 g_io_channel_flush(source, NULL); |
9 | 101 } |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
102 g_free(buffer); |
9 | 103 |
104 buffer = NULL; | |
105 } | |
106 } | |
107 | |
108 if (error) | |
109 { | |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
110 log_printf("error reading socket: %s\n", error->message); |
9 | 111 g_error_free(error); |
112 } | |
113 } | |
114 | |
1299
584b947dc5ed
hopefully fixed a freeze on solaris
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1291
diff
changeset
|
115 if (condition & G_IO_HUP || status == G_IO_STATUS_EOF || status == G_IO_STATUS_ERROR) |
9 | 116 { |
117 rc->clients = g_list_remove(rc->clients, client); | |
118 | |
506
03d66738b225
Handle the newline in DEBUG_N() macro instead of adding one
Laurent Monin <geeqie@norz.org>
parents:
495
diff
changeset
|
119 DEBUG_1("HUP detected, closing client."); |
03d66738b225
Handle the newline in DEBUG_N() macro instead of adding one
Laurent Monin <geeqie@norz.org>
parents:
495
diff
changeset
|
120 DEBUG_1("client count %d", g_list_length(rc->clients)); |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
121 |
9 | 122 g_source_remove(client->channel_id); |
123 close(client->fd); | |
124 g_free(client); | |
125 } | |
126 | |
127 return TRUE; | |
128 } | |
129 | |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
130 static void remote_server_client_add(RemoteConnection *rc, gint fd) |
9 | 131 { |
132 RemoteClient *client; | |
133 GIOChannel *channel; | |
134 | |
135 if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS) | |
136 { | |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
137 log_printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS); |
9 | 138 close(fd); |
139 return; | |
140 } | |
141 | |
142 client = g_new0(RemoteClient, 1); | |
143 client->rc = rc; | |
144 client->fd = fd; | |
145 | |
146 channel = g_io_channel_unix_new(fd); | |
147 client->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP, | |
148 remote_server_client_cb, client, NULL); | |
149 g_io_channel_unref(channel); | |
150 | |
151 rc->clients = g_list_append(rc->clients, client); | |
506
03d66738b225
Handle the newline in DEBUG_N() macro instead of adding one
Laurent Monin <geeqie@norz.org>
parents:
495
diff
changeset
|
152 DEBUG_1("client count %d", g_list_length(rc->clients)); |
9 | 153 } |
154 | |
155 static void remote_server_clients_close(RemoteConnection *rc) | |
156 { | |
157 while (rc->clients) | |
158 { | |
159 RemoteClient *client = rc->clients->data; | |
160 | |
161 rc->clients = g_list_remove(rc->clients, client); | |
162 | |
163 g_source_remove(client->channel_id); | |
164 close(client->fd); | |
165 g_free(client); | |
166 } | |
167 } | |
168 | |
169 static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition, gpointer data) | |
170 { | |
171 RemoteConnection *rc = data; | |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
172 gint fd; |
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
173 guint alen; |
9 | 174 |
175 fd = accept(rc->fd, NULL, &alen); | |
176 if (fd == -1) | |
177 { | |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
178 log_printf("error accepting socket: %s\n", strerror(errno)); |
9 | 179 return TRUE; |
180 } | |
181 | |
182 remote_server_client_add(rc, fd); | |
183 | |
184 return TRUE; | |
185 } | |
186 | |
2738
c6e5a43c87e5
Fix #162: Cannot symlink file if two geeqie instances are running
Colin Clark <colin.clark@cclark.uk>
parents:
2731
diff
changeset
|
187 gboolean remote_server_exists(const gchar *path) |
9 | 188 { |
189 RemoteConnection *rc; | |
190 | |
191 /* verify server up */ | |
192 rc = remote_client_open(path); | |
193 remote_close(rc); | |
194 | |
195 if (rc) return TRUE; | |
196 | |
197 /* unable to connect, remove socket file to free up address */ | |
198 unlink(path); | |
199 return FALSE; | |
200 } | |
201 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
202 static RemoteConnection *remote_server_open(const gchar *path) |
9 | 203 { |
204 RemoteConnection *rc; | |
205 struct sockaddr_un addr; | |
206 gint sun_path_len; | |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
207 gint fd; |
9 | 208 GIOChannel *channel; |
209 | |
210 if (remote_server_exists(path)) | |
211 { | |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
212 log_printf("Address already in use: %s\n", path); |
9 | 213 return NULL; |
214 } | |
215 | |
216 fd = socket(PF_UNIX, SOCK_STREAM, 0); | |
217 if (fd == -1) return NULL; | |
218 | |
219 addr.sun_family = AF_UNIX; | |
220 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); | |
221 strncpy(addr.sun_path, path, sun_path_len); | |
222 if (bind(fd, &addr, sizeof(addr)) == -1 || | |
223 listen(fd, REMOTE_SERVER_BACKLOG) == -1) | |
224 { | |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
225 log_printf("error subscribing to socket: %s\n", strerror(errno)); |
9 | 226 close(fd); |
227 return NULL; | |
228 } | |
229 | |
230 rc = g_new0(RemoteConnection, 1); | |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
231 |
9 | 232 rc->server = TRUE; |
233 rc->fd = fd; | |
234 rc->path = g_strdup(path); | |
235 | |
236 channel = g_io_channel_unix_new(rc->fd); | |
2184 | 237 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL); |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
238 |
9 | 239 rc->channel_id = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, G_IO_IN, |
240 remote_server_read_cb, rc, NULL); | |
241 g_io_channel_unref(channel); | |
242 | |
243 return rc; | |
244 } | |
245 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
246 static void remote_server_subscribe(RemoteConnection *rc, RemoteReadFunc *func, gpointer data) |
9 | 247 { |
248 if (!rc || !rc->server) return; | |
249 | |
250 rc->read_func = func; | |
251 rc->read_data = data; | |
252 } | |
253 | |
254 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
255 static RemoteConnection *remote_client_open(const gchar *path) |
9 | 256 { |
257 RemoteConnection *rc; | |
258 struct stat st; | |
259 struct sockaddr_un addr; | |
260 gint sun_path_len; | |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
261 gint fd; |
9 | 262 |
263 if (stat(path, &st) != 0 || !S_ISSOCK(st.st_mode)) return NULL; | |
264 | |
265 fd = socket(PF_UNIX, SOCK_STREAM, 0); | |
266 if (fd == -1) return NULL; | |
267 | |
268 addr.sun_family = AF_UNIX; | |
269 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); | |
270 strncpy(addr.sun_path, path, sun_path_len); | |
271 if (connect(fd, &addr, sizeof(addr)) == -1) | |
442 | 272 { |
506
03d66738b225
Handle the newline in DEBUG_N() macro instead of adding one
Laurent Monin <geeqie@norz.org>
parents:
495
diff
changeset
|
273 DEBUG_1("error connecting to socket: %s", strerror(errno)); |
442 | 274 close(fd); |
275 return NULL; | |
276 } | |
9 | 277 |
278 rc = g_new0(RemoteConnection, 1); | |
279 rc->server = FALSE; | |
280 rc->fd = fd; | |
281 rc->path = g_strdup(path); | |
282 | |
283 return rc; | |
284 } | |
285 | |
2714
e0251a8eba95
Merge remote-tracking branches 'github/merge-requests/581', 'github/merge-requests/576', 'github/merge-requests/574' and 'github/merge-requests/573'
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2712
diff
changeset
|
286 static sig_atomic_t sigpipe_occurred = FALSE; |
9 | 287 |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
288 static void sighandler_sigpipe(gint sig) |
9 | 289 { |
2714
e0251a8eba95
Merge remote-tracking branches 'github/merge-requests/581', 'github/merge-requests/576', 'github/merge-requests/574' and 'github/merge-requests/573'
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2712
diff
changeset
|
290 sigpipe_occurred = TRUE; |
9 | 291 } |
292 | |
1444 | 293 static gboolean remote_client_send(RemoteConnection *rc, const gchar *text) |
9 | 294 { |
295 struct sigaction new_action, old_action; | |
1437 | 296 gboolean ret = FALSE; |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
297 GError *error = NULL; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
298 GIOChannel *channel; |
9 | 299 |
300 if (!rc || rc->server) return FALSE; | |
301 if (!text) return TRUE; | |
302 | |
2714
e0251a8eba95
Merge remote-tracking branches 'github/merge-requests/581', 'github/merge-requests/576', 'github/merge-requests/574' and 'github/merge-requests/573'
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2712
diff
changeset
|
303 sigpipe_occurred = FALSE; |
9 | 304 |
305 new_action.sa_handler = sighandler_sigpipe; | |
512
0896f486ec6f
Remove whitespace between function name and first parenthesis for the sake of consistency.
Laurent Monin <geeqie@norz.org>
parents:
507
diff
changeset
|
306 sigemptyset(&new_action.sa_mask); |
9 | 307 new_action.sa_flags = 0; |
308 | |
309 /* setup our signal handler */ | |
512
0896f486ec6f
Remove whitespace between function name and first parenthesis for the sake of consistency.
Laurent Monin <geeqie@norz.org>
parents:
507
diff
changeset
|
310 sigaction(SIGPIPE, &new_action, &old_action); |
9 | 311 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
312 channel = g_io_channel_unix_new(rc->fd); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
313 |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
314 g_io_channel_write_chars(channel, text, -1, NULL, &error); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
315 g_io_channel_write_chars(channel, "\n", -1, NULL, &error); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
316 g_io_channel_flush(channel, &error); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
317 |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
318 if (error) |
9 | 319 { |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
320 log_printf("error reading socket: %s\n", error->message); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
321 g_error_free(error); |
9 | 322 ret = FALSE;; |
323 } | |
324 else | |
325 { | |
326 ret = TRUE; | |
327 } | |
328 | |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
329 if (ret) |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
330 { |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
331 gchar *buffer = NULL; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
332 gsize termpos; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
333 while (g_io_channel_read_line(channel, &buffer, NULL, &termpos, &error) == G_IO_STATUS_NORMAL) |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
334 { |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
335 if (buffer) |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
336 { |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
337 if (buffer[0] == '\n') /* empty line finishes the command */ |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
338 { |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
339 g_free(buffer); |
1556
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
340 fflush(stdout); |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
341 break; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
342 } |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
343 buffer[termpos] = '\0'; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
344 printf("%s\n", buffer); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
345 g_free(buffer); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
346 buffer = NULL; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
347 } |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
348 } |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
349 |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
350 if (error) |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
351 { |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
352 log_printf("error reading socket: %s\n", error->message); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
353 g_error_free(error); |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
354 ret = FALSE; |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
355 } |
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
356 } |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
357 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
358 |
9 | 359 /* restore the original signal handler */ |
512
0896f486ec6f
Remove whitespace between function name and first parenthesis for the sake of consistency.
Laurent Monin <geeqie@norz.org>
parents:
507
diff
changeset
|
360 sigaction(SIGPIPE, &old_action, NULL); |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
361 g_io_channel_unref(channel); |
9 | 362 return ret; |
363 } | |
364 | |
365 void remote_close(RemoteConnection *rc) | |
366 { | |
367 if (!rc) return; | |
368 | |
369 if (rc->server) | |
370 { | |
371 remote_server_clients_close(rc); | |
372 | |
373 g_source_remove(rc->channel_id); | |
374 unlink(rc->path); | |
375 } | |
376 | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
377 if (rc->read_data) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
378 g_free(rc->read_data); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
379 |
9 | 380 close(rc->fd); |
381 | |
382 g_free(rc->path); | |
383 g_free(rc); | |
384 } | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
385 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
386 /* |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
387 *----------------------------------------------------------------------------- |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
388 * remote functions |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
389 *----------------------------------------------------------------------------- |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
390 */ |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
391 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
392 static void gr_image_next(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
393 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
394 layout_image_next(lw_id); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
395 } |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
396 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
397 static void gr_new_window(const gchar *text, GIOChannel *channel, gpointer data) |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
398 { |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
399 LayoutWindow *lw = NULL; |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
400 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
401 if (!layout_valid(&lw)) return; |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
402 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
403 lw_id = layout_menu_new_window(NULL, lw); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
404 } |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
405 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
406 static gboolean gr_close_window_cb() |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
407 { |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
408 if (!layout_valid(&lw_id)) return FALSE; |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
409 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
410 layout_menu_close_cb(NULL, lw_id); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
411 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
412 return FALSE; |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
413 } |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
414 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
415 static void gr_close_window(const gchar *text, GIOChannel *channel, gpointer data) |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
416 { |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
417 g_idle_add(gr_close_window_cb, NULL); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
418 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
419 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
420 static void gr_image_prev(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
421 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
422 layout_image_prev(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
423 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
424 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
425 static void gr_image_first(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
426 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
427 layout_image_first(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
428 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
429 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
430 static void gr_image_last(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
431 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
432 layout_image_last(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
433 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
434 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
435 static void gr_fullscreen_toggle(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
436 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
437 layout_image_full_screen_toggle(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
438 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
439 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
440 static void gr_fullscreen_start(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
441 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
442 layout_image_full_screen_start(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
443 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
444 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
445 static void gr_fullscreen_stop(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
446 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
447 layout_image_full_screen_stop(lw_id); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
448 } |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
449 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
450 static void gr_lw_id(const gchar *text, GIOChannel *channel, gpointer data) |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
451 { |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
452 lw_id = layout_find_by_layout_id(text); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
453 if (!lw_id) |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
454 { |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
455 log_printf("remote sent window ID that does not exist:\"%s\"\n",text); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
456 } |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
457 layout_valid(&lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
458 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
459 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
460 static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
461 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
462 GList *list; |
1927
d1a5b8633919
always check for sidecars by readdir
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1868
diff
changeset
|
463 FileData *dir_fd = file_data_new_dir(text); |
783
0e45ed008a1c
replaced directory path with FileData* dir_fd
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
781
diff
changeset
|
464 list = filelist_recursive(dir_fd); |
0e45ed008a1c
replaced directory path with FileData* dir_fd
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
781
diff
changeset
|
465 file_data_unref(dir_fd); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
466 if (!list) return; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
467 //printf("length: %d\n", g_list_length(list)); |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
468 layout_image_slideshow_stop(lw_id); |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
469 layout_image_slideshow_start_from_list(lw_id, list); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
470 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
471 |
2502
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
472 static void gr_cache_thumb(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
473 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
474 if (!g_strcmp0(text, "clear")) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
475 cache_maintain_home_remote(FALSE, TRUE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
476 else if (!g_strcmp0(text, "clean")) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
477 cache_maintain_home_remote(FALSE, FALSE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
478 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
479 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
480 static void gr_cache_shared(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
481 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
482 if (!g_strcmp0(text, "clear")) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
483 cache_manager_standard_process_remote(TRUE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
484 else if (!g_strcmp0(text, "clean")) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
485 cache_manager_standard_process_remote(FALSE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
486 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
487 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
488 static void gr_cache_metadata(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
489 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
490 cache_maintain_home_remote(TRUE, FALSE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
491 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
492 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
493 static void gr_cache_render(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
494 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
495 cache_manager_render_remote(text, FALSE, FALSE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
496 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
497 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
498 static void gr_cache_render_recurse(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
499 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
500 cache_manager_render_remote(text, TRUE, FALSE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
501 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
502 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
503 static void gr_cache_render_standard(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
504 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
505 if(options->thumbnails.spec_standard) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
506 cache_manager_render_remote(text, FALSE, TRUE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
507 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
508 |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
509 static void gr_cache_render_standard_recurse(const gchar *text, GIOChannel *channel, gpointer data) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
510 { |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
511 if(options->thumbnails.spec_standard) |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
512 cache_manager_render_remote(text, TRUE, TRUE); |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
513 } |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
514 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
515 static void gr_slideshow_toggle(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
516 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
517 layout_image_slideshow_toggle(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
518 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
519 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
520 static void gr_slideshow_start(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
521 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
522 layout_image_slideshow_start(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
523 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
524 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
525 static void gr_slideshow_stop(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
526 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
527 layout_image_slideshow_stop(lw_id); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
528 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
529 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
530 static void gr_slideshow_delay(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
531 { |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
532 gdouble t1, t2, t3, n; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
533 gint res; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
534 |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
535 res = sscanf(text, "%lf:%lf:%lf", &t1, &t2, &t3); |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
536 if (res == 3) |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
537 { |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
538 n = (t1 * 3600) + (t2 * 60) + t3; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
539 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS || |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
540 t1 >= 24 || t2 >= 60 || t3 >= 60) |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
541 { |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
542 printf_term(TRUE, "Remote slideshow delay out of range (%.1f to %.1f)\n", |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
543 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
544 return; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
545 } |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
546 } |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
547 else if (res == 2) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
548 { |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
549 n = t1 * 60 + t2; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
550 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS || |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
551 t1 >= 60 || t2 >= 60) |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
552 { |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
553 printf_term(TRUE, "Remote slideshow delay out of range (%.1f to %.1f)\n", |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
554 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
555 return; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
556 } |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
557 } |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
558 else if (res == 1) |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
559 { |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
560 n = t1; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
561 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS) |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
562 { |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
563 printf_term(TRUE, "Remote slideshow delay out of range (%.1f to %.1f)\n", |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
564 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
565 return; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
566 } |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
567 } |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
568 else |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
569 { |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
570 n = 0; |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
571 } |
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
572 |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
573 options->slideshow.delay = (gint)(n * 10.0 + 0.01); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
574 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
575 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
576 static void gr_tools_show(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
577 { |
1416
3ba63f325b08
Use gboolean pseudo type where applicable.
Laurent Monin <geeqie@norz.org>
parents:
1367
diff
changeset
|
578 gboolean popped; |
3ba63f325b08
Use gboolean pseudo type where applicable.
Laurent Monin <geeqie@norz.org>
parents:
1367
diff
changeset
|
579 gboolean hidden; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
580 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
581 if (layout_tools_float_get(lw_id, &popped, &hidden) && hidden) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
582 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
583 layout_tools_float_set(lw_id, popped, FALSE); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
584 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
585 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
586 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
587 static void gr_tools_hide(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
588 { |
1416
3ba63f325b08
Use gboolean pseudo type where applicable.
Laurent Monin <geeqie@norz.org>
parents:
1367
diff
changeset
|
589 gboolean popped; |
3ba63f325b08
Use gboolean pseudo type where applicable.
Laurent Monin <geeqie@norz.org>
parents:
1367
diff
changeset
|
590 gboolean hidden; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
591 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
592 if (layout_tools_float_get(lw_id, &popped, &hidden) && !hidden) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
593 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
594 layout_tools_float_set(lw_id, popped, TRUE); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
595 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
596 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
597 |
1444 | 598 static gboolean gr_quit_idle_cb(gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
599 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
600 exit_program(); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
601 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
602 return FALSE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
603 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
604 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
605 static void gr_quit(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
606 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
607 /* schedule exit when idle, if done from within a |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
608 * remote handler remote_close will crash |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
609 */ |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
610 g_idle_add(gr_quit_idle_cb, NULL); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
611 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
612 |
2464
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
613 static void gr_file_load_no_raise(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
614 { |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
615 gchar *filename = expand_tilde(text); |
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
616 |
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
617 if (isfile(filename)) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
618 { |
781
a47bf5b8a85b
Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
Laurent Monin <geeqie@norz.org>
parents:
713
diff
changeset
|
619 if (file_extension_match(filename, GQ_COLLECTION_EXT)) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
620 { |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
621 collection_window_new(filename); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
622 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
623 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
624 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
625 layout_set_path(lw_id, filename); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
626 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
627 } |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
628 else if (isdir(filename)) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
629 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
630 layout_set_path(lw_id, filename); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
631 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
632 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
633 { |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
634 log_printf("remote sent filename that does not exist:\"%s\"\n", filename); |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
635 layout_set_path(lw_id, homedir()); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
636 } |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
637 |
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
638 g_free(filename); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
639 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
640 |
2464
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
641 static void gr_file_load(const gchar *text, GIOChannel *channel, gpointer data) |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
642 { |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
643 gr_file_load_no_raise(text, channel, data); |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
644 |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
645 gr_raise(text, channel, data); |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
646 } |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
647 |
2731
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
648 static void gr_pixel_info(const gchar *text, GIOChannel *channel, gpointer data) |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
649 { |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
650 gchar *pixel_info; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
651 gint x_pixel, y_pixel; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
652 gint width, height; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
653 gint r_mouse, g_mouse, b_mouse; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
654 PixbufRenderer *pr; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
655 LayoutWindow *lw = NULL; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
656 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
657 if (!layout_valid(&lw_id)) return; |
2731
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
658 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
659 pr = (PixbufRenderer*)lw_id->image->pr; |
2731
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
660 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
661 if (pr) |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
662 { |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
663 pixbuf_renderer_get_image_size(pr, &width, &height); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
664 if (width < 1 || height < 1) return; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
665 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
666 pixbuf_renderer_get_mouse_position(pr, &x_pixel, &y_pixel); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
667 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
668 if (x_pixel >= 0 && y_pixel >= 0) |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
669 { |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
670 pixbuf_renderer_get_pixel_colors(pr, x_pixel, y_pixel, |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
671 &r_mouse, &g_mouse, &b_mouse); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
672 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
673 pixel_info = g_strdup_printf(_("[%d,%d]: RGB(%3d,%3d,%3d)"), |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
674 x_pixel, y_pixel, |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
675 r_mouse, g_mouse, b_mouse); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
676 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
677 g_io_channel_write_chars(channel, pixel_info, -1, NULL, NULL); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
678 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
679 |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
680 g_free(pixel_info); |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
681 } |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
682 else |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
683 { |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
684 return; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
685 } |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
686 } |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
687 else |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
688 { |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
689 return; |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
690 } |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
691 } |
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
692 |
2801
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
693 static void gr_rectangle(const gchar *text, GIOChannel *channel, gpointer data) |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
694 { |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
695 gchar *rectangle_info; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
696 PixbufRenderer *pr; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
697 LayoutWindow *lw = NULL; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
698 gint x1, y1, x2, y2; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
699 |
2820
a58a176761eb
Bug fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2801
diff
changeset
|
700 if (!options->draw_rectangle) return; |
2801
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
701 if (!layout_valid(&lw_id)) return; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
702 |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
703 pr = (PixbufRenderer*)lw_id->image->pr; |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
704 |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
705 if (pr) |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
706 { |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
707 image_get_rectangle(&x1, &y1, &x2, &y2); |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
708 rectangle_info = g_strdup_printf(_("%dx%d+%d+%d"), |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
709 (x2 > x1) ? x2 - x1 : x1 - x2, |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
710 (y2 > y1) ? y2 - y1 : y1 - y2, |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
711 (x2 > x1) ? x1 : x2, |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
712 (y2 > y1) ? y1 : y2); |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
713 |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
714 g_io_channel_write_chars(channel, rectangle_info, -1, NULL, NULL); |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
715 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
716 |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
717 g_free(rectangle_info); |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
718 } |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
719 } |
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
720 |
2418
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
721 static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data) |
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
722 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
723 if (!layout_valid(&lw_id)) return; |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
724 |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
725 if (image_get_path(lw_id->image)) |
2465
58073aea8bc0
Bug fix: Remote --tell output
Colin Clark <cclark@mcb.net>
parents:
2464
diff
changeset
|
726 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
727 g_io_channel_write_chars(channel, image_get_path(lw_id->image), -1, NULL, NULL); |
2465
58073aea8bc0
Bug fix: Remote --tell output
Colin Clark <cclark@mcb.net>
parents:
2464
diff
changeset
|
728 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
58073aea8bc0
Bug fix: Remote --tell output
Colin Clark <cclark@mcb.net>
parents:
2464
diff
changeset
|
729 } |
2418
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
730 } |
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
731 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
732 static void gr_config_load(const gchar *text, GIOChannel *channel, gpointer data) |
1467
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
733 { |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
734 gchar *filename = expand_tilde(text); |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
735 |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
736 if (isfile(filename)) |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
737 { |
1484
f3b033a71fc9
improved sidebar configuration
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1475
diff
changeset
|
738 load_config_from_file(filename, FALSE); |
1467
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
739 } |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
740 else |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
741 { |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
742 log_printf("remote sent filename that does not exist:\"%s\"\n", filename); |
2384
82d8d3deae03
Bug Fix #426: geeqie -r file:FILE crashes if FILE does not exist
Colin Clark <cclark@mcb.net>
parents:
2350
diff
changeset
|
743 layout_set_path(NULL, homedir()); |
1467
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
744 } |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
745 |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
746 g_free(filename); |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
747 } |
bbb656b9b78e
added "load config" command to remote control
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1444
diff
changeset
|
748 |
1556
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
749 static void gr_get_sidecars(const gchar *text, GIOChannel *channel, gpointer data) |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
750 { |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
751 gchar *filename = expand_tilde(text); |
1936
ed6aa14b66c9
rename file_data_new_simple to file_data_new_group, filedata.c cleanup
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1927
diff
changeset
|
752 FileData *fd = file_data_new_group(filename); |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
753 |
1556
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
754 GList *work; |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
755 if (fd->parent) fd = fd->parent; |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
756 |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
757 g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
758 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
759 |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
760 work = fd->sidecar_files; |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
761 |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
762 while (work) |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
763 { |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
764 fd = work->data; |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
765 work = work->next; |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
766 g_io_channel_write_chars(channel, fd->path, -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
767 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
768 } |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
769 g_free(filename); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
770 } |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
771 |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
772 static void gr_get_destination(const gchar *text, GIOChannel *channel, gpointer data) |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
773 { |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
774 gchar *filename = expand_tilde(text); |
1936
ed6aa14b66c9
rename file_data_new_simple to file_data_new_group, filedata.c cleanup
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1927
diff
changeset
|
775 FileData *fd = file_data_new_group(filename); |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
776 |
1556
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
777 if (fd->change && fd->change->dest) |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
778 { |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
779 g_io_channel_write_chars(channel, fd->change->dest, -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
780 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
781 } |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
782 g_free(filename); |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
783 } |
62084cfe78f1
added remote interface for exporting additional info (sidecars,
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1554
diff
changeset
|
784 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
785 static void gr_file_view(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
786 { |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
787 gchar *filename = expand_tilde(text); |
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
788 |
1936
ed6aa14b66c9
rename file_data_new_simple to file_data_new_group, filedata.c cleanup
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1927
diff
changeset
|
789 view_window_new(file_data_new_group(filename)); |
653
602bec267255
Expand tilde with file: and view: remote parameters.
Laurent Monin <geeqie@norz.org>
parents:
652
diff
changeset
|
790 g_free(filename); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
791 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
792 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
793 static void gr_list_clear(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
794 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
795 RemoteData *remote_data = data; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
796 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
797 if (remote_data->command_collection) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
798 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
799 collection_unref(remote_data->command_collection); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
800 remote_data->command_collection = NULL; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
801 } |
995 | 802 } |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
803 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
804 static void gr_list_add(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
805 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
806 RemoteData *remote_data = data; |
1437 | 807 gboolean new = TRUE; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
808 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
809 if (!remote_data->command_collection) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
810 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
811 CollectionData *cd; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
812 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
813 cd = collection_new(""); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
814 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
815 g_free(cd->path); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
816 cd->path = NULL; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
817 g_free(cd->name); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
818 cd->name = g_strdup(_("Command line")); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
819 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
820 remote_data->command_collection = cd; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
821 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
822 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
823 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
824 new = (!collection_get_first(remote_data->command_collection)); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
825 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
826 |
1936
ed6aa14b66c9
rename file_data_new_simple to file_data_new_group, filedata.c cleanup
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1927
diff
changeset
|
827 if (collection_add(remote_data->command_collection, file_data_new_group(text), FALSE) && new) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
828 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
829 layout_image_set_collection(NULL, remote_data->command_collection, |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
830 collection_get_first(remote_data->command_collection)); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
831 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
832 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
833 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
834 static void gr_raise(const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
835 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
836 LayoutWindow *lw = NULL; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
837 |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
838 if (layout_valid(&lw_id)) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
839 { |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
840 gtk_window_present(GTK_WINDOW(lw_id->window)); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
841 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
842 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
843 |
2647
9f1adad6c2cf
Addl fix 269: Image marks "save" feature
Colin Clark <colin.clark@cclark.uk>
parents:
2639
diff
changeset
|
844 #ifdef HAVE_LUA |
2639
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
845 static void gr_lua(const gchar *text, GIOChannel *channel, gpointer data) |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
846 { |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
847 gchar *result = NULL; |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
848 gchar **lua_command; |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
849 |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
850 lua_command = g_strsplit(text, ",", 2); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
851 |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
852 if (lua_command[0] && lua_command[1]) |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
853 { |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
854 FileData *fd = file_data_new_group(lua_command[0]); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
855 result = g_strdup(lua_callvalue(fd, lua_command[1], NULL)); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
856 if (result) |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
857 { |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
858 g_io_channel_write_chars(channel, result, -1, NULL, NULL); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
859 } |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
860 else |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
861 { |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
862 g_io_channel_write_chars(channel, N_("lua error: no data"), -1, NULL, NULL); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
863 } |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
864 } |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
865 else |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
866 { |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
867 g_io_channel_write_chars(channel, N_("lua error: no data"), -1, NULL, NULL); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
868 } |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
869 |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
870 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
871 |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
872 g_strfreev(lua_command); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
873 g_free(result); |
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
874 } |
2647
9f1adad6c2cf
Addl fix 269: Image marks "save" feature
Colin Clark <colin.clark@cclark.uk>
parents:
2639
diff
changeset
|
875 #endif |
2639
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
876 |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
877 typedef struct _RemoteCommandEntry RemoteCommandEntry; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
878 struct _RemoteCommandEntry { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
879 gchar *opt_s; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
880 gchar *opt_l; |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
881 void (*func)(const gchar *text, GIOChannel *channel, gpointer data); |
1444 | 882 gboolean needs_extra; |
883 gboolean prefer_command_line; | |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
884 gchar *parameter; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
885 gchar *description; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
886 }; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
887 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
888 static RemoteCommandEntry remote_commands[] = { |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
889 /* short, long callback, extra, prefer, parameter, description */ |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
890 { "-n", "--next", gr_image_next, FALSE, FALSE, NULL, N_("next image") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
891 { "-b", "--back", gr_image_prev, FALSE, FALSE, NULL, N_("previous image") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
892 { NULL, "--first", gr_image_first, FALSE, FALSE, NULL, N_("first image") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
893 { NULL, "--last", gr_image_last, FALSE, FALSE, NULL, N_("last image") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
894 { "-f", "--fullscreen", gr_fullscreen_toggle, FALSE, TRUE, NULL, N_("toggle full screen") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
895 { "-fs","--fullscreen-start", gr_fullscreen_start, FALSE, FALSE, NULL, N_("start full screen") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
896 { "-fS","--fullscreen-stop", gr_fullscreen_stop, FALSE, FALSE, NULL, N_("stop full screen") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
897 { "-s", "--slideshow", gr_slideshow_toggle, FALSE, TRUE, NULL, N_("toggle slide show") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
898 { "-ss","--slideshow-start", gr_slideshow_start, FALSE, FALSE, NULL, N_("start slide show") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
899 { "-sS","--slideshow-stop", gr_slideshow_stop, FALSE, FALSE, NULL, N_("stop slide show") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
900 { NULL, "--slideshow-recurse:", gr_slideshow_start_rec, TRUE, FALSE, N_("<FOLDER>"), N_("start recursive slide show in FOLDER") }, |
2657
cc61621468a9
Slideshow --remote delay in hrs-mins-secs
Colin Clark <colin.clark@cclark.uk>
parents:
2647
diff
changeset
|
901 { "-d", "--delay=", gr_slideshow_delay, TRUE, FALSE, N_("<[H:][M:][N][.M]>"), N_("set slide show delay to Hrs Mins N.M seconds") }, |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
902 { "+t", "--tools-show", gr_tools_show, FALSE, TRUE, NULL, N_("show tools") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
903 { "-t", "--tools-hide", gr_tools_hide, FALSE, TRUE, NULL, N_("hide tools") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
904 { "-q", "--quit", gr_quit, FALSE, FALSE, NULL, N_("quit") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
905 { NULL, "--config-load:", gr_config_load, TRUE, FALSE, N_("<FILE>"), N_("load configuration from FILE") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
906 { NULL, "--get-sidecars:", gr_get_sidecars, TRUE, FALSE, N_("<FILE>"), N_("get list of sidecars of FILE") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
907 { NULL, "--get-destination:", gr_get_destination, TRUE, FALSE, N_("<FILE>"), N_("get destination path of FILE") }, |
2464
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
908 { NULL, "file:", gr_file_load, TRUE, FALSE, N_("<FILE>"), N_("open FILE, bring Geeqie window to the top") }, |
a235aad08c32
Fix #201: Geeqie to pop to top of current windows when open up with -r
Colin Clark <cclark@mcb.net>
parents:
2418
diff
changeset
|
909 { NULL, "File:", gr_file_load_no_raise, TRUE, FALSE, N_("<FILE>"), N_("open FILE, do not bring Geeqie window to the top") }, |
2418
8ff8a1df17c9
Command line option to print current filename
Colin Clark <cclark@mcb.net>
parents:
2384
diff
changeset
|
910 { NULL, "--tell", gr_file_tell, FALSE, FALSE, NULL, N_("print filename of current image") }, |
2731
304fbae3fd0f
Remote command --pixel-info
Colin Clark <colin.clark@cclark.uk>
parents:
2714
diff
changeset
|
911 { NULL, "--pixel-info", gr_pixel_info, FALSE, FALSE, NULL, N_("print pixel info of mouse pointer on current image") }, |
2801
3e9ca298bb1d
Fix #251: Crop simulation
Colin Clark <colin.clark@cclark.uk>
parents:
2739
diff
changeset
|
912 { NULL, "--get-rectangle", gr_rectangle, FALSE, FALSE, NULL, N_("get rectangle co-ordinates") }, |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
913 { NULL, "view:", gr_file_view, TRUE, FALSE, N_("<FILE>"), N_("open FILE in new window") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
914 { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL, N_("clear command line collection list") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
915 { NULL, "--list-add:", gr_list_add, TRUE, FALSE, N_("<FILE>"), N_("add FILE to command line collection list") }, |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
916 { NULL, "raise", gr_raise, FALSE, FALSE, NULL, N_("bring the Geeqie window to the top") }, |
2739
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
917 { NULL, "--id:", gr_lw_id, TRUE, FALSE, N_("<ID>"), N_("window id for following commands") }, |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
918 { NULL, "--new-window", gr_new_window, FALSE, FALSE, NULL, N_("new window") }, |
a03b5446e68f
Additional remote commands for layout windows
Colin Clark <colin.clark@cclark.uk>
parents:
2738
diff
changeset
|
919 { NULL, "--close-window", gr_close_window, FALSE, FALSE, NULL, N_("close window") }, |
2502
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
920 { "-ct:", "--cache-thumbs:", gr_cache_thumb, TRUE, FALSE, N_("clear|clean"), N_("clear or clean thumbnail cache") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
921 { "-cs:", "--cache-shared:", gr_cache_shared, TRUE, FALSE, N_("clear|clean"), N_("clear or clean shared thumbnail cache") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
922 { "-cm","--cache-metadata", gr_cache_metadata, FALSE, FALSE, NULL, N_(" clean the metadata cache") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
923 { "-cr:", "--cache-render:", gr_cache_render, TRUE, FALSE, N_("<folder> "), N_(" render thumbnails") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
924 { "-crr:", "--cache-render-recurse:", gr_cache_render_recurse, TRUE, FALSE, N_("<folder> "), N_("render thumbnails recursively") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
925 { "-crs:", "--cache-render-shared:", gr_cache_render_standard, TRUE, FALSE, N_("<folder> "), N_(" render thumbnails (see Help)") }, |
728c2b544eec
Fix #314: Remote commands for thumbnail maintenance
Colin Clark <colin.clark@cclark.uk>
parents:
2465
diff
changeset
|
926 { "-crsr:", "--cache-render-shared-recurse:", gr_cache_render_standard_recurse, TRUE, FALSE, N_("<folder>"), N_(" render thumbnails recursively (see Help)") }, |
2647
9f1adad6c2cf
Addl fix 269: Image marks "save" feature
Colin Clark <colin.clark@cclark.uk>
parents:
2639
diff
changeset
|
927 #ifdef HAVE_LUA |
2639
18460ea0ceef
Fix #269: External image marks - (--remote --lua)
Colin Clark <colin.clark@cclark.uk>
parents:
2606
diff
changeset
|
928 { NULL, "--lua:", gr_lua, TRUE, FALSE, N_("<FILE>,<lua script>"), N_("run lua script on FILE") }, |
2647
9f1adad6c2cf
Addl fix 269: Image marks "save" feature
Colin Clark <colin.clark@cclark.uk>
parents:
2639
diff
changeset
|
929 #endif |
2606
1e344397544c
Remove some stuff that is throwing errors in gcc-7
Klaus Ethgen <Klaus@Ethgen.de>
parents:
2502
diff
changeset
|
930 { NULL, NULL, NULL, FALSE, FALSE, NULL, NULL } |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
931 }; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
932 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
933 static RemoteCommandEntry *remote_command_find(const gchar *text, const gchar **offset) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
934 { |
1437 | 935 gboolean match = FALSE; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
936 gint i; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
937 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
938 i = 0; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
939 while (!match && remote_commands[i].func != NULL) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
940 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
941 if (remote_commands[i].needs_extra) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
942 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
943 if (remote_commands[i].opt_s && |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
944 strncmp(remote_commands[i].opt_s, text, strlen(remote_commands[i].opt_s)) == 0) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
945 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
946 if (offset) *offset = text + strlen(remote_commands[i].opt_s); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
947 return &remote_commands[i]; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
948 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
949 else if (remote_commands[i].opt_l && |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
950 strncmp(remote_commands[i].opt_l, text, strlen(remote_commands[i].opt_l)) == 0) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
951 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
952 if (offset) *offset = text + strlen(remote_commands[i].opt_l); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
953 return &remote_commands[i]; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
954 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
955 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
956 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
957 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
958 if ((remote_commands[i].opt_s && strcmp(remote_commands[i].opt_s, text) == 0) || |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
959 (remote_commands[i].opt_l && strcmp(remote_commands[i].opt_l, text) == 0)) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
960 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
961 if (offset) *offset = text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
962 return &remote_commands[i]; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
963 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
964 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
965 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
966 i++; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
967 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
968 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
969 return NULL; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
970 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
971 |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
972 static void remote_cb(RemoteConnection *rc, const gchar *text, GIOChannel *channel, gpointer data) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
973 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
974 RemoteCommandEntry *entry; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
975 const gchar *offset; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
976 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
977 entry = remote_command_find(text, &offset); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
978 if (entry && entry->func) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
979 { |
1554
bdd7004d7d80
improved remote protocol to allow bidirectional communication
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1523
diff
changeset
|
980 entry->func(offset, channel, data); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
981 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
982 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
983 { |
673
c9c2bc042e10
Do not use printf() directly but use new wrapper function log_printf() instead.
Laurent Monin <geeqie@norz.org>
parents:
671
diff
changeset
|
984 log_printf("unknown remote command:%s\n", text); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
985 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
986 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
987 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
988 void remote_help(void) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
989 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
990 gint i; |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
991 gchar *s_opt_param; |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
992 gchar *l_opt_param; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
993 |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
994 print_term(FALSE, _("Remote command list:\n")); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
995 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
996 i = 0; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
997 while (remote_commands[i].func != NULL) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
998 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
999 if (remote_commands[i].description) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1000 { |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1001 s_opt_param = g_strconcat(remote_commands[i].opt_s, remote_commands[i].parameter, NULL); |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1002 l_opt_param = g_strconcat(remote_commands[i].opt_l, remote_commands[i].parameter, NULL); |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1003 printf_term(FALSE, " %-11s%-1s %-30s%-s\n", |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1004 (remote_commands[i].opt_s) ? s_opt_param : "", |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1005 (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ", |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1006 (remote_commands[i].opt_l) ? l_opt_param : "", |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1007 _(remote_commands[i].description)); |
2290
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1008 g_free(s_opt_param); |
e16280b66879
Update command line options documentation
Colin Clark <cclark@mcb.net>
parents:
2221
diff
changeset
|
1009 g_free(l_opt_param); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1010 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1011 i++; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1012 } |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1013 printf_term(FALSE, N_("\n All other command line parameters are used as plain files if they exists.\n")); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1014 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1015 |
1000
07f6093c1c1a
For the sake of consistency, use glib basic types everywhere.
Laurent Monin <geeqie@norz.org>
parents:
995
diff
changeset
|
1016 GList *remote_build_list(GList *list, gint argc, gchar *argv[], GList **errors) |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1017 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1018 gint i; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1019 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1020 i = 1; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1021 while (i < argc) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1022 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1023 RemoteCommandEntry *entry; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1024 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1025 entry = remote_command_find(argv[i], NULL); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1026 if (entry) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1027 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1028 list = g_list_append(list, argv[i]); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1029 } |
1868 | 1030 else if (errors && !isfile(argv[i])) |
652
ecbc361c6b7f
Display a message when invalid remote options are used.
Laurent Monin <geeqie@norz.org>
parents:
649
diff
changeset
|
1031 { |
ecbc361c6b7f
Display a message when invalid remote options are used.
Laurent Monin <geeqie@norz.org>
parents:
649
diff
changeset
|
1032 *errors = g_list_append(*errors, argv[i]); |
ecbc361c6b7f
Display a message when invalid remote options are used.
Laurent Monin <geeqie@norz.org>
parents:
649
diff
changeset
|
1033 } |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1034 i++; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1035 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1036 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1037 return list; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1038 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1039 |
1868 | 1040 /** |
1041 * \param arg_exec Binary (argv0) | |
1042 * \param remote_list Evaluated and recognized remote commands | |
1043 * \param path The current path | |
1044 * \param cmd_list List of all non collections in Path | |
1045 * \param collection_list List of all collections in argv | |
1046 */ | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1047 void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path, |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1048 GList *cmd_list, GList *collection_list) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1049 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1050 RemoteConnection *rc; |
1437 | 1051 gboolean started = FALSE; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1052 gchar *buf; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1053 |
1145
94adf34fe826
Use functions to return directories instead of constants.
Laurent Monin <geeqie@norz.org>
parents:
1144
diff
changeset
|
1054 buf = g_build_filename(get_rc_dir(), ".command", NULL); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1055 rc = remote_client_open(buf); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1056 if (!rc) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1057 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1058 GString *command; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1059 GList *work; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1060 gint retry_count = 12; |
1437 | 1061 gboolean blank = FALSE; |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1062 |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1063 printf_term(FALSE, _("Remote %s not running, starting..."), GQ_APPNAME); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1064 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1065 command = g_string_new(arg_exec); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1066 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1067 work = remote_list; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1068 while (work) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1069 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1070 gchar *text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1071 RemoteCommandEntry *entry; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1072 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1073 text = work->data; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1074 work = work->next; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1075 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1076 entry = remote_command_find(text, NULL); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1077 if (entry) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1078 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1079 if (entry->prefer_command_line) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1080 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1081 remote_list = g_list_remove(remote_list, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1082 g_string_append(command, " "); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1083 g_string_append(command, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1084 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1085 if (entry->opt_l && strcmp(entry->opt_l, "file:") == 0) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1086 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1087 blank = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1088 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1089 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1090 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1091 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1092 if (blank || cmd_list || path) g_string_append(command, " --blank"); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1093 if (get_debug_level()) g_string_append(command, " --debug"); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1094 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1095 g_string_append(command, " &"); |
1144
79248cd0d16e
Add a wrapper around system() call named runcmd() which allows easier debugging. Improve the code launching the help browser.
Laurent Monin <geeqie@norz.org>
parents:
1055
diff
changeset
|
1096 runcmd(command->str); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1097 g_string_free(command, TRUE); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1098 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1099 while (!rc && retry_count > 0) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1100 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1101 usleep((retry_count > 10) ? 500000 : 1000000); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1102 rc = remote_client_open(buf); |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1103 if (!rc) print_term(FALSE, "."); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1104 retry_count--; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1105 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1106 |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1107 print_term(FALSE, "\n"); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1108 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1109 started = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1110 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1111 g_free(buf); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1112 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1113 if (rc) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1114 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1115 GList *work; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1116 const gchar *prefix; |
1437 | 1117 gboolean use_path = TRUE; |
1118 gboolean sent = FALSE; | |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1119 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1120 work = remote_list; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1121 while (work) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1122 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1123 gchar *text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1124 RemoteCommandEntry *entry; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1125 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1126 text = work->data; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1127 work = work->next; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1128 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1129 entry = remote_command_find(text, NULL); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1130 if (entry && |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1131 entry->opt_l && |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1132 strcmp(entry->opt_l, "file:") == 0) use_path = FALSE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1133 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1134 remote_client_send(rc, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1135 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1136 sent = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1137 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1138 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1139 if (cmd_list && cmd_list->next) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1140 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1141 prefix = "--list-add:"; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1142 remote_client_send(rc, "--list-clear"); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1143 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1144 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1145 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1146 prefix = "file:"; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1147 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1148 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1149 work = cmd_list; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1150 while (work) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1151 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1152 FileData *fd; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1153 gchar *text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1154 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1155 fd = work->data; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1156 work = work->next; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1157 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1158 text = g_strconcat(prefix, fd->path, NULL); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1159 remote_client_send(rc, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1160 g_free(text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1161 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1162 sent = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1163 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1164 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1165 if (path && !cmd_list && use_path) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1166 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1167 gchar *text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1168 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1169 text = g_strdup_printf("file:%s", path); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1170 remote_client_send(rc, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1171 g_free(text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1172 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1173 sent = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1174 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1175 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1176 work = collection_list; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1177 while (work) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1178 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1179 const gchar *name; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1180 gchar *text; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1181 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1182 name = work->data; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1183 work = work->next; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1184 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1185 text = g_strdup_printf("file:%s", name); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1186 remote_client_send(rc, text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1187 g_free(text); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1188 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1189 sent = TRUE; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1190 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1191 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1192 if (!started && !sent) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1193 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1194 remote_client_send(rc, "raise"); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1195 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1196 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1197 else |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1198 { |
2678
195267d1c78f
Fix #548: Send text output to stdout
cclark <colin.clark@cclark.uk>
parents:
2657
diff
changeset
|
1199 print_term(TRUE, _("Remote not available\n")); |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1200 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1201 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1202 _exit(0); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1203 } |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1204 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1205 RemoteConnection *remote_server_init(gchar *path, CollectionData *command_collection) |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1206 { |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1207 RemoteConnection *remote_connection = remote_server_open(path); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1208 RemoteData *remote_data = g_new(RemoteData, 1); |
2185
c14a1d8e6aa4
Trim trailing white spaces on empty lines.
Laurent Monin <zas@norz.org>
parents:
2184
diff
changeset
|
1209 |
649
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1210 remote_data->command_collection = command_collection; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1211 |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1212 remote_server_subscribe(remote_connection, remote_cb, remote_data); |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1213 return remote_connection; |
31ec921c17f2
Move all remote stuff from main.c to remote.[ch].
Laurent Monin <geeqie@norz.org>
parents:
512
diff
changeset
|
1214 } |
1055
4bbdfab3c89a
Adding a vim modeline to all files - patch by Klaus Ethgen
Vladimir Nadvornik <nadvornik@suse.cz>
parents:
1022
diff
changeset
|
1215 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |