Mercurial > gftp.yaz
annotate src/gtk/menu-items.c @ 21:4b244bf9d84d
2002-09-16 Brian Masney <masneyb@gftp.org>
* src/gtk/gftp-gtk.c, src/gtk/menu-items.c, src/gtk/misc-gtk.c -
Fixed compile errors when compiling against GTK+ 1.2
* src/gtk/misc-gtk.c (MakeEditDialog, MakeYesNoDialog) - fixed to work
with GTK+ 1.2
author | masneyb |
---|---|
date | Tue, 17 Sep 2002 12:00:50 +0000 |
parents | 3b2dcdefc7e9 |
children | c8ec7877432e |
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> | |
21 | |
22 static int do_change_dir ( gftp_window_data * wdata, | |
23 char * directory ); | |
24 static void *do_change_dir_thread ( void * data ); | |
25 static RETSIGTYPE sig_chdirquit ( int signo ); | |
26 static sigjmp_buf chdirenvir; | |
27 | |
28 void | |
29 change_setting (gftp_window_data * wdata, int menuitem, GtkWidget * checkmenu) | |
30 { | |
31 switch (menuitem) | |
32 { | |
33 case 1: | |
34 if (wdata->request != NULL) | |
35 gftp_set_data_type (wdata->request, GFTP_TYPE_ASCII); | |
36 break; | |
37 case 2: | |
38 if (wdata->request != NULL) | |
39 gftp_set_data_type (wdata->request, GFTP_TYPE_BINARY); | |
40 break; | |
41 case 3: | |
42 current_wdata = &window1; | |
43 other_wdata = &window2; | |
44 if (wdata->request) | |
45 update_window_info (); | |
46 break; | |
47 case 4: | |
48 current_wdata = &window2; | |
49 other_wdata = &window1; | |
50 if (wdata->request) | |
51 update_window_info (); | |
52 break; | |
53 } | |
54 } | |
55 | |
56 | |
57 void | |
58 tb_openurl_dialog (gpointer data) | |
59 { | |
60 const char *edttxt; | |
61 | |
62 if (current_wdata->request->stopable) | |
63 { | |
64 ftp_log (gftp_logging_misc, NULL, | |
65 _("%s: Please hit the stop button first to do anything else\n"), | |
66 _("OpenURL")); | |
67 return; | |
68 } | |
69 | |
70 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry)); | |
71 if (*edttxt == '\0') | |
72 { | |
73 ftp_log (gftp_logging_misc, NULL, | |
74 _("OpenURL: Operation canceled...you must enter a string\n")); | |
75 return; | |
76 } | |
77 | |
78 if (GFTP_IS_CONNECTED (current_wdata->request)) | |
79 disconnect (current_wdata); | |
80 else if (edttxt != NULL && *edttxt != '\0') | |
81 toolbar_hostedit (NULL, NULL); | |
82 else | |
83 openurl_dialog (current_wdata); | |
84 } | |
85 | |
86 | |
19 | 87 static void |
88 do_openurl (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
1 | 89 { |
90 const char *tempstr; | |
91 | |
92 if (current_wdata->request->stopable) | |
93 { | |
94 ftp_log (gftp_logging_misc, NULL, | |
95 _("%s: Please hit the stop button first to do anything else\n"), | |
96 _("OpenURL")); | |
97 return; | |
98 } | |
99 | |
19 | 100 tempstr = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
1 | 101 if (*tempstr == '\0') |
102 { | |
103 ftp_log (gftp_logging_misc, NULL, | |
104 _("OpenURL: Operation canceled...you must enter a string\n")); | |
105 return; | |
106 } | |
107 | |
108 if (GFTP_IS_CONNECTED (wdata->request)) | |
109 disconnect (wdata); | |
110 | |
111 if (gftp_parse_url (wdata->request, tempstr) == 0) | |
112 { | |
19 | 113 gtk_widget_destroy (ddata->dialog); |
1 | 114 ftp_connect (wdata, wdata->request, 1); |
115 } | |
116 else | |
117 { | |
19 | 118 gtk_widget_destroy (ddata->dialog); |
1 | 119 ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"), tempstr); |
120 } | |
19 | 121 ddata->dialog = NULL; |
122 } | |
123 | |
124 | |
125 void | |
126 openurl_dialog (gpointer data) | |
127 { | |
128 MakeEditDialog (_("Connect via URL"), _("Enter ftp url to connect to"), | |
129 NULL, 1, NULL, gftp_dialog_button_connect, do_openurl, data, | |
130 NULL, NULL); | |
1 | 131 } |
132 | |
133 | |
134 void | |
135 disconnect (gpointer data) | |
136 { | |
137 gftp_window_data * wdata; | |
138 | |
139 wdata = data; | |
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; | |
360 templist = g_list_first (wdata->files); | |
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 | |
478 filelist = g_list_first (wdata->files); | |
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 { | |
556 sj = sigsetjmp (chdirenvir, 1); | |
557 signal (SIGINT, sig_chdirquit); | |
558 signal (SIGALRM, sig_chdirquit); | |
559 } | |
560 else | |
561 sj = 0; | |
562 | |
563 success = 0; | |
564 if (sj == 0) | |
565 { | |
566 if (wdata->request->network_timeout > 0) | |
567 alarm (wdata->request->network_timeout); | |
568 success = gftp_set_directory (wdata->request, wdata->request->directory); | |
569 alarm (0); | |
570 } | |
571 else | |
572 { | |
573 gftp_disconnect (wdata->request); | |
574 wdata->request->logging_function (gftp_logging_error, | |
575 wdata->request->user_data, | |
576 _("Operation canceled\n")); | |
577 } | |
578 | |
579 if (wdata->request->use_threads) | |
580 { | |
581 signal (SIGINT, SIG_DFL); | |
582 signal (SIGALRM, SIG_IGN); | |
583 } | |
584 | |
585 wdata->request->user_data = NULL; | |
586 wdata->request->stopable = 0; | |
587 return ((void *) success); | |
588 } | |
589 | |
590 | |
591 static RETSIGTYPE | |
592 sig_chdirquit (int signo) | |
593 { | |
594 signal (signo, sig_chdirquit); | |
595 siglongjmp (chdirenvir, signo == SIGINT ? 1 : 2); | |
596 } | |
597 | |
598 | |
599 void | |
600 clearlog (gpointer data) | |
601 { | |
602 guint len; | |
603 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
604 len = gtk_text_get_length (GTK_TEXT (logwdw)); | |
605 gtk_text_set_point (GTK_TEXT (logwdw), len); | |
606 gtk_text_backward_delete (GTK_TEXT (logwdw), len); | |
607 #else | |
608 GtkTextBuffer * textbuf; | |
609 GtkTextIter iter, iter2; | |
610 | |
611 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
612 len = gtk_text_buffer_get_char_count (textbuf); | |
613 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
614 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
615 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
616 #endif | |
617 } | |
618 | |
619 | |
620 void | |
621 viewlog (gpointer data) | |
622 { | |
623 char *tempstr, *txt, *pos; | |
624 guint textlen; | |
625 ssize_t len; | |
626 int fd; | |
627 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
628 GtkTextBuffer * textbuf; | |
629 GtkTextIter iter, iter2; | |
630 #endif | |
631 | |
632 tempstr = g_strconcat (tmp_directory, "/gftp-view.XXXXXXXXXX", NULL); | |
633 if ((fd = mkstemp (tempstr)) < 0) | |
634 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
635 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
636 _("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
|
637 g_strerror (errno)); |
1 | 638 g_free (tempstr); |
639 return; | |
640 } | |
641 chmod (tempstr, S_IRUSR | S_IWUSR); | |
642 unlink (tempstr); | |
643 | |
644 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
645 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); | |
646 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
647 #else | |
648 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
649 textlen = gtk_text_buffer_get_char_count (textbuf); | |
650 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
651 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
652 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
653 #endif | |
654 pos = txt; | |
655 do | |
656 { | |
657 if ((len = write (fd, pos, textlen)) == -1) | |
658 { | |
659 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), tempstr, g_strerror (errno)); | |
660 break; | |
661 } | |
662 textlen -= len; | |
663 pos += len; | |
664 } while (textlen > 0); | |
665 | |
666 lseek (fd, 0, SEEK_SET); | |
667 view_file (tempstr, fd, 1, 0, 0, 1, NULL, NULL); | |
668 close (fd); | |
669 g_free (tempstr); | |
670 g_free (txt); | |
671 } | |
672 | |
673 | |
674 static void | |
675 dosavelog (GtkWidget * widget, GtkFileSelection * fs) | |
676 { | |
677 const char *filename; | |
678 char *txt, *pos; | |
679 guint textlen; | |
680 ssize_t len; | |
681 FILE *fd; | |
682 int ok; | |
683 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
684 GtkTextBuffer * textbuf; | |
685 GtkTextIter iter, iter2; | |
686 #endif | |
687 | |
688 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); | |
689 if ((fd = fopen (filename, "w")) == NULL) | |
690 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
691 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
692 _("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
|
693 g_strerror (errno)); |
1 | 694 return; |
695 } | |
696 | |
697 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
698 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); | |
699 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
700 #else | |
701 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
702 textlen = gtk_text_buffer_get_char_count (textbuf); | |
703 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
704 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
705 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
706 #endif | |
707 | |
708 ok = 1; | |
709 pos = txt; | |
710 do | |
711 { | |
712 if ((len = write (fileno (fd), pos, textlen)) == -1) | |
713 { | |
714 ok = 0; | |
715 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), filename, g_strerror (errno)); | |
716 break; | |
717 } | |
718 | |
719 textlen -= len; | |
720 pos += len; | |
721 } while (textlen > 0); | |
722 | |
723 if (ok) | |
724 ftp_log (gftp_logging_misc, NULL, | |
725 _("Successfully wrote the log file to %s\n"), filename); | |
726 | |
727 fclose (fd); | |
728 g_free (txt); | |
729 } | |
730 | |
731 | |
732 void | |
19 | 733 savelog (gpointer data) |
734 { | |
735 GtkWidget *filew; | |
736 | |
737 filew = gtk_file_selection_new (_("Save Log")); | |
738 | |
739 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
740 "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); | |
741 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
742 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
743 GTK_OBJECT (filew)); | |
744 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); | |
745 | |
746 gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); | |
747 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); | |
748 gtk_widget_show (filew); | |
749 } | |
750 | |
751 | |
752 void | |
1 | 753 clear_cache (gpointer data) |
754 { | |
755 gftp_clear_cache_files (); | |
756 } | |
757 | |
758 | |
759 void | |
760 about_dialog (gpointer data) | |
761 { | |
762 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, | |
763 * dialog; | |
764 char *tempstr, *no_license_agreement, *str, buf[255]; | |
765 size_t len; | |
766 FILE * fd; | |
767 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
768 GtkTextBuffer * textbuf; | |
769 GtkTextIter iter; | |
770 guint textlen; | |
771 #endif | |
772 | |
773 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); | |
774 | |
19 | 775 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 |
1 | 776 dialog = gtk_dialog_new (); |
777 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); | |
778 gtk_container_border_width (GTK_CONTAINER | |
779 (GTK_DIALOG (dialog)->action_area), 5); | |
780 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
19 | 781 #else |
782 dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, | |
783 GTK_STOCK_CLOSE, | |
784 GTK_RESPONSE_CLOSE, | |
785 NULL); | |
786 #endif | |
787 gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); | |
1 | 788 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); |
19 | 789 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); |
790 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); | |
1 | 791 gtk_widget_realize (dialog); |
792 | |
19 | 793 if (gftp_icon != NULL) |
794 { | |
795 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | |
796 gftp_icon->bitmap); | |
797 gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); | |
798 } | |
799 | |
1 | 800 notebook = gtk_notebook_new (); |
801 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | |
802 TRUE, 0); | |
803 gtk_widget_show (notebook); | |
804 | |
805 box = gtk_vbox_new (TRUE, 5); | |
806 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
807 gtk_widget_show (box); | |
808 | |
809 tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); | |
810 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
811 gtk_widget_show (tempwid); | |
812 | |
813 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"), | |
814 version); | |
815 str = _("Translated by"); | |
816 if (strcmp (str, "Translated by") != 0) | |
817 { | |
818 tempstr = g_realloc (tempstr, strlen (tempstr) + strlen (str) + 1); | |
819 strcat (tempstr, str); | |
820 } | |
821 tempwid = gtk_label_new (tempstr); | |
822 g_free (tempstr); | |
823 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
824 gtk_widget_show (tempwid); | |
825 | |
826 label = gtk_label_new (_("About")); | |
827 gtk_widget_show (label); | |
828 | |
829 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
830 | |
831 box = gtk_vbox_new (FALSE, 5); | |
832 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
833 gtk_widget_show (box); | |
834 | |
835 tempwid = gtk_table_new (1, 2, FALSE); | |
836 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); | |
837 gtk_widget_show (tempwid); | |
838 | |
839 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
840 view = gtk_text_new (NULL, NULL); | |
841 gtk_text_set_editable (GTK_TEXT (view), FALSE); | |
842 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); | |
843 | |
844 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, | |
845 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
846 0, 0); | |
847 gtk_widget_show (view); | |
848 | |
849 vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); | |
850 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, | |
851 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
852 gtk_widget_show (vscroll); | |
853 #else | |
854 view = gtk_text_view_new (); | |
855 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); | |
856 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); | |
857 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); | |
858 | |
859 vscroll = gtk_scrolled_window_new (NULL, NULL); | |
860 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), | |
861 GTK_POLICY_AUTOMATIC, | |
862 GTK_POLICY_AUTOMATIC); | |
863 | |
864 gtk_container_add (GTK_CONTAINER (vscroll), view); | |
865 gtk_widget_show (view); | |
866 | |
867 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, | |
868 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
869 0, 0); | |
870 gtk_widget_show (vscroll); | |
871 | |
872 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); | |
873 #endif | |
874 | |
875 label = gtk_label_new (_("License Agreement")); | |
876 gtk_widget_show (label); | |
877 | |
878 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
879 | |
19 | 880 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 |
1 | 881 tempwid = gtk_button_new_with_label (_(" Close ")); |
882 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | |
883 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | |
884 FALSE, FALSE, 0); | |
885 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | |
886 GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
887 GTK_OBJECT (dialog)); | |
888 gtk_widget_grab_default (tempwid); | |
889 gtk_widget_show (tempwid); | |
19 | 890 #else |
891 g_signal_connect_swapped (GTK_OBJECT (dialog), "response", | |
892 G_CALLBACK (gtk_widget_destroy), | |
893 GTK_OBJECT (dialog)); | |
894 #endif | |
1 | 895 |
896 tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); | |
897 if (access (tempstr, F_OK) != 0) | |
898 { | |
899 g_free (tempstr); | |
900 tempstr = expand_path (SHARE_DIR "/COPYING"); | |
901 if (access (tempstr, F_OK) != 0) | |
902 { | |
903 g_free (tempstr); | |
904 tempstr = expand_path (BASE_CONF_DIR "/COPYING"); | |
905 if (access (tempstr, F_OK) != 0) | |
906 { | |
907 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
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 return; | |
917 } | |
918 } | |
919 } | |
920 | |
921 if ((fd = fopen (tempstr, "r")) == NULL) | |
922 { | |
923 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
924 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, | |
925 no_license_agreement, -1); | |
926 #else | |
927 textlen = gtk_text_buffer_get_char_count (textbuf); | |
928 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
929 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
930 #endif | |
931 gtk_widget_show (dialog); | |
932 g_free (tempstr); | |
933 return; | |
934 } | |
935 g_free (tempstr); | |
936 | |
937 memset (buf, 0, sizeof (buf)); | |
938 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) | |
939 { | |
940 buf[len] = '\0'; | |
941 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
942 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); | |
943 #else | |
944 textlen = gtk_text_buffer_get_char_count (textbuf); | |
945 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
946 gtk_text_buffer_insert (textbuf, &iter, buf, -1); | |
947 #endif | |
948 } | |
949 fclose (fd); | |
950 gtk_widget_show (dialog); | |
951 g_free (no_license_agreement); | |
952 gftp_free_pixmap ("gftp-logo.xpm"); | |
953 } | |
954 | |
955 | |
956 void | |
957 compare_windows (gpointer data) | |
958 { | |
959 gftp_file * curfle, * otherfle; | |
960 GList * curlist, * otherlist; | |
961 int row; | |
962 | |
963 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
964 return; | |
965 | |
966 deselectall (&window1); | |
967 deselectall (&window2); | |
968 | |
969 row = 0; | |
970 curlist = window1.files; | |
971 while (curlist != NULL) | |
972 { | |
973 curfle = curlist->data; | |
974 if (!curfle->shown) | |
975 { | |
976 curlist = curlist->next; | |
977 continue; | |
978 } | |
979 | |
980 otherlist = window2.files; | |
981 while (otherlist != NULL) | |
982 { | |
983 otherfle = otherlist->data; | |
984 if (!otherfle->shown) | |
985 { | |
986 otherlist = otherlist->next; | |
987 continue; | |
988 } | |
989 | |
990 if (strcmp (otherfle->file, curfle->file) == 0 && | |
991 otherfle->isdir == curfle->isdir && | |
992 (curfle->isdir || otherfle->size == curfle->size)) | |
993 break; | |
994 | |
995 otherlist = otherlist->next; | |
996 } | |
997 | |
998 if (otherlist == NULL) | |
999 gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); | |
1000 row++; | |
1001 curlist = curlist->next; | |
1002 } | |
1003 | |
1004 row = 0; | |
1005 curlist = window2.files; | |
1006 while (curlist != NULL) | |
1007 { | |
1008 curfle = curlist->data; | |
1009 if (!curfle->shown) | |
1010 { | |
1011 curlist = curlist->next; | |
1012 continue; | |
1013 } | |
1014 | |
1015 otherlist = window1.files; | |
1016 while (otherlist != NULL) | |
1017 { | |
1018 otherfle = otherlist->data; | |
1019 if (!otherfle->shown) | |
1020 { | |
1021 otherlist = otherlist->next; | |
1022 continue; | |
1023 } | |
1024 | |
1025 if (strcmp (otherfle->file, curfle->file) == 0 && | |
1026 otherfle->isdir == curfle->isdir && | |
1027 (curfle->isdir || otherfle->size == curfle->size)) | |
1028 break; | |
1029 | |
1030 otherlist = otherlist->next; | |
1031 } | |
1032 | |
1033 if (otherlist == NULL) | |
1034 gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); | |
1035 row++; | |
1036 curlist = curlist->next; | |
1037 } | |
1038 } | |
1039 |