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