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