annotate src/gtk/options_dialog.c @ 19:3b2dcdefc7e9

2002-09-15 Brian Masney <masneyb@gftp.org> * lib/gftp.h (struct gftp_transfer) - changed the type of numfiles and numdirs from unsigned long to long. This must be a signed field. This is a bug I introduced a few days ago. * lib/local.c (local_put_file) - remove the + off of the ab mode to fdopen. This is also a bug I introduced a few days ago. * src/gtk/transfer.c (gftp_gtk_calc_kbs) - make sure that the variable difftime isn't a negative number when computing the KB/s * src/gtk/menu-items.c (save_directory_listing) - remove casts to GTK_OBJECT for the str variable * src/gtk/gftp-gtk.c - use GTK_STOCK_* icons in place of left.xpm, right.xpm, up.xpm, down.xpm and stop.xpm in GTK+ 2.0 port * src/gtk/bookmarks.c - show GTK_STOCK_* icons on the popup menu * src/gtk/bookmarks.c, src/gtk/chmod_dialog.c, src/gtk/menu-items.c, src/gtk/misc-gtk.c, src/gtk/options_dialog.c and src/gtk/view_dialog.c - use gtk_dialog_new_with_buttons in GTK+ 2.0 port to create the dialog. Also, associate gFTP icon with this dialog * src/gtk/misc-gtk.c - changed the interface of MakeEditDialog and MakeYesNoDialog. In the GTK+ 2.0 port, I now use stock icons in the dialog buttons.
author masneyb
date Mon, 16 Sep 2002 12:27:50 +0000
parents 8b1883341c6f
children c8ec7877432e
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 /* menu-items.c - menu callbacks */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org> */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 /* */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 /*****************************************************************************/
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 #include <gftp-gtk.h>
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
21
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22 static void make_proxy_hosts_tab ( GtkWidget * notebook );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
23 static void add_host_to_listbox ( GList * templist );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24 static void add_proxy_host ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 static void add_toggle ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28 static void add_ok ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30 static void delete_proxy_host ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32 static void proxy_toggle ( GtkList * list,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33 GtkWidget * child,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35 static void apply_changes ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37 static void clean_old_changes ( GtkWidget * widget,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 gpointer data );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 static char *get_proxy_config ( void );
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 static GtkWidget * proxy_text, * proxy_list, * new_proxy_domain, * network1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 * network2, * network3, * network4, * netmask1, * netmask2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43 * netmask3, * netmask4, * domain_active, * proxy_combo,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44 * def_proto_combo;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
45 static GList * new_proxy_hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 static char *custom_proxy;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
48 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
49 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
50 options_action (GtkWidget * widget, gint response, gpointer user_data)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
51 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
52 switch (response)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
53 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
54 case GTK_RESPONSE_APPLY:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
55 apply_changes (widget, NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
56 break;
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
57 case GTK_RESPONSE_OK:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
58 apply_changes (widget, NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
59 /* no break */
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
60 default:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
61 gtk_widget_destroy (widget);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
62 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
63 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
64 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
65
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
66
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
67 void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
68 options_dialog (gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 GtkWidget * dialog, * tempwid, * notebook, * table, * box;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 char tempstr[20], *pos, *endpos, *oldstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
72 int i, tbl_col, tbl_num, combo_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73 GList * combo_list;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
75 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 dialog = gtk_dialog_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 gtk_window_set_title (GTK_WINDOW (dialog), _("Options"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
82 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
83 dialog = gtk_dialog_new_with_buttons (_("Options"), NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
84 GTK_STOCK_SAVE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
85 GTK_RESPONSE_OK,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
86 GTK_STOCK_CANCEL,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
87 GTK_RESPONSE_CANCEL,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
88 GTK_STOCK_APPLY,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
89 GTK_RESPONSE_APPLY,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
90 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
91 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
92 gtk_window_set_wmclass (GTK_WINDOW(dialog), "options", "gFTP");
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
94 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
95 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
96 gtk_widget_realize (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
97
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
98 if (gftp_icon != NULL)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
99 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
100 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
101 gftp_icon->bitmap);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
102 gdk_window_set_icon_name (dialog->window, _("gFTP Icon"));
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
103 }
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
104
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
105 notebook = gtk_notebook_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
106 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
107 TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
108 gtk_widget_show (notebook);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
109
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
110 tbl_num = tbl_col = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
111 table = box = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
112 for (i=0; config_file_vars[i].key != NULL; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
113 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
114 if (!config_file_vars[i].shown)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
115 continue;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
116
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
117 switch (config_file_vars[i].type)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
118 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
119 case CONFIG_NOTEBOOK:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
120 box = gtk_vbox_new (FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
121 gtk_container_border_width (GTK_CONTAINER (box), 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
122 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
123
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
124 tempwid = gtk_label_new (_(config_file_vars[i].description));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
125 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
126 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
127 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
128 case CONFIG_TABLE:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
129 table = gtk_table_new (1, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
130 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
131 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
132 gtk_box_pack_start (GTK_BOX (box), table, FALSE, FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
133 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
134 tbl_num = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
135 tbl_col = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
136 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
137 case CONFIG_COMBO:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
138 gtk_table_resize (GTK_TABLE (table), tbl_num, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
139
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
140 tempwid = gtk_label_new (_(config_file_vars[i].description));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
141 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
142 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
143 tbl_num - 1, tbl_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
144 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
145
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
146 tempwid = gtk_combo_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
147 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 1, 2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
148 tbl_num - 1, tbl_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
149 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
150 config_file_vars[i].widget = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
151
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
152 /* We only have Default Protocol and the Proxy type as the two
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
153 combo types. If I add more later on, I'll work on a better
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
154 interface for all this stuff */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
155 if (strcmp (config_file_vars[i].comment, "DP") == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
156 def_proto_combo = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
157 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
158 proxy_combo = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
159
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
160 tbl_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
161 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
162 case CONFIG_TEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
163 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
164 proxy_text = gtk_text_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
165 gtk_text_set_editable (GTK_TEXT (proxy_text), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
166 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
167 proxy_text = gtk_text_view_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
168 gtk_text_view_set_editable (GTK_TEXT_VIEW (proxy_text), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
169 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
170 gtk_widget_set_size_request (proxy_text, -1, 75);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
171 gtk_table_attach_defaults (GTK_TABLE (table), proxy_text, 0, 2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
172 tbl_num - 1, tbl_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
173 gtk_widget_show (proxy_text);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
174 config_file_vars[i].widget = proxy_text;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
175
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
176 tbl_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
177 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
178 case CONFIG_CHARTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
179 case CONFIG_CHARPASS:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
180 case CONFIG_INTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
181 case CONFIG_UINTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
182 case CONFIG_FLOATTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
183 gtk_table_resize (GTK_TABLE (table), tbl_num, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
184
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
185 tempwid = gtk_label_new (_(config_file_vars[i].description));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
186 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
187 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
188 tbl_num - 1, tbl_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
189 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
190
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
191 tempwid = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
192 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 1, 2,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
193 tbl_num - 1, tbl_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
194
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
195 switch (config_file_vars[i].type)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
196 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
197 case CONFIG_INTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
198 case CONFIG_UINTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
199 g_snprintf (tempstr, sizeof (tempstr), "%d",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
200 *(int *) config_file_vars[i].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
201 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
202 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
203 case CONFIG_FLOATTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
204 g_snprintf (tempstr, sizeof (tempstr), "%.2f",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
205 *(double *) config_file_vars[i].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
206 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
207 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
208 case CONFIG_CHARTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
209 gtk_entry_set_text (GTK_ENTRY (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
210 *(char **) config_file_vars[i].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
211 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
212 case CONFIG_CHARPASS:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
213 gtk_entry_set_text (GTK_ENTRY (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
214 *(char **) config_file_vars[i].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
215 gtk_entry_set_visibility (GTK_ENTRY (tempwid), 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
216 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
217 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
218 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
219 config_file_vars[i].widget = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
220 tbl_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
221 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
222 case CONFIG_CHECKBOX:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
223 tempwid = gtk_check_button_new_with_label (
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
224 _(config_file_vars[i].description));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
225 gtk_table_attach_defaults (GTK_TABLE (table), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
226 tbl_col, tbl_col + 1, tbl_num, tbl_num + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
227 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
228 *(int *) config_file_vars[i].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
229 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
230 config_file_vars[i].widget = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
231 tbl_col++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
232 if (tbl_col == 2)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
233 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
234 tbl_col = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
235 tbl_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
236 gtk_table_resize (GTK_TABLE (table), tbl_num + 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
237 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
238 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
239 case CONFIG_LABEL:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
240 tempwid = gtk_label_new (_(config_file_vars[i].description));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
241 gtk_misc_set_alignment (GTK_MISC (tempwid), tbl_col, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
242 gtk_table_attach_defaults (GTK_TABLE (table), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
243 tbl_col, tbl_col + 1, tbl_num, tbl_num + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
244 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
245 config_file_vars[i].widget = tempwid;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
246 tbl_col++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
247 if (tbl_col == 2)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
248 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
249 tbl_col = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
250 tbl_num++;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
251 gtk_table_resize (GTK_TABLE (table), tbl_num + 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
252 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
253 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
254 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
255 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
256
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
257 combo_num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
258 combo_list = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
259 for (i = 0; gftp_protocols[i].name != NULL; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
260 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
261 if (strcmp (default_protocol, gftp_protocols[i].name) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
262 combo_num = i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
263 tempwid = gtk_list_item_new_with_label (gftp_protocols[i].name);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
264 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
265 combo_list = g_list_append (combo_list, tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
266 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
267 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (def_proto_combo)->list),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
268 combo_list);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
269 gtk_list_select_item (GTK_LIST (GTK_COMBO (def_proto_combo)->list),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
270 combo_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
271
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
272 combo_list = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
273 for (i = 0; proxy_type[i].key != NULL; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
274 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
275 tempwid = gtk_list_item_new_with_label (_(proxy_type[i].key));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
276 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
277 combo_list = g_list_append (combo_list, tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
278 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
279 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (proxy_combo)->list), combo_list);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
280 combo_list = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
281
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
282 custom_proxy = g_malloc0 (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
283 if (proxy_config == NULL || *proxy_config == '\0')
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
284 combo_num = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
285 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
286 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
287 pos = proxy_config;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
288 while ((endpos = strstr (pos, "%n")))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
289 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
290 *endpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
291 oldstr = custom_proxy;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
292 custom_proxy = g_strconcat (custom_proxy, pos, "\n", NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
293 g_free (oldstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
294 *endpos = '%';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
295 pos = endpos + 2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
296 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
297
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
298 for (combo_num = 1; combo_num < GFTP_CUSTOM_PROXY_NUM; combo_num++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
299 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
300 if (strcmp (proxy_type[combo_num].description, custom_proxy) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
301 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
302 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
303 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
304
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
305 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (proxy_combo)->list),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
306 "select_child", GTK_SIGNAL_FUNC (proxy_toggle), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
307 gtk_list_select_item (GTK_LIST (GTK_COMBO (proxy_combo)->list), combo_num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
308
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
309 make_proxy_hosts_tab (notebook);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
310
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
311 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
312 tempwid = gtk_button_new_with_label (_("OK"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
313 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
314 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
315 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
316 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
317 GTK_SIGNAL_FUNC (apply_changes), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
318 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
319 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
320 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
321 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
322
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
323 tempwid = gtk_button_new_with_label (_(" Cancel "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
324 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
325 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
326 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
327 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
328 GTK_SIGNAL_FUNC (clean_old_changes), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
329 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
330 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
331 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
332 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
333
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
334 tempwid = gtk_button_new_with_label (_("Apply"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
335 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
336 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
337 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
338 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
339 GTK_SIGNAL_FUNC (apply_changes), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
340 gtk_widget_grab_default (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
341 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
342 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
343 g_signal_connect (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
344 G_CALLBACK (options_action), NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
345 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
346
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
347 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
348 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
349
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
350
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
351 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
352 make_proxy_hosts_tab (GtkWidget * notebook)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
353 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
354 GtkWidget *tempwid, *box, *hbox, *scroll;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
355 gftp_proxy_hosts *hosts, *newhosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
356 char *add_data[2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
357 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
358
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
359 add_data[0] = _("Network");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
360 add_data[1] = _("Netmask");
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
361
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
362 box = gtk_vbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
363 gtk_container_border_width (GTK_CONTAINER (box), 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
364 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
365
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
366 tempwid = gtk_label_new (_("Local Hosts"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
367 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
368 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
369
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
370 scroll = gtk_scrolled_window_new (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
371 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
372 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
373 gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
374
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
375 proxy_list = gtk_clist_new_with_titles (2, add_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
376 gtk_container_add (GTK_CONTAINER (scroll), proxy_list);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
377 gtk_clist_set_column_auto_resize (GTK_CLIST (proxy_list), 0, TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
378 gtk_clist_set_column_auto_resize (GTK_CLIST (proxy_list), 1, TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
379 gtk_widget_show (proxy_list);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
380 gtk_widget_show (scroll);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
381
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
382 hbox = gtk_hbox_new (TRUE, 15);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
383 gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
384 gtk_widget_show (hbox);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
385
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
386 tempwid = gtk_button_new_with_label (_("Add"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
387 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
388 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
389 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
390 GTK_SIGNAL_FUNC (add_proxy_host), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
391 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
392
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
393 tempwid = gtk_button_new_with_label (_("Edit"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
394 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
395 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
396 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
397 GTK_SIGNAL_FUNC (add_proxy_host), (gpointer) 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
398 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
399
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
400 tempwid = gtk_button_new_with_label (_("Delete"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
401 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
402 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
403 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
404 GTK_SIGNAL_FUNC (delete_proxy_host), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
405 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
406
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
407 new_proxy_hosts = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
408 for (templist = proxy_hosts; templist != NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
409 templist = templist->next)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
410 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
411 hosts = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
412 newhosts = g_malloc (sizeof (*newhosts));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
413 memcpy (newhosts, hosts, sizeof (*newhosts));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
414 if (newhosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
415 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
416 newhosts->domain = g_malloc (strlen (hosts->domain) + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
417 strcpy (newhosts->domain, hosts->domain);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
418 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
419 new_proxy_hosts = g_list_prepend (new_proxy_hosts, newhosts);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
420 add_host_to_listbox (new_proxy_hosts);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
421 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
422 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
423
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
424
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
425 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
426 add_host_to_listbox (GList * templist)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
427 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
428 gftp_proxy_hosts *hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
429 char *add_data[2];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
430 int num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
431
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
432 hosts = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
433 if (hosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
434 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
435 add_data[0] = hosts->domain;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
436 add_data[1] = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
437 num = gtk_clist_append (GTK_CLIST (proxy_list), add_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
438 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
439 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
440 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
441 add_data[0] = g_strdup_printf ("%d.%d.%d.%d",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
442 hosts->ipv4_network_address >> 24 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
443 hosts->ipv4_network_address >> 16 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
444 hosts->ipv4_network_address >> 8 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
445 hosts->ipv4_network_address & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
446 add_data[1] = g_strdup_printf ("%d.%d.%d.%d",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
447 hosts->ipv4_netmask >> 24 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
448 hosts->ipv4_netmask >> 16 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
449 hosts->ipv4_netmask >> 8 & 0xff,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
450 hosts->ipv4_netmask & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
451 num = gtk_clist_append (GTK_CLIST (proxy_list), add_data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
452 g_free (add_data[0]);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
453 g_free (add_data[1]);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
454 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
455 gtk_clist_set_row_data (GTK_CLIST (proxy_list), num, (gpointer) templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
456 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
457
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
458
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
459 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
460 static void
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
461 proxyhosts_action (GtkWidget * widget, gint response, gpointer user_data)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
462 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
463 switch (response)
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
464 {
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
465 case GTK_RESPONSE_OK:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
466 add_ok (widget, user_data);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
467 /* no break */
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
468 default:
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
469 gtk_widget_destroy (widget);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
470 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
471 }
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
472 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
473
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
474
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
475 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
476 add_proxy_host (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
477 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
478 GtkWidget *tempwid, *dialog, *frame, *box, *table;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
479 gftp_proxy_hosts *hosts;
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
480 char *tempstr, *title;
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
481 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
482
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
483 if (data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
484 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
485 if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
486 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
487 templist = gtk_clist_get_row_data (GTK_CLIST (proxy_list),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
488 (int) templist->data);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
489 hosts = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
490 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
491 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
492 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
493 hosts = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
494 templist = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
495 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
496
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
497 title = hosts ? _("Edit Host") : _("Add Host");
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
498 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
499 dialog = gtk_dialog_new ();
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
500 gtk_window_set_title (GTK_WINDOW (dialog), title);
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
501 gtk_container_border_width (GTK_CONTAINER
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
502 (GTK_DIALOG (dialog)->action_area), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
503 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
504 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
505 gtk_grab_add (dialog);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
506 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
507 dialog = gtk_dialog_new_with_buttons (title, NULL, 0,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
508 GTK_STOCK_SAVE,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
509 GTK_RESPONSE_OK,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
510 GTK_STOCK_CANCEL,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
511 GTK_RESPONSE_CANCEL,
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
512 NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
513 #endif
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
514 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
515 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
516 gtk_window_set_wmclass (GTK_WINDOW(dialog), "hostinfo", "Gftp");
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
517 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
518
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
519 frame = gtk_frame_new (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
520 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, TRUE, TRUE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
521 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
522 gtk_widget_show (frame);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
523
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
524 box = gtk_hbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
525 gtk_container_border_width (GTK_CONTAINER (box), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
526 gtk_container_add (GTK_CONTAINER (frame), box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
527 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
528
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
529 tempwid = gtk_label_new (_("Domain"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
530 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
531 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
532
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
533 new_proxy_domain = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
534 gtk_box_pack_start (GTK_BOX (box), new_proxy_domain, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
535 gtk_widget_show (new_proxy_domain);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
536
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
537 frame = gtk_frame_new (NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
538 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, TRUE, TRUE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
539 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
540 gtk_widget_show (frame);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
541
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
542 table = gtk_table_new (4, 2, FALSE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
543 gtk_container_border_width (GTK_CONTAINER (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
544 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
545 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
546 gtk_container_add (GTK_CONTAINER (frame), table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
547 gtk_widget_show (table);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
548
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
549 tempwid = gtk_label_new (_("Network Address"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
550 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
551 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 0, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
552 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
553
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
554 box = gtk_hbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
555 gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 0, 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
556 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
557
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
558 network1 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
559 gtk_widget_set_size_request (network1, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
560
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
561 gtk_box_pack_start (GTK_BOX (box), network1, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
562 gtk_widget_show (network1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
563
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
564 network2 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
565 gtk_widget_set_size_request (network2, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
566
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
567 gtk_box_pack_start (GTK_BOX (box), network2, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
568 gtk_widget_show (network2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
569
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
570 network3 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
571 gtk_widget_set_size_request (network3, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
572
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
573 gtk_box_pack_start (GTK_BOX (box), network3, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
574 gtk_widget_show (network3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
575
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
576 network4 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
577 gtk_widget_set_size_request (network4, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
578
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
579 gtk_box_pack_start (GTK_BOX (box), network4, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
580 gtk_widget_show (network4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
581
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
582 tempwid = gtk_label_new (_("Netmask"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
583 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
584 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
585 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
586
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
587 box = gtk_hbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
588 gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 1, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
589 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
590
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
591 netmask1 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
592 gtk_widget_set_size_request (netmask1, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
593
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
594 gtk_box_pack_start (GTK_BOX (box), netmask1, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
595 gtk_widget_show (netmask1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
596
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
597 netmask2 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
598 gtk_widget_set_size_request (netmask2, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
599
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
600 gtk_box_pack_start (GTK_BOX (box), netmask2, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
601 gtk_widget_show (netmask2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
602
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
603 netmask3 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
604 gtk_widget_set_size_request (netmask3, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
605
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
606 gtk_box_pack_start (GTK_BOX (box), netmask3, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
607 gtk_widget_show (netmask3);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
608
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
609 netmask4 = gtk_entry_new ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
610 gtk_widget_set_size_request (netmask4, 28, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
611
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
612 gtk_box_pack_start (GTK_BOX (box), netmask4, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
613 gtk_widget_show (netmask4);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
614
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
615 box = gtk_hbox_new (FALSE, 5);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
616 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, TRUE,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
617 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
618 gtk_widget_show (box);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
619
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
620 domain_active = gtk_radio_button_new_with_label (NULL, _("Domain"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
621 gtk_signal_connect (GTK_OBJECT (domain_active), "toggled",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
622 GTK_SIGNAL_FUNC (add_toggle), (gpointer) 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
623 gtk_box_pack_start (GTK_BOX (box), domain_active, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
624 gtk_widget_show (domain_active);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
625
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
626 tempwid = gtk_radio_button_new_with_label (gtk_radio_button_group
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
627 (GTK_RADIO_BUTTON (domain_active)),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
628 _("Network"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
629 gtk_signal_connect (GTK_OBJECT (tempwid), "toggled",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
630 GTK_SIGNAL_FUNC (add_toggle), NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
631 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
632 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
633
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
634 if (!hosts || !hosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
635 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
636 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
637 add_toggle (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
638 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
639 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
640 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
641 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (domain_active), TRUE);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
642 add_toggle (NULL, (gpointer) 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
643 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
644
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
645 if (hosts)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
646 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
647 if (hosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
648 gtk_entry_set_text (GTK_ENTRY (new_proxy_domain), hosts->domain);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
649 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
650 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
651 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 24 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
652 gtk_entry_set_text (GTK_ENTRY (network1), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
653 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
654
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
655 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 16 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
656 gtk_entry_set_text (GTK_ENTRY (network2), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
657 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
658
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
659 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 8 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
660 gtk_entry_set_text (GTK_ENTRY (network3), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
661 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
662
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
663 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
664 gtk_entry_set_text (GTK_ENTRY (network4), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
665 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
666
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
667 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 24 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
668 gtk_entry_set_text (GTK_ENTRY (netmask1), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
669 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
670
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
671 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 16 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
672 gtk_entry_set_text (GTK_ENTRY (netmask2), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
673 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
674
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
675 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 8 & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
676 gtk_entry_set_text (GTK_ENTRY (netmask3), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
677 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
678
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
679 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask & 0xff);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
680 gtk_entry_set_text (GTK_ENTRY (netmask4), tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
681 g_free (tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
682 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
683 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
684
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
685 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
686 tempwid = gtk_button_new_with_label (_("OK"));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
687 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
688 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
689 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
690 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
691 GTK_SIGNAL_FUNC (add_ok), (gpointer) templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
692 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
693 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
694 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
695 gtk_widget_show (tempwid);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
696
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
697 tempwid = gtk_button_new_with_label (_(" Cancel "));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
698 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
699 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
700 TRUE, TRUE, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
701 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
702 GTK_SIGNAL_FUNC (gtk_widget_destroy),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
703 GTK_OBJECT (dialog));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
704 gtk_widget_show (tempwid);
19
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
705 #else
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
706 g_signal_connect (GTK_OBJECT (dialog), "response",
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
707 G_CALLBACK (proxyhosts_action), NULL);
3b2dcdefc7e9 2002-09-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 1
diff changeset
708 #endif
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
709
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
710 gtk_widget_show (dialog);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
711 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
712
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
713
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
714 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
715 add_toggle (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
716 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
717 gtk_widget_set_sensitive (new_proxy_domain, data != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
718 gtk_widget_set_sensitive (network1, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
719 gtk_widget_set_sensitive (network2, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
720 gtk_widget_set_sensitive (network3, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
721 gtk_widget_set_sensitive (network4, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
722 gtk_widget_set_sensitive (netmask1, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
723 gtk_widget_set_sensitive (netmask2, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
724 gtk_widget_set_sensitive (netmask3, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
725 gtk_widget_set_sensitive (netmask4, data == NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
726 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
727
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
728
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
729 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
730 add_ok (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
731 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
732 gftp_proxy_hosts *hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
733 const char *edttxt;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
734 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
735 int num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
736
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
737 if ((templist = data) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
738 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
739 hosts = g_malloc0 (sizeof (*hosts));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
740 new_proxy_hosts = g_list_append (new_proxy_hosts, hosts);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
741 for (templist = new_proxy_hosts; templist->next != NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
742 templist = templist->next);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
743 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
744 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
745 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
746 num = gtk_clist_find_row_from_data (GTK_CLIST (proxy_list), templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
747 if (num != -1)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
748 gtk_clist_remove (GTK_CLIST (proxy_list), num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
749 hosts = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
750 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
751
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
752 if (hosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
753 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
754 g_free (hosts->domain);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
755 hosts->domain = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
756 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
757
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
758 if (GTK_TOGGLE_BUTTON (domain_active)->active)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
759 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
760 edttxt = gtk_entry_get_text (GTK_ENTRY (new_proxy_domain));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
761 hosts->domain = g_malloc (strlen (edttxt) + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
762 strcpy (hosts->domain, edttxt);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
763 hosts->ipv4_netmask = hosts->ipv4_network_address = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
764 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
765 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
766 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
767 edttxt = gtk_entry_get_text (GTK_ENTRY (network1));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
768 hosts->ipv4_network_address = (strtol (edttxt, NULL, 10) & 0xff) << 24;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
769
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
770 edttxt = gtk_entry_get_text (GTK_ENTRY (network2));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
771 hosts->ipv4_network_address |= (strtol (edttxt, NULL, 10) & 0xff) << 16;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
772
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
773 edttxt = gtk_entry_get_text (GTK_ENTRY (network3));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
774 hosts->ipv4_network_address |= (strtol (edttxt, NULL, 10) & 0xff) << 8;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
775
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
776 edttxt = gtk_entry_get_text (GTK_ENTRY (network4));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
777 hosts->ipv4_network_address |= strtol (edttxt, NULL, 10) & 0xff;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
778
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
779 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask1));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
780 hosts->ipv4_netmask = (strtol (edttxt, NULL, 10) & 0xff) << 24;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
781
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
782 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask2));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
783 hosts->ipv4_netmask |= (strtol (edttxt, NULL, 10) & 0xff) << 16;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
784
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
785 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask3));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
786 hosts->ipv4_netmask |= (strtol (edttxt, NULL, 10) & 0xff) << 8;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
787
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
788 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask4));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
789 hosts->ipv4_netmask |= strtol (edttxt, NULL, 10) & 0xff;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
790 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
791 add_host_to_listbox (templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
792 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
793
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
794
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
795 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
796 delete_proxy_host (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
797 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
798 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
799 int num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
800
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
801 if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
802 return;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
803 num = (int) templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
804 templist = gtk_clist_get_row_data (GTK_CLIST (proxy_list), num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
805 new_proxy_hosts = g_list_remove_link (new_proxy_hosts, templist);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
806 gtk_clist_remove (GTK_CLIST (proxy_list), num);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
807 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
808
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
809
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
810 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
811 proxy_toggle (GtkList * list, GtkWidget * child, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
812 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
813 int proxy_num;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
814 char *str;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
815
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
816 #if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
817 GtkTextIter iter, iter2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
818 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
819 guint len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
820 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
821
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
822 proxy_num = gtk_list_child_position (list, child);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
823 if (proxy_num == GFTP_CUSTOM_PROXY_NUM)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
824 str = custom_proxy;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
825 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
826 str = proxy_type[proxy_num].description;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
827
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
828 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
829 gtk_text_set_point (GTK_TEXT (proxy_text), 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
830 gtk_text_forward_delete (GTK_TEXT (proxy_text),
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
831 gtk_text_get_length (GTK_TEXT (proxy_text)));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
832
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
833 gtk_text_insert (GTK_TEXT (proxy_text), NULL, NULL, NULL, str, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
834 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
835 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (proxy_text));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
836 len = gtk_text_buffer_get_char_count (textbuf);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
837 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
838 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
839 gtk_text_buffer_delete (textbuf, &iter, &iter2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
840
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
841 len = gtk_text_buffer_get_char_count (textbuf);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
842 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len - 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
843 gtk_text_buffer_insert (textbuf, &iter, str, -1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
844 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
845 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
846
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
847
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
848 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
849 apply_changes (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
850 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
851 const char *tempstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
852 int num, found, i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
853 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
854
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
855 for (num = 0; config_file_vars[num].var != NULL; num++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
856 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
857 if (config_file_vars[num].widget != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
858 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
859 switch (config_file_vars[num].type)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
860 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
861 case CONFIG_CHECKBOX:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
862 *(int *) config_file_vars[num].var =
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
863 GTK_TOGGLE_BUTTON (config_file_vars[num].widget)->active;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
864 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
865 case CONFIG_INTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
866 case CONFIG_UINTTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
867 tempstr = gtk_entry_get_text (
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
868 GTK_ENTRY (config_file_vars[num].widget));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
869 *(int *) config_file_vars[num].var = strtol (tempstr, NULL, 10);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
870 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
871 case CONFIG_FLOATTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
872 tempstr = gtk_entry_get_text (
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
873 GTK_ENTRY (config_file_vars[num].widget));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
874 *(double *) config_file_vars[num].var = strtod (tempstr, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
875 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
876 case CONFIG_CHARTEXT:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
877 case CONFIG_CHARPASS:
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
878 tempstr = gtk_entry_get_text (
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
879 GTK_ENTRY (config_file_vars[num].widget));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
880 g_free (*(char **) config_file_vars[num].var);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
881 *(char **) config_file_vars[num].var =
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
882 g_malloc (strlen (tempstr) + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
883 strcpy (*(char **) config_file_vars[num].var, tempstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
884 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
885 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
886 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
887 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
888
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
889 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (def_proto_combo)->entry));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
890 found = 0;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
891 for (i = 0; gftp_protocols[i].name; i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
892 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
893 if (strcmp (gftp_protocols[i].name, tempstr) == 0)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
894 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
895 found = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
896 break;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
897 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
898 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
899
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
900 if (found)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
901 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
902 g_free (default_protocol);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
903 default_protocol = g_strconcat (tempstr, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
904 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
905
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
906 templist = proxy_hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
907 proxy_hosts = new_proxy_hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
908 new_proxy_hosts = templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
909 clean_old_changes (NULL, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
910
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
911 if (proxy_config != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
912 g_free (proxy_config);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
913 proxy_config = get_proxy_config ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
914
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
915 gftp_write_config_file ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
916 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
917
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
918
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
919 static void
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
920 clean_old_changes (GtkWidget * widget, gpointer data)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
921 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
922 gftp_proxy_hosts *hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
923 GList *templist;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
924
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
925 templist = new_proxy_hosts;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
926 while (templist != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
927 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
928 hosts = templist->data;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
929 if (hosts->domain)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
930 g_free (hosts->domain);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
931 g_free (hosts);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
932 templist = templist->next;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
933 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
934 g_list_free (new_proxy_hosts);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
935 new_proxy_hosts = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
936
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
937 if (custom_proxy != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
938 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
939 g_free (custom_proxy);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
940 custom_proxy = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
941 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
942 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
943
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
944
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
945 static char *
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
946 get_proxy_config (void)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
947 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
948 char *newstr, *oldstr, *pos, *endpos, *textstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
949 guint len;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
950 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
951 char tmp[128];
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
952 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
953 GtkTextBuffer * textbuf;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
954 GtkTextIter iter, iter2;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
955 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
956
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
957 textstr = NULL;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
958 newstr = g_malloc (1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
959 *newstr = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
960
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
961 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
962 /*
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
963 GTK_TEXT uses wchar_t instead of char in environment of multibyte encoding
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
964 locale (ex Japanese), so we must convert from wide character
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
965 to multibyte charator.... Yasuyuki Furukawa (yasu@on.cs.keio.ac.jp)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
966 */
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
967 if (GTK_TEXT (proxy_text)->use_wchar)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
968 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
969 wcstombs (tmp, (wchar_t *) GTK_TEXT (proxy_text)->text.wc,
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
970 sizeof (tmp));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
971 pos = tmp;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
972 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
973 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
974 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
975 oldstr = (char *) GTK_TEXT (proxy_text)->text.ch;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
976 len = gtk_text_get_length (GTK_TEXT (proxy_text));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
977 textstr = g_malloc (len + 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
978 strncpy (textstr, oldstr, len);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
979 textstr[len] = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
980 pos = textstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
981 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
982 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
983 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (proxy_text));
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
984 len = gtk_text_buffer_get_char_count (textbuf);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
985 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
986 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
987 pos = textstr = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
988 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
989
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
990 do
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
991 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
992 if ((endpos = strchr (pos, '\n')) != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
993 *endpos = '\0';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
994 oldstr = newstr;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
995 if (endpos != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
996 newstr = g_strconcat (newstr, pos, "%n", NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
997 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
998 newstr = g_strconcat (newstr, pos, NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
999 g_free (oldstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1000 if (endpos != NULL)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1001 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1002 *endpos = '\n';
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1003 pos = endpos + 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1004 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1005 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1006 while (endpos != NULL);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1007
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1008 #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1009 if (!GTK_TEXT (proxy_text)->use_wchar)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1010 g_free (textstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1011 #else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1012 g_free (textstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1013 #endif
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1014
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1015 return (newstr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1016 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1017