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