annotate src/gtk/view_dialog.c @ 894:14476a8a4d2b

2007-3-15 Brian Masney <masneyb@gftp.org> * src/gtk/transfer.c src/gtk/view_dialog.c - combined some duplicate code that was used to view and edit files. * lib/gftp.h src/gtk/transfer.c src/gtk/view_dialog.c src/uicommon/gftpui.c - removed is_fd member from the gftp_file structure.
author masneyb
date Fri, 16 Mar 2007 02:33:05 +0000
parents 1808cebed602
children c2be64b831d9
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);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
155 argv[n + 1] = g_strdup (filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
156 argv[n + 2] = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
157
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
158 newproc = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
159 switch ((ret = fork ()))
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 case 0:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
162 close (fd);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
163 execvp (argv[0], argv);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
164 _exit (1);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
165 case -1:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
166 for (n = 0; argv[n] != NULL; n++)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
167 g_free (argv[n]);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
168 ftp_log (gftp_logging_error, NULL,
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
169 _("View: Cannot fork another process: %s\n"), g_strerror (errno));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
170 break;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
171 default:
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
172 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
173 filename);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
174 newproc = g_malloc0 (sizeof (*newproc));
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
175 newproc->pid = ret;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
176 newproc->argv = argv;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
177 if (wdata == &window2)
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 newproc->fromwdata = &window2;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
180 newproc->towdata = &window1;
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 else
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
183 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
184 newproc->fromwdata = &window1;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
185 newproc->towdata = &window2;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
186 }
368
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
187 newproc->torequest = gftp_copy_request (newproc->towdata->request);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
188 newproc->filename = g_strdup (filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
189 if (remote_filename != NULL)
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
190 newproc->remote_filename = g_strdup (remote_filename);
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
191 newproc->view = viewedit;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
192 newproc->rm = del_file;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
193 newproc->dontupload = dontupload;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
194 viewedit_processes = g_list_append (viewedit_processes, newproc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
195 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
196 return (newproc);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 45
diff changeset
197 }
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
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 void
767
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
201 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
202 unsigned int start_pos, unsigned int dontupload,
49cfbe02926b 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
203 char *remote_filename, gftp_window_data * wdata)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 GtkWidget * dialog, * view, * table, * tempwid;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
206 char buf[8192], *view_program, *edit_program;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
207 gftp_config_list_vars * tmplistvar;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 gftp_file_extensions * tempext;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 gftp_viewedit_data * newproc;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 GtkAdjustment * vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 GList * templist;
521
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
212 size_t stlen;
739afd9df73c 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 499
diff changeset
213 int doclose;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 ssize_t n;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
215 #if GTK_MAJOR_VERSION > 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 GtkTextIter iter;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 stlen = strlen (filename);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
222 gftp_lookup_global_option ("ext", &tmplistvar);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
223 for (templist = tmplistvar->list; templist != NULL; templist = templist->next)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 tempext = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 if (stlen >= tempext->stlen &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 strcmp (&filename[stlen - tempext->stlen], tempext->ext) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 if (*tempext->view_program == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 ftp_log (gftp_logging_misc, NULL, _("Opening %s with %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 filename, tempext->view_program);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 fork_process (tempext->view_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
239 if (wdata != NULL)
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
240 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
241 gftp_lookup_request_option (wdata->request, "view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
242 gftp_lookup_request_option (wdata->request, "edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
243 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
244 else
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
245 {
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
246 gftp_lookup_global_option ("view_program", &view_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
247 gftp_lookup_global_option ("edit_program", &edit_program);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
248 }
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
249
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 if (viewedit && *view_program != '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 /* Open the file with the default file viewer */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 fork_process (view_program, filename, fd, remote_filename, viewedit,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 58
diff changeset
257 else if (!viewedit && *edit_program != '\0')
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 /* Open the file with the default file editor */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 newproc = fork_process (edit_program, filename, fd, remote_filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 viewedit, del_file, dontupload, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 stat (filename, &newproc->st);
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 ftp_log (gftp_logging_misc, NULL, _("Viewing file %s\n"), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 if (fd == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 if ((fd = open (filename, O_RDONLY)) < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
272 ftp_log (gftp_logging_error, NULL,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 _("View: Cannot open file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 doclose = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281 lseek (fd, 0, SEEK_SET);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282 doclose = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
284
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
285 if (del_file)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
286 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
287 if (unlink (filename) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
288 ftp_log (gftp_logging_misc, NULL, _("Successfully removed %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
289 filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
290 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
291 ftp_log (gftp_logging_error, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
292 _("Error: Could not remove file %s: %s\n"), filename,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
293 g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
296 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297 dialog = gtk_dialog_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 gtk_window_set_title (GTK_WINDOW (dialog), filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 5);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
301 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
302 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
303 dialog = gtk_dialog_new_with_buttons (filename, NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
304 GTK_STOCK_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
305 GTK_RESPONSE_CLOSE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
306 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
307 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
308 gtk_window_set_wmclass (GTK_WINDOW(dialog), "fileview", "gFTP");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
309 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 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
311 gtk_widget_realize (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
312
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
313 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
314 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
315 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
316 gftp_icon->bitmap);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
317 gdk_window_set_icon_name (dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
318 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 table = gtk_table_new (1, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
323 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 view = gtk_text_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325 gtk_text_set_editable (GTK_TEXT (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328 gtk_table_attach (GTK_TABLE (table), view, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 tempwid = gtk_vscrollbar_new (GTK_TEXT (view)->vadj);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 gtk_table_attach (GTK_TABLE (table), tempwid, 1, 2, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 vadj = GTK_TEXT (view)->vadj;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 view = gtk_text_view_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
342 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
343 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
344
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
345 tempwid = gtk_scrolled_window_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
346 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 GTK_POLICY_AUTOMATIC,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
348 GTK_POLICY_AUTOMATIC);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
349
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350 gtk_container_add (GTK_CONTAINER (tempwid), view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 gtk_widget_show (view);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 gtk_table_attach (GTK_TABLE (table), tempwid, 0, 1, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tempwid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360 gtk_widget_set_size_request (table, 500, 400);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
363 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 tempwid = gtk_button_new_with_label (_(" Close "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 FALSE, FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
371 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
372 g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
373 G_CALLBACK (gtk_widget_destroy),
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
374 GTK_OBJECT (dialog));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
375 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 buf[sizeof (buf) - 1] = '\0';
444
d469882002d9 2004-3-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 422
diff changeset
378 while ((n = read (fd, buf, sizeof (buf) - 1)) > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 buf[n] = '\0';
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
381 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 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
385 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, -1);
2366865be140 2004-10-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 521
diff changeset
386 gtk_text_buffer_insert (textbuf, &iter, buf, -1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 if (doclose)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 close (fd);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 if (!start_pos)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 gtk_adjustment_set_value (vadj, vadj->upper);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398