annotate src/gtk/menu-items.c @ 767:49cfbe02926b

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