annotate src/gtk/misc-gtk.c @ 195:3fa7b4f4ab78

2003-6-19 Brian Masney <masneyb@gftp.org> * autogen.sh - updated to hopefully make it more portable across various systems * lib/rfc959.c - change variable type of data_addr_len from size_t to socklen_t (fixed warnings on 64 bit machines) * src/gtk/chmod_dialog.c src/gtk/gftp-gtk.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/options_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c - rather than casting from integer to pointer and vice versa, use GINT_TO_POINTER and GPOINTER_TO_INT. These macros do the exact same thing and I'm still getting compiler warnings on Debian Sparc64 with -m64, but at least I'll be able to fix the define in glib and then these warnings will be fixed then
author masneyb
date Fri, 20 Jun 2003 01:39:44 +0000
parents 876747813a60
children 8fea1b1a2ec6
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 /* misc-gtk.c - misc stuff for the gtk+ 1.2 port of gftp */
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., 675 Mass Ave, Cambridge, MA 02139, 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: 31
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 GtkWidget * statuswid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27 remove_files_window (gftp_window_data * wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 wdata->show_selected = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31 gtk_clist_clear (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32 free_file_list (wdata->files);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33 wdata->files = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 void
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
39 ftp_log (gftp_logging_level level, gftp_request * request,
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
40 const char *string, ...)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
42 guint max_log_window_size;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
43 int upd, free_logstr;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44 gftp_log * newlog;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
45 char *logstr;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 gint delsize;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47 va_list argp;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
48 guint len;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
49 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50 gftp_color * color;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51 GdkColor fore;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52 #else
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
53 char *utf8_str;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55 GtkTextIter iter, iter2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 const char *descr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
59 va_start (argp, string);
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
60 if (strcmp (string, "%s") == 0)
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
61 {
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
62 logstr = va_arg (argp, char *);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
63 free_logstr = 0;
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
64 }
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
65 else
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
66 {
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
67 logstr = g_strdup_vprintf (string, argp);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
68 free_logstr = 1;
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
69 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 va_end (argp);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
72 #if GTK_MAJOR_VERSION > 1
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
73 if (!g_utf8_validate (logstr, -1, NULL))
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
74 {
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
75 if ((utf8_str = gftp_string_to_utf8 (request, logstr)) != NULL)
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
76 {
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
77 if (free_logstr)
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
78 g_free (logstr);
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
79 else
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
80 free_logstr = 1;
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
81
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
82 logstr = utf8_str;
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
83 }
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
84 }
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
85 #endif
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
86
190
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
87 if (pthread_self () != main_thread_id)
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
88 {
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
89 newlog = g_malloc0 (sizeof (*newlog));
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
90 newlog->type = level;
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
91 if (free_logstr)
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
92 newlog->msg = logstr;
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
93 else
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
94 newlog->msg = g_strdup (logstr);
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
95
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
96 pthread_mutex_lock (&log_mutex);
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
97 gftp_file_transfer_logs = g_list_append (gftp_file_transfer_logs, newlog);
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
98 pthread_mutex_unlock (&log_mutex);
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
99 return;
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
100 }
876747813a60 2003-6-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 186
diff changeset
101
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
102 if (gftp_logfd != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
103 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
104 if (fwrite (logstr, strlen (logstr), 1, gftp_logfd) != 1)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
106 fclose (gftp_logfd);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
107 gftp_logfd = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109 else
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
110 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
111 fflush (gftp_logfd);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
112 if (ferror (gftp_logfd))
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
113 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
114 fclose (gftp_logfd);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
115 gftp_logfd = NULL;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
116 }
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
117 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 upd = logwdw_vadj->upper - logwdw_vadj->page_size == logwdw_vadj->value;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
122 gftp_lookup_global_option ("max_log_window_size", &max_log_window_size);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
123
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
124 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 switch (level)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 case gftp_logging_send:
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
128 gftp_lookup_global_option ("send_color", &color);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 case gftp_logging_recv:
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
131 gftp_lookup_global_option ("recv_color", &color);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 case gftp_logging_error:
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
134 gftp_lookup_global_option ("error_color", &color);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 default:
151
2f15b3000dbc 2003-4-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 129
diff changeset
137 gftp_lookup_global_option ("misc_color", &color);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 memset (&fore, 0, sizeof (fore));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 fore.red = color->red;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143 fore.green = color->green;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 fore.blue = color->blue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146 gtk_text_freeze (GTK_TEXT (logwdw));
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
147 gtk_text_insert (GTK_TEXT (logwdw), NULL, &fore, NULL, logstr, -1);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149 len = gtk_text_get_length (GTK_TEXT (logwdw));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150 if (max_log_window_size > 0 && len > max_log_window_size)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 delsize = len - max_log_window_size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 gtk_text_set_point (GTK_TEXT (logwdw), delsize);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 gtk_text_backward_delete (GTK_TEXT (logwdw), delsize);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 len = max_log_window_size;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 gtk_text_set_point (GTK_TEXT (logwdw), len);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159 gtk_text_thaw (GTK_TEXT (logwdw));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 if (upd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 gtk_adjustment_set_value (logwdw_vadj, logwdw_vadj->upper);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 switch (level)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 case gftp_logging_send:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 descr = "send";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 case gftp_logging_recv:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 descr = "recv";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 case gftp_logging_error:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 descr = "error";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175 default:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 descr = "misc";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 len = gtk_text_buffer_get_char_count (textbuf);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len);
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
183 gtk_text_buffer_insert_with_tags_by_name (textbuf, &iter, logstr, -1,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184 descr, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 if (upd)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 gtk_text_buffer_move_mark (textbuf, logwdw_textmark, &iter);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (logwdw), logwdw_textmark,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190 0, 1, 1, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
193 if (max_log_window_size > 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194 {
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
195 delsize = len + g_utf8_strlen (logstr, -1) - max_log_window_size;
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
196
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
197 if (delsize > 0)
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
198 {
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
199 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
200 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, delsize);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
201 gtk_text_buffer_delete (textbuf, &iter, &iter2);
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
202 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
206 if (free_logstr)
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
207 g_free (logstr);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 refresh (gftp_window_data * wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 if (!check_status (_("Refresh"), wdata, 0, 0, 0, 1))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 gtk_clist_freeze (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 remove_files_window (wdata);
182
33b394ebba68 2003-6-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
218 gftp_delete_cache_entry (wdata->request, NULL, 0);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 ftp_list_files (wdata, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 gtk_clist_thaw (GTK_CLIST (wdata->listbox));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 update_window_info (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 char *tempstr, empty[] = "";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 GtkWidget * tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 int i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 if (current_wdata->request != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
233 if ((tempstr = current_wdata->request->hostname) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 tempstr = empty;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
237 if ((tempstr = current_wdata->request->username) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 tempstr = empty;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (useredit)->entry), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
241 if ((tempstr = current_wdata->request->password) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 tempstr = empty;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 gtk_entry_set_text (GTK_ENTRY (passedit), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
245 if (current_wdata->request->port != 0)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 {
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
247 tempstr = g_strdup_printf ("%d", current_wdata->request->port);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 for (i=0; gftp_protocols[i].init != NULL; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 if (current_wdata->request->init == gftp_protocols[i].init)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256 gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), i);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 update_window (&window1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
263 update_window (&window2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
265 tempwid = gtk_item_factory_get_widget (factory, menus[tools_start+2].path);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 gtk_widget_set_sensitive (tempwid, GFTP_IS_CONNECTED (window1.request)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 && GFTP_IS_CONNECTED (window2.request));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
271 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
272 set_menu_sensitive (gftp_window_data * wdata, char *path, int sensitive)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
273 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
274 GtkWidget * tempwid;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
275 char * pos;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
276
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
277 tempwid = NULL;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
278
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
279 if (factory != NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
280 tempwid = gtk_item_factory_get_widget (factory, path);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
281 if (tempwid)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
282 gtk_widget_set_sensitive (tempwid, sensitive);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
283
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
284 if ((pos = strchr (path + 1, '/')) == NULL)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
285 pos = path;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
286
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
287 if (wdata->ifactory)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
288 tempwid = gtk_item_factory_get_widget (wdata->ifactory, pos);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
289 if (tempwid)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
290 gtk_widget_set_sensitive (tempwid, sensitive);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
291 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
292
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
293
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 update_window (gftp_window_data * wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297 char *dir, *tempstr, *temp1str, *fspec;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 int connected, start;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 connected = GFTP_IS_CONNECTED (wdata->request);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 if (connected)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 fspec = wdata->show_selected ? "Selected" : strcmp (wdata->filespec, "*") == 0 ? _("All Files") : wdata->filespec;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
305 if ((temp1str = wdata->request->hostname) == NULL ||
66
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
306 wdata->request->protonum == GFTP_LOCAL_NUM)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307 temp1str = "";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308 tempstr = g_strconcat (temp1str, *temp1str == '\0' ? "[" : " [",
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
309 gftp_protocols[wdata->request->protonum].name,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310 wdata->request->cached ? _("] (Cached) [") : "] [",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
311 fspec, "]", current_wdata == wdata ? "*" : "", NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 gtk_label_set (GTK_LABEL (wdata->hoststxt), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
313 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
314
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
315 if ((dir = wdata->request->directory) == NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 temp1str = "";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318 temp1str = dir;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry),temp1str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322 else if (wdata->hoststxt != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 tempstr = g_strconcat (_("Not connected"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325 current_wdata == wdata ? "*" : "", NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 gtk_label_set (GTK_LABEL (wdata->hoststxt), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (wdata->combo)->entry), "");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 if (wdata == &window1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332 start = local_start;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 start = remote_start;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 set_menu_sensitive (wdata, menus[start + 3].path, connected &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337 strcmp (wdata->request->url_prefix, "file") != 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 set_menu_sensitive (wdata, menus[start + 5].path, connected);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 set_menu_sensitive (wdata, menus[start + 6].path, connected);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 set_menu_sensitive (wdata, menus[start + 7].path, connected);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 set_menu_sensitive (wdata, menus[start + 8].path, connected);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
342 set_menu_sensitive (wdata, menus[start + 9].path, connected);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
343 set_menu_sensitive (wdata, menus[start + 11].path, connected);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
344 set_menu_sensitive (wdata, menus[start + 12].path, connected &&
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
345 wdata->request->site != NULL);
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
346 set_menu_sensitive (wdata, menus[start + 13].path, connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 wdata->request->chdir!= NULL);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
348 set_menu_sensitive (wdata, menus[start + 14].path, connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
349 wdata->request->chmod != NULL);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
350 set_menu_sensitive (wdata, menus[start + 15].path, connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 wdata->request->mkdir != NULL);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
352 set_menu_sensitive (wdata, menus[start + 16].path, connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 wdata->request->rename != NULL);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
354 set_menu_sensitive (wdata, menus[start + 17].path, connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355 wdata->request->rmdir != NULL &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356 wdata->request->rmfile != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357 set_menu_sensitive (wdata, menus[start + 18].path, connected &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358 wdata->request->get_file != NULL);
14
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
359 set_menu_sensitive (wdata, menus[start + 19].path, connected &&
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
360 wdata->request->get_file != NULL);
83090328581e * More largefile support. Hopefully all that is left is the configure stuff
masneyb
parents: 7
diff changeset
361 set_menu_sensitive (wdata, menus[start + 20].path, connected);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365 GtkWidget *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 toolbar_pixmap (GtkWidget * widget, char *filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 gftp_graphic * graphic;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369 GtkWidget *pix;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 if (filename == NULL || *filename == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374 graphic = open_xpm (widget, filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 if (graphic == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 if ((pix = gtk_pixmap_new (graphic->pixmap, graphic->bitmap)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 gtk_widget_show (pix);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 return (pix);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 gftp_graphic *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 open_xpm (GtkWidget * widget, char *filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 gftp_graphic * graphic;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 GtkStyle *style;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392 char *exfile;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 return (graphic);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 style = gtk_widget_get_style (widget);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399 if ((exfile = get_xpm_path (filename, 0)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 graphic = g_malloc0 (sizeof (*graphic));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 graphic->pixmap = gdk_pixmap_create_from_xpm (widget->window,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 &graphic->bitmap, &style->bg[GTK_STATE_NORMAL], exfile);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 g_free (exfile);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 if (graphic->pixmap == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 g_free (graphic);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 ftp_log (gftp_logging_error, NULL, _("Error opening file %s: %s\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
411 exfile, g_strerror (errno));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412 return (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
414
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
415 graphic->filename = g_strdup (filename);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416 g_hash_table_insert (graphic_hash_table, graphic->filename, graphic);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 return (graphic);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
419 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
421
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423 gftp_free_pixmap (char *filename)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 gftp_graphic * graphic;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
426
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
427 if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
428 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
429
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
430 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
431 gdk_pixmap_unref (graphic->pixmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
432 gdk_bitmap_unref (graphic->bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433 #else
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
434 g_object_unref (graphic->pixmap);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
435 g_object_unref (graphic->bitmap);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 g_hash_table_remove (graphic_hash_table, filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439 g_free (graphic->filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440 g_free (graphic);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
441 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
442
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
444 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
445 gftp_get_pixmap (GtkWidget * widget, char *filename, GdkPixmap ** pix,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 GdkBitmap ** bitmap)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
447 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
448 gftp_graphic * graphic;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
449
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
450 if (filename == NULL || *filename == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
451 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
452 *pix = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
453 *bitmap = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
456
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457 if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458 graphic = open_xpm (widget, filename);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
459
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
460 if (graphic == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
461 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
462 *pix = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
463 *bitmap = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
464 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
465 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
466
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
467 *pix = graphic->pixmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
468 *bitmap = graphic->bitmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
469 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
470
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
471
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
472 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
473 check_status (char *name, gftp_window_data *wdata, int check_other_stop,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
474 int only_one, int at_least_one, int func)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
475 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
476 gftp_window_data * owdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
477
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478 owdata = wdata == &window1 ? &window2 : &window1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
479
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
480 if (wdata->request->stopable)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
483 _("%s: Please hit the stop button first to do anything else\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
484 name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
485 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
486 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
487
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
488 if (check_other_stop && owdata->request->stopable)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
490 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491 _("%s: Please hit the stop button first to do anything else\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492 name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
493 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
494 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
496 if (!GFTP_IS_CONNECTED (wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
497 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
498 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
499 _("%s: Not connected to a remote site\n"), name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
500 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
501 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
502
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503 if (!func)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
504 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
505 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
506 _("%s: This feature is not available using this protocol\n"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
507 name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
508 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
509 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
510
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
511 if (only_one && !IS_ONE_SELECTED (wdata))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
512 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
513 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
514 _("%s: You must only have one item selected\n"), name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
515 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
516 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
517
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518 if (at_least_one && !only_one && IS_NONE_SELECTED (wdata))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 ftp_log (gftp_logging_misc, NULL,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
521 _("%s: You must have at least one item selected\n"), name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
522 return (0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
523 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
524 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
527
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
528 /* FIXME - check this */
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
529 static gchar *
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
530 gftp_item_factory_translate (const char *path, gpointer func_data)
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
531 {
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
532 const gchar *strip_prefix = func_data;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
533 const char *result;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
534
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
535 if (strip_prefix)
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
536 {
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
537 char *tmp_path = g_strconcat (strip_prefix, path, NULL);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
538 result = gettext (tmp_path);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
539 if (result == tmp_path)
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
540 result = path;
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
541 g_free (tmp_path);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
542 }
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
543 else
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
544 result = gettext (path);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
545
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
546 return (char *)result;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
547 }
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
548
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
549
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
550 GtkItemFactory *
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
551 item_factory_new (GtkType container_type, const char *path,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
552 GtkAccelGroup *accel_group, const char *strip_prefix)
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
553 {
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
554 GtkItemFactory *result = gtk_item_factory_new (container_type, path, accel_group);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
555 gchar *strip_prefix_dup = g_strdup (g_strdup (strip_prefix));
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
556
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
557 gtk_item_factory_set_translate_func (result, gftp_item_factory_translate,
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
558 strip_prefix_dup, NULL);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
559
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
560 if (strip_prefix_dup)
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
561 gtk_object_set_data_full (GTK_OBJECT (result), "gftp-strip-prefix",
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
562 strip_prefix_dup, (GDestroyNotify)g_free);
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
563
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
564 return result;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
565 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
566
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
567
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
568 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
569 create_item_factory (GtkItemFactory * ifactory, guint n_entries,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570 GtkItemFactoryEntry * entries, gpointer callback_data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
571 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
572 int i;
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
573 const char *strip_prefix = gtk_object_get_data (GTK_OBJECT (ifactory), "gftp-strip-prefix");
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
574 int strip_prefix_len = 0;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
575
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
576 if (strip_prefix)
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
577 strip_prefix_len = strlen (strip_prefix);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
578
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
579 for (i = 0; i < n_entries; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
580 {
7
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
581 GtkItemFactoryEntry dummy_item = entries[i];
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
582 if (strip_prefix && strncmp (entries[i].path, strip_prefix, strip_prefix_len) == 0)
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
583 dummy_item.path += strip_prefix_len;
5551ab2301fe * Fixed a DND crash
masneyb
parents: 1
diff changeset
584
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
585 gtk_item_factory_create_item (ifactory, &dummy_item, callback_data, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
586 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
587 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
589 GList *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
590 get_next_selection (GList * selection, GList ** list, int *curnum)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
591 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
592 gftp_file * tempfle;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
593 int i, newpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
594
195
3fa7b4f4ab78 2003-6-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 190
diff changeset
595 newpos = GPOINTER_TO_INT (selection->data);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
596 i = *curnum - newpos;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
597
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 if (i < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
599 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600 while (i != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
601 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
602 tempfle = (*list)->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
603 if (tempfle->shown)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
604 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
605 ++*curnum;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
606 i++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
607 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
608 *list = (*list)->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
609 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
610 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
611 else if (i > 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
612 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613 while (i != 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
614 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
615 tempfle = (*list)->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
616 if (tempfle->shown)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
617 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
618 --*curnum;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
619 i--;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
620 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
621 *list = (*list)->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
622 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
623 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
624
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
625 tempfle = (*list)->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
626 while ((*list)->next && !tempfle->shown)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
627 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
628 *list = (*list)->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
629 tempfle = (*list)->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
630 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
631 return (selection->next);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
632 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
633
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
634
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
635 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
636 add_history (GtkWidget * widget, GList ** history, unsigned int *histlen,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
637 const char *str)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
638 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
639 GList *node, *delnode;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
640 char *tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
641 int i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
642
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
643 if (str == NULL || *str == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
644 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
645
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
646 for (node = *history; node != NULL; node = node->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
647 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
648 if (strcmp ((char *) node->data, str) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
649 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
650 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
651
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
652 if (node == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
653 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
654 if (*histlen >= MAX_HIST_LEN)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
655 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
656 node = *history;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
657 for (i = 1; i < MAX_HIST_LEN; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
658 node = node->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
659 node->prev->next = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
660 node->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
661 delnode = node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
662 while (delnode != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
663 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
664 if (delnode->data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
665 g_free (delnode->data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
666 delnode = delnode->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
667 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
668 g_list_free (node);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
669 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
670 tempstr = g_strdup (str);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
671 *history = g_list_prepend (*history, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
672 ++*histlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
673 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
674 else if (node->prev != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
675 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
676 node->prev->next = node->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
677 if (node->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
678 node->next->prev = node->prev;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
679 node->prev = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
680 node->next = *history;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
681 if (node->next != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
682 node->next->prev = node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
683 *history = node;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
684 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
685 gtk_combo_set_popdown_strings (GTK_COMBO (widget), *history);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
686 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
687
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
688
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
689 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
690 check_reconnect (gftp_window_data *wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
691 {
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
692 return (wdata->request->cached && wdata->request->datafd < 0 &&
66
cd3e457cbc85 2002-11-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 63
diff changeset
693 !wdata->request->always_connected &&
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
694 !ftp_connect (wdata, wdata->request, 0) ? -1 : 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
695 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
696
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
697
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
698 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
699 add_file_listbox (gftp_window_data * wdata, gftp_file * fle)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
700 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
701 char *add_data[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, *pos;
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
702 gftp_config_list_vars * tmplistvar;
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
703 int clist_num, show_hidden_files;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
704 gftp_file_extensions * tempext;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
705 char *tempstr, *str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
706 GdkBitmap * bitmap;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
707 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
708 GdkPixmap * pix;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
709 size_t stlen;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
710
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
711 gftp_lookup_request_option (wdata->request, "show_hidden_files",
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
712 &show_hidden_files);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
713
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
714 if (wdata->show_selected)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
715 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
716 fle->shown = fle->was_sel;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
717 if (!fle->shown)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
718 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
719 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
720 else if ((!show_hidden_files && *fle->file == '.' &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
721 strcmp (fle->file, "..") != 0) ||
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
722 !gftp_match_filespec (fle->file, wdata->filespec))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
723 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
724 fle->shown = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
725 fle->was_sel = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
726 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
727 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
728 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
729 fle->shown = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
730
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
731 clist_num = gtk_clist_append (GTK_CLIST (wdata->listbox), add_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
732
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
733 if (fle->was_sel)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
734 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
735 fle->was_sel = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
736 gtk_clist_select_row (GTK_CLIST (wdata->listbox), clist_num, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
737 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
738
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
739 pix = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
740 bitmap = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
741 if (strcmp (fle->file, "..") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
742 gftp_get_pixmap (wdata->listbox, "dotdot.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
743 else if (fle->islink && fle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
744 gftp_get_pixmap (wdata->listbox, "linkdir.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
745 else if (fle->islink)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
746 gftp_get_pixmap (wdata->listbox, "linkfile.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
747 else if (fle->isdir)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
748 gftp_get_pixmap (wdata->listbox, "dir.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
749 else if (fle->isexe)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
750 gftp_get_pixmap (wdata->listbox, "exe.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
751 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
752 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
753 stlen = strlen (fle->file);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
754 gftp_lookup_global_option ("ext", &tmplistvar);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
755 templist = tmplistvar->list;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
756 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
757 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
758 tempext = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
759 if (stlen >= tempext->stlen &&
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
760 strcmp (&fle->file[stlen - tempext->stlen], tempext->ext) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
761 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
762 gftp_get_pixmap (wdata->listbox, tempext->filename, &pix,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
763 &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
764 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
765 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
766 templist = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
767 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
768 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
769
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
770 if (pix == NULL && bitmap == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
771 gftp_get_pixmap (wdata->listbox, "doc.xpm", &pix, &bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
772
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
773 gtk_clist_set_pixmap (GTK_CLIST (wdata->listbox), clist_num, 0, pix, bitmap);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
774
184
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
775 if (fle->utf8_file)
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
776 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 1,
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
777 fle->utf8_file);
65eb40fb4f03 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 182
diff changeset
778 else if (fle->file)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
779 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 1, fle->file);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
780
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
781 if (fle->attribs && (*fle->attribs == 'b' || *fle->attribs == 'c'))
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
782 tempstr = g_strdup_printf ("%d, %d", major (fle->size),
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
783 minor (fle->size));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
784 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
785 tempstr = insert_commas (fle->size, NULL, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
786
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
787 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 2, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
788 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
789
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
790 if (fle->user)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
791 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 3, fle->user);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
792 if (fle->group)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
793 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 4, fle->group);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
794 if ((str = ctime (&fle->datetime)))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
795 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
796 if ((pos = strchr (str, '\n')) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
797 *pos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
798 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 5, str);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
799 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
800 if (fle->attribs)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
801 gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 6, fle->attribs);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
802
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
803 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
804
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
805
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
806 #if GTK_MAJOR_VERSION == 1
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
807 static void
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
808 ok_dialog_response (GtkWidget * widget, gftp_dialog_data * ddata)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
809 {
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
810 if (ddata->edit == NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
811 gtk_widget_destroy (ddata->dialog);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
812
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
813 if (ddata->yesfunc != NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
814 ddata->yesfunc (ddata->yespointer, ddata);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
815
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
816 if (ddata->edit != NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
817 gtk_widget_destroy (ddata->dialog);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
818
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
819 g_free (ddata);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
820 }
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
821
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
822
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
823 static void
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
824 cancel_dialog_response (GtkWidget * widget, gftp_dialog_data * ddata)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
825 {
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
826 if (ddata->edit == NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
827 gtk_widget_destroy (ddata->dialog);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
828
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
829 if (ddata->nofunc != NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
830 ddata->nofunc (ddata->nopointer, ddata);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
831
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
832 if (ddata->edit != NULL)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
833 gtk_widget_destroy (ddata->dialog);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
834
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
835 g_free (ddata);
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
836 }
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
837 #else
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
838 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
839 dialog_response (GtkWidget * widget, gint response, gftp_dialog_data * ddata)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
840 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
841 if (ddata->edit == NULL)
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
842 gtk_widget_destroy (ddata->dialog);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
843
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
844 switch (response)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
845 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
846 case GTK_RESPONSE_YES:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
847 if (ddata->yesfunc != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
848 ddata->yesfunc (ddata->yespointer, ddata);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
849 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
850 default:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
851 if (ddata->nofunc != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
852 ddata->nofunc (ddata->nopointer, ddata);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
853 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
854 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
855
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
856 if (ddata->edit != NULL)
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
857 gtk_widget_destroy (ddata->dialog);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
858
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
859 g_free (ddata);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
860 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
861 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
862
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
863
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
864 static gint
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
865 dialog_keypress (GtkWidget * widget, GdkEventKey * event, gpointer data)
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
866 {
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
867 if (event->type != GDK_KEY_PRESS)
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
868 return (FALSE);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
869
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
870 if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return)
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
871 {
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
872 #if GTK_MAJOR_VERSION == 1
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
873 ok_dialog_response (widget, data);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
874 #else
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
875 dialog_response (widget, GTK_RESPONSE_YES, data);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
876 #endif
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
877 return (TRUE);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
878 }
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
879 else if (event->keyval == GDK_Escape)
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
880 {
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
881 #if GTK_MAJOR_VERSION == 1
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
882 cancel_dialog_response (widget, data);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
883 #else
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
884 dialog_response (widget, GTK_RESPONSE_NO, data);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
885 #endif
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
886 return (TRUE);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
887 }
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
888
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
889 return (FALSE);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
890 }
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
891
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
892
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
894 MakeEditDialog (char *diagtxt, char *infotxt, char *deftext, int passwd_item,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
895 char *checktext,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
896 gftp_dialog_button okbutton, void (*okfunc) (), void *okptr,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
897 void (*cancelfunc) (), void *cancelptr)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898 {
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
899 GtkWidget * tempwid, * dialog;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
900 gftp_dialog_data * ddata;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
901 const gchar * yes_text;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
902
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
903 ddata = g_malloc (sizeof (*ddata));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
904 ddata->yesfunc = okfunc;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
905 ddata->yespointer = okptr;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
906 ddata->nofunc = cancelfunc;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
907 ddata->nopointer = cancelptr;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
909 #if GTK_MAJOR_VERSION == 1
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
910 dialog = gtk_dialog_new ();
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
911 gtk_window_set_title (GTK_WINDOW (dialog), diagtxt);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
912 gtk_grab_add (dialog);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 gtk_container_border_width (GTK_CONTAINER
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
914 (GTK_DIALOG (dialog)->action_area), 5);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
915 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
916 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
917 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
918 switch (okbutton)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
919 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
920 case gftp_dialog_button_create:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
921 yes_text = GTK_STOCK_ADD;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
922 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
923 case gftp_dialog_button_change:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
924 yes_text = _("Change");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
925 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
926 case gftp_dialog_button_connect:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
927 yes_text = _("Connect");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
928 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
929 case gftp_dialog_button_rename:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
930 yes_text = _("Rename");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
931 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
932 default:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
933 yes_text = GTK_STOCK_MISSING_IMAGE;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
934 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
935 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
937 dialog = gtk_dialog_new_with_buttons (_(diagtxt), NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
938 yes_text,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
939 GTK_RESPONSE_YES,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
940 GTK_STOCK_CANCEL,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
941 GTK_RESPONSE_NO,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
942 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
943 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
944 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
945 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
946 gtk_window_set_wmclass (GTK_WINDOW(dialog), "edit", "gFTP");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
947 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
948 gtk_widget_realize (dialog);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
949
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
950 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
951 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
952 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
953 gftp_icon->bitmap);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
954 gdk_window_set_icon_name (dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
955 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
956
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
957 ddata->dialog = dialog;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
958
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
959 tempwid = gtk_label_new (infotxt);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
960 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), tempwid, TRUE,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
961 TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
962 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
963
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
964 ddata->edit = gtk_entry_new ();
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
965 gtk_signal_connect (GTK_OBJECT (ddata->edit), "key_press_event",
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
966 GTK_SIGNAL_FUNC (dialog_keypress), (gpointer) ddata);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
967
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
968 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ddata->edit, TRUE,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
969 TRUE, 0);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
970 gtk_widget_grab_focus (ddata->edit);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
971 gtk_entry_set_visibility (GTK_ENTRY (ddata->edit), passwd_item);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
972
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
973 if (deftext != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
974 {
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
975 gtk_entry_set_text (GTK_ENTRY (ddata->edit), deftext);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
976 gtk_entry_select_region (GTK_ENTRY (ddata->edit), 0, strlen (deftext));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
977 }
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
978 gtk_widget_show (ddata->edit);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
979
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
980 if (checktext != NULL)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
981 {
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
982 ddata->checkbox = gtk_check_button_new_with_label (checktext);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
983 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
984 ddata->checkbox, TRUE, TRUE, 0);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
985 gtk_widget_show (ddata->checkbox);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
986 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
987
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
988 #if GTK_MAJOR_VERSION == 1
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
989 switch (okbutton)
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
990 {
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
991 case gftp_dialog_button_create:
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
992 yes_text = _("Add");
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
993 break;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
994 case gftp_dialog_button_change:
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
995 yes_text = _("Change");
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
996 break;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
997 case gftp_dialog_button_connect:
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
998 yes_text = _("Connect");
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
999 break;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1000 case gftp_dialog_button_rename:
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1001 yes_text = _("Rename");
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1002 break;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1003 default:
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1004 yes_text = "";
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1005 break;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1006 }
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1007
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1008 tempwid = gtk_button_new_with_label (yes_text);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1009 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1010 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1011 TRUE, TRUE, 0);
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1012 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1013 GTK_SIGNAL_FUNC (ok_dialog_response),
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1014 ddata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1015 gtk_widget_grab_default (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1016 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1017
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1018 tempwid = gtk_button_new_with_label (_("Cancel"));
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1019 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1020 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1021 TRUE, TRUE, 0);
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1022 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1023 GTK_SIGNAL_FUNC (cancel_dialog_response),
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1024 ddata);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1025 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1026 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1027 g_signal_connect (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1028 G_CALLBACK (dialog_response), ddata);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1029 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1030
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1031 gtk_widget_show (dialog);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1032 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1033
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1034
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1035 void
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1036 MakeYesNoDialog (char *diagtxt, char *infotxt,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1037 void (*yesfunc) (), gpointer yespointer,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1038 void (*nofunc) (), gpointer nopointer)
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1039 {
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1040 GtkWidget * text, * dialog;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1041 gftp_dialog_data * ddata;
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
1042 #if GTK_MAJOR_VERSION == 1
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1043 GtkWidget * tempwid;
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1044 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1045
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1046 ddata = g_malloc (sizeof (*ddata));
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1047 ddata->yesfunc = yesfunc;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1048 ddata->yespointer = yespointer;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1049 ddata->nofunc = nofunc;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1050 ddata->nopointer = nopointer;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1051
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
1052 #if GTK_MAJOR_VERSION == 1
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1053 dialog = gtk_dialog_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1054 gtk_grab_add (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1055 gtk_window_set_title (GTK_WINDOW (dialog), diagtxt);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1056 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1057 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1058 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1059 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1060 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1061 dialog = gtk_dialog_new_with_buttons (_(diagtxt), NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1062 GTK_STOCK_YES,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1063 GTK_RESPONSE_YES,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1064 GTK_STOCK_NO,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1065 GTK_RESPONSE_NO,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1066 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1067 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1068 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1069 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 5);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1070 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1071 gtk_window_set_wmclass (GTK_WINDOW(dialog), "yndiag", "gFTP");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1072 gtk_widget_realize (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1073
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1074 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1075 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1076 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1077 gftp_icon->bitmap);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 151
diff changeset
1078 gdk_window_set_icon_name (dialog->window, gftp_version);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1079 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1080
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1081 ddata->dialog = dialog;
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1082
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1083 text = gtk_label_new (infotxt);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1084 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), text, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1085 gtk_widget_show (text);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1086
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
1087 #if GTK_MAJOR_VERSION == 1
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1088 tempwid = gtk_button_new_with_label (_(" Yes "));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1089 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1090 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1091 FALSE, FALSE, 0);
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1092 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
1093 GTK_SIGNAL_FUNC (ok_dialog_response), ddata);
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
1094
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1095 gtk_widget_grab_default (tempwid);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1096 gtk_widget_show (tempwid);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1097
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1098 tempwid = gtk_button_new_with_label (_(" No "));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1099 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1100 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1101 FALSE, FALSE, 0);
21
4b244bf9d84d 2002-09-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 19
diff changeset
1102 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
72
c48f19f24050 2002-12-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 66
diff changeset
1103 GTK_SIGNAL_FUNC (cancel_dialog_response), ddata);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1104 gtk_widget_show (tempwid);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1105
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1106 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1107 g_signal_connect (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1108 G_CALLBACK (dialog_response), ddata);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 14
diff changeset
1109 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1110
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1111 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1112 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1113
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1114
48
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1115 static gint
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1116 delete_event (GtkWidget * widget, GdkEvent * event, gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1117 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1118 return (TRUE);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1119 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1120
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1121
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1122 static void
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1123 trans_stop_button (GtkWidget * widget, gpointer data)
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1124 {
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1125 gftp_transfer * transfer;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1126
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1127 transfer = data;
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1128 pthread_kill (((gftp_window_data *) transfer->fromwdata)->tid, SIGINT);
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1129 }
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1130
e5f6054590b5 2002-11-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 47
diff changeset
1131
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1132 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1133 update_directory_download_progress (gftp_transfer * transfer)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1134 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1135 static GtkWidget * dialog = NULL, * textwid, * stopwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1136 char tempstr[255];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1137 GtkWidget * vbox;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1138
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1139 if (transfer->numfiles < 0 || transfer->numdirs < 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1140 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1141 if (dialog != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1142 gtk_widget_destroy (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1143 dialog = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1144 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1145 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1146
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1147 if (dialog == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1148 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1149 dialog = gtk_window_new (GTK_WINDOW_POPUP);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1150 gtk_grab_add (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1151 gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1152 GTK_SIGNAL_FUNC (delete_event), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1153 gtk_window_set_title (GTK_WINDOW (dialog),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1154 _("Getting directory listings"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1155 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1156 gtk_window_set_wmclass (GTK_WINDOW(dialog), "dirlist", "gFTP");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1157
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1158 vbox = gtk_vbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1159 gtk_container_border_width (GTK_CONTAINER (vbox), 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1160 gtk_container_add (GTK_CONTAINER (dialog), vbox);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1161 gtk_widget_show (vbox);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1162
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1163 textwid = gtk_label_new (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1164 gtk_box_pack_start (GTK_BOX (vbox), textwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1165 gtk_widget_show (textwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1166
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1167 statuswid = gtk_progress_bar_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1168 gtk_progress_set_activity_mode (GTK_PROGRESS (statuswid), 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1169 gtk_progress_bar_set_activity_step (GTK_PROGRESS_BAR (statuswid), 3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1170 gtk_progress_bar_set_activity_blocks (GTK_PROGRESS_BAR (statuswid), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1171 gtk_box_pack_start (GTK_BOX (vbox), statuswid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1172 gtk_widget_show (statuswid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1173
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1174 stopwid = gtk_button_new_with_label (_(" Stop "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1175 gtk_signal_connect (GTK_OBJECT (stopwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1176 GTK_SIGNAL_FUNC (trans_stop_button), transfer);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1177 gtk_box_pack_start (GTK_BOX (vbox), stopwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1178 gtk_widget_show (stopwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1179
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1180 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1181 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1182
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1183 g_snprintf (tempstr, sizeof (tempstr),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1184 _("Received %ld directories\nand %ld files"),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1185 transfer->numdirs, transfer->numfiles);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1186 gtk_label_set_text (GTK_LABEL (textwid), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1187 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1188
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1189
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1190 void *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1191 generic_thread (void * (*func) (void *), gftp_window_data * wdata)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1192 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1193 void * ret;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1194
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1195 if (wdata->request->use_threads)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1196 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1197 wdata->request->stopable = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1198 gtk_widget_set_sensitive (stop_btn, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1199 pthread_create (&wdata->tid, NULL, func, wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1200
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1201 while (wdata->request->stopable)
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 21
diff changeset
1202 {
33
c8ec7877432e 2002-10-06 Brian Masney <masneyb@gftp.org>
masneyb
parents: 31
diff changeset
1203 GDK_THREADS_LEAVE ();
45
311e29c40ed6 2002-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 43
diff changeset
1204 #if GTK_MAJOR_VERSION == 1
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 21
diff changeset
1205 g_main_iteration (TRUE);
41
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
1206 #else
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
1207 g_main_context_iteration (NULL, TRUE);
4bcfaf6307b5 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 33
diff changeset
1208 #endif
31
d930e06af9ae 2002-10-03 Brian Masney <masneyb@gftp.org>
masneyb
parents: 21
diff changeset
1209 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1210
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1211 pthread_join (wdata->tid, &ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1212 gtk_widget_set_sensitive (stop_btn, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1213 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1214 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1215 ret = func (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1216
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1217 if (!GFTP_IS_CONNECTED (wdata->request))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1218 disconnect (wdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1219
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1220 return (ret);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1221 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1222
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1223
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1224 int
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1225 progress_timeout (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1226 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1227 gftp_transfer * tdata;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1228 double val;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1229
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1230 tdata = data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1231
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1232 update_directory_download_progress (tdata);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1233
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1234 val = gtk_progress_get_value (GTK_PROGRESS (statuswid));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1235 if (val >= 1.0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1236 val = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1237 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1238 val += 0.10;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1239 gtk_progress_bar_update (GTK_PROGRESS_BAR (statuswid), val);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1240
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1241 return (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1242 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1243
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1244
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1245 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1246 display_cached_logs (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1247 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1248 gftp_log * templog;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1249 GList * templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1250
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1251 pthread_mutex_lock (&log_mutex);
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
1252 templist = gftp_file_transfer_logs;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1253 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1254 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1255 templog = (gftp_log *) templist->data;
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 184
diff changeset
1256 ftp_log (templog->type, NULL, "%s", templog->msg);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1257 g_free (templog->msg);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1258 g_free (templog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1259 templist->data = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1260 templist = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1261 }
129
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
1262 g_list_free (gftp_file_transfer_logs);
fe0b21c006f6 2003-4-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 72
diff changeset
1263 gftp_file_transfer_logs = NULL;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1264 pthread_mutex_unlock (&log_mutex);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1265 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1266
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1267
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1268 RETSIGTYPE
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1269 signal_handler (int signo)
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1270 {
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1271 signal (signo, signal_handler);
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1272
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1273 if (use_jmp_environment)
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1274 siglongjmp (jmp_environment, signo == SIGINT ? 1 : 2);
43
36e2868ce8b7 2002-10-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 42
diff changeset
1275 else if (signo == SIGINT)
36e2868ce8b7 2002-10-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 42
diff changeset
1276 exit (1);
42
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1277 }
cd169e4789df 2002-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 41
diff changeset
1278