annotate src/gtk/view_dialog.c @ 48:e5f6054590b5

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