annotate src/gtk/view_dialog.c @ 992:9c583f570950 default tip

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