Mercurial > gftp.yaz
annotate src/gtk/menu-items.c @ 992:9c583f570950 default tip
more character set conversion on remote file names.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 15 Sep 2010 11:42:57 +0900 |
parents | 19b6d55e2646 |
children |
rev | line source |
---|---|
1 | 1 /*****************************************************************************/ |
2 /* menu-items.c - menu callbacks */ | |
885 | 3 /* Copyright (C) 1998-2007 Brian Masney <masneyb@gftp.org> */ |
1 | 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 | |
518 | 20 #include "gftp-gtk.h" |
33 | 21 static const char cvsid[] = "$Id$"; |
1 | 22 |
23 static void | |
875 | 24 update_window_listbox (gftp_window_data * wdata) |
1 | 25 { |
26 GList * templist, * filelist; | |
27 gftp_file * tempfle; | |
28 int num; | |
29 | |
30 filelist = wdata->files; | |
525 | 31 templist = gftp_gtk_get_list_selection (wdata); |
1 | 32 num = 0; |
33 while (templist != NULL) | |
34 { | |
35 templist = get_next_selection (templist, &filelist, &num); | |
36 tempfle = filelist->data; | |
37 tempfle->was_sel = 1; | |
38 } | |
39 | |
40 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
41 gtk_clist_clear (GTK_CLIST (wdata->listbox)); | |
42 templist = wdata->files; | |
43 while (templist != NULL) | |
44 { | |
45 tempfle = templist->data; | |
46 add_file_listbox (wdata, tempfle); | |
47 templist = templist->next; | |
48 } | |
49 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
50 update_window (wdata); | |
51 } | |
52 | |
53 | |
875 | 54 static void |
55 dochange_filespec (gftp_window_data * wdata, gftp_dialog_data * ddata) | |
56 { | |
57 const char *edttext; | |
58 | |
59 wdata->show_selected = 0; | |
60 | |
61 edttext = gtk_entry_get_text (GTK_ENTRY (ddata->edit)); | |
62 if (*edttext == '\0') | |
63 { | |
64 ftp_log (gftp_logging_error, NULL, | |
65 _("Change Filespec: Operation canceled...you must enter a string\n")); | |
66 return; | |
67 } | |
68 | |
69 if (wdata->filespec) | |
70 g_free (wdata->filespec); | |
71 | |
72 wdata->filespec = g_strdup (edttext); | |
73 update_window_listbox (wdata); | |
74 } | |
75 | |
76 | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
77 void |
19 | 78 change_filespec (gpointer data) |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
79 { |
19 | 80 gftp_window_data * wdata; |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
81 |
19 | 82 wdata = data; |
83 if (!check_status (_("Change Filespec"), wdata, 0, 0, 0, 1)) | |
84 return; | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
85 |
19 | 86 MakeEditDialog (_("Change Filespec"), _("Enter the new file specification"), |
87 wdata->filespec, 1, NULL, gftp_dialog_button_change, | |
88 dochange_filespec, wdata, NULL, NULL); | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
89 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
90 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
91 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
92 static void |
21 | 93 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
|
94 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
95 gtk_widget_destroy (str->filew); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
96 g_free (str); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
97 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
98 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
99 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
100 static void |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
101 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
|
102 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
103 const char *filename; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
104 gftp_file * tempfle; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
105 GList * templist; |
131 | 106 char *tempstr; |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
107 FILE * fd; |
131 | 108 |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
109 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
110 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
|
111 if ((fd = fopen (filename, "w")) == NULL) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
112 { |
677 | 113 ftp_log (gftp_logging_error, NULL, |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
114 _("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
|
115 g_strerror (errno)); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
116 return; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
117 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
118 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
119 for (templist = str->wdata->files; |
276 | 120 templist != NULL; |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
121 templist = templist->next) |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
122 { |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
123 tempfle = templist->data; |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
124 |
295 | 125 if (!tempfle->shown) |
126 continue; | |
127 | |
830 | 128 tempstr = gftp_gen_ls_string (NULL, tempfle, NULL, NULL); |
131 | 129 fprintf (fd, "%s\n", tempstr); |
130 g_free (tempstr); | |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
131 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
132 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
133 fclose (fd); |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
134 } |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
135 |
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
136 |
19 | 137 void |
138 save_directory_listing (gpointer data) | |
139 { | |
140 gftp_save_dir_struct * str; | |
141 GtkWidget *filew; | |
142 | |
143 filew = gtk_file_selection_new (_("Save Directory Listing")); | |
144 | |
941 | 145 str = g_malloc0 (sizeof (*str)); |
19 | 146 str->filew = filew; |
147 str->wdata = data; | |
148 | |
149 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
150 "clicked", GTK_SIGNAL_FUNC (dosave_directory_listing), | |
151 str); | |
21 | 152 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), |
153 "clicked", | |
154 GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); | |
155 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), | |
156 "clicked", | |
157 GTK_SIGNAL_FUNC (destroy_save_directory_listing), str); | |
19 | 158 |
159 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Directory Listing", "gFTP"); | |
160 gtk_widget_show (filew); | |
161 } | |
162 | |
163 | |
1 | 164 void |
165 show_selected (gpointer data) | |
166 { | |
167 gftp_window_data * wdata; | |
168 | |
169 wdata = data; | |
170 wdata->show_selected = 1; | |
875 | 171 update_window_listbox (wdata); |
1 | 172 } |
173 | |
174 | |
175 void | |
176 selectall (gpointer data) | |
177 { | |
178 gftp_window_data * wdata; | |
179 | |
180 wdata = data; | |
181 wdata->show_selected = 0; | |
182 gtk_clist_select_all (GTK_CLIST (wdata->listbox)); | |
183 } | |
184 | |
185 | |
186 void | |
187 selectallfiles (gpointer data) | |
188 { | |
189 gftp_window_data * wdata; | |
190 gftp_file * tempfle; | |
191 GList *templist; | |
192 int i; | |
193 | |
194 wdata = data; | |
195 wdata->show_selected = 0; | |
196 gtk_clist_freeze (GTK_CLIST (wdata->listbox)); | |
197 i = 0; | |
39 | 198 templist = wdata->files; |
1 | 199 while (templist != NULL) |
200 { | |
201 tempfle = (gftp_file *) templist->data; | |
202 if (tempfle->shown) | |
203 { | |
499 | 204 if (S_ISDIR (tempfle->st_mode)) |
1 | 205 gtk_clist_unselect_row (GTK_CLIST (wdata->listbox), i, 0); |
206 else | |
207 gtk_clist_select_row (GTK_CLIST (wdata->listbox), i, 0); | |
208 i++; | |
209 } | |
210 templist = templist->next; | |
211 } | |
212 gtk_clist_thaw (GTK_CLIST (wdata->listbox)); | |
213 } | |
214 | |
215 | |
216 void | |
217 deselectall (gpointer data) | |
218 { | |
219 gftp_window_data * wdata; | |
220 | |
221 wdata = data; | |
222 wdata->show_selected = 0; | |
223 gtk_clist_unselect_all (GTK_CLIST (wdata->listbox)); | |
224 } | |
225 | |
226 | |
227 int | |
228 chdir_edit (GtkWidget * widget, gpointer data) | |
229 { | |
230 gftp_window_data * wdata; | |
231 const char *edttxt; | |
232 char *tempstr; | |
233 | |
234 wdata = data; | |
445 | 235 if (!check_status (_("Chdir"), wdata, gftpui_common_use_threads (wdata->request), 0, 0, |
341 | 236 wdata->request->chdir != NULL)) |
237 return (0); | |
337 | 238 |
239 if (check_reconnect (wdata) < 0) | |
240 return (0); | |
241 | |
341 | 242 edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry)); |
243 | |
1 | 244 if (!GFTP_IS_CONNECTED (wdata->request) && *edttxt != '\0') |
245 { | |
246 toolbar_hostedit (NULL, NULL); | |
247 return (0); | |
248 } | |
249 | |
555 | 250 if ((tempstr = gftp_expand_path (wdata->request, edttxt)) == NULL) |
1 | 251 return (FALSE); |
252 | |
341 | 253 if (gftpui_run_chdir (wdata, tempstr)) |
254 add_history (wdata->combo, wdata->history, wdata->histlen, edttxt); | |
1 | 255 |
256 g_free (tempstr); | |
341 | 257 return (0); |
1 | 258 } |
259 | |
260 | |
261 void | |
262 clearlog (gpointer data) | |
263 { | |
767 | 264 gint len; |
265 | |
45 | 266 #if GTK_MAJOR_VERSION == 1 |
1 | 267 len = gtk_text_get_length (GTK_TEXT (logwdw)); |
268 gtk_text_set_point (GTK_TEXT (logwdw), len); | |
269 gtk_text_backward_delete (GTK_TEXT (logwdw), len); | |
270 #else | |
271 GtkTextBuffer * textbuf; | |
272 GtkTextIter iter, iter2; | |
273 | |
274 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
275 len = gtk_text_buffer_get_char_count (textbuf); | |
276 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
444 | 277 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len); |
1 | 278 gtk_text_buffer_delete (textbuf, &iter, &iter2); |
279 #endif | |
280 } | |
281 | |
282 | |
283 void | |
284 viewlog (gpointer data) | |
285 { | |
286 char *tempstr, *txt, *pos; | |
767 | 287 gint textlen; |
1 | 288 ssize_t len; |
289 int fd; | |
45 | 290 #if GTK_MAJOR_VERSION > 1 |
1 | 291 GtkTextBuffer * textbuf; |
292 GtkTextIter iter, iter2; | |
293 #endif | |
294 | |
41 | 295 tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL); |
1 | 296 if ((fd = mkstemp (tempstr)) < 0) |
297 { | |
677 | 298 ftp_log (gftp_logging_error, NULL, |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
299 _("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
|
300 g_strerror (errno)); |
1 | 301 g_free (tempstr); |
302 return; | |
303 } | |
304 chmod (tempstr, S_IRUSR | S_IWUSR); | |
305 | |
45 | 306 #if GTK_MAJOR_VERSION == 1 |
1 | 307 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
308 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
309 #else | |
310 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
311 textlen = gtk_text_buffer_get_char_count (textbuf); | |
312 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
444 | 313 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen); |
1 | 314 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); |
588 | 315 |
316 /* gtk_text_buffer_get_char_count() returns the number of characters, | |
317 not bytes. So get the number of bytes that need to be written out */ | |
318 textlen = strlen (txt); | |
1 | 319 #endif |
320 pos = txt; | |
444 | 321 |
322 while (textlen > 0) | |
1 | 323 { |
324 if ((len = write (fd, pos, textlen)) == -1) | |
325 { | |
677 | 326 ftp_log (gftp_logging_error, NULL, |
186 | 327 _("Error: Error writing to %s: %s\n"), |
328 tempstr, g_strerror (errno)); | |
1 | 329 break; |
330 } | |
331 textlen -= len; | |
332 pos += len; | |
444 | 333 } |
1 | 334 |
444 | 335 fsync (fd); |
1 | 336 lseek (fd, 0, SEEK_SET); |
444 | 337 view_file (tempstr, fd, 1, 1, 0, 1, NULL, NULL); |
1 | 338 close (fd); |
444 | 339 |
1 | 340 g_free (tempstr); |
341 g_free (txt); | |
342 } | |
343 | |
344 | |
345 static void | |
346 dosavelog (GtkWidget * widget, GtkFileSelection * fs) | |
347 { | |
348 const char *filename; | |
349 char *txt, *pos; | |
767 | 350 gint textlen; |
1 | 351 ssize_t len; |
352 FILE *fd; | |
353 int ok; | |
45 | 354 #if GTK_MAJOR_VERSION > 1 |
1 | 355 GtkTextBuffer * textbuf; |
356 GtkTextIter iter, iter2; | |
357 #endif | |
358 | |
359 filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); | |
360 if ((fd = fopen (filename, "w")) == NULL) | |
361 { | |
677 | 362 ftp_log (gftp_logging_error, NULL, |
14
83090328581e
* More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents:
1
diff
changeset
|
363 _("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
|
364 g_strerror (errno)); |
1 | 365 return; |
366 } | |
367 | |
45 | 368 #if GTK_MAJOR_VERSION == 1 |
1 | 369 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); |
370 txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); | |
371 #else | |
372 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); | |
373 textlen = gtk_text_buffer_get_char_count (textbuf); | |
374 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
444 | 375 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen); |
1 | 376 txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); |
588 | 377 |
378 /* gtk_text_buffer_get_char_count() returns the number of characters, | |
379 not bytes. So get the number of bytes that need to be written out */ | |
380 textlen = strlen (txt); | |
1 | 381 #endif |
382 | |
383 ok = 1; | |
384 pos = txt; | |
385 do | |
386 { | |
387 if ((len = write (fileno (fd), pos, textlen)) == -1) | |
388 { | |
389 ok = 0; | |
677 | 390 ftp_log (gftp_logging_error, NULL, |
186 | 391 _("Error: Error writing to %s: %s\n"), |
392 filename, g_strerror (errno)); | |
1 | 393 break; |
394 } | |
395 | |
396 textlen -= len; | |
397 pos += len; | |
398 } while (textlen > 0); | |
399 | |
400 if (ok) | |
401 ftp_log (gftp_logging_misc, NULL, | |
402 _("Successfully wrote the log file to %s\n"), filename); | |
403 | |
404 fclose (fd); | |
405 g_free (txt); | |
406 } | |
407 | |
408 | |
409 void | |
19 | 410 savelog (gpointer data) |
411 { | |
412 GtkWidget *filew; | |
413 | |
414 filew = gtk_file_selection_new (_("Save Log")); | |
415 | |
416 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
417 "clicked", GTK_SIGNAL_FUNC (dosavelog), filew); | |
418 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), | |
419 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
420 GTK_OBJECT (filew)); | |
421 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); | |
422 | |
423 gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "gftp.log"); | |
424 gtk_window_set_wmclass (GTK_WINDOW(filew), "Save Log", "gFTP"); | |
425 gtk_widget_show (filew); | |
426 } | |
427 | |
428 | |
429 void | |
1 | 430 clear_cache (gpointer data) |
431 { | |
432 gftp_clear_cache_files (); | |
433 } | |
434 | |
435 | |
436 void | |
437 about_dialog (gpointer data) | |
438 { | |
483 | 439 GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, * dialog; |
440 char *tempstr, *temp1str, *no_license_agreement, *str, buf[255], *share_dir; | |
1 | 441 size_t len; |
442 FILE * fd; | |
45 | 443 #if GTK_MAJOR_VERSION > 1 |
1 | 444 GtkTextBuffer * textbuf; |
445 GtkTextIter iter; | |
767 | 446 gint textlen; |
1 | 447 #endif |
448 | |
483 | 449 share_dir = gftp_get_share_dir (); |
450 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); | |
1 | 451 |
45 | 452 #if GTK_MAJOR_VERSION == 1 |
1 | 453 dialog = gtk_dialog_new (); |
454 gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP")); | |
455 gtk_container_border_width (GTK_CONTAINER | |
456 (GTK_DIALOG (dialog)->action_area), 5); | |
457 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
19 | 458 #else |
459 dialog = gtk_dialog_new_with_buttons (_("About gFTP"), NULL, 0, | |
460 GTK_STOCK_CLOSE, | |
461 GTK_RESPONSE_CLOSE, | |
462 NULL); | |
463 #endif | |
464 gtk_window_set_wmclass (GTK_WINDOW(dialog), "about", "gFTP"); | |
1 | 465 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); |
19 | 466 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); |
467 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5); | |
1 | 468 gtk_widget_realize (dialog); |
469 | |
19 | 470 if (gftp_icon != NULL) |
471 { | |
472 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | |
473 gftp_icon->bitmap); | |
168 | 474 gdk_window_set_icon_name (dialog->window, gftp_version); |
19 | 475 } |
476 | |
1 | 477 notebook = gtk_notebook_new (); |
478 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | |
479 TRUE, 0); | |
480 gtk_widget_show (notebook); | |
481 | |
482 box = gtk_vbox_new (TRUE, 5); | |
483 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
484 gtk_widget_show (box); | |
485 | |
486 tempwid = toolbar_pixmap (dialog, "gftp-logo.xpm"); | |
487 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
488 gtk_widget_show (tempwid); | |
489 | |
885 | 490 tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2007 Brian Masney <masneyb@gftp.org>\nOfficial Homepage: http://www.gftp.org/\n"), gftp_version); |
1 | 491 str = _("Translated by"); |
492 if (strcmp (str, "Translated by") != 0) | |
493 { | |
767 | 494 tempstr = g_realloc (tempstr, |
495 (gulong) (strlen (tempstr) + strlen (str) + 1)); | |
1 | 496 strcat (tempstr, str); |
497 } | |
498 tempwid = gtk_label_new (tempstr); | |
499 g_free (tempstr); | |
500 gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0); | |
501 gtk_widget_show (tempwid); | |
502 | |
503 label = gtk_label_new (_("About")); | |
504 gtk_widget_show (label); | |
505 | |
506 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
507 | |
508 box = gtk_vbox_new (FALSE, 5); | |
509 gtk_container_border_width (GTK_CONTAINER (box), 10); | |
510 gtk_widget_show (box); | |
511 | |
512 tempwid = gtk_table_new (1, 2, FALSE); | |
513 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0); | |
514 gtk_widget_show (tempwid); | |
515 | |
45 | 516 #if GTK_MAJOR_VERSION == 1 |
1 | 517 view = gtk_text_new (NULL, NULL); |
518 gtk_text_set_editable (GTK_TEXT (view), FALSE); | |
519 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE); | |
520 | |
521 gtk_table_attach (GTK_TABLE (tempwid), view, 0, 1, 0, 1, | |
522 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
523 0, 0); | |
524 gtk_widget_show (view); | |
525 | |
526 vscroll = gtk_vscrollbar_new (GTK_TEXT (view)->vadj); | |
527 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 1, 2, 0, 1, | |
528 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); | |
529 gtk_widget_show (vscroll); | |
530 #else | |
531 view = gtk_text_view_new (); | |
532 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); | |
533 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); | |
534 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); | |
535 | |
536 vscroll = gtk_scrolled_window_new (NULL, NULL); | |
537 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (vscroll), | |
538 GTK_POLICY_AUTOMATIC, | |
539 GTK_POLICY_AUTOMATIC); | |
540 | |
541 gtk_container_add (GTK_CONTAINER (vscroll), view); | |
542 gtk_widget_show (view); | |
543 | |
544 gtk_table_attach (GTK_TABLE (tempwid), vscroll, 0, 1, 0, 1, | |
545 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK, | |
546 0, 0); | |
547 gtk_widget_show (vscroll); | |
548 | |
549 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); | |
550 #endif | |
551 | |
552 label = gtk_label_new (_("License Agreement")); | |
553 gtk_widget_show (label); | |
554 | |
555 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label); | |
556 | |
45 | 557 #if GTK_MAJOR_VERSION == 1 |
1 | 558 tempwid = gtk_button_new_with_label (_(" Close ")); |
559 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | |
560 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | |
561 FALSE, FALSE, 0); | |
562 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | |
563 GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
564 GTK_OBJECT (dialog)); | |
565 gtk_widget_grab_default (tempwid); | |
566 gtk_widget_show (tempwid); | |
19 | 567 #else |
568 g_signal_connect_swapped (GTK_OBJECT (dialog), "response", | |
569 G_CALLBACK (gtk_widget_destroy), | |
570 GTK_OBJECT (dialog)); | |
571 #endif | |
1 | 572 |
573 tempstr = g_strconcat ("/usr/share/common-licenses/GPL", NULL); | |
574 if (access (tempstr, F_OK) != 0) | |
575 { | |
576 g_free (tempstr); | |
483 | 577 temp1str = g_strconcat (share_dir, "/COPYING", NULL); |
555 | 578 tempstr = gftp_expand_path (NULL, temp1str); |
483 | 579 g_free (temp1str); |
1 | 580 if (access (tempstr, F_OK) != 0) |
581 { | |
582 g_free (tempstr); | |
555 | 583 tempstr = gftp_expand_path (NULL, BASE_CONF_DIR "/COPYING"); |
1 | 584 if (access (tempstr, F_OK) != 0) |
585 { | |
45 | 586 #if GTK_MAJOR_VERSION == 1 |
1 | 587 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
588 no_license_agreement, -1); | |
589 #else | |
590 textlen = gtk_text_buffer_get_char_count (textbuf); | |
444 | 591 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); |
1 | 592 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); |
593 #endif | |
594 gtk_widget_show (dialog); | |
595 return; | |
596 } | |
597 } | |
598 } | |
599 | |
600 if ((fd = fopen (tempstr, "r")) == NULL) | |
601 { | |
45 | 602 #if GTK_MAJOR_VERSION == 1 |
1 | 603 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, |
604 no_license_agreement, -1); | |
605 #else | |
606 textlen = gtk_text_buffer_get_char_count (textbuf); | |
444 | 607 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); |
1 | 608 gtk_text_buffer_insert (textbuf, &iter, no_license_agreement, -1); |
609 #endif | |
610 gtk_widget_show (dialog); | |
611 g_free (tempstr); | |
612 return; | |
613 } | |
614 g_free (tempstr); | |
615 | |
616 memset (buf, 0, sizeof (buf)); | |
617 while ((len = fread (buf, 1, sizeof (buf) - 1, fd))) | |
618 { | |
619 buf[len] = '\0'; | |
45 | 620 #if GTK_MAJOR_VERSION == 1 |
1 | 621 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1); |
622 #else | |
623 textlen = gtk_text_buffer_get_char_count (textbuf); | |
444 | 624 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, textlen); |
1 | 625 gtk_text_buffer_insert (textbuf, &iter, buf, -1); |
626 #endif | |
627 } | |
628 fclose (fd); | |
629 gtk_widget_show (dialog); | |
630 g_free (no_license_agreement); | |
631 gftp_free_pixmap ("gftp-logo.xpm"); | |
632 } | |
633 | |
634 | |
875 | 635 static void |
636 _do_compare_windows (gftp_window_data * win1, gftp_window_data * win2) | |
1 | 637 { |
638 gftp_file * curfle, * otherfle; | |
639 GList * curlist, * otherlist; | |
499 | 640 int row, curdir, othdir; |
1 | 641 |
642 row = 0; | |
875 | 643 curlist = win1->files; |
1 | 644 while (curlist != NULL) |
645 { | |
646 curfle = curlist->data; | |
647 if (!curfle->shown) | |
648 { | |
649 curlist = curlist->next; | |
650 continue; | |
651 } | |
652 | |
875 | 653 otherlist = win2->files; |
1 | 654 while (otherlist != NULL) |
655 { | |
656 otherfle = otherlist->data; | |
657 if (!otherfle->shown) | |
658 { | |
659 otherlist = otherlist->next; | |
660 continue; | |
661 } | |
662 | |
499 | 663 curdir = S_ISDIR (curfle->st_mode); |
664 othdir = S_ISDIR (otherfle->st_mode); | |
665 | |
1 | 666 if (strcmp (otherfle->file, curfle->file) == 0 && |
499 | 667 curdir == othdir && |
668 (curdir || otherfle->size == curfle->size)) | |
1 | 669 break; |
670 | |
671 otherlist = otherlist->next; | |
672 } | |
673 | |
674 if (otherlist == NULL) | |
875 | 675 gtk_clist_select_row (GTK_CLIST (win1->listbox), row, 0); |
1 | 676 row++; |
677 curlist = curlist->next; | |
678 } | |
679 } | |
875 | 680 |
681 | |
682 void | |
683 compare_windows (gpointer data) | |
684 { | |
685 if (!check_status (_("Compare Windows"), &window2, 1, 0, 0, 1)) | |
686 return; | |
687 | |
688 deselectall (&window1); | |
689 deselectall (&window2); | |
690 | |
691 _do_compare_windows (&window1, &window2); | |
692 _do_compare_windows (&window2, &window1); | |
693 } |