1
|
1 /*****************************************************************************/
|
|
2 /* menu-items.c - menu callbacks */
|
255
|
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
|
1
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
18 /*****************************************************************************/
|
|
19
|
518
|
20 #include "gftp-gtk.h"
|
33
|
21 static const char cvsid[] = "$Id$";
|
1
|
22
|
136
|
23 static GtkWidget * proxy_list, * new_proxy_domain, * network1,
|
1
|
24 * network2, * network3, * network4, * netmask1, * netmask2,
|
136
|
25 * netmask3, * netmask4, * domain_active;
|
518
|
26 static gftp_options_dialog_data * gftp_option_data;
|
229
|
27 static GList * new_proxy_hosts = NULL;
|
136
|
28
|
|
29 static void
|
|
30 _setup_option (gftp_option_type_enum otype,
|
|
31 gftp_options_dialog_data * option_data,
|
|
32 void * (*ui_print_function) (gftp_config_vars * cv,
|
229
|
33 void *user_data,
|
|
34 void *value),
|
136
|
35 void (*ui_save_function) (gftp_config_vars * cv,
|
139
|
36 void *user_data),
|
|
37 void (*ui_cancel_function) (gftp_config_vars * cv,
|
|
38 void *user_data))
|
|
39
|
136
|
40 {
|
|
41 gftp_option_types[otype].user_data = option_data;
|
|
42 gftp_option_types[otype].ui_print_function = ui_print_function;
|
|
43 gftp_option_types[otype].ui_save_function = ui_save_function;
|
139
|
44 gftp_option_types[otype].ui_cancel_function = ui_cancel_function;
|
136
|
45 }
|
|
46
|
|
47
|
|
48 static void *
|
139
|
49 _gen_input_widget (gftp_options_dialog_data * option_data, char *label, char *tiptxt)
|
136
|
50 {
|
139
|
51 GtkTooltips * tooltip;
|
136
|
52 GtkWidget * tempwid;
|
|
53
|
|
54 option_data->tbl_row_num++;
|
|
55 gtk_table_resize (GTK_TABLE (option_data->table),
|
|
56 option_data->tbl_row_num, 2);
|
|
57
|
|
58 tempwid = gtk_label_new (_(label));
|
|
59 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
|
|
60 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 0, 1,
|
|
61 option_data->tbl_row_num - 1,
|
|
62 option_data->tbl_row_num);
|
|
63 gtk_widget_show (tempwid);
|
|
64
|
|
65 tempwid = gtk_entry_new ();
|
|
66 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 1, 2,
|
|
67 option_data->tbl_row_num - 1,
|
|
68 option_data->tbl_row_num);
|
|
69 gtk_widget_show (tempwid);
|
139
|
70
|
|
71 if (tiptxt != NULL)
|
|
72 {
|
|
73 tooltip = gtk_tooltips_new ();
|
294
|
74 gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltip), tempwid, _(tiptxt), NULL);
|
139
|
75 }
|
|
76
|
136
|
77 return (tempwid);
|
|
78 }
|
|
79
|
|
80
|
|
81 static void *
|
229
|
82 _print_option_type_newtable (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
83 {
|
|
84 gftp_options_dialog_data * option_data;
|
|
85
|
|
86 option_data = user_data;
|
|
87
|
|
88 option_data->table = gtk_table_new (1, 2, FALSE);
|
|
89 gtk_table_set_row_spacings (GTK_TABLE (option_data->table), 5);
|
|
90 gtk_table_set_col_spacings (GTK_TABLE (option_data->table), 5);
|
|
91 gtk_box_pack_start (GTK_BOX (option_data->box), option_data->table, FALSE,
|
|
92 FALSE, 0);
|
|
93 gtk_widget_show (option_data->table);
|
|
94 option_data->tbl_row_num = 0;
|
|
95 option_data->tbl_col_num = 0;
|
|
96
|
|
97 return (NULL);
|
|
98 }
|
|
99
|
|
100
|
|
101 static void *
|
229
|
102 _print_option_type_text (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
103 {
|
|
104 gftp_options_dialog_data * option_data;
|
|
105 GtkWidget * tempwid;
|
|
106
|
|
107 option_data = user_data;
|
|
108
|
139
|
109 tempwid = _gen_input_widget (option_data, cv->description, cv->comment);
|
229
|
110 if (value != NULL)
|
|
111 gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) value);
|
218
|
112
|
136
|
113 return (tempwid);
|
|
114 }
|
|
115
|
|
116
|
|
117 static void
|
|
118 _save_option_type_text (gftp_config_vars * cv, void *user_data)
|
|
119 {
|
|
120 gftp_options_dialog_data * option_data;
|
|
121 const char *tempstr;
|
|
122
|
|
123 option_data = user_data;
|
|
124 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
|
|
125
|
229
|
126 if (option_data->bm == NULL)
|
|
127 gftp_set_global_option (cv->key, tempstr);
|
|
128 else
|
|
129 gftp_set_bookmark_option (option_data->bm, cv->key, tempstr);
|
136
|
130 }
|
|
131
|
|
132
|
|
133 static GtkWidget *
|
|
134 _gen_combo_widget (gftp_options_dialog_data * option_data, char *label)
|
|
135 {
|
|
136 GtkWidget * tempwid, * combo;
|
|
137
|
|
138 option_data->tbl_row_num++;
|
|
139 gtk_table_resize (GTK_TABLE (option_data->table),
|
|
140 option_data->tbl_row_num, 2);
|
|
141
|
|
142 tempwid = gtk_label_new (_(label));
|
|
143 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
|
|
144 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 0, 1,
|
|
145 option_data->tbl_row_num - 1,
|
|
146 option_data->tbl_row_num);
|
|
147 gtk_widget_show (tempwid);
|
|
148
|
|
149 combo = gtk_combo_new ();
|
|
150 gtk_table_attach_defaults (GTK_TABLE (option_data->table), combo, 1, 2,
|
|
151 option_data->tbl_row_num - 1,
|
|
152 option_data->tbl_row_num);
|
|
153 return (combo);
|
|
154 }
|
|
155
|
|
156
|
|
157 static void *
|
229
|
158 _print_option_type_textcombo (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
159 {
|
|
160 gftp_options_dialog_data * option_data;
|
139
|
161 GtkWidget * tempwid, * combo;
|
136
|
162 GList * widget_list;
|
139
|
163 GtkTooltips * tooltip;
|
136
|
164 int selitem, i;
|
|
165 char **clist;
|
|
166
|
|
167 option_data = user_data;
|
|
168 combo = _gen_combo_widget (option_data, cv->description);
|
|
169
|
|
170 if (cv->listdata != NULL)
|
|
171 {
|
|
172 selitem = 0;
|
|
173 widget_list = NULL;
|
|
174
|
|
175 clist = cv->listdata;
|
|
176 for (i=0; clist[i] != NULL; i++)
|
|
177 {
|
229
|
178 if (value != NULL && strcasecmp ((char *) value, clist[i]) == 0)
|
136
|
179 selitem = i;
|
|
180
|
|
181 tempwid = gtk_list_item_new_with_label (clist[i]);
|
|
182 gtk_widget_show (tempwid);
|
|
183 widget_list = g_list_append (widget_list, tempwid);
|
|
184 }
|
|
185
|
|
186 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list), widget_list);
|
|
187 gtk_list_select_item (GTK_LIST (GTK_COMBO (combo)->list), selitem);
|
|
188 }
|
|
189
|
|
190 gtk_widget_show (combo);
|
139
|
191
|
|
192 if (cv->comment != NULL)
|
|
193 {
|
|
194 tooltip = gtk_tooltips_new ();
|
294
|
195 gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltip), combo, _(cv->comment), NULL);
|
139
|
196 }
|
|
197
|
136
|
198 return (combo);
|
|
199 }
|
|
200
|
|
201
|
|
202 static void
|
|
203 _save_option_type_textcombo (gftp_config_vars * cv, void *user_data)
|
|
204 {
|
|
205 gftp_options_dialog_data * option_data;
|
|
206 const char *tempstr;
|
|
207
|
|
208 option_data = user_data;
|
|
209
|
|
210 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (cv->user_data)->entry));
|
|
211
|
229
|
212 if (option_data->bm == NULL)
|
|
213 gftp_set_global_option (cv->key, tempstr);
|
|
214 else
|
|
215 gftp_set_bookmark_option (option_data->bm, cv->key, tempstr);
|
136
|
216 }
|
|
217
|
|
218
|
|
219 static void
|
|
220 _textcomboedt_toggle (GtkList * list, GtkWidget * child, gpointer data)
|
|
221 {
|
|
222 gftp_textcomboedt_widget_data * widdata;
|
|
223 gftp_textcomboedt_data * tedata;
|
139
|
224 char *insert_text;
|
136
|
225 int num, isedit;
|
|
226 #if GTK_MAJOR_VERSION > 1
|
|
227 GtkTextIter iter, iter2;
|
|
228 GtkTextBuffer * textbuf;
|
|
229 guint len;
|
|
230 #endif
|
|
231
|
|
232 widdata = data;
|
|
233 tedata = widdata->cv->listdata;
|
|
234
|
|
235 num = gtk_list_child_position (list, child);
|
|
236 isedit = tedata[num].flags & GFTP_TEXTCOMBOEDT_EDITABLE;
|
|
237 #if GTK_MAJOR_VERSION == 1
|
|
238 gtk_text_set_editable (GTK_TEXT (widdata->text), isedit);
|
|
239 #else
|
|
240 gtk_text_view_set_editable (GTK_TEXT_VIEW (widdata->text), isedit);
|
|
241 #endif
|
|
242
|
|
243 if (isedit)
|
139
|
244 insert_text = widdata->custom_edit_value;
|
|
245 else
|
|
246 insert_text = tedata[num].text;
|
136
|
247
|
|
248 #if GTK_MAJOR_VERSION == 1
|
|
249 gtk_text_set_point (GTK_TEXT (widdata->text), 0);
|
|
250 gtk_text_forward_delete (GTK_TEXT (widdata->text),
|
|
251 gtk_text_get_length (GTK_TEXT (widdata->text)));
|
|
252
|
|
253 gtk_text_insert (GTK_TEXT (widdata->text), NULL, NULL, NULL,
|
139
|
254 insert_text, -1);
|
136
|
255 #else
|
|
256 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widdata->text));
|
|
257 len = gtk_text_buffer_get_char_count (textbuf);
|
|
258 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
|
287
|
259 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len);
|
136
|
260 gtk_text_buffer_delete (textbuf, &iter, &iter2);
|
|
261
|
|
262 len = gtk_text_buffer_get_char_count (textbuf);
|
287
|
263 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len);
|
139
|
264 gtk_text_buffer_insert (textbuf, &iter, insert_text, -1);
|
136
|
265 #endif
|
|
266 }
|
|
267
|
|
268
|
139
|
269 static char *
|
|
270 _gftp_convert_to_newlines (char *str)
|
|
271 {
|
|
272 char *stpos, *endpos, *ret, savechar;
|
|
273 size_t len;
|
|
274
|
|
275 ret = g_strdup ("");
|
|
276 len = 0;
|
219
|
277
|
139
|
278 for (stpos = str;
|
|
279 (endpos = strstr (stpos, "%n")) != NULL;
|
|
280 stpos = endpos + 2)
|
|
281 {
|
|
282 savechar = *endpos;
|
|
283 *endpos = '\0';
|
|
284
|
|
285 len += strlen (stpos) + 1;
|
|
286 ret = g_realloc (ret, len + 1);
|
|
287 strcat (ret, stpos);
|
|
288 strcat (ret, "\n");
|
|
289
|
|
290 *endpos = savechar;
|
|
291 }
|
|
292
|
219
|
293 if (stpos != NULL && *stpos != '\0')
|
|
294 {
|
|
295 len += strlen (stpos);
|
|
296 ret = g_realloc (ret, len + 1);
|
|
297 strcat (ret, stpos);
|
|
298 }
|
|
299
|
139
|
300 return (ret);
|
|
301 }
|
|
302
|
|
303
|
|
304 static char *
|
|
305 _gftp_convert_from_newlines (char *str)
|
|
306 {
|
|
307 char *stpos, *endpos, *ret, savechar;
|
|
308 size_t len;
|
|
309
|
|
310 ret = g_strdup ("");
|
|
311 len = 0;
|
219
|
312
|
139
|
313 for (stpos = str;
|
|
314 (endpos = strchr (stpos, '\n')) != NULL;
|
|
315 stpos = endpos + 1)
|
|
316 {
|
|
317 savechar = *endpos;
|
|
318 *endpos = '\0';
|
|
319
|
|
320 len += strlen (stpos) + 2;
|
|
321 ret = g_realloc (ret, len + 1);
|
|
322 strcat (ret, stpos);
|
|
323 strcat (ret, "%n");
|
|
324
|
|
325 *endpos = savechar;
|
|
326 }
|
|
327
|
219
|
328 if (stpos != NULL && *stpos != '\0')
|
|
329 {
|
|
330 len += strlen (stpos);
|
|
331 ret = g_realloc (ret, len + 1);
|
|
332 strcat (ret, stpos);
|
|
333 }
|
|
334
|
139
|
335 return (ret);
|
|
336 }
|
|
337
|
|
338
|
136
|
339 static void *
|
229
|
340 _print_option_type_textcomboedt (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
341 {
|
|
342 gftp_textcomboedt_widget_data * widdata;
|
|
343 GtkWidget * combo, * textwid, * tempwid;
|
|
344 gftp_options_dialog_data * option_data;
|
|
345 gftp_textcomboedt_data * tedata;
|
|
346 int i, selitem, edititem;
|
139
|
347 GtkTooltips * tooltip;
|
136
|
348 GList * widget_list;
|
|
349 char *tempstr;
|
|
350
|
|
351 option_data = user_data;
|
|
352 combo = _gen_combo_widget (option_data, cv->description);
|
139
|
353
|
|
354 tempstr = NULL;
|
229
|
355 if (value != NULL)
|
|
356 tempstr = _gftp_convert_to_newlines (value);
|
139
|
357 if (tempstr == NULL)
|
|
358 tempstr = g_strdup ("");
|
136
|
359
|
|
360 edititem = selitem = -1;
|
|
361 if (cv->listdata != NULL)
|
|
362 {
|
|
363 widget_list = NULL;
|
|
364
|
|
365 tedata = cv->listdata;
|
|
366 for (i=0; tedata[i].description != NULL; i++)
|
|
367 {
|
|
368 if (tedata[i].flags & GFTP_TEXTCOMBOEDT_EDITABLE)
|
|
369 edititem = i;
|
|
370
|
139
|
371 if (selitem == -1 &&
|
|
372 strcasecmp (tempstr, tedata[i].text) == 0)
|
136
|
373 selitem = i;
|
|
374
|
|
375 tempwid = gtk_list_item_new_with_label (tedata[i].description);
|
|
376 gtk_widget_show (tempwid);
|
|
377 widget_list = g_list_append (widget_list, tempwid);
|
|
378 }
|
|
379
|
|
380 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list), widget_list);
|
|
381
|
139
|
382 if (selitem == -1 && edititem != -1)
|
|
383 selitem = edititem;
|
136
|
384 }
|
|
385
|
139
|
386 if (selitem == -1)
|
136
|
387 selitem = 0;
|
|
388
|
|
389 option_data->tbl_row_num++;
|
|
390 gtk_table_resize (GTK_TABLE (option_data->table),
|
|
391 option_data->tbl_row_num, 2);
|
|
392
|
|
393 #if GTK_MAJOR_VERSION == 1
|
|
394 textwid = gtk_text_new (NULL, NULL);
|
|
395 #else
|
|
396 textwid = gtk_text_view_new ();
|
|
397 #endif
|
|
398 gtk_widget_set_size_request (textwid, -1, 75);
|
|
399 gtk_table_attach_defaults (GTK_TABLE (option_data->table), textwid, 0, 2,
|
|
400 option_data->tbl_row_num - 1,
|
|
401 option_data->tbl_row_num);
|
|
402 gtk_widget_show (textwid);
|
|
403
|
|
404 widdata = g_malloc0 (sizeof (*widdata));
|
|
405 widdata->combo = combo;
|
|
406 widdata->text = textwid;
|
|
407 widdata->cv = cv;
|
139
|
408 widdata->custom_edit_value = tempstr;
|
136
|
409
|
|
410 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->list),
|
|
411 "select_child",
|
|
412 GTK_SIGNAL_FUNC (_textcomboedt_toggle), widdata);
|
|
413 gtk_list_select_item (GTK_LIST (GTK_COMBO (combo)->list), selitem);
|
|
414 gtk_widget_show (combo);
|
|
415
|
139
|
416 if (cv->comment != NULL)
|
|
417 {
|
|
418 tooltip = gtk_tooltips_new ();
|
294
|
419 gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltip), combo, _(cv->comment), NULL);
|
139
|
420
|
|
421 tooltip = gtk_tooltips_new ();
|
294
|
422 gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltip), textwid, _(cv->comment),
|
|
423 NULL);
|
139
|
424 }
|
|
425
|
|
426 return (widdata);
|
|
427 }
|
|
428
|
|
429
|
|
430 static void
|
136
|
431 _save_option_type_textcomboedt (gftp_config_vars * cv, void *user_data)
|
|
432 {
|
139
|
433 gftp_textcomboedt_widget_data * widdata;
|
518
|
434 gftp_options_dialog_data * option_data;
|
229
|
435 char *newstr, *proxy_config;
|
139
|
436 int freeit;
|
136
|
437 #if GTK_MAJOR_VERSION == 1
|
|
438 char tmp[128];
|
|
439 #else
|
|
440 GtkTextBuffer * textbuf;
|
|
441 GtkTextIter iter, iter2;
|
|
442 size_t len;
|
|
443 #endif
|
|
444
|
518
|
445 option_data = user_data;
|
139
|
446 widdata = cv->user_data;
|
136
|
447
|
|
448 #if GTK_MAJOR_VERSION == 1
|
|
449 /*
|
|
450 GTK_TEXT uses wchar_t instead of char in environment of multibyte encoding
|
|
451 locale (ex Japanese), so we must convert from wide character
|
|
452 to multibyte charator.... Yasuyuki Furukawa (yasu@on.cs.keio.ac.jp)
|
|
453 */
|
139
|
454 if (GTK_TEXT (widdata->text)->use_wchar)
|
136
|
455 {
|
139
|
456 wcstombs (tmp, (wchar_t *) GTK_TEXT (widdata->text)->text.wc, sizeof (tmp));
|
|
457 newstr = tmp;
|
136
|
458 }
|
|
459 else
|
219
|
460 newstr = (char *) GTK_TEXT (widdata->text)->text.ch;
|
|
461
|
|
462 freeit = 0;
|
136
|
463 #else
|
139
|
464 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widdata->text));
|
136
|
465 len = gtk_text_buffer_get_char_count (textbuf);
|
|
466 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
|
287
|
467 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len);
|
136
|
468 newstr = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0);
|
139
|
469 freeit = 1;
|
136
|
470 #endif
|
|
471
|
229
|
472 proxy_config = _gftp_convert_from_newlines (newstr);
|
139
|
473
|
229
|
474 if (option_data->bm == NULL)
|
|
475 gftp_set_global_option (cv->key, proxy_config);
|
|
476 else
|
|
477 gftp_set_bookmark_option (option_data->bm, cv->key, proxy_config);
|
|
478
|
|
479 g_free (proxy_config);
|
139
|
480
|
|
481 if (freeit)
|
|
482 g_free (newstr);
|
136
|
483 }
|
|
484
|
|
485
|
|
486 static void *
|
229
|
487 _print_option_type_hidetext (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
488 {
|
|
489 gftp_options_dialog_data * option_data;
|
|
490 GtkWidget * tempwid;
|
|
491
|
|
492 option_data = user_data;
|
|
493
|
139
|
494 tempwid = _gen_input_widget (option_data, cv->description, cv->comment);
|
136
|
495 gtk_entry_set_visibility (GTK_ENTRY (tempwid), 0);
|
229
|
496 gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) value);
|
136
|
497 return (tempwid);
|
|
498 }
|
|
499
|
|
500
|
|
501 static void *
|
229
|
502 _print_option_type_int (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
503 {
|
|
504 gftp_options_dialog_data * option_data;
|
|
505 GtkWidget * tempwid;
|
|
506 char tempstr[20];
|
|
507
|
|
508 option_data = user_data;
|
|
509
|
139
|
510 tempwid = _gen_input_widget (option_data, cv->description, cv->comment);
|
229
|
511 g_snprintf (tempstr, sizeof (tempstr), "%d", GPOINTER_TO_INT(value));
|
136
|
512 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr);
|
|
513 return (tempwid);
|
|
514 }
|
|
515
|
|
516
|
|
517 static void
|
|
518 _save_option_type_int (gftp_config_vars * cv, void *user_data)
|
|
519 {
|
|
520 gftp_options_dialog_data * option_data;
|
|
521 const char *tempstr;
|
472
|
522 intptr_t val;
|
136
|
523
|
|
524 option_data = user_data;
|
|
525 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
|
227
|
526
|
229
|
527 val = strtol (tempstr, NULL, 10);
|
|
528
|
|
529 if (option_data->bm == NULL)
|
|
530 gftp_set_global_option (cv->key, GINT_TO_POINTER(val));
|
|
531 else
|
|
532 gftp_set_bookmark_option (option_data->bm, cv->key, GINT_TO_POINTER(val));
|
136
|
533 }
|
|
534
|
|
535
|
|
536 static void *
|
229
|
537 _print_option_type_checkbox (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
538 {
|
|
539 gftp_options_dialog_data * option_data;
|
139
|
540 GtkTooltips * tooltip;
|
136
|
541 GtkWidget * tempwid;
|
|
542
|
|
543 option_data = user_data;
|
|
544
|
|
545 if (option_data->last_option != gftp_option_type_checkbox)
|
229
|
546 _print_option_type_newtable (NULL, user_data, NULL);
|
136
|
547
|
|
548 if (option_data->tbl_col_num == 0)
|
|
549 {
|
|
550 option_data->tbl_row_num++;
|
|
551 gtk_table_resize (GTK_TABLE (option_data->table),
|
|
552 option_data->tbl_row_num + 1, 2);
|
|
553 }
|
|
554
|
|
555 tempwid = gtk_check_button_new_with_label (_(cv->description));
|
|
556 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid,
|
|
557 option_data->tbl_col_num,
|
|
558 option_data->tbl_col_num + 1,
|
|
559 option_data->tbl_row_num,
|
|
560 option_data->tbl_row_num + 1);
|
|
561 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid),
|
229
|
562 GPOINTER_TO_INT(value));
|
136
|
563 gtk_widget_show (tempwid);
|
|
564
|
|
565 option_data->tbl_col_num = (option_data->tbl_col_num + 1) % 2;
|
139
|
566
|
|
567 if (cv->comment != NULL)
|
|
568 {
|
|
569 tooltip = gtk_tooltips_new ();
|
294
|
570 gtk_tooltips_set_tip (GTK_TOOLTIPS(tooltip), tempwid, _(cv->comment),
|
|
571 NULL);
|
139
|
572 }
|
|
573
|
136
|
574 return (tempwid);
|
|
575 }
|
|
576
|
|
577
|
|
578 static void
|
|
579 _save_option_type_checkbox (gftp_config_vars * cv, void *user_data)
|
|
580 {
|
|
581 gftp_options_dialog_data * option_data;
|
472
|
582 intptr_t val;
|
136
|
583
|
|
584 option_data = user_data;
|
229
|
585
|
|
586 val = GTK_TOGGLE_BUTTON (cv->user_data)->active;
|
|
587
|
|
588 if (option_data->bm == NULL)
|
|
589 gftp_set_global_option (cv->key, GINT_TO_POINTER (val));
|
|
590 else
|
|
591 gftp_set_bookmark_option (option_data->bm, cv->key, GINT_TO_POINTER (val));
|
136
|
592 }
|
|
593
|
|
594
|
|
595 static void *
|
229
|
596 _print_option_type_float (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
597 {
|
|
598 gftp_options_dialog_data * option_data;
|
|
599 GtkWidget * tempwid;
|
|
600 char tempstr[20];
|
|
601 float f;
|
|
602
|
|
603 option_data = user_data;
|
|
604
|
139
|
605 tempwid = _gen_input_widget (option_data, cv->description, cv->comment);
|
229
|
606 memcpy (&f, &value, sizeof (f));
|
136
|
607 g_snprintf (tempstr, sizeof (tempstr), "%.2f", f);
|
|
608 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr);
|
|
609 return (tempwid);
|
|
610 }
|
|
611
|
|
612
|
|
613 static void
|
|
614 _save_option_type_float (gftp_config_vars * cv, void *user_data)
|
|
615 {
|
|
616 gftp_options_dialog_data * option_data;
|
472
|
617 union { void *ptr; float f; } fv;
|
136
|
618 const char *tempstr;
|
|
619
|
|
620 option_data = user_data;
|
|
621 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data));
|
472
|
622 fv.f = strtod (tempstr, NULL);
|
229
|
623
|
|
624 if (option_data->bm == NULL)
|
472
|
625 gftp_set_global_option (cv->key, fv.ptr);
|
229
|
626 else
|
472
|
627 gftp_set_bookmark_option (option_data->bm, cv->key, fv.ptr);
|
136
|
628 }
|
|
629
|
|
630
|
|
631 static void *
|
229
|
632 _print_option_type_notebook (gftp_config_vars * cv, void *user_data, void *value)
|
136
|
633 {
|
|
634 gftp_options_dialog_data * option_data;
|
|
635 GtkWidget * tempwid;
|
|
636
|
|
637 option_data = user_data;
|
|
638
|
|
639 option_data->box = gtk_vbox_new (FALSE, 0);
|
|
640 gtk_container_border_width (GTK_CONTAINER (option_data->box), 10);
|
|
641 gtk_widget_show (option_data->box);
|
|
642
|
|
643 tempwid = gtk_label_new (_(cv->description));
|
|
644 gtk_widget_show (tempwid);
|
|
645 gtk_notebook_append_page (GTK_NOTEBOOK (option_data->notebook),
|
|
646 option_data->box, tempwid);
|
|
647
|
229
|
648 _print_option_type_newtable (NULL, user_data, NULL);
|
136
|
649
|
|
650 return (NULL);
|
|
651 }
|
1
|
652
|
48
|
653
|
|
654 static void
|
|
655 clean_old_changes (GtkWidget * widget, gpointer data)
|
|
656 {
|
239
|
657 gftp_textcomboedt_widget_data * widdata;
|
|
658 gftp_config_vars * cv;
|
|
659 GList * templist;
|
|
660 int i;
|
|
661
|
|
662 for (templist = gftp_options_list;
|
|
663 templist != NULL;
|
|
664 templist = templist->next)
|
|
665 {
|
|
666 cv = templist->data;
|
|
667
|
|
668 for (i=0; cv[i].key != NULL; i++)
|
|
669 {
|
|
670 widdata = cv->user_data;
|
|
671 if (widdata != NULL)
|
|
672 {
|
|
673 if (widdata->custom_edit_value != NULL)
|
|
674 g_free (widdata->custom_edit_value);
|
|
675 g_free (widdata);
|
|
676 cv->user_data = NULL;
|
|
677 }
|
|
678 }
|
|
679 }
|
|
680
|
218
|
681 if (new_proxy_hosts != NULL)
|
48
|
682 {
|
218
|
683 gftp_free_proxy_hosts (new_proxy_hosts);
|
|
684 new_proxy_hosts = NULL;
|
48
|
685 }
|
|
686 }
|
|
687
|
|
688
|
|
689 static void
|
|
690 apply_changes (GtkWidget * widget, gpointer data)
|
|
691 {
|
218
|
692 gftp_config_list_vars * proxy_hosts;
|
136
|
693 gftp_config_vars * cv;
|
|
694 GList * templist;
|
|
695 int i;
|
48
|
696
|
136
|
697 for (templist = gftp_options_list;
|
|
698 templist != NULL;
|
|
699 templist = templist->next)
|
48
|
700 {
|
136
|
701 cv = templist->data;
|
|
702
|
|
703 for (i=0; cv[i].key != NULL; i++)
|
48
|
704 {
|
136
|
705 if (!(cv[i].ports_shown & GFTP_PORT_GTK))
|
|
706 continue;
|
|
707
|
|
708 if (gftp_option_types[cv[i].otype].ui_save_function == NULL)
|
|
709 continue;
|
|
710
|
|
711 gftp_option_types[cv[i].otype].ui_save_function (&cv[i], gftp_option_types[cv[i].otype].user_data);
|
48
|
712 }
|
|
713 }
|
218
|
714
|
|
715 gftp_lookup_global_option ("dont_use_proxy", &proxy_hosts);
|
|
716
|
|
717 if (proxy_hosts->list != NULL)
|
|
718 gftp_free_proxy_hosts (proxy_hosts->list);
|
|
719
|
|
720 proxy_hosts->list = new_proxy_hosts;
|
|
721 new_proxy_hosts = NULL;
|
341
|
722 gftpui_show_or_hide_command ();
|
48
|
723 }
|
|
724
|
|
725
|
45
|
726 #if GTK_MAJOR_VERSION > 1
|
19
|
727 static void
|
|
728 options_action (GtkWidget * widget, gint response, gpointer user_data)
|
|
729 {
|
|
730 switch (response)
|
|
731 {
|
|
732 case GTK_RESPONSE_APPLY:
|
|
733 apply_changes (widget, NULL);
|
|
734 break;
|
|
735 case GTK_RESPONSE_OK:
|
|
736 apply_changes (widget, NULL);
|
|
737 /* no break */
|
|
738 default:
|
218
|
739 clean_old_changes (widget, user_data);
|
19
|
740 gtk_widget_destroy (widget);
|
|
741 }
|
|
742 }
|
|
743 #endif
|
|
744
|
|
745
|
48
|
746 static void
|
|
747 add_host_to_listbox (GList * templist)
|
|
748 {
|
|
749 gftp_proxy_hosts *hosts;
|
|
750 char *add_data[2];
|
|
751 int num;
|
|
752
|
|
753 hosts = templist->data;
|
|
754 if (hosts->domain)
|
|
755 {
|
|
756 add_data[0] = hosts->domain;
|
|
757 add_data[1] = NULL;
|
|
758 num = gtk_clist_append (GTK_CLIST (proxy_list), add_data);
|
|
759 }
|
|
760 else
|
|
761 {
|
|
762 add_data[0] = g_strdup_printf ("%d.%d.%d.%d",
|
|
763 hosts->ipv4_network_address >> 24 & 0xff,
|
|
764 hosts->ipv4_network_address >> 16 & 0xff,
|
|
765 hosts->ipv4_network_address >> 8 & 0xff,
|
|
766 hosts->ipv4_network_address & 0xff);
|
|
767 add_data[1] = g_strdup_printf ("%d.%d.%d.%d",
|
|
768 hosts->ipv4_netmask >> 24 & 0xff,
|
|
769 hosts->ipv4_netmask >> 16 & 0xff,
|
|
770 hosts->ipv4_netmask >> 8 & 0xff,
|
|
771 hosts->ipv4_netmask & 0xff);
|
|
772 num = gtk_clist_append (GTK_CLIST (proxy_list), add_data);
|
|
773 g_free (add_data[0]);
|
|
774 g_free (add_data[1]);
|
|
775 }
|
218
|
776
|
48
|
777 gtk_clist_set_row_data (GTK_CLIST (proxy_list), num, (gpointer) templist);
|
|
778 }
|
|
779
|
|
780
|
|
781 static void
|
|
782 add_ok (GtkWidget * widget, gpointer data)
|
|
783 {
|
|
784 gftp_proxy_hosts *hosts;
|
|
785 const char *edttxt;
|
|
786 GList *templist;
|
|
787 int num;
|
|
788
|
218
|
789 templist = data;
|
|
790 if (templist == NULL)
|
48
|
791 {
|
|
792 hosts = g_malloc0 (sizeof (*hosts));
|
|
793 new_proxy_hosts = g_list_append (new_proxy_hosts, hosts);
|
|
794 for (templist = new_proxy_hosts; templist->next != NULL;
|
|
795 templist = templist->next);
|
|
796 }
|
|
797 else
|
|
798 {
|
|
799 num = gtk_clist_find_row_from_data (GTK_CLIST (proxy_list), templist);
|
|
800 if (num != -1)
|
|
801 gtk_clist_remove (GTK_CLIST (proxy_list), num);
|
|
802 hosts = templist->data;
|
|
803 }
|
|
804
|
|
805 if (hosts->domain)
|
|
806 {
|
|
807 g_free (hosts->domain);
|
|
808 hosts->domain = NULL;
|
|
809 }
|
|
810
|
|
811 if (GTK_TOGGLE_BUTTON (domain_active)->active)
|
|
812 {
|
|
813 edttxt = gtk_entry_get_text (GTK_ENTRY (new_proxy_domain));
|
218
|
814 hosts->domain = g_strdup (edttxt);
|
48
|
815 hosts->ipv4_netmask = hosts->ipv4_network_address = 0;
|
|
816 }
|
|
817 else
|
|
818 {
|
|
819 edttxt = gtk_entry_get_text (GTK_ENTRY (network1));
|
|
820 hosts->ipv4_network_address = (strtol (edttxt, NULL, 10) & 0xff) << 24;
|
|
821
|
|
822 edttxt = gtk_entry_get_text (GTK_ENTRY (network2));
|
|
823 hosts->ipv4_network_address |= (strtol (edttxt, NULL, 10) & 0xff) << 16;
|
|
824
|
|
825 edttxt = gtk_entry_get_text (GTK_ENTRY (network3));
|
|
826 hosts->ipv4_network_address |= (strtol (edttxt, NULL, 10) & 0xff) << 8;
|
|
827
|
|
828 edttxt = gtk_entry_get_text (GTK_ENTRY (network4));
|
|
829 hosts->ipv4_network_address |= strtol (edttxt, NULL, 10) & 0xff;
|
|
830
|
|
831 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask1));
|
|
832 hosts->ipv4_netmask = (strtol (edttxt, NULL, 10) & 0xff) << 24;
|
|
833
|
|
834 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask2));
|
|
835 hosts->ipv4_netmask |= (strtol (edttxt, NULL, 10) & 0xff) << 16;
|
|
836
|
|
837 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask3));
|
|
838 hosts->ipv4_netmask |= (strtol (edttxt, NULL, 10) & 0xff) << 8;
|
|
839
|
|
840 edttxt = gtk_entry_get_text (GTK_ENTRY (netmask4));
|
|
841 hosts->ipv4_netmask |= strtol (edttxt, NULL, 10) & 0xff;
|
|
842 }
|
218
|
843
|
48
|
844 add_host_to_listbox (templist);
|
|
845 }
|
|
846
|
|
847
|
|
848 #if GTK_MAJOR_VERSION > 1
|
|
849 static void
|
|
850 proxyhosts_action (GtkWidget * widget, gint response, gpointer user_data)
|
|
851 {
|
|
852 switch (response)
|
|
853 {
|
|
854 case GTK_RESPONSE_OK:
|
|
855 add_ok (widget, user_data);
|
|
856 /* no break */
|
|
857 default:
|
|
858 gtk_widget_destroy (widget);
|
|
859 }
|
|
860 }
|
|
861 #endif
|
|
862
|
|
863
|
|
864 static void
|
|
865 add_toggle (GtkWidget * widget, gpointer data)
|
|
866 {
|
|
867 gtk_widget_set_sensitive (new_proxy_domain, data != NULL);
|
|
868 gtk_widget_set_sensitive (network1, data == NULL);
|
|
869 gtk_widget_set_sensitive (network2, data == NULL);
|
|
870 gtk_widget_set_sensitive (network3, data == NULL);
|
|
871 gtk_widget_set_sensitive (network4, data == NULL);
|
|
872 gtk_widget_set_sensitive (netmask1, data == NULL);
|
|
873 gtk_widget_set_sensitive (netmask2, data == NULL);
|
|
874 gtk_widget_set_sensitive (netmask3, data == NULL);
|
|
875 gtk_widget_set_sensitive (netmask4, data == NULL);
|
|
876 }
|
|
877
|
|
878
|
|
879 static void
|
|
880 delete_proxy_host (GtkWidget * widget, gpointer data)
|
|
881 {
|
|
882 GList *templist;
|
|
883 int num;
|
|
884
|
227
|
885 gftp_configuration_changed = 1; /* FIXME */
|
|
886
|
48
|
887 if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
|
|
888 return;
|
195
|
889 num = GPOINTER_TO_INT (templist->data);
|
48
|
890 templist = gtk_clist_get_row_data (GTK_CLIST (proxy_list), num);
|
|
891 new_proxy_hosts = g_list_remove_link (new_proxy_hosts, templist);
|
|
892 gtk_clist_remove (GTK_CLIST (proxy_list), num);
|
|
893 }
|
|
894
|
|
895
|
|
896 static void
|
|
897 add_proxy_host (GtkWidget * widget, gpointer data)
|
|
898 {
|
|
899 GtkWidget *tempwid, *dialog, *frame, *box, *table;
|
|
900 gftp_proxy_hosts *hosts;
|
|
901 char *tempstr, *title;
|
|
902 GList *templist;
|
|
903
|
227
|
904 gftp_configuration_changed = 1; /* FIXME */
|
|
905
|
48
|
906 if (data)
|
|
907 {
|
|
908 if ((templist = GTK_CLIST (proxy_list)->selection) == NULL)
|
|
909 return;
|
|
910 templist = gtk_clist_get_row_data (GTK_CLIST (proxy_list),
|
195
|
911 GPOINTER_TO_INT (templist->data));
|
48
|
912 hosts = templist->data;
|
|
913 }
|
|
914 else
|
|
915 {
|
|
916 hosts = NULL;
|
|
917 templist = NULL;
|
|
918 }
|
|
919
|
|
920 title = hosts ? _("Edit Host") : _("Add Host");
|
|
921 #if GTK_MAJOR_VERSION == 1
|
|
922 dialog = gtk_dialog_new ();
|
|
923 gtk_window_set_title (GTK_WINDOW (dialog), title);
|
|
924 gtk_container_border_width (GTK_CONTAINER
|
|
925 (GTK_DIALOG (dialog)->action_area), 5);
|
|
926 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
|
|
927 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE);
|
|
928 gtk_grab_add (dialog);
|
|
929 #else
|
|
930 dialog = gtk_dialog_new_with_buttons (title, NULL, 0,
|
|
931 GTK_STOCK_SAVE,
|
|
932 GTK_RESPONSE_OK,
|
|
933 GTK_STOCK_CANCEL,
|
|
934 GTK_RESPONSE_CANCEL,
|
|
935 NULL);
|
|
936 #endif
|
|
937 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10);
|
|
938 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
|
|
939 gtk_window_set_wmclass (GTK_WINDOW(dialog), "hostinfo", "Gftp");
|
|
940 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
|
941
|
|
942 frame = gtk_frame_new (NULL);
|
|
943 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, TRUE, TRUE,
|
|
944 0);
|
|
945 gtk_widget_show (frame);
|
|
946
|
|
947 box = gtk_hbox_new (FALSE, 5);
|
|
948 gtk_container_border_width (GTK_CONTAINER (box), 5);
|
|
949 gtk_container_add (GTK_CONTAINER (frame), box);
|
|
950 gtk_widget_show (box);
|
|
951
|
|
952 tempwid = gtk_label_new (_("Domain"));
|
|
953 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
|
|
954 gtk_widget_show (tempwid);
|
|
955
|
|
956 new_proxy_domain = gtk_entry_new ();
|
|
957 gtk_box_pack_start (GTK_BOX (box), new_proxy_domain, TRUE, TRUE, 0);
|
|
958 gtk_widget_show (new_proxy_domain);
|
|
959
|
|
960 frame = gtk_frame_new (NULL);
|
|
961 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame, TRUE, TRUE,
|
|
962 0);
|
|
963 gtk_widget_show (frame);
|
|
964
|
|
965 table = gtk_table_new (4, 2, FALSE);
|
|
966 gtk_container_border_width (GTK_CONTAINER (table), 5);
|
|
967 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
|
968 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
|
|
969 gtk_container_add (GTK_CONTAINER (frame), table);
|
|
970 gtk_widget_show (table);
|
|
971
|
|
972 tempwid = gtk_label_new (_("Network Address"));
|
|
973 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
|
|
974 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 0, 1);
|
|
975 gtk_widget_show (tempwid);
|
|
976
|
|
977 box = gtk_hbox_new (FALSE, 5);
|
|
978 gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 0, 1);
|
|
979 gtk_widget_show (box);
|
|
980
|
|
981 network1 = gtk_entry_new ();
|
|
982 gtk_widget_set_size_request (network1, 28, -1);
|
|
983
|
|
984 gtk_box_pack_start (GTK_BOX (box), network1, TRUE, TRUE, 0);
|
|
985 gtk_widget_show (network1);
|
|
986
|
|
987 network2 = gtk_entry_new ();
|
|
988 gtk_widget_set_size_request (network2, 28, -1);
|
|
989
|
|
990 gtk_box_pack_start (GTK_BOX (box), network2, TRUE, TRUE, 0);
|
|
991 gtk_widget_show (network2);
|
|
992
|
|
993 network3 = gtk_entry_new ();
|
|
994 gtk_widget_set_size_request (network3, 28, -1);
|
|
995
|
|
996 gtk_box_pack_start (GTK_BOX (box), network3, TRUE, TRUE, 0);
|
|
997 gtk_widget_show (network3);
|
|
998
|
|
999 network4 = gtk_entry_new ();
|
|
1000 gtk_widget_set_size_request (network4, 28, -1);
|
|
1001
|
|
1002 gtk_box_pack_start (GTK_BOX (box), network4, TRUE, TRUE, 0);
|
|
1003 gtk_widget_show (network4);
|
|
1004
|
|
1005 tempwid = gtk_label_new (_("Netmask"));
|
|
1006 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5);
|
|
1007 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, 1, 2);
|
|
1008 gtk_widget_show (tempwid);
|
|
1009
|
|
1010 box = gtk_hbox_new (FALSE, 5);
|
|
1011 gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 1, 2);
|
|
1012 gtk_widget_show (box);
|
|
1013
|
|
1014 netmask1 = gtk_entry_new ();
|
|
1015 gtk_widget_set_size_request (netmask1, 28, -1);
|
|
1016
|
|
1017 gtk_box_pack_start (GTK_BOX (box), netmask1, TRUE, TRUE, 0);
|
|
1018 gtk_widget_show (netmask1);
|
|
1019
|
|
1020 netmask2 = gtk_entry_new ();
|
|
1021 gtk_widget_set_size_request (netmask2, 28, -1);
|
|
1022
|
|
1023 gtk_box_pack_start (GTK_BOX (box), netmask2, TRUE, TRUE, 0);
|
|
1024 gtk_widget_show (netmask2);
|
|
1025
|
|
1026 netmask3 = gtk_entry_new ();
|
|
1027 gtk_widget_set_size_request (netmask3, 28, -1);
|
|
1028
|
|
1029 gtk_box_pack_start (GTK_BOX (box), netmask3, TRUE, TRUE, 0);
|
|
1030 gtk_widget_show (netmask3);
|
|
1031
|
|
1032 netmask4 = gtk_entry_new ();
|
|
1033 gtk_widget_set_size_request (netmask4, 28, -1);
|
|
1034
|
|
1035 gtk_box_pack_start (GTK_BOX (box), netmask4, TRUE, TRUE, 0);
|
|
1036 gtk_widget_show (netmask4);
|
|
1037
|
|
1038 box = gtk_hbox_new (FALSE, 5);
|
|
1039 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), box, TRUE, TRUE,
|
|
1040 0);
|
|
1041 gtk_widget_show (box);
|
|
1042
|
|
1043 domain_active = gtk_radio_button_new_with_label (NULL, _("Domain"));
|
|
1044 gtk_signal_connect (GTK_OBJECT (domain_active), "toggled",
|
|
1045 GTK_SIGNAL_FUNC (add_toggle), (gpointer) 1);
|
|
1046 gtk_box_pack_start (GTK_BOX (box), domain_active, TRUE, TRUE, 0);
|
|
1047 gtk_widget_show (domain_active);
|
|
1048
|
|
1049 tempwid = gtk_radio_button_new_with_label (gtk_radio_button_group
|
|
1050 (GTK_RADIO_BUTTON (domain_active)),
|
|
1051 _("Network"));
|
|
1052 gtk_signal_connect (GTK_OBJECT (tempwid), "toggled",
|
|
1053 GTK_SIGNAL_FUNC (add_toggle), NULL);
|
|
1054 gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
|
|
1055 gtk_widget_show (tempwid);
|
|
1056
|
|
1057 if (!hosts || !hosts->domain)
|
|
1058 {
|
|
1059 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid), TRUE);
|
|
1060 add_toggle (NULL, NULL);
|
|
1061 }
|
|
1062 else
|
|
1063 {
|
|
1064 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (domain_active), TRUE);
|
|
1065 add_toggle (NULL, (gpointer) 1);
|
|
1066 }
|
|
1067
|
|
1068 if (hosts)
|
|
1069 {
|
|
1070 if (hosts->domain)
|
|
1071 gtk_entry_set_text (GTK_ENTRY (new_proxy_domain), hosts->domain);
|
|
1072 else
|
|
1073 {
|
|
1074 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 24 & 0xff);
|
|
1075 gtk_entry_set_text (GTK_ENTRY (network1), tempstr);
|
|
1076 g_free (tempstr);
|
|
1077
|
|
1078 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 16 & 0xff);
|
|
1079 gtk_entry_set_text (GTK_ENTRY (network2), tempstr);
|
|
1080 g_free (tempstr);
|
|
1081
|
|
1082 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address >> 8 & 0xff);
|
|
1083 gtk_entry_set_text (GTK_ENTRY (network3), tempstr);
|
|
1084 g_free (tempstr);
|
|
1085
|
|
1086 tempstr = g_strdup_printf ("%d", hosts->ipv4_network_address & 0xff);
|
|
1087 gtk_entry_set_text (GTK_ENTRY (network4), tempstr);
|
|
1088 g_free (tempstr);
|
|
1089
|
|
1090 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 24 & 0xff);
|
|
1091 gtk_entry_set_text (GTK_ENTRY (netmask1), tempstr);
|
|
1092 g_free (tempstr);
|
|
1093
|
|
1094 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 16 & 0xff);
|
|
1095 gtk_entry_set_text (GTK_ENTRY (netmask2), tempstr);
|
|
1096 g_free (tempstr);
|
|
1097
|
|
1098 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask >> 8 & 0xff);
|
|
1099 gtk_entry_set_text (GTK_ENTRY (netmask3), tempstr);
|
|
1100 g_free (tempstr);
|
|
1101
|
|
1102 tempstr = g_strdup_printf ("%d", hosts->ipv4_netmask & 0xff);
|
|
1103 gtk_entry_set_text (GTK_ENTRY (netmask4), tempstr);
|
|
1104 g_free (tempstr);
|
|
1105 }
|
|
1106 }
|
|
1107
|
|
1108 #if GTK_MAJOR_VERSION == 1
|
|
1109 tempwid = gtk_button_new_with_label (_("OK"));
|
|
1110 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
|
1111 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
|
|
1112 TRUE, TRUE, 0);
|
|
1113 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1114 GTK_SIGNAL_FUNC (add_ok), (gpointer) templist);
|
|
1115 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
|
|
1116 GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
1117 GTK_OBJECT (dialog));
|
|
1118 gtk_widget_show (tempwid);
|
|
1119
|
|
1120 tempwid = gtk_button_new_with_label (_(" Cancel "));
|
|
1121 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
|
1122 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
|
|
1123 TRUE, TRUE, 0);
|
|
1124 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
|
|
1125 GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
1126 GTK_OBJECT (dialog));
|
|
1127 gtk_widget_show (tempwid);
|
|
1128 #else
|
|
1129 g_signal_connect (GTK_OBJECT (dialog), "response",
|
|
1130 G_CALLBACK (proxyhosts_action), NULL);
|
|
1131 #endif
|
|
1132
|
|
1133 gtk_widget_show (dialog);
|
|
1134 }
|
|
1135
|
|
1136 static void
|
|
1137 make_proxy_hosts_tab (GtkWidget * notebook)
|
|
1138 {
|
|
1139 GtkWidget *tempwid, *box, *hbox, *scroll;
|
218
|
1140 gftp_config_list_vars * proxy_hosts;
|
48
|
1141 char *add_data[2];
|
218
|
1142 GList * templist;
|
48
|
1143
|
|
1144 add_data[0] = _("Network");
|
|
1145 add_data[1] = _("Netmask");
|
|
1146
|
|
1147 box = gtk_vbox_new (FALSE, 5);
|
|
1148 gtk_container_border_width (GTK_CONTAINER (box), 10);
|
|
1149 gtk_widget_show (box);
|
|
1150
|
|
1151 tempwid = gtk_label_new (_("Local Hosts"));
|
|
1152 gtk_widget_show (tempwid);
|
|
1153 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, tempwid);
|
|
1154
|
|
1155 scroll = gtk_scrolled_window_new (NULL, NULL);
|
|
1156 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
|
|
1157 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
1158 gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
|
|
1159
|
|
1160 proxy_list = gtk_clist_new_with_titles (2, add_data);
|
|
1161 gtk_container_add (GTK_CONTAINER (scroll), proxy_list);
|
|
1162 gtk_clist_set_column_auto_resize (GTK_CLIST (proxy_list), 0, TRUE);
|
|
1163 gtk_clist_set_column_auto_resize (GTK_CLIST (proxy_list), 1, TRUE);
|
|
1164 gtk_widget_show (proxy_list);
|
|
1165 gtk_widget_show (scroll);
|
|
1166
|
218
|
1167 gftp_lookup_global_option ("dont_use_proxy", &proxy_hosts);
|
|
1168 new_proxy_hosts = gftp_copy_proxy_hosts (proxy_hosts->list);
|
|
1169
|
|
1170 for (templist = new_proxy_hosts;
|
|
1171 templist != NULL;
|
|
1172 templist = templist->next)
|
|
1173 add_host_to_listbox (templist);
|
|
1174
|
48
|
1175 hbox = gtk_hbox_new (TRUE, 15);
|
218
|
1176
|
48
|
1177 gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
|
1178 gtk_widget_show (hbox);
|
|
1179
|
|
1180 tempwid = gtk_button_new_with_label (_("Add"));
|
|
1181 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
|
1182 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
|
|
1183 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1184 GTK_SIGNAL_FUNC (add_proxy_host), NULL);
|
|
1185 gtk_widget_show (tempwid);
|
|
1186
|
|
1187 tempwid = gtk_button_new_with_label (_("Edit"));
|
|
1188 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
|
1189 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
|
|
1190 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1191 GTK_SIGNAL_FUNC (add_proxy_host), (gpointer) 1);
|
|
1192 gtk_widget_show (tempwid);
|
|
1193
|
|
1194 tempwid = gtk_button_new_with_label (_("Delete"));
|
|
1195 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
|
1196 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0);
|
|
1197 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1198 GTK_SIGNAL_FUNC (delete_proxy_host), NULL);
|
|
1199 gtk_widget_show (tempwid);
|
|
1200 }
|
|
1201
|
|
1202
|
229
|
1203 static gftp_options_dialog_data *
|
|
1204 _init_option_data (void)
|
227
|
1205 {
|
229
|
1206 gftp_options_dialog_data * option_data;
|
|
1207
|
|
1208 option_data = g_malloc0 (sizeof (*option_data));
|
227
|
1209
|
|
1210 _setup_option (gftp_option_type_text, option_data,
|
|
1211 _print_option_type_text, _save_option_type_text, NULL);
|
|
1212 _setup_option (gftp_option_type_textcombo, option_data,
|
|
1213 _print_option_type_textcombo, _save_option_type_textcombo,
|
|
1214 NULL);
|
|
1215 _setup_option (gftp_option_type_textcomboedt, option_data,
|
|
1216 _print_option_type_textcomboedt,
|
|
1217 _save_option_type_textcomboedt,
|
239
|
1218 NULL);
|
227
|
1219 _setup_option (gftp_option_type_hidetext, option_data,
|
|
1220 _print_option_type_hidetext, _save_option_type_text, NULL);
|
|
1221 _setup_option (gftp_option_type_int, option_data,
|
|
1222 _print_option_type_int, _save_option_type_int, NULL);
|
|
1223 _setup_option (gftp_option_type_checkbox, option_data,
|
|
1224 _print_option_type_checkbox, _save_option_type_checkbox, NULL);
|
|
1225 _setup_option (gftp_option_type_float, option_data,
|
|
1226 _print_option_type_float, _save_option_type_float, NULL);
|
|
1227 _setup_option (gftp_option_type_notebook, option_data,
|
|
1228 _print_option_type_notebook, NULL, NULL);
|
229
|
1229
|
|
1230 return (option_data);
|
227
|
1231 }
|
|
1232
|
|
1233
|
1
|
1234 void
|
|
1235 options_dialog (gpointer data)
|
|
1236 {
|
136
|
1237 gftp_config_vars * cv;
|
|
1238 GList * templist;
|
229
|
1239 void *value;
|
136
|
1240 int i;
|
151
|
1241 #if GTK_MAJOR_VERSION == 1
|
|
1242 GtkWidget * tempwid;
|
|
1243 #endif
|
136
|
1244
|
518
|
1245 gftp_option_data = _init_option_data ();
|
1
|
1246
|
45
|
1247 #if GTK_MAJOR_VERSION == 1
|
526
|
1248 gftp_option_data->dialog = gtk_dialog_new ();
|
|
1249 gtk_window_set_title (GTK_WINDOW (gftp_option_data->dialog), _("Options"));
|
|
1250 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (gftp_option_data->dialog)->action_area), 5);
|
|
1251 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->action_area), 15);
|
|
1252 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->action_area), TRUE);
|
19
|
1253 #else
|
518
|
1254 gftp_option_data->dialog = gtk_dialog_new_with_buttons (_("Options"), NULL, 0,
|
136
|
1255 GTK_STOCK_OK,
|
19
|
1256 GTK_RESPONSE_OK,
|
|
1257 GTK_STOCK_CANCEL,
|
|
1258 GTK_RESPONSE_CANCEL,
|
|
1259 GTK_STOCK_APPLY,
|
|
1260 GTK_RESPONSE_APPLY,
|
|
1261 NULL);
|
|
1262 #endif
|
518
|
1263 gtk_window_set_wmclass (GTK_WINDOW(gftp_option_data->dialog),
|
|
1264 "options", "gFTP");
|
|
1265 gtk_window_set_position (GTK_WINDOW (gftp_option_data->dialog),
|
|
1266 GTK_WIN_POS_MOUSE);
|
|
1267 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (gftp_option_data->dialog)->vbox), 10);
|
|
1268 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->vbox), 2);
|
|
1269 gtk_widget_realize (gftp_option_data->dialog);
|
19
|
1270
|
|
1271 if (gftp_icon != NULL)
|
|
1272 {
|
518
|
1273 gdk_window_set_icon (gftp_option_data->dialog->window, NULL,
|
|
1274 gftp_icon->pixmap, gftp_icon->bitmap);
|
|
1275 gdk_window_set_icon_name (gftp_option_data->dialog->window, gftp_version);
|
19
|
1276 }
|
1
|
1277
|
518
|
1278 gftp_option_data->notebook = gtk_notebook_new ();
|
|
1279 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->vbox),
|
|
1280 gftp_option_data->notebook, TRUE, TRUE, 0);
|
|
1281 gtk_widget_show (gftp_option_data->notebook);
|
1
|
1282
|
136
|
1283 cv = gftp_options_list->data;
|
518
|
1284 gftp_option_data->last_option = cv[0].otype;
|
136
|
1285 for (templist = gftp_options_list;
|
|
1286 templist != NULL;
|
|
1287 templist = templist->next)
|
|
1288 {
|
|
1289 cv = templist->data;
|
1
|
1290
|
136
|
1291 for (i=0; cv[i].key != NULL; i++)
|
|
1292 {
|
|
1293 if (!(cv[i].ports_shown & GFTP_PORT_GTK))
|
|
1294 continue;
|
|
1295
|
|
1296 if (gftp_option_types[cv[i].otype].ui_print_function == NULL)
|
|
1297 continue;
|
|
1298
|
229
|
1299 if (*cv[i].key != '\0')
|
|
1300 gftp_lookup_global_option (cv[i].key, &value);
|
|
1301 else
|
|
1302 value = NULL;
|
136
|
1303
|
229
|
1304 cv[i].user_data = gftp_option_types[cv[i].otype].ui_print_function (&cv[i], gftp_option_types[cv[i].otype].user_data, value);
|
|
1305
|
518
|
1306 gftp_option_data->last_option = cv[i].otype;
|
1
|
1307 }
|
|
1308 }
|
|
1309
|
518
|
1310 make_proxy_hosts_tab (gftp_option_data->notebook);
|
218
|
1311
|
45
|
1312 #if GTK_MAJOR_VERSION == 1
|
1
|
1313 tempwid = gtk_button_new_with_label (_("OK"));
|
|
1314 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
518
|
1315 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->action_area),
|
136
|
1316 tempwid, TRUE, TRUE, 0);
|
1
|
1317 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1318 GTK_SIGNAL_FUNC (apply_changes), NULL);
|
|
1319 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
|
|
1320 GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
518
|
1321 GTK_OBJECT (gftp_option_data->dialog));
|
1
|
1322 gtk_widget_show (tempwid);
|
|
1323
|
|
1324 tempwid = gtk_button_new_with_label (_(" Cancel "));
|
|
1325 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
518
|
1326 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->action_area),
|
136
|
1327 tempwid, TRUE, TRUE, 0);
|
1
|
1328 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1329 GTK_SIGNAL_FUNC (clean_old_changes), NULL);
|
|
1330 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked",
|
|
1331 GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
518
|
1332 GTK_OBJECT (gftp_option_data->dialog));
|
1
|
1333 gtk_widget_show (tempwid);
|
|
1334
|
|
1335 tempwid = gtk_button_new_with_label (_("Apply"));
|
|
1336 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
|
518
|
1337 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (gftp_option_data->dialog)->action_area),
|
136
|
1338 tempwid, TRUE, TRUE, 0);
|
1
|
1339 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked",
|
|
1340 GTK_SIGNAL_FUNC (apply_changes), NULL);
|
|
1341 gtk_widget_grab_default (tempwid);
|
|
1342 gtk_widget_show (tempwid);
|
19
|
1343 #else
|
518
|
1344 g_signal_connect (GTK_OBJECT (gftp_option_data->dialog), "response",
|
19
|
1345 G_CALLBACK (options_action), NULL);
|
|
1346 #endif
|
1
|
1347
|
518
|
1348 gtk_widget_show (gftp_option_data->dialog);
|
1
|
1349 }
|
|
1350
|
227
|
1351
|
|
1352 void
|
229
|
1353 gftp_gtk_setup_bookmark_options (GtkWidget * notebook, gftp_bookmarks_var * bm)
|
227
|
1354 {
|
|
1355 gftp_config_vars * cv;
|
|
1356 GList * templist;
|
229
|
1357 void *value;
|
227
|
1358 int i;
|
|
1359
|
518
|
1360 gftp_option_data = _init_option_data ();
|
|
1361 gftp_option_data->bm = bm;
|
|
1362 gftp_option_data->notebook = notebook;
|
227
|
1363
|
|
1364 cv = gftp_options_list->data;
|
518
|
1365 gftp_option_data->last_option = cv[0].otype;
|
227
|
1366 for (templist = gftp_options_list;
|
|
1367 templist != NULL;
|
|
1368 templist = templist->next)
|
|
1369 {
|
|
1370 cv = templist->data;
|
|
1371
|
|
1372 for (i=0; cv[i].key != NULL; i++)
|
|
1373 {
|
|
1374 if (!(cv[i].flags & GFTP_CVARS_FLAGS_SHOW_BOOKMARK))
|
|
1375 continue;
|
|
1376
|
|
1377 if (gftp_option_types[cv[i].otype].ui_print_function == NULL)
|
|
1378 continue;
|
|
1379
|
229
|
1380 if (*cv[i].key != '\0')
|
|
1381 gftp_lookup_bookmark_option (bm, cv[i].key, &value);
|
|
1382 else
|
|
1383 value = NULL;
|
227
|
1384
|
518
|
1385 cv[i].user_data = gftp_option_types[cv[i].otype].ui_print_function (&cv[i], gftp_option_data, value);
|
229
|
1386
|
518
|
1387 gftp_option_data->last_option = cv[i].otype;
|
227
|
1388 }
|
|
1389 }
|
|
1390 }
|
|
1391
|
|
1392
|
|
1393 void
|
229
|
1394 gftp_gtk_save_bookmark_options (gftp_bookmarks_var * bm)
|
227
|
1395 {
|
|
1396 gftp_config_vars * cv;
|
|
1397 GList * templist;
|
|
1398 int i;
|
|
1399
|
|
1400 for (templist = gftp_options_list;
|
|
1401 templist != NULL;
|
|
1402 templist = templist->next)
|
|
1403 {
|
|
1404 cv = templist->data;
|
|
1405
|
|
1406 for (i=0; cv[i].key != NULL; i++)
|
|
1407 {
|
|
1408 if (!(cv[i].flags & GFTP_CVARS_FLAGS_SHOW_BOOKMARK))
|
|
1409 continue;
|
|
1410
|
|
1411 if (gftp_option_types[cv[i].otype].ui_save_function == NULL)
|
|
1412 continue;
|
|
1413
|
518
|
1414 gftp_option_types[cv[i].otype].ui_save_function (&cv[i],
|
|
1415 gftp_option_data);
|
227
|
1416 }
|
|
1417 }
|
|
1418 }
|
|
1419
|