annotate src/gtk/misc-gtk.c @ 991:b884506e569c

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