Mercurial > gftp.yaz
annotate src/gtk/menu-items.c @ 19:3b2dcdefc7e9
2002-09-15 Brian Masney <masneyb@gftp.org>
* lib/gftp.h (struct gftp_transfer) - changed the type of numfiles and
numdirs from unsigned long to long. This must be a signed field. This
is a bug I introduced a few days ago.
* lib/local.c (local_put_file) - remove the + off of the ab mode to
fdopen. This is also a bug I introduced a few days ago.
* src/gtk/transfer.c (gftp_gtk_calc_kbs) - make sure that the variable
difftime isn't a negative number when computing the KB/s
* src/gtk/menu-items.c (save_directory_listing) - remove casts to
GTK_OBJECT for the str variable
* src/gtk/gftp-gtk.c - use GTK_STOCK_* icons in place of left.xpm,
right.xpm, up.xpm, down.xpm and stop.xpm in GTK+ 2.0 port
* src/gtk/bookmarks.c - show GTK_STOCK_* icons on the popup menu
* src/gtk/bookmarks.c, src/gtk/chmod_dialog.c, src/gtk/menu-items.c,
src/gtk/misc-gtk.c, src/gtk/options_dialog.c and
src/gtk/view_dialog.c - use gtk_dialog_new_with_buttons in GTK+ 2.0
port to create the dialog. Also, associate gFTP icon with this dialog
* src/gtk/misc-gtk.c - changed the interface of MakeEditDialog and
MakeYesNoDialog. In the GTK+ 2.0 port, I now use stock icons in the
dialog buttons.
author | masneyb |
---|---|
date | Mon, 16 Sep 2002 12:27:50 +0000 |
parents | 83090328581e |
children | 4b244bf9d84d |
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 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
208 destroy_save_directory_listing (gftp_save_dir_struct * str) |
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); | |
290 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
291 "clicked", | |
292 GTK_SIGNAL_FUNC (destroy_save_directory_listing), | |
293 str); | |
294 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); | |
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; | |
359 templist = g_list_first (wdata->files); | |
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 | |
477 filelist = g_list_first (wdata->files); | |
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 { | |
555 sj = sigsetjmp (chdirenvir, 1); | |
556 signal (SIGINT, sig_chdirquit); | |
557 signal (SIGALRM, sig_chdirquit); | |
558 } | |
559 else | |
560 sj = 0; | |
561 | |
562 success = 0; | |
563 if (sj == 0) | |
564 { | |
565 if (wdata->request->network_timeout > 0) | |
566 alarm (wdata->request->network_timeout); | |
567 success = gftp_set_directory (wdata->request, wdata->request->directory); | |
568 alarm (0); | |
569 } | |
570 else | |
571 { | |
572 gftp_disconnect (wdata->request); | |
573 wdata->request->logging_function (gftp_logging_error, | |
574 wdata->request->user_data, | |
575 _("Operation canceled\n")); | |
576 } | |
577 | |
578 if (wdata->request->use_threads) | |
579 { | |
580 signal (SIGINT, SIG_DFL); | |
581 signal (SIGALRM, SIG_IGN); | |
582 } | |
583 | |
584 wdata->request->user_data = NULL; | |
585 wdata->request->stopable = 0; | |
586 return ((void *) success); | |
587 } | |
588 | |
589 | |
590 static RETSIGTYPE | |
591 sig_chdirquit (int signo) | |
592 { | |
593 signal (signo, sig_chdirquit); | |
594 siglongjmp (chdirenvir, signo == SIGINT ? 1 : 2); | |
595 } | |
596 | |
597 | |
598 void | |
599 clearlog (gpointer data) | |
600 { | |
601 guint len; | |
602 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
603 len = gtk_text_get_length (GTK_TEXT (logwdw)); | |
604 gtk_text_set_point (GTK_TEXT (logwdw), len); | |
605 gtk_text_backward_delete (GTK_TEXT (logwdw), len); | |
606 #else | |
607 GtkTextBuffer * textbuf; | |
608 GtkTextIter iter, iter2; | |
609 | |
610 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
611 len = gtk_text_buffer_get_char_count (textbuf); | |
612 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
613 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
614 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
615 #endif | |
616 } | |
617 | |
618 | |
619 void | |
620 viewlog (gpointer data) | |
621 { | |
622 char *tempstr, *txt, *pos; | |
623 guint textlen; | |
624 ssize_t len; | |
625 int fd; | |
626 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
627 GtkTextBuffer * textbuf; | |
628 GtkTextIter iter, iter2; | |
629 #endif | |
630 | |
631 tempstr = g_strconcat (tmp_directory, "/gftp-view.XXXXXXXXXX", NULL); | |
632 if ((fd = mkstemp (tempstr)) < 0) | |
633 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
634 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
635 _("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
|
636 g_strerror (errno)); |
1 | 637 g_free (tempstr); |
638 return; | |
639 } | |
640 chmod (tempstr, S_IRUSR | S_IWUSR); | |
641 unlink (tempstr); | |
642 | |
643 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
644 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); | |
645 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
646 #else | |
647 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
648 textlen = gtk_text_buffer_get_char_count (textbuf); | |
649 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
650 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
651 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
652 #endif | |
653 pos = txt; | |
654 do | |
655 { | |
656 if ((len = write (fd, pos, textlen)) == -1) | |
657 { | |
658 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), tempstr, g_strerror (errno)); | |
659 break; | |
660 } | |
661 textlen -= len; | |
662 pos += len; | |
663 } while (textlen > 0); | |
664 | |
665 lseek (fd, 0, SEEK_SET); | |
666 view_file (tempstr, fd, 1, 0, 0, 1, NULL, NULL); | |
667 close (fd); | |
668 g_free (tempstr); | |
669 g_free (txt); | |
670 } | |
671 | |
672 | |
673 static void | |
674 dosavelog (GtkWidget * widget, GtkFileSelection * fs) | |
675 { | |
676 const char *filename; | |
677 char *txt, *pos; | |
678 guint textlen; | |
679 ssize_t len; | |
680 FILE *fd; | |
681 int ok; | |
682 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
683 GtkTextBuffer * textbuf; | |
684 GtkTextIter iter, iter2; | |
685 #endif | |
686 | |
687 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); | |
688 if ((fd = fopen (filename, "w")) == NULL) | |
689 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
690 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
691 _("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
|
692 g_strerror (errno)); |
1 | 693 return; |
694 } | |
695 | |
696 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
697 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); | |
698 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
699 #else | |
700 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
701 textlen = gtk_text_buffer_get_char_count (textbuf); | |
702 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
703 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
704 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
705 #endif | |
706 | |
707 ok = 1; | |
708 pos = txt; | |
709 do | |
710 { | |
711 if ((len = write (fileno (fd), pos, textlen)) == -1) | |
712 { | |
713 ok = 0; | |
714 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), filename, g_strerror (errno)); | |
715 break; | |
716 } | |
717 | |
718 textlen -= len; | |
719 pos += len; | |
720 } while (textlen > 0); | |
721 | |
722 if (ok) | |
723 ftp_log (gftp_logging_misc, NULL, | |
724 _("Successfully wrote the log file to %s\n"), filename); | |
725 | |
726 fclose (fd); | |
727 g_free (txt); | |
728 } | |
729 | |
730 | |
731 void | |
19 | 732 savelog (gpointer data) |
733 { | |
734 GtkWidget *filew; | |
735 | |
736 filew = gtk_file_selection_new (_("Save Log")); | |
737 | |
738 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
739 "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); | |
740 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
741 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
742 GTK_OBJECT (filew)); | |
743 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); | |
744 | |
745 gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); | |
746 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); | |
747 gtk_widget_show (filew); | |
748 } | |
749 | |
750 | |
751 void | |
1 | 752 clear_cache (gpointer data) |
753 { | |
754 gftp_clear_cache_files (); | |
755 } | |
756 | |
757 | |
758 void | |
759 about_dialog (gpointer data) | |
760 { | |
761 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, | |
762 * dialog; | |
763 char *tempstr, *no_license_agreement, *str, buf[255]; | |
764 size_t len; | |
765 FILE * fd; | |
766 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2) | |
767 GtkTextBuffer * textbuf; | |
768 GtkTextIter iter; | |
769 guint textlen; | |
770 #endif | |
771 | |
772 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); | |
773 | |
19 | 774 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 |
1 | 775 dialog = gtk_dialog_new (); |
776 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); | |
777 gtk_container_border_width (GTK_CONTAINER | |
778 (GTK_DIALOG (dialog)->action_area), 5); | |
779 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
19 | 780 #else |
781 dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, | |
782 GTK_STOCK_CLOSE, | |
783 GTK_RESPONSE_CLOSE, | |
784 NULL); | |
785 #endif | |
786 gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); | |
1 | 787 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); |
19 | 788 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); |
789 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); | |
1 | 790 gtk_widget_realize (dialog); |
791 | |
19 | 792 if (gftp_icon != NULL) |
793 { | |
794 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | |
795 gftp_icon->bitmap); | |
796 gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); | |
797 } | |
798 | |
1 | 799 notebook = gtk_notebook_new (); |
800 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | |
801 TRUE, 0); | |
802 gtk_widget_show (notebook); | |
803 | |
804 box = gtk_vbox_new (TRUE, 5); | |
805 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
806 gtk_widget_show (box); | |
807 | |
808 tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); | |
809 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
810 gtk_widget_show (tempwid); | |
811 | |
812 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"), | |
813 version); | |
814 str = _("Translated by"); | |
815 if (strcmp (str, "Translated by") != 0) | |
816 { | |
817 tempstr = g_realloc (tempstr, strlen (tempstr) + strlen (str) + 1); | |
818 strcat (tempstr, str); | |
819 } | |
820 tempwid = gtk_label_new (tempstr); | |
821 g_free (tempstr); | |
822 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
823 gtk_widget_show (tempwid); | |
824 | |
825 label = gtk_label_new (_("About")); | |
826 gtk_widget_show (label); | |
827 | |
828 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
829 | |
830 box = gtk_vbox_new (FALSE, 5); | |
831 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
832 gtk_widget_show (box); | |
833 | |
834 tempwid = gtk_table_new (1, 2, FALSE); | |
835 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); | |
836 gtk_widget_show (tempwid); | |
837 | |
838 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
839 view = gtk_text_new (NULL, NULL); | |
840 gtk_text_set_editable (GTK_TEXT (view), FALSE); | |
841 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); | |
842 | |
843 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, | |
844 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
845 0, 0); | |
846 gtk_widget_show (view); | |
847 | |
848 vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); | |
849 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, | |
850 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
851 gtk_widget_show (vscroll); | |
852 #else | |
853 view = gtk_text_view_new (); | |
854 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); | |
855 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); | |
856 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); | |
857 | |
858 vscroll = gtk_scrolled_window_new (NULL, NULL); | |
859 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), | |
860 GTK_POLICY_AUTOMATIC, | |
861 GTK_POLICY_AUTOMATIC); | |
862 | |
863 gtk_container_add (GTK_CONTAINER (vscroll), view); | |
864 gtk_widget_show (view); | |
865 | |
866 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, | |
867 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
868 0, 0); | |
869 gtk_widget_show (vscroll); | |
870 | |
871 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); | |
872 #endif | |
873 | |
874 label = gtk_label_new (_("License Agreement")); | |
875 gtk_widget_show (label); | |
876 | |
877 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
878 | |
19 | 879 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 |
1 | 880 tempwid = gtk_button_new_with_label (_(" Close ")); |
881 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | |
882 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | |
883 FALSE, FALSE, 0); | |
884 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | |
885 GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
886 GTK_OBJECT (dialog)); | |
887 gtk_widget_grab_default (tempwid); | |
888 gtk_widget_show (tempwid); | |
19 | 889 #else |
890 g_signal_connect_swapped (GTK_OBJECT (dialog), "response", | |
891 G_CALLBACK (gtk_widget_destroy), | |
892 GTK_OBJECT (dialog)); | |
893 #endif | |
1 | 894 |
895 tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); | |
896 if (access (tempstr, F_OK) != 0) | |
897 { | |
898 g_free (tempstr); | |
899 tempstr = expand_path (SHARE_DIR "/COPYING"); | |
900 if (access (tempstr, F_OK) != 0) | |
901 { | |
902 g_free (tempstr); | |
903 tempstr = expand_path (BASE_CONF_DIR "/COPYING"); | |
904 if (access (tempstr, F_OK) != 0) | |
905 { | |
906 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
907 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, | |
908 no_license_agreement, -1); | |
909 #else | |
910 textlen = gtk_text_buffer_get_char_count (textbuf); | |
911 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
912 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
913 #endif | |
914 gtk_widget_show (dialog); | |
915 return; | |
916 } | |
917 } | |
918 } | |
919 | |
920 if ((fd = fopen (tempstr, "r")) == NULL) | |
921 { | |
922 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
923 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, | |
924 no_license_agreement, -1); | |
925 #else | |
926 textlen = gtk_text_buffer_get_char_count (textbuf); | |
927 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
928 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
929 #endif | |
930 gtk_widget_show (dialog); | |
931 g_free (tempstr); | |
932 return; | |
933 } | |
934 g_free (tempstr); | |
935 | |
936 memset (buf, 0, sizeof (buf)); | |
937 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) | |
938 { | |
939 buf[len] = '\0'; | |
940 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2 | |
941 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); | |
942 #else | |
943 textlen = gtk_text_buffer_get_char_count (textbuf); | |
944 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
945 gtk_text_buffer_insert (textbuf, &iter, buf, -1); | |
946 #endif | |
947 } | |
948 fclose (fd); | |
949 gtk_widget_show (dialog); | |
950 g_free (no_license_agreement); | |
951 gftp_free_pixmap ("gftp-logo.xpm"); | |
952 } | |
953 | |
954 | |
955 void | |
956 compare_windows (gpointer data) | |
957 { | |
958 gftp_file * curfle, * otherfle; | |
959 GList * curlist, * otherlist; | |
960 int row; | |
961 | |
962 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
963 return; | |
964 | |
965 deselectall (&window1); | |
966 deselectall (&window2); | |
967 | |
968 row = 0; | |
969 curlist = window1.files; | |
970 while (curlist != NULL) | |
971 { | |
972 curfle = curlist->data; | |
973 if (!curfle->shown) | |
974 { | |
975 curlist = curlist->next; | |
976 continue; | |
977 } | |
978 | |
979 otherlist = window2.files; | |
980 while (otherlist != NULL) | |
981 { | |
982 otherfle = otherlist->data; | |
983 if (!otherfle->shown) | |
984 { | |
985 otherlist = otherlist->next; | |
986 continue; | |
987 } | |
988 | |
989 if (strcmp (otherfle->file, curfle->file) == 0 && | |
990 otherfle->isdir == curfle->isdir && | |
991 (curfle->isdir || otherfle->size == curfle->size)) | |
992 break; | |
993 | |
994 otherlist = otherlist->next; | |
995 } | |
996 | |
997 if (otherlist == NULL) | |
998 gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); | |
999 row++; | |
1000 curlist = curlist->next; | |
1001 } | |
1002 | |
1003 row = 0; | |
1004 curlist = window2.files; | |
1005 while (curlist != NULL) | |
1006 { | |
1007 curfle = curlist->data; | |
1008 if (!curfle->shown) | |
1009 { | |
1010 curlist = curlist->next; | |
1011 continue; | |
1012 } | |
1013 | |
1014 otherlist = window1.files; | |
1015 while (otherlist != NULL) | |
1016 { | |
1017 otherfle = otherlist->data; | |
1018 if (!otherfle->shown) | |
1019 { | |
1020 otherlist = otherlist->next; | |
1021 continue; | |
1022 } | |
1023 | |
1024 if (strcmp (otherfle->file, curfle->file) == 0 && | |
1025 otherfle->isdir == curfle->isdir && | |
1026 (curfle->isdir || otherfle->size == curfle->size)) | |
1027 break; | |
1028 | |
1029 otherlist = otherlist->next; | |
1030 } | |
1031 | |
1032 if (otherlist == NULL) | |
1033 gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); | |
1034 row++; | |
1035 curlist = curlist->next; | |
1036 } | |
1037 } | |
1038 |