annotate src/gtk/view_dialog.c @ 444:d469882002d9

2004-3-21 Brian Masney <masneyb@gftp.org> * src/gtk/view_dialog.c src/gtk/menu-items.c - cleanups to the view log code
author masneyb
date Sun, 21 Mar 2004 13:22:41 +0000
parents 38bfc112ab46
children 39e9945288ea
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 /* view_dialog.c - view dialog box and ftp routines */
255
2ad324cf4930 2003-8-11 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
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., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include "gftp-gtk.h"
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
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 gftp_file * curfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 view_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28 GList * templist, * filelist, * newfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 gftp_window_data * fromwdata, * towdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30 gftp_file * new_fle;
402
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
31 char *suffix;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
32 int num;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 fromwdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35 towdata = fromwdata == &window1 ? &window2 : &window1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36 if (!check_status (_("View"), fromwdata, 0, 1, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 templist = GTK_CLIST (fromwdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 filelist = fromwdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43 curfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
45 if (curfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
48 _("View: %s is a directory. Cannot view it.\n"), curfle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
49 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
52 if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
53 view_file (curfle->file, 0, 1, 0, 1, 1, NULL, fromwdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 new_fle = copy_fdata (curfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57 if (new_fle->destfile)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58 g_free (new_fle->destfile);
402
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
59
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
60 if ((suffix = strrchr (curfle->file, '.')) != NULL)
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
61 {
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
62 new_fle->destfile = g_strconcat (g_get_tmp_dir (),
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
63 "/gftp-view.XXXXXX", suffix, NULL);
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
64 new_fle->fd = mkstemps (new_fle->destfile, strlen (suffix));
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
65 }
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
66 else
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
67 {
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
68 new_fle->destfile = g_strconcat (g_get_tmp_dir (),
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
69 "/gftp-view.XXXXXX", NULL);
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
70 new_fle->fd = mkstemps (new_fle->destfile, 0);
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
71 }
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
72
57087926bf03 2004-2-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
73 if (new_fle->fd < 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74 {
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 1
diff changeset
75 ftp_log (gftp_logging_misc, NULL,
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 1
diff changeset
76 _("Error: Cannot open %s for writing: %s\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 new_fle->destfile, g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 free_fdata (new_fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
82 fchmod (new_fle->fd, S_IRUSR | S_IWUSR);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 new_fle->is_fd = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85 new_fle->done_view = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 new_fle->done_rm = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87 newfile = g_list_append (NULL, new_fle);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
88 gftpui_common_add_file_transfer (fromwdata->request, towdata->request,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
89 fromwdata, towdata, newfile);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
94 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
95 edit_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
96 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
97 gftp_window_data * fromwdata, * towdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
98 GList * templist, * filelist, * newfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
99 gftp_file * new_fle;
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
100 char *edit_program, *suffix;
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
101 int num;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
102
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 fromwdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104 towdata = fromwdata == &window1 ? &window2 : &window1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 if (!check_status (_("Edit"), fromwdata, 0, 1, 1, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
108 gftp_lookup_request_option (fromwdata->request, "edit_program",
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
109 &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
110
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 if (*edit_program == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 _("Edit: You must specify an editor in the options dialog\n"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 templist = GTK_CLIST (fromwdata->listbox)->selection;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 filelist = fromwdata->files;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 templist = get_next_selection (templist, &filelist, &num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 curfle = filelist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 if (curfle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 _("Edit: %s is a directory. Cannot edit it.\n"), curfle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
131 if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 view_file (curfle->file, 0, 0, 0, 1, 1, NULL, fromwdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 new_fle = copy_fdata (curfle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 if (new_fle->destfile)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 g_free (new_fle->destfile);
422
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
138
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
139 if ((suffix = strrchr (curfle->file, '.')) != NULL)
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
140 {
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
141 new_fle->destfile = g_strconcat (g_get_tmp_dir (),
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
142 "/gftp-view.XXXXXX", suffix, NULL);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
143 new_fle->fd = mkstemps (new_fle->destfile, strlen (suffix));
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
144 }
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
145 else
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
146 {
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
147 new_fle->destfile = g_strconcat (g_get_tmp_dir (),
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
148 "/gftp-view.XXXXXX", NULL);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
149 new_fle->fd = mkstemps (new_fle->destfile, 0);
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
150 }
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
151
38bfc112ab46 2004-3-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 402
diff changeset
152 if (new_fle->fd < 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 {
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 1
diff changeset
154 ftp_log (gftp_logging_misc, NULL,
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 1
diff changeset
155 _("Error: Cannot open %s for writing: %s\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 new_fle->destfile, g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 free_fdata (new_fle);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160
58
c01d91c10f6c 2002-11-20 Brian Masney <masneyb@gftp.org>
masneyb
parents: 48
diff changeset
161 fchmod (new_fle->fd, S_IRUSR | S_IWUSR);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 new_fle->is_fd = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 new_fle->done_edit = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 newfile = g_list_append (NULL, new_fle);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
166 gftpui_common_add_file_transfer (fromwdata->request, towdata->request,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 294
diff changeset
167 fromwdata, towdata, newfile);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
172 static gftp_viewedit_data *
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
173 fork_process (char *proc, char *filename, int fd, char *remote_filename,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
174 int viewedit, int del_file, int dontupload,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
175 gftp_window_data * wdata)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
176 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
177 gftp_viewedit_data * newproc;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
178 char *pos, *endpos, **argv;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
179 pid_t ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
180 int n;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
181
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
182 argv = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
183 n = 0;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
184 pos = proc;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
185 while ((endpos = strchr (pos, ' ')) != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
186 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
187 *endpos = '\0';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
188 n++;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
189 argv = g_realloc (argv, n * sizeof (char *));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
190 argv[n - 1] = g_strdup (pos);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
191 *endpos = ' ';
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
192 pos = endpos + 1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
193 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
194 argv = g_realloc (argv, (n + 3) * sizeof (char *));
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
195 argv[n] = g_strdup (pos);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
196 argv[n + 1] = g_strdup (filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
197 argv[n + 2] = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
198
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
199 newproc = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
200 switch ((ret = fork ()))
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
201 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
202 case 0:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
203 close (fd);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
204 execvp (argv[0], argv);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
205 _exit (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
206 case -1:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
207 for (n = 0; argv[n] != NULL; n++)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
208 g_free (argv[n]);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
209 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
210 _("View: Cannot fork another process: %s\n"), g_strerror (errno));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
211 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
212 default:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
213 ftp_log (gftp_logging_misc, NULL, _("Running program: %s %s\n"), proc,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
214 filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
215 newproc = g_malloc0 (sizeof (*newproc));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
216 newproc->pid = ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
217 newproc->argv = argv;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
218 if (wdata == &window2)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
219 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
220 newproc->fromwdata = &window2;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
221 newproc->towdata = &window1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
222 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
223 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
224 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
225 newproc->fromwdata = &window1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
226 newproc->towdata = &window2;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
227 }
368
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
228 newproc->torequest = gftp_copy_request (newproc->towdata->request);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
229 newproc->filename = g_strdup (filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
230 if (remote_filename != NULL)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
231 newproc->remote_filename = g_strdup (remote_filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
232 newproc->view = viewedit;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
233 newproc->rm = del_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
234 newproc->dontupload = dontupload;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
235 viewedit_processes = g_list_append (viewedit_processes, newproc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
236 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
237 return (newproc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
238 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
239
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
240
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 view_file (char *filename, int fd, int viewedit, int del_file, int start_pos,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 int dontupload, char *remote_filename, gftp_window_data * wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 GtkWidget * dialog, * view, * table, * tempwid;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
246 char buf[8192], *view_program, *edit_program;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
247 gftp_config_list_vars * tmplistvar;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 gftp_file_extensions * tempext;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 gftp_viewedit_data * newproc;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 GtkAdjustment * vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 int stlen, doclose;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 ssize_t n;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
254 #if GTK_MAJOR_VERSION > 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 GtkTextIter iter;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 guint len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 stlen = strlen (filename);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
262 gftp_lookup_global_option ("ext", &tmplistvar);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
263 for (templist = tmplistvar->list; templist != NULL; templist = templist->next)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 tempext = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 if (stlen >= tempext->stlen &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 if (*tempext->view_program == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 ftp_log (gftp_logging_misc, NULL, _("Opening %s with %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 filename, tempext->view_program);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 fork_process (tempext->view_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
279 if (wdata != NULL)
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
280 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
281 gftp_lookup_request_option (wdata->request, "view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
282 gftp_lookup_request_option (wdata->request, "edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
283 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
284 else
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
285 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
286 gftp_lookup_global_option ("view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
287 gftp_lookup_global_option ("edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
288 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
289
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
290 if (viewedit && *view_program != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
291 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
292 /* Open the file with the default file viewer */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
293 fork_process (view_program, filename, fd, remote_filename, viewedit,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
297 else if (!viewedit && *edit_program != '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 /* Open the file with the default file editor */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 newproc = fork_process (edit_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 stat (filename, &newproc->st);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
305
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
306 ftp_log (gftp_logging_misc, NULL, _("Viewing file %s\n"), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308 if (fd == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
309 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 if ((fd = open (filename, O_RDONLY)) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
311 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
313 _("View: Cannot open file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
314 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
315 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 lseek (fd, 0, SEEK_SET);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322 doclose = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325 if (del_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 if (unlink (filename) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328 ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332 _("Error: Could not remove file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
336 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337 dialog = gtk_dialog_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 gtk_window_set_title (GTK_WINDOW (dialog), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 5);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
341 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
342 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
343 dialog = gtk_dialog_new_with_buttons (filename, NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
344 GTK_STOCK_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
345 GTK_RESPONSE_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
346 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
347 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
348 gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
349 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
351 gtk_widget_realize (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
352
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
353 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
354 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
355 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
356 gftp_icon->bitmap);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
357 gdk_window_set_icon_name (dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
358 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360 table = gtk_table_new (1, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
363 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 view = gtk_text_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 gtk_text_set_editable (GTK_TEXT (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 gtk_table_attach (GTK_TABLE (table), view, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373 tempwid = gtk_vscrollbar_new (GTK_TEXT (view)->vadj);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374 gtk_table_attach (GTK_TABLE (table), tempwid, 1, 2, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 vadj = GTK_TEXT (view)->vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 view = gtk_text_view_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385 tempwid = gtk_scrolled_window_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 GTK_POLICY_AUTOMATIC,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 GTK_POLICY_AUTOMATIC);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 gtk_container_add (GTK_CONTAINER (tempwid), view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 gtk_table_attach (GTK_TABLE (table), tempwid, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398 vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 gtk_widget_set_size_request (table, 500, 400);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
403 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 tempwid = gtk_button_new_with_label (_(" Close "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406 FALSE, FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
411 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
412 g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
413 G_CALLBACK (gtk_widget_destroy),
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
414 GTK_OBJECT (dialog));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
415 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417 buf[sizeof (buf) - 1] = '\0';
444
d469882002d9 2004-3-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
418 while ((n = read (fd, buf, sizeof (buf) - 1)) > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
419 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420 buf[n] = '\0';
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
421 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 len = gtk_text_buffer_get_char_count (textbuf);
444
d469882002d9 2004-3-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
426 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len);
d469882002d9 2004-3-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
427 gtk_text_buffer_insert (textbuf, &iter, buf, n);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
428 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
429 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
430
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
431 if (doclose)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
432 close (fd);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
434 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
435
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436 if (!start_pos)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437 gtk_adjustment_set_value (vadj, vadj->upper);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439