annotate src/gtk/view_dialog.c @ 885:1808cebed602

2007-3-12 Brian Masney <masneyb@gftp.org> * lib/* src/* - updated copyright dates
author masneyb
date Tue, 13 Mar 2007 01:52:50 +0000
parents 49cfbe02926b
children 14476a8a4d2b
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 */
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 767
diff changeset
3 /* Copyright (C) 1998-2007 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
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 444
diff changeset
45 if (S_ISDIR (curfle->st_mode))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
47 ftp_log (gftp_logging_error, NULL,
1
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 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
75 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
76 _("Error: Cannot open %s for writing: %s\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 new_fle->destfile, g_strerror (errno));
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 588
diff changeset
78 gftp_file_destroy (new_fle, 1);
1
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 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
113 ftp_log (gftp_logging_error, NULL,
1
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
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 444
diff changeset
124 if (S_ISDIR (curfle->st_mode))
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
126 ftp_log (gftp_logging_error, NULL,
1
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 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
154 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
155 _("Error: Cannot open %s for writing: %s\n"),
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 new_fle->destfile, g_strerror (errno));
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 588
diff changeset
157 gftp_file_destroy (new_fle, 1);
1
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,
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
174 unsigned int viewedit, unsigned int del_file,
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
175 unsigned int dontupload, gftp_window_data * wdata)
48
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++;
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
189 argv = g_realloc (argv, (gulong) 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 }
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
194 argv = g_realloc (argv, (gulong) (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
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
242 view_file (char *filename, int fd, unsigned int viewedit, unsigned int del_file,
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
243 unsigned int start_pos, unsigned int dontupload,
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
244 char *remote_filename, gftp_window_data * wdata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 GtkWidget * dialog, * view, * table, * tempwid;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
247 char buf[8192], *view_program, *edit_program;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
248 gftp_config_list_vars * tmplistvar;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 gftp_file_extensions * tempext;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 gftp_viewedit_data * newproc;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 GtkAdjustment * vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 GList * templist;
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
253 size_t stlen;
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
254 int doclose;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 ssize_t n;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
256 #if GTK_MAJOR_VERSION > 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 GtkTextIter iter;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 stlen = strlen (filename);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
263 gftp_lookup_global_option ("ext", &tmplistvar);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
264 for (templist = tmplistvar->list; templist != NULL; templist = templist->next)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 tempext = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 if (stlen >= tempext->stlen &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 if (*tempext->view_program == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 ftp_log (gftp_logging_misc, NULL, _("Opening %s with %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 filename, tempext->view_program);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 fork_process (tempext->view_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
280 if (wdata != NULL)
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
281 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
282 gftp_lookup_request_option (wdata->request, "view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
283 gftp_lookup_request_option (wdata->request, "edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
284 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
285 else
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
286 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
287 gftp_lookup_global_option ("view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
288 gftp_lookup_global_option ("edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
289 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
290
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
291 if (viewedit && *view_program != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
292 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
293 /* Open the file with the default file viewer */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 fork_process (view_program, filename, fd, remote_filename, viewedit,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
298 else if (!viewedit && *edit_program != '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 /* Open the file with the default file editor */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 newproc = fork_process (edit_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 stat (filename, &newproc->st);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
305 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
306
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307 ftp_log (gftp_logging_misc, NULL, _("Viewing file %s\n"), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
309 if (fd == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
311 if ((fd = open (filename, O_RDONLY)) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
313 ftp_log (gftp_logging_error, NULL,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
314 _("View: Cannot open file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
315 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322 lseek (fd, 0, SEEK_SET);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 doclose = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 if (del_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328 if (unlink (filename) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 _("Error: Could not remove file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
337 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 dialog = gtk_dialog_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 gtk_window_set_title (GTK_WINDOW (dialog), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 5);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
342 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
343 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
344 dialog = gtk_dialog_new_with_buttons (filename, NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
345 GTK_STOCK_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
346 GTK_RESPONSE_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
347 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
348 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
349 gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
350 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 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
352 gtk_widget_realize (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
353
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
354 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
355 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
356 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
357 gftp_icon->bitmap);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
358 gdk_window_set_icon_name (dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
359 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 table = gtk_table_new (1, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
364 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 view = gtk_text_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 gtk_text_set_editable (GTK_TEXT (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 gtk_table_attach (GTK_TABLE (table), view, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374 tempwid = gtk_vscrollbar_new (GTK_TEXT (view)->vadj);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375 gtk_table_attach (GTK_TABLE (table), tempwid, 1, 2, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 vadj = GTK_TEXT (view)->vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381 view = gtk_text_view_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 tempwid = gtk_scrolled_window_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 GTK_POLICY_AUTOMATIC,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 GTK_POLICY_AUTOMATIC);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 gtk_container_add (GTK_CONTAINER (tempwid), view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 gtk_table_attach (GTK_TABLE (table), tempwid, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 gtk_widget_set_size_request (table, 500, 400);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
404 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 tempwid = gtk_button_new_with_label (_(" Close "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 FALSE, FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
411 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
412 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
413 g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
414 G_CALLBACK (gtk_widget_destroy),
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
415 GTK_OBJECT (dialog));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
416 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 buf[sizeof (buf) - 1] = '\0';
444
d469882002d9 2004-3-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
419 while ((n = read (fd, buf, sizeof (buf) - 1)) > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
421 buf[n] = '\0';
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
422 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
588
2366865be140 2004-10-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
426 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, -1);
2366865be140 2004-10-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
427 gtk_text_buffer_insert (textbuf, &iter, buf, -1);
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