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