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