Mercurial > gftp.yaz
annotate src/gtk/menu-items.c @ 129:fe0b21c006f6
2003-4-13 Brian Masney <masneyb@gftp.org>
* lib/config_file.c - implemented gftp_set_global_option()
* lib/gftp.h lib/misc.c - added gftp_tdata_new()
* src/text/gftp-text.c src/gtk/transfer.c - use gftp_tdata_new()
* src/gtk/bookmarks.c - In run_bookmark(), use gftp_parse_bookmark()
function. Renamed all instances of gftp_bookmarks to
gftp_bookmarks_var
* src/gtk/gftp-gtk.[ch] - added global variables viewedit_processes
and viewedit_processes_done. These used to be declared in
lib/options.h
* src/gtk/gftp-gtk.h (struct gftp_window_data) - removed sortcol and
sortasds variables. Added prefix_col_str variable. This will either be
local or remote
* src/gtk/misc-gtk.c - removed r_gethostbyname() and r_getservbyname()
* src/gtk/transfer.c - removed gftp_gtk_calc_kbs(), get_status() and
parse_attribs(). These are in the lib/ directory now. Also, use
g_static_mutex_*() functions from glib instead of pthread_mutex_*()
* src/gtk/bookmark.c src/gtk/dnd.c src/gtk/menu-items.c
src/gtk/transfer.c - use g_strdup() instead of g_malloc()/strcpy()
* src/gtk/options_dialog.c - commented out large parts of this file.
This file is busted at the moment
* src/gtk/*.[ch] - Use new configuration interface in all source
files. Updated copyright dates on all source files
author | masneyb |
---|---|
date | Sun, 13 Apr 2003 15:21:13 +0000 |
parents | a12bcbc2fce4 |
children | c77f85763e28 |
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: | |
129 | 29 if (window1.request != NULL) |
30 gftp_set_request_option (window1.request, "ascii_transfers", GINT_TO_POINTER(1)); | |
31 | |
32 if (window2.request != NULL) | |
33 gftp_set_request_option (window2.request, "ascii_transfers", GINT_TO_POINTER(1)); | |
1 | 34 break; |
35 case 2: | |
129 | 36 if (window1.request != NULL) |
37 gftp_set_request_option (window1.request, "ascii_transfers", GINT_TO_POINTER(0)); | |
38 | |
39 if (window2.request != NULL) | |
40 gftp_set_request_option (window2.request, "ascii_transfers", GINT_TO_POINTER(0)); | |
1 | 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; | |
47 | 141 gftp_delete_cache_entry (wdata->request, 1); |
1 | 142 gftp_disconnect (wdata->request); |
143 remove_files_window (wdata); | |
144 update_window (wdata); | |
145 } | |
146 | |
147 | |
148 static void | |
19 | 149 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) |
1 | 150 { |
151 GList * templist, * filelist; | |
152 gftp_file * tempfle; | |
153 const char *edttext; | |
154 int num; | |
155 | |
156 wdata->show_selected = 0; | |
157 | |
19 | 158 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); |
1 | 159 if (*edttext == '\0') |
160 { | |
161 ftp_log (gftp_logging_misc, NULL, | |
162 _("Change Filespec: Operation canceled...you must enter a string\n")); | |
163 return; | |
164 } | |
165 if (wdata->filespec) | |
166 g_free (wdata->filespec); | |
129 | 167 wdata->filespec = g_strdup (edttext); |
1 | 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; | |
39 | 361 templist = wdata->files; |
1 | 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 | |
48 | 426 static void * |
427 do_change_dir_thread (void * data) | |
428 { | |
129 | 429 int success, sj, network_timeout; |
48 | 430 gftp_window_data * wdata; |
431 | |
432 wdata = data; | |
433 | |
434 if (wdata->request->use_threads) | |
435 { | |
436 sj = sigsetjmp (jmp_environment, 1); | |
437 use_jmp_environment = 1; | |
438 } | |
439 else | |
440 sj = 0; | |
441 | |
129 | 442 gftp_lookup_request_option (wdata->request, "network_timeout", |
443 &network_timeout); | |
444 | |
48 | 445 success = 0; |
446 if (sj == 0) | |
447 { | |
129 | 448 if (network_timeout > 0) |
449 alarm (network_timeout); | |
48 | 450 success = gftp_set_directory (wdata->request, wdata->request->directory); |
451 alarm (0); | |
452 } | |
453 else | |
454 { | |
455 gftp_disconnect (wdata->request); | |
456 wdata->request->logging_function (gftp_logging_error, | |
457 wdata->request->user_data, | |
458 _("Operation canceled\n")); | |
459 } | |
460 | |
461 if (wdata->request->use_threads) | |
462 use_jmp_environment = 0; | |
463 | |
464 wdata->request->stopable = 0; | |
465 return ((void *) success); | |
466 } | |
467 | |
468 | |
469 static int | |
470 do_change_dir (gftp_window_data * wdata, char *directory) | |
471 { | |
472 char *olddir; | |
473 int ret; | |
474 | |
475 if (directory != wdata->request->directory) | |
476 { | |
477 olddir = wdata->request->directory; | |
129 | 478 wdata->request->directory = g_strdup (directory); |
48 | 479 } |
480 else | |
481 olddir = NULL; | |
482 | |
483 ret = (int) generic_thread (do_change_dir_thread, wdata); | |
484 | |
485 if (!GFTP_IS_CONNECTED (wdata->request)) | |
486 { | |
487 disconnect (wdata); | |
488 if (olddir != NULL) | |
489 g_free (olddir); | |
490 return (-2); | |
491 } | |
492 | |
493 if (ret != 0) | |
494 { | |
495 g_free (wdata->request->directory); | |
496 wdata->request->directory = olddir; | |
497 } | |
498 else | |
499 g_free (olddir); | |
500 | |
501 return (ret); | |
502 } | |
503 | |
504 | |
1 | 505 int |
506 chdir_edit (GtkWidget * widget, gpointer data) | |
507 { | |
508 gftp_window_data * wdata; | |
509 const char *edttxt; | |
510 char *tempstr; | |
511 | |
512 wdata = data; | |
513 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry)); | |
514 if (!GFTP_IS_CONNECTED (wdata->request) && *edttxt != '\0') | |
515 { | |
516 toolbar_hostedit (NULL, NULL); | |
517 return (0); | |
518 } | |
519 | |
520 if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 0, 0, | |
521 wdata->request->chdir != NULL)) | |
522 return (FALSE); | |
523 | |
524 if ((tempstr = expand_path (edttxt)) == NULL) | |
525 return (FALSE); | |
526 | |
527 if (check_reconnect (wdata) < 0) | |
528 return (FALSE); | |
529 | |
530 if (do_change_dir (wdata, tempstr) == 0) | |
531 { | |
532 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
533 remove_files_window (wdata); | |
534 ftp_list_files (wdata, 1); | |
535 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
536 add_history (wdata->combo, wdata->history, wdata->histlen, tempstr); | |
537 } | |
538 | |
539 g_free (tempstr); | |
540 return (FALSE); | |
541 } | |
542 | |
543 | |
544 int | |
545 chdir_dialog (gpointer data) | |
546 { | |
547 GList * templist, * filelist; | |
548 gftp_window_data * wdata; | |
549 char *newdir, *tempstr; | |
550 gftp_file *tempfle; | |
551 int num, ret; | |
552 | |
553 wdata = data; | |
554 if (!check_status (_("Chdir"), wdata, wdata->request->use_threads, 1, 0, | |
555 wdata->request->chdir != NULL)) | |
556 return (0); | |
557 | |
39 | 558 filelist = wdata->files; |
1 | 559 templist = GTK_CLIST (wdata->listbox)->selection; |
560 num = 0; | |
561 templist = get_next_selection (templist, &filelist, &num); | |
562 tempfle = filelist->data; | |
563 | |
129 | 564 newdir = g_strconcat (wdata->request->directory, "/", tempfle->file, NULL); |
1 | 565 remove_double_slashes (newdir); |
566 if ((tempstr = expand_path (newdir)) == NULL) | |
567 return (0); | |
568 g_free (newdir); | |
569 | |
570 if (check_reconnect (wdata) < 0) | |
571 return (0); | |
572 | |
573 ret = 0; | |
574 if (do_change_dir (wdata, tempstr) == 0) | |
575 { | |
576 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
577 remove_files_window (wdata); | |
578 ftp_list_files (wdata, 1); | |
579 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
580 ret = 1; | |
581 } | |
582 g_free (tempstr); | |
583 return (ret); | |
584 } | |
585 | |
586 | |
587 void | |
588 clearlog (gpointer data) | |
589 { | |
590 guint len; | |
45 | 591 #if GTK_MAJOR_VERSION == 1 |
1 | 592 len = gtk_text_get_length (GTK_TEXT (logwdw)); |
593 gtk_text_set_point (GTK_TEXT (logwdw), len); | |
594 gtk_text_backward_delete (GTK_TEXT (logwdw), len); | |
595 #else | |
596 GtkTextBuffer * textbuf; | |
597 GtkTextIter iter, iter2; | |
598 | |
599 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
600 len = gtk_text_buffer_get_char_count (textbuf); | |
601 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
602 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
603 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
604 #endif | |
605 } | |
606 | |
607 | |
608 void | |
609 viewlog (gpointer data) | |
610 { | |
611 char *tempstr, *txt, *pos; | |
612 guint textlen; | |
613 ssize_t len; | |
614 int fd; | |
45 | 615 #if GTK_MAJOR_VERSION > 1 |
1 | 616 GtkTextBuffer * textbuf; |
617 GtkTextIter iter, iter2; | |
618 #endif | |
619 | |
41 | 620 tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL); |
1 | 621 if ((fd = mkstemp (tempstr)) < 0) |
622 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
623 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
624 _("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
|
625 g_strerror (errno)); |
1 | 626 g_free (tempstr); |
627 return; | |
628 } | |
629 chmod (tempstr, S_IRUSR | S_IWUSR); | |
630 unlink (tempstr); | |
631 | |
45 | 632 #if GTK_MAJOR_VERSION == 1 |
1 | 633 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
634 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
635 #else | |
636 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
637 textlen = gtk_text_buffer_get_char_count (textbuf); | |
638 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
639 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
640 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
641 #endif | |
642 pos = txt; | |
643 do | |
644 { | |
645 if ((len = write (fd, pos, textlen)) == -1) | |
646 { | |
647 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), tempstr, g_strerror (errno)); | |
648 break; | |
649 } | |
650 textlen -= len; | |
651 pos += len; | |
652 } while (textlen > 0); | |
653 | |
654 lseek (fd, 0, SEEK_SET); | |
655 view_file (tempstr, fd, 1, 0, 0, 1, NULL, NULL); | |
656 close (fd); | |
657 g_free (tempstr); | |
658 g_free (txt); | |
659 } | |
660 | |
661 | |
662 static void | |
663 dosavelog (GtkWidget * widget, GtkFileSelection * fs) | |
664 { | |
665 const char *filename; | |
666 char *txt, *pos; | |
667 guint textlen; | |
668 ssize_t len; | |
669 FILE *fd; | |
670 int ok; | |
45 | 671 #if GTK_MAJOR_VERSION > 1 |
1 | 672 GtkTextBuffer * textbuf; |
673 GtkTextIter iter, iter2; | |
674 #endif | |
675 | |
676 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); | |
677 if ((fd = fopen (filename, "w")) == NULL) | |
678 { | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
679 ftp_log (gftp_logging_misc, NULL, |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
680 _("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
|
681 g_strerror (errno)); |
1 | 682 return; |
683 } | |
684 | |
45 | 685 #if GTK_MAJOR_VERSION == 1 |
1 | 686 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
687 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
688 #else | |
689 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
690 textlen = gtk_text_buffer_get_char_count (textbuf); | |
691 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
692 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen - 1); | |
693 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | |
694 #endif | |
695 | |
696 ok = 1; | |
697 pos = txt; | |
698 do | |
699 { | |
700 if ((len = write (fileno (fd), pos, textlen)) == -1) | |
701 { | |
702 ok = 0; | |
703 ftp_log (gftp_logging_misc, NULL, _("Error: Error writing to %s: %s\n"), filename, g_strerror (errno)); | |
704 break; | |
705 } | |
706 | |
707 textlen -= len; | |
708 pos += len; | |
709 } while (textlen > 0); | |
710 | |
711 if (ok) | |
712 ftp_log (gftp_logging_misc, NULL, | |
713 _("Successfully wrote the log file to %s\n"), filename); | |
714 | |
715 fclose (fd); | |
716 g_free (txt); | |
717 } | |
718 | |
719 | |
720 void | |
19 | 721 savelog (gpointer data) |
722 { | |
723 GtkWidget *filew; | |
724 | |
725 filew = gtk_file_selection_new (_("Save Log")); | |
726 | |
727 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
728 "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); | |
729 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
730 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
731 GTK_OBJECT (filew)); | |
732 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); | |
733 | |
734 gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); | |
735 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); | |
736 gtk_widget_show (filew); | |
737 } | |
738 | |
739 | |
740 void | |
1 | 741 clear_cache (gpointer data) |
742 { | |
743 gftp_clear_cache_files (); | |
744 } | |
745 | |
746 | |
747 void | |
748 about_dialog (gpointer data) | |
749 { | |
750 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, | |
751 * dialog; | |
752 char *tempstr, *no_license_agreement, *str, buf[255]; | |
753 size_t len; | |
754 FILE * fd; | |
45 | 755 #if GTK_MAJOR_VERSION > 1 |
1 | 756 GtkTextBuffer * textbuf; |
757 GtkTextIter iter; | |
758 guint textlen; | |
759 #endif | |
760 | |
761 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); | |
762 | |
45 | 763 #if GTK_MAJOR_VERSION == 1 |
1 | 764 dialog = gtk_dialog_new (); |
765 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); | |
766 gtk_container_border_width (GTK_CONTAINER | |
767 (GTK_DIALOG (dialog)->action_area), 5); | |
768 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
19 | 769 #else |
770 dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, | |
771 GTK_STOCK_CLOSE, | |
772 GTK_RESPONSE_CLOSE, | |
773 NULL); | |
774 #endif | |
775 gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); | |
1 | 776 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); |
19 | 777 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); |
778 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); | |
1 | 779 gtk_widget_realize (dialog); |
780 | |
19 | 781 if (gftp_icon != NULL) |
782 { | |
783 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | |
784 gftp_icon->bitmap); | |
785 gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); | |
786 } | |
787 | |
1 | 788 notebook = gtk_notebook_new (); |
789 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | |
790 TRUE, 0); | |
791 gtk_widget_show (notebook); | |
792 | |
793 box = gtk_vbox_new (TRUE, 5); | |
794 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
795 gtk_widget_show (box); | |
796 | |
797 tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); | |
798 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
799 gtk_widget_show (tempwid); | |
800 | |
129 | 801 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"), gftp_version); |
1 | 802 str = _("Translated by"); |
803 if (strcmp (str, "Translated by") != 0) | |
804 { | |
805 tempstr = g_realloc (tempstr, strlen (tempstr) + strlen (str) + 1); | |
806 strcat (tempstr, str); | |
807 } | |
808 tempwid = gtk_label_new (tempstr); | |
809 g_free (tempstr); | |
810 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
811 gtk_widget_show (tempwid); | |
812 | |
813 label = gtk_label_new (_("About")); | |
814 gtk_widget_show (label); | |
815 | |
816 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
817 | |
818 box = gtk_vbox_new (FALSE, 5); | |
819 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
820 gtk_widget_show (box); | |
821 | |
822 tempwid = gtk_table_new (1, 2, FALSE); | |
823 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); | |
824 gtk_widget_show (tempwid); | |
825 | |
45 | 826 #if GTK_MAJOR_VERSION == 1 |
1 | 827 view = gtk_text_new (NULL, NULL); |
828 gtk_text_set_editable (GTK_TEXT (view), FALSE); | |
829 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); | |
830 | |
831 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, | |
832 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
833 0, 0); | |
834 gtk_widget_show (view); | |
835 | |
836 vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); | |
837 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, | |
838 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
839 gtk_widget_show (vscroll); | |
840 #else | |
841 view = gtk_text_view_new (); | |
842 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); | |
843 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); | |
844 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); | |
845 | |
846 vscroll = gtk_scrolled_window_new (NULL, NULL); | |
847 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), | |
848 GTK_POLICY_AUTOMATIC, | |
849 GTK_POLICY_AUTOMATIC); | |
850 | |
851 gtk_container_add (GTK_CONTAINER (vscroll), view); | |
852 gtk_widget_show (view); | |
853 | |
854 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, | |
855 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
856 0, 0); | |
857 gtk_widget_show (vscroll); | |
858 | |
859 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); | |
860 #endif | |
861 | |
862 label = gtk_label_new (_("License Agreement")); | |
863 gtk_widget_show (label); | |
864 | |
865 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
866 | |
45 | 867 #if GTK_MAJOR_VERSION == 1 |
1 | 868 tempwid = gtk_button_new_with_label (_(" Close ")); |
869 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | |
870 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | |
871 FALSE, FALSE, 0); | |
872 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | |
873 GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
874 GTK_OBJECT (dialog)); | |
875 gtk_widget_grab_default (tempwid); | |
876 gtk_widget_show (tempwid); | |
19 | 877 #else |
878 g_signal_connect_swapped (GTK_OBJECT (dialog), "response", | |
879 G_CALLBACK (gtk_widget_destroy), | |
880 GTK_OBJECT (dialog)); | |
881 #endif | |
1 | 882 |
883 tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); | |
884 if (access (tempstr, F_OK) != 0) | |
885 { | |
886 g_free (tempstr); | |
887 tempstr = expand_path (SHARE_DIR "/COPYING"); | |
888 if (access (tempstr, F_OK) != 0) | |
889 { | |
890 g_free (tempstr); | |
891 tempstr = expand_path (BASE_CONF_DIR "/COPYING"); | |
892 if (access (tempstr, F_OK) != 0) | |
893 { | |
45 | 894 #if GTK_MAJOR_VERSION == 1 |
1 | 895 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
896 no_license_agreement, -1); | |
897 #else | |
898 textlen = gtk_text_buffer_get_char_count (textbuf); | |
899 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
900 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
901 #endif | |
902 gtk_widget_show (dialog); | |
903 return; | |
904 } | |
905 } | |
906 } | |
907 | |
908 if ((fd = fopen (tempstr, "r")) == NULL) | |
909 { | |
45 | 910 #if GTK_MAJOR_VERSION == 1 |
1 | 911 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
912 no_license_agreement, -1); | |
913 #else | |
914 textlen = gtk_text_buffer_get_char_count (textbuf); | |
915 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
916 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); | |
917 #endif | |
918 gtk_widget_show (dialog); | |
919 g_free (tempstr); | |
920 return; | |
921 } | |
922 g_free (tempstr); | |
923 | |
924 memset (buf, 0, sizeof (buf)); | |
925 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) | |
926 { | |
927 buf[len] = '\0'; | |
45 | 928 #if GTK_MAJOR_VERSION == 1 |
1 | 929 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); |
930 #else | |
931 textlen = gtk_text_buffer_get_char_count (textbuf); | |
932 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen - 1); | |
933 gtk_text_buffer_insert (textbuf, &iter, buf, -1); | |
934 #endif | |
935 } | |
936 fclose (fd); | |
937 gtk_widget_show (dialog); | |
938 g_free (no_license_agreement); | |
939 gftp_free_pixmap ("gftp-logo.xpm"); | |
940 } | |
941 | |
942 | |
943 void | |
944 compare_windows (gpointer data) | |
945 { | |
946 gftp_file * curfle, * otherfle; | |
947 GList * curlist, * otherlist; | |
948 int row; | |
949 | |
950 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
951 return; | |
952 | |
953 deselectall (&window1); | |
954 deselectall (&window2); | |
955 | |
956 row = 0; | |
957 curlist = window1.files; | |
958 while (curlist != NULL) | |
959 { | |
960 curfle = curlist->data; | |
961 if (!curfle->shown) | |
962 { | |
963 curlist = curlist->next; | |
964 continue; | |
965 } | |
966 | |
967 otherlist = window2.files; | |
968 while (otherlist != NULL) | |
969 { | |
970 otherfle = otherlist->data; | |
971 if (!otherfle->shown) | |
972 { | |
973 otherlist = otherlist->next; | |
974 continue; | |
975 } | |
976 | |
977 if (strcmp (otherfle->file, curfle->file) == 0 && | |
978 otherfle->isdir == curfle->isdir && | |
979 (curfle->isdir || otherfle->size == curfle->size)) | |
980 break; | |
981 | |
982 otherlist = otherlist->next; | |
983 } | |
984 | |
985 if (otherlist == NULL) | |
986 gtk_clist_select_row (GTK_CLIST (window1.listbox), row, 0); | |
987 row++; | |
988 curlist = curlist->next; | |
989 } | |
990 | |
991 row = 0; | |
992 curlist = window2.files; | |
993 while (curlist != NULL) | |
994 { | |
995 curfle = curlist->data; | |
996 if (!curfle->shown) | |
997 { | |
998 curlist = curlist->next; | |
999 continue; | |
1000 } | |
1001 | |
1002 otherlist = window1.files; | |
1003 while (otherlist != NULL) | |
1004 { | |
1005 otherfle = otherlist->data; | |
1006 if (!otherfle->shown) | |
1007 { | |
1008 otherlist = otherlist->next; | |
1009 continue; | |
1010 } | |
1011 | |
1012 if (strcmp (otherfle->file, curfle->file) == 0 && | |
1013 otherfle->isdir == curfle->isdir && | |
1014 (curfle->isdir || otherfle->size == curfle->size)) | |
1015 break; | |
1016 | |
1017 otherlist = otherlist->next; | |
1018 } | |
1019 | |
1020 if (otherlist == NULL) | |
1021 gtk_clist_select_row (GTK_CLIST (window2.listbox), row, 0); | |
1022 row++; | |
1023 curlist = curlist->next; | |
1024 } | |
1025 } | |
1026 |