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