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