Mercurial > gftp.yaz
annotate src/gtk/menu-items.c @ 48:e5f6054590b5
2002-11-5 Brian Masney <masneyb@gftp.org>
* lib/*.c src/gtk/*.c - removed function declarations for the static
functions from the top of the file. I had to rearrange the order of a
bunch of functions to avoid compiler warnings
* lib/gftp.h - include sys/sysmacros.h. If major() and minor() isn't
defined, give a compiler warning and define our own
* lib/local.c (local_get_next_file) - if this file is a device, store
the major/minor number in the file size
* src/gtk/misc-gtk.c (add_file_listbox) - if this file is a device,
use the major() and minor() macros to display the major and minor number
author | masneyb |
---|---|
date | Wed, 06 Nov 2002 02:20:25 +0000 |
parents | eec25f215772 |
children | a12bcbc2fce4 |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* menu-items.c - menu callbacks */ | |
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */ | |
4 /* */ | |
5 /* This program is free software; you can redistribute it and/or modify */ | |
6 /* it under the terms of the GNU General Public License as published by */ | |
7 /* the Free Software Foundation; either version 2 of the License, or */ | |
8 /* (at your option) any later version. */ | |
9 /* */ | |
10 /* This program is distributed in the hope that it will be useful, */ | |
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
13 /* GNU General Public License for more details. */ | |
14 /* */ | |
15 /* You should have received a copy of the GNU General Public License */ | |
16 /* along with this program; if not, write to the Free Software */ | |
17 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
18 /*****************************************************************************/ | |
19 | |
20 #include <gftp-gtk.h> | |
33 | 21 static const char cvsid[] = "$Id$"; |
1 | 22 |
23 void | |
24 change_setting (gftp_window_data * wdata, int menuitem, GtkWidget * checkmenu) | |
25 { | |
26 switch (menuitem) | |
27 { | |
28 case 1: | |
29 if (wdata->request != NULL) | |
30 gftp_set_data_type (wdata->request, GFTP_TYPE_ASCII); | |
31 break; | |
32 case 2: | |
33 if (wdata->request != NULL) | |
34 gftp_set_data_type (wdata->request, GFTP_TYPE_BINARY); | |
35 break; | |
36 case 3: | |
37 current_wdata = &window1; | |
38 other_wdata = &window2; | |
39 if (wdata->request) | |
40 update_window_info (); | |
41 break; | |
42 case 4: | |
43 current_wdata = &window2; | |
44 other_wdata = &window1; | |
45 if (wdata->request) | |
46 update_window_info (); | |
47 break; | |
48 } | |
49 } | |
50 | |
51 | |
52 void | |
53 tb_openurl_dialog (gpointer data) | |
54 { | |
55 const char *edttxt; | |
56 | |
57 if (current_wdata->request->stopable) | |
58 { | |
59 ftp_log (gftp_logging_misc, NULL, | |
60 _("%s: Please hit the stop button first to do anything else\n"), | |
61 _("OpenURL")); | |
62 return; | |
63 } | |
64 | |
65 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); | |
66 if (*edttxt == '\0') | |
67 { | |
68 ftp_log (gftp_logging_misc, NULL, | |
69 _("OpenURL: Operation canceled...you must enter a string\n")); | |
70 return; | |
71 } | |
72 | |
73 if (GFTP_IS_CONNECTED (current_wdata->request)) | |
74 disconnect (current_wdata); | |
75 else if (edttxt != NULL && *edttxt != '\0') | |
76 toolbar_hostedit (NULL, NULL); | |
77 else | |
78 openurl_dialog (current_wdata); | |
79 } | |
80 | |
81 | |
19 | 82 static void |
83 do_openurl (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
1 | 84 { |
85 const char *tempstr; | |
86 | |
87 if (current_wdata->request->stopable) | |
88 { | |
89 ftp_log (gftp_logging_misc, NULL, | |
90 _("%s: Please hit the stop button first to do anything else\n"), | |
91 _("OpenURL")); | |
92 return; | |
93 } | |
94 | |
19 | 95 tempstr = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
1 | 96 if (*tempstr == '\0') |
97 { | |
98 ftp_log (gftp_logging_misc, NULL, | |
99 _("OpenURL: Operation canceled...you must enter a string\n")); | |
100 return; | |
101 } | |
102 | |
103 if (GFTP_IS_CONNECTED (wdata->request)) | |
104 disconnect (wdata); | |
105 | |
106 if (gftp_parse_url (wdata->request, tempstr) == 0) | |
107 { | |
19 | 108 gtk_widget_destroy (ddata->dialog); |
1 | 109 ftp_connect (wdata, wdata->request, 1); |
110 } | |
111 else | |
112 { | |
19 | 113 gtk_widget_destroy (ddata->dialog); |
1 | 114 ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"), tempstr); |
115 } | |
19 | 116 ddata->dialog = NULL; |
117 } | |
118 | |
119 | |
120 void | |
121 openurl_dialog (gpointer data) | |
122 { | |
123 MakeEditDialog (_("Connect via URL"), _("Enter ftp url to connect to"), | |
124 NULL, 1, NULL, gftp_dialog_button_connect, do_openurl, data, | |
125 NULL, NULL); | |
1 | 126 } |
127 | |
128 | |
129 void | |
130 disconnect (gpointer data) | |
131 { | |
132 gftp_window_data * wdata; | |
133 | |
134 wdata = data; | |
47 | 135 gftp_delete_cache_entry (wdata->request, 1); |
1 | 136 gftp_disconnect (wdata->request); |
137 remove_files_window (wdata); | |
138 update_window (wdata); | |
139 } | |
140 | |
141 | |
142 static void | |
19 | 143 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) |
1 | 144 { |
145 GList * templist, * filelist; | |
146 gftp_file * tempfle; | |
147 const char *edttext; | |
148 int num; | |
149 | |
150 wdata->show_selected = 0; | |
151 | |
19 | 152 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
1 | 153 if (*edttext == '\0') |
154 { | |
155 ftp_log (gftp_logging_misc, NULL, | |
156 _("Change Filespec: Operation canceled...you must enter a string\n")); | |
157 return; | |
158 } | |
159 if (wdata->filespec) | |
160 g_free (wdata->filespec); | |
161 wdata->filespec = g_malloc (strlen (edttext) + 1); | |
162 strcpy (wdata->filespec, edttext); | |
163 | |
164 filelist = wdata->files; | |
165 templist = GTK_CLIST (wdata->listbox)->selection; | |
166 num = 0; | |
167 while (templist != NULL) | |
168 { | |
169 templist = get_next_selection (templist, &filelist, &num); | |
170 tempfle = filelist->data; | |
171 tempfle->was_sel = 1; | |
172 } | |
173 | |
174 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
175 gtk_clist_clear (GTK_CLIST (wdata->listbox)); | |
176 templist = wdata->files; | |
177 while (templist != NULL) | |
178 { | |
179 tempfle = templist->data; | |
180 add_file_listbox (wdata, tempfle); | |
181 templist = templist->next; | |
182 } | |
183 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
184 update_window (wdata); | |
185 } | |
186 | |
187 | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
188 void |
19 | 189 change_filespec (gpointer data) |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
190 { |
19 | 191 gftp_window_data * wdata; |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
192 |
19 | 193 wdata = data; |
194 if (!check_status (_("Change Filespec"), wdata, 0, 0, 0, 1)) | |
195 return; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
196 |
19 | 197 MakeEditDialog (_("Change Filespec"), _("Enter the new file specification"), |
198 wdata->filespec, 1, NULL, gftp_dialog_button_change, | |
199 dochange_filespec, wdata, NULL, NULL); | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
200 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
201 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
202 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
203 static void |
21 | 204 destroy_save_directory_listing (GtkWidget * widget, gftp_save_dir_struct * str) |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
205 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
206 gtk_widget_destroy (str->filew); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
207 g_free (str); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
208 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
209 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
210 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
211 static void |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
212 dosave_directory_listing (GtkWidget * widget, gftp_save_dir_struct * str) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
213 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
214 const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
215 "Aug", "Sep", "Oct", "Nov", "Dec" }; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
216 const char *filename; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
217 struct tm *lt; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
218 gftp_file * tempfle; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
219 GList * templist; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
220 FILE * fd; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
221 time_t t; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
222 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
223 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (str->filew)); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
224 if ((fd = fopen (filename, "w")) == NULL) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
225 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
226 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
227 _("Error: Cannot open %s for writing: %s\n"), filename, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
228 g_strerror (errno)); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
229 return; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
230 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
231 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
232 time (&t); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
233 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
234 for (templist = str->wdata->files; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
235 templist->next != NULL; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
236 templist = templist->next) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
237 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
238 tempfle = templist->data; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
239 fprintf (fd, "%10s %8s %8s ", tempfle->attribs, tempfle->user, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
240 tempfle->group); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
241 if (tempfle->attribs && (*tempfle->attribs == 'b' || |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
242 *tempfle->attribs == 'c')) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
243 fprintf (fd, "%5d, %4d", (((unsigned int) tempfle->size) >> 16) & 0xFF, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
244 ((unsigned int) tempfle->size) & 0xFF); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
245 else |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
246 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
247 #if defined (_LARGEFILE_SOURCE) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
248 fprintf (fd, "%11lld", tempfle->size); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
249 #else |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
250 fprintf (fd, "%11ld", tempfle->size); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
251 #endif |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
252 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
253 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
254 lt = localtime (&tempfle->datetime); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
255 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
256 if (tempfle->datetime > t || |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
257 t - 3600*24*90 > tempfle->datetime) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
258 fprintf (fd, " %s %2d %4d", months[lt->tm_mon], lt->tm_mday, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
259 lt->tm_year + 1900); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
260 else |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
261 fprintf (fd, " %s %2d %02d:%02d", months[lt->tm_mon], lt->tm_mday, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
262 lt->tm_hour, lt->tm_min); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
263 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
264 fprintf (fd, " %s\n", tempfle->file); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
265 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
266 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
267 fclose (fd); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
268 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
269 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
270 |
19 | 271 void |
272 save_directory_listing (gpointer data) | |
273 { | |
274 gftp_save_dir_struct * str; | |
275 GtkWidget *filew; | |
276 | |
277 filew = gtk_file_selection_new (_("Save Directory Listing")); | |
278 | |
279 str = g_malloc (sizeof (*str)); | |
280 str->filew = filew; | |
281 str->wdata = data; | |
282 | |
283 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
284 "clicked", GTK_SIGNAL_FUNC (dosave_directory_listing), | |
285 str); | |
21 | 286 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), |
287 "clicked", | |
288 GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); | |
289 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), | |
290 "clicked", | |
291 GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); | |
19 | 292 |
293 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Directory Listing", "gFTP"); | |
294 gtk_widget_show (filew); | |
295 } | |
296 | |
297 | |
1 | 298 void |
299 show_selected (gpointer data) | |
300 { | |
301 GList * templist, * filelist; | |
302 gftp_window_data * wdata; | |
303 gftp_file * tempfle; | |
304 int num; | |
305 | |
306 wdata = data; | |
307 wdata->show_selected = 1; | |
308 | |
309 filelist = wdata->files; | |
310 templist = GTK_CLIST (wdata->listbox)->selection; | |
311 num = 0; | |
312 while (templist != NULL) | |
313 { | |
314 templist = get_next_selection (templist, &filelist, &num); | |
315 tempfle = filelist->data; | |
316 tempfle->was_sel = 1; | |
317 } | |
318 | |
319 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
320 gtk_clist_clear (GTK_CLIST (wdata->listbox)); | |
321 templist = wdata->files; | |
322 while (templist != NULL) | |
323 { | |
324 tempfle = templist->data; | |
325 add_file_listbox (wdata, tempfle); | |
326 templist = templist->next; | |
327 } | |
328 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
329 update_window (wdata); | |
330 } | |
331 | |
332 | |
333 void | |
334 selectall (gpointer data) | |
335 { | |
336 gftp_window_data * wdata; | |
337 | |
338 wdata = data; | |
339 wdata->show_selected = 0; | |
340 gtk_clist_select_all (GTK_CLIST (wdata->listbox)); | |
341 } | |
342 | |
343 | |
344 void | |
345 selectallfiles (gpointer data) | |
346 { | |
347 gftp_window_data * wdata; | |
348 gftp_file * tempfle; | |
349 GList *templist; | |
350 int i; | |
351 | |
352 wdata = data; | |
353 wdata->show_selected = 0; | |
354 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
355 i = 0; | |
39 | 356 templist = wdata->files; |
1 | 357 while (templist != NULL) |
358 { | |
359 tempfle = (gftp_file *) templist->data; | |
360 if (tempfle->shown) | |
361 { | |
362 if (tempfle->isdir) | |
363 gtk_clist_unselect_row (GTK_CLIST (wdata->listbox), i, 0); | |
364 else | |
365 gtk_clist_select_row (GTK_CLIST (wdata->listbox), i, 0); | |
366 i++; | |
367 } | |
368 templist = templist->next; | |
369 } | |
370 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
371 } | |
372 | |
373 | |
374 void | |
375 deselectall (gpointer data) | |
376 { | |
377 gftp_window_data * wdata; | |
378 | |
379 wdata = data; | |
380 wdata->show_selected = 0; | |
381 gtk_clist_unselect_all (GTK_CLIST (wdata->listbox)); | |
382 } | |
383 | |
384 | |
19 | 385 static void |
386 dosite (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
1 | 387 { |
388 const char *edttext; | |
389 | |
19 | 390 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
1 | 391 if (*edttext == '\0') |
392 { | |
393 ftp_log (gftp_logging_misc, NULL, | |
394 _("SITE: Operation canceled...you must enter a string\n")); | |
395 return; | |
396 } | |
397 | |
398 if (check_reconnect (wdata) < 0) | |
399 return; | |
400 gftp_site_cmd (wdata->request, edttext); | |
401 | |
402 if (!GFTP_IS_CONNECTED (wdata->request)) | |
403 disconnect (wdata); | |
404 } | |
405 | |
406 | |
19 | 407 void |
408 site_dialog (gpointer data) | |
409 { | |
410 gftp_window_data * wdata; | |
411 | |
412 wdata = data; | |
413 if (!check_status (_("Site"), wdata, 0, 0, 0, wdata->request->site != NULL)) | |
414 return; | |
415 | |
416 MakeEditDialog (_("Site"), _("Enter site-specific command"), NULL, 1, | |
417 NULL, gftp_dialog_button_ok, dosite, wdata, NULL, NULL); | |
418 } | |
419 | |
420 | |
48 | 421 static void * |
422 do_change_dir_thread (void * data) | |
423 { | |
424 gftp_window_data * wdata; | |
425 int success, sj; | |
426 | |
427 wdata = data; | |
428 wdata->request->user_data = (void *) 0x01; | |
429 | |
430 if (wdata->request->use_threads) | |
431 { | |
432 sj = sigsetjmp (jmp_environment, 1); | |
433 use_jmp_environment = 1; | |
434 } | |
435 else | |
436 sj = 0; | |
437 | |
438 success = 0; | |
439 if (sj == 0) | |
440 { | |
441 if (wdata->request->network_timeout > 0) | |
442 alarm (wdata->request->network_timeout); | |
443 success = gftp_set_directory (wdata->request, wdata->request->directory); | |
444 alarm (0); | |
445 } | |
446 else | |
447 { | |
448 gftp_disconnect (wdata->request); | |
449 wdata->request->logging_function (gftp_logging_error, | |
450 wdata->request->user_data, | |
451 _("Operation canceled\n")); | |
452 } | |
453 | |
454 if (wdata->request->use_threads) | |
455 use_jmp_environment = 0; | |
456 | |
457 wdata->request->user_data = NULL; | |
458 wdata->request->stopable = 0; | |
459 return ((void *) success); | |
460 } | |
461 | |
462 | |
463 static int | |
464 do_change_dir (gftp_window_data * wdata, char *directory) | |
465 { | |
466 char *olddir; | |
467 int ret; | |
468 | |
469 if (directory != wdata->request->directory) | |
470 { | |
471 olddir = wdata->request->directory; | |
472 wdata->request->directory = g_malloc (strlen (directory) + 1); | |
473 strcpy (wdata->request->directory, directory); | |
474 } | |
475 else | |
476 olddir = NULL; | |
477 | |
478 ret = (int) generic_thread (do_change_dir_thread, wdata); | |
479 | |
480 if (!GFTP_IS_CONNECTED (wdata->request)) | |
481 { | |
482 disconnect (wdata); | |
483 if (olddir != NULL) | |
484 g_free (olddir); | |
485 return (-2); | |
486 } | |
487 | |
488 if (ret != 0) | |
489 { | |
490 g_free (wdata->request->directory); | |
491 wdata->request->directory = olddir; | |
492 } | |
493 else | |
494 g_free (olddir); | |
495 | |
496 return (ret); | |
497 } | |
498 | |
499 | |
1 | 500 int |
501 chdir_edit (GtkWidget * widget, gpointer data) | |
502 { | |
503 gftp_window_data * wdata; | |
504 const char *edttxt; | |
505 char *tempstr; | |
506 | |
507 wdata = data; | |
508 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry)); | |
509 if (!GFTP_IS_CONNECTED (wdata->request) && *edttxt != '\0') | |
510 { | |
511 toolbar_hostedit (NULL, NULL); | |
512 return (0); | |
513 } | |
514 | |
515 if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 0, 0, | |
516 wdata->request->chdir != NULL)) | |
517 return (FALSE); | |
518 | |
519 if ((tempstr = expand_path (edttxt)) == NULL) | |
520 return (FALSE); | |
521 | |
522 if (check_reconnect (wdata) < 0) | |
523 return (FALSE); | |
524 | |
525 if (do_change_dir (wdata, tempstr) == 0) | |
526 { | |
527 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
528 remove_files_window (wdata); | |
529 ftp_list_files (wdata, 1); | |
530 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
531 add_history (wdata->combo, wdata->history, wdata->histlen, tempstr); | |
532 } | |
533 | |
534 g_free (tempstr); | |
535 return (FALSE); | |
536 } | |
537 | |
538 | |
539 int | |
540 chdir_dialog (gpointer data) | |
541 { | |
542 GList * templist, * filelist; | |
543 gftp_window_data * wdata; | |
544 char *newdir, *tempstr; | |
545 gftp_file *tempfle; | |
546 int num, ret; | |
547 | |
548 wdata = data; | |
549 if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 1, 0, | |
550 wdata->request->chdir != NULL)) | |
551 return (0); | |
552 | |
39 | 553 filelist = wdata->files; |
1 | 554 templist = GTK_CLIST (wdata->listbox)->selection; |
555 num = 0; | |
556 templist = get_next_selection (templist, &filelist, &num); | |
557 tempfle = filelist->data; | |
558 | |
559 newdir = g_strconcat (GFTP_GET_DIRECTORY (wdata->request), "/", | |
560 tempfle->file, NULL); | |
561 remove_double_slashes (newdir); | |
562 if ((tempstr = expand_path (newdir)) == NULL) | |
563 return (0); | |
564 g_free (newdir); | |
565 | |
566 if (check_reconnect (wdata) < 0) | |
567 return (0); | |
568 | |
569 ret = 0; | |
570 if (do_change_dir (wdata, tempstr) == 0) | |
571 { | |
572 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
573 remove_files_window (wdata); | |
574 ftp_list_files (wdata, 1); | |
575 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
576 ret = 1; | |
577 } | |
578 g_free (tempstr); | |
579 return (ret); | |
580 } | |
581 | |
582 | |
583 void | |
584 clearlog (gpointer data) | |
585 { | |
586 guint len; | |
45 | 587 #if GTK_MAJOR_VERSION == 1 |
1 | 588 len = gtk_text_get_length (GTK_TEXT (logwdw)); |
589 gtk_text_set_point (GTK_TEXT (logwdw), len); | |
590 gtk_text_backward_delete (GTK_TEXT (logwdw), len); | |
591 #else | |
592 GtkTextBuffer * textbuf; | |
593 GtkTextIter iter, iter2; | |
594 | |
595 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
596 len = gtk_text_buffer_get_char_count (textbuf); | |
597 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
598 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
599 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
600 #endif | |
601 } | |
602 | |
603 | |
604 void | |
605 viewlog (gpointer data) | |
606 { | |
607 char *tempstr, *txt, *pos; | |
608 guint textlen; | |
609 ssize_t len; | |
610 int fd; | |
45 | 611 #if GTK_MAJOR_VERSION > 1 |
1 | 612 GtkTextBuffer * textbuf; |
613 GtkTextIter iter, iter2; | |
614 #endif | |
615 | |
41 | 616 tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL); |
1 | 617 if ((fd = mkstemp (tempstr)) < 0) |
618 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
619 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
620 _("Error: Cannot open %s for writing: %s\n"), tempstr, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
621 g_strerror (errno)); |
1 | 622 g_free (tempstr); |
623 return; | |
624 } | |
625 chmod (tempstr, S_IRUSR | S_IWUSR); | |
626 unlink (tempstr); | |
627 | |
45 | 628 #if GTK_MAJOR_VERSION == 1 |
1 | 629 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
630 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
631 #else | |
632 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
633 textlen = gtk_text_buffer_get_char_count (textbuf); | |
634 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
635 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
636 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
637 #endif | |
638 pos = txt; | |
639 do | |
640 { | |
641 if ((len = write (fd, pos, textlen)) == -1) | |
642 { | |
643 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), tempstr, g_strerror (errno)); | |
644 break; | |
645 } | |
646 textlen -= len; | |
647 pos += len; | |
648 } while (textlen > 0); | |
649 | |
650 lseek (fd, 0, SEEK_SET); | |
651 view_file (tempstr, fd, 1, 0, 0, 1, NULL, NULL); | |
652 close (fd); | |
653 g_free (tempstr); | |
654 g_free (txt); | |
655 } | |
656 | |
657 | |
658 static void | |
659 dosavelog (GtkWidget * widget, GtkFileSelection * fs) | |
660 { | |
661 const char *filename; | |
662 char *txt, *pos; | |
663 guint textlen; | |
664 ssize_t len; | |
665 FILE *fd; | |
666 int ok; | |
45 | 667 #if GTK_MAJOR_VERSION > 1 |
1 | 668 GtkTextBuffer * textbuf; |
669 GtkTextIter iter, iter2; | |
670 #endif | |
671 | |
672 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); | |
673 if ((fd = fopen (filename, "w")) == NULL) | |
674 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
675 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
676 _("Error: Cannot open %s for writing: %s\n"), filename, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
677 g_strerror (errno)); |
1 | 678 return; |
679 } | |
680 | |
45 | 681 #if GTK_MAJOR_VERSION == 1 |
1 | 682 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
683 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
684 #else | |
685 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
686 textlen = gtk_text_buffer_get_char_count (textbuf); | |
687 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
688 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
689 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
690 #endif | |
691 | |
692 ok = 1; | |
693 pos = txt; | |
694 do | |
695 { | |
696 if ((len = write (fileno (fd), pos, textlen)) == -1) | |
697 { | |
698 ok = 0; | |
699 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), filename, g_strerror (errno)); | |
700 break; | |
701 } | |
702 | |
703 textlen -= len; | |
704 pos += len; | |
705 } while (textlen > 0); | |
706 | |
707 if (ok) | |
708 ftp_log (gftp_logging_misc, NULL, | |
709 _("Successfully wrote the log file to %s\n"), filename); | |
710 | |
711 fclose (fd); | |
712 g_free (txt); | |
713 } | |
714 | |
715 | |
716 void | |
19 | 717 savelog (gpointer data) |
718 { | |
719 GtkWidget *filew; | |
720 | |
721 filew = gtk_file_selection_new (_("Save Log")); | |
722 | |
723 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
724 "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); | |
725 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
726 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
727 GTK_OBJECT (filew)); | |
728 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); | |
729 | |
730 gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); | |
731 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); | |
732 gtk_widget_show (filew); | |
733 } | |
734 | |
735 | |
736 void | |
1 | 737 clear_cache (gpointer data) |
738 { | |
739 gftp_clear_cache_files (); | |
740 } | |
741 | |
742 | |
743 void | |
744 about_dialog (gpointer data) | |
745 { | |
746 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, | |
747 * dialog; | |
748 char *tempstr, *no_license_agreement, *str, buf[255]; | |
749 size_t len; | |
750 FILE * fd; | |
45 | 751 #if GTK_MAJOR_VERSION > 1 |
1 | 752 GtkTextBuffer * textbuf; |
753 GtkTextIter iter; | |
754 guint textlen; | |
755 #endif | |
756 | |
757 no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, SHARE_DIR); | |
758 | |
45 | 759 #if GTK_MAJOR_VERSION == 1 |
1 | 760 dialog = gtk_dialog_new (); |
761 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); | |
762 gtk_container_border_width (GTK_CONTAINER | |
763 (GTK_DIALOG (dialog)->action_area), 5); | |
764 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
19 | 765 #else |
766 dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, | |
767 GTK_STOCK_CLOSE, | |
768 GTK_RESPONSE_CLOSE, | |
769 NULL); | |
770 #endif | |
771 gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); | |
1 | 772 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); |
19 | 773 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); |
774 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); | |
1 | 775 gtk_widget_realize (dialog); |
776 | |
19 | 777 if (gftp_icon != NULL) |
778 { | |
779 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | |
780 gftp_icon->bitmap); | |
781 gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); | |
782 } | |
783 | |
1 | 784 notebook = gtk_notebook_new (); |
785 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | |
786 TRUE, 0); | |
787 gtk_widget_show (notebook); | |
788 | |
789 box = gtk_vbox_new (TRUE, 5); | |
790 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
791 gtk_widget_show (box); | |
792 | |
793 tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); | |
794 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
795 gtk_widget_show (tempwid); | |
796 | |
797 tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2002 Brian Masney <masneyb@gftp.org>\nOfficial Homepage: http://www.gftp.org/\nLogo by: Aaron Worley <planet_hoth@yahoo.com>\n"), | |
798 version); | |
799 str = _("Translated by"); | |
800 if (strcmp (str, "Translated by") != 0) | |
801 { | |
802 tempstr = g_realloc (tempstr, strlen (tempstr) + strlen (str) + 1); | |
803 strcat (tempstr, str); | |
804 } | |
805 tempwid = gtk_label_new (tempstr); | |
806 g_free (tempstr); | |
807 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
808 gtk_widget_show (tempwid); | |
809 | |
810 label = gtk_label_new (_("About")); | |
811 gtk_widget_show (label); | |
812 | |
813 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
814 | |
815 box = gtk_vbox_new (FALSE, 5); | |
816 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
817 gtk_widget_show (box); | |
818 | |
819 tempwid = gtk_table_new (1, 2, FALSE); | |
820 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); | |
821 gtk_widget_show (tempwid); | |
822 | |
45 | 823 #if GTK_MAJOR_VERSION == 1 |
1 | 824 view = gtk_text_new (NULL, NULL); |
825 gtk_text_set_editable (GTK_TEXT (view), FALSE); | |
826 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); | |
827 | |
828 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, | |
829 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
830 0, 0); | |
831 gtk_widget_show (view); | |
832 | |
833 vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); | |
834 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, | |
835 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
836 gtk_widget_show (vscroll); | |
837 #else | |
838 view = gtk_text_view_new (); | |
839 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); | |
840 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); | |
841 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); | |
842 | |
843 vscroll = gtk_scrolled_window_new (NULL, NULL); | |
844 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), | |
845 GTK_POLICY_AUTOMATIC, | |
846 GTK_POLICY_AUTOMATIC); | |
847 | |
848 gtk_container_add (GTK_CONTAINER (vscroll), view); | |
849 gtk_widget_show (view); | |
850 | |
851 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, | |
852 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
853 0, 0); | |
854 gtk_widget_show (vscroll); | |
855 | |
856 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); | |
857 #endif | |
858 | |
859 label = gtk_label_new (_("License Agreement")); | |
860 gtk_widget_show (label); | |
861 | |
862 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
863 | |
45 | 864 #if GTK_MAJOR_VERSION == 1 |
1 | 865 tempwid = gtk_button_new_with_label (_(" Close ")); |
866 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | |
867 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | |
868 FALSE, FALSE, 0); | |
869 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | |
870 GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
871 GTK_OBJECT (dialog)); | |
872 gtk_widget_grab_default (tempwid); | |
873 gtk_widget_show (tempwid); | |
19 | 874 #else |
875 g_signal_connect_swapped (GTK_OBJECT (dialog), "response", | |
876 G_CALLBACK (gtk_widget_destroy), | |
877 GTK_OBJECT (dialog)); | |
878 #endif | |
1 | 879 |
880 tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); | |
881 if (access (tempstr, F_OK) != 0) | |
882 { | |
883 g_free (tempstr); | |
884 tempstr = expand_path (SHARE_DIR "/COPYING"); | |
885 if (access (tempstr, F_OK) != 0) | |
886 { | |
887 g_free (tempstr); | |
888 tempstr = expand_path (BASE_CONF_DIR "/COPYING"); | |
889 if (access (tempstr, F_OK) != 0) | |
890 { | |
45 | 891 #if GTK_MAJOR_VERSION == 1 |
1 | 892 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
893 no_license_agreement, -1); | |
894 #else | |
895 textlen = gtk_text_buffer_get_char_count (textbuf); | |
896 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
897 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
898 #endif | |
899 gtk_widget_show (dialog); | |
900 return; | |
901 } | |
902 } | |
903 } | |
904 | |
905 if ((fd = fopen (tempstr, "r")) == NULL) | |
906 { | |
45 | 907 #if GTK_MAJOR_VERSION == 1 |
1 | 908 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
909 no_license_agreement, -1); | |
910 #else | |
911 textlen = gtk_text_buffer_get_char_count (textbuf); | |
912 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
913 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
914 #endif | |
915 gtk_widget_show (dialog); | |
916 g_free (tempstr); | |
917 return; | |
918 } | |
919 g_free (tempstr); | |
920 | |
921 memset (buf, 0, sizeof (buf)); | |
922 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) | |
923 { | |
924 buf[len] = '\0'; | |
45 | 925 #if GTK_MAJOR_VERSION == 1 |
1 | 926 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); |
927 #else | |
928 textlen = gtk_text_buffer_get_char_count (textbuf); | |
929 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
930 gtk_text_buffer_insert (textbuf, &iter, buf, -1); | |
931 #endif | |
932 } | |
933 fclose (fd); | |
934 gtk_widget_show (dialog); | |
935 g_free (no_license_agreement); | |
936 gftp_free_pixmap ("gftp-logo.xpm"); | |
937 } | |
938 | |
939 | |
940 void | |
941 compare_windows (gpointer data) | |
942 { | |
943 gftp_file * curfle, * otherfle; | |
944 GList * curlist, * otherlist; | |
945 int row; | |
946 | |
947 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
948 return; | |
949 | |
950 deselectall (&window1); | |
951 deselectall (&window2); | |
952 | |
953 row = 0; | |
954 curlist = window1.files; | |
955 while (curlist != NULL) | |
956 { | |
957 curfle = curlist->data; | |
958 if (!curfle->shown) | |
959 { | |
960 curlist = curlist->next; | |
961 continue; | |
962 } | |
963 | |
964 otherlist = window2.files; | |
965 while (otherlist != NULL) | |
966 { | |
967 otherfle = otherlist->data; | |
968 if (!otherfle->shown) | |
969 { | |
970 otherlist = otherlist->next; | |
971 continue; | |
972 } | |
973 | |
974 if (strcmp (otherfle->file, curfle->file) == 0 && | |
975 otherfle->isdir == curfle->isdir && | |
976 (curfle->isdir || otherfle->size == curfle->size)) | |
977 break; | |
978 | |
979 otherlist = otherlist->next; | |
980 } | |
981 | |
982 if (otherlist == NULL) | |
983 gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); | |
984 row++; | |
985 curlist = curlist->next; | |
986 } | |
987 | |
988 row = 0; | |
989 curlist = window2.files; | |
990 while (curlist != NULL) | |
991 { | |
992 curfle = curlist->data; | |
993 if (!curfle->shown) | |
994 { | |
995 curlist = curlist->next; | |
996 continue; | |
997 } | |
998 | |
999 otherlist = window1.files; | |
1000 while (otherlist != NULL) | |
1001 { | |
1002 otherfle = otherlist->data; | |
1003 if (!otherfle->shown) | |
1004 { | |
1005 otherlist = otherlist->next; | |
1006 continue; | |
1007 } | |
1008 | |
1009 if (strcmp (otherfle->file, curfle->file) == 0 && | |
1010 otherfle->isdir == curfle->isdir && | |
1011 (curfle->isdir || otherfle->size == curfle->size)) | |
1012 break; | |
1013 | |
1014 otherlist = otherlist->next; | |
1015 } | |
1016 | |
1017 if (otherlist == NULL) | |
1018 gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); | |
1019 row++; | |
1020 curlist = curlist->next; | |
1021 } | |
1022 } | |
1023 |