Mercurial > gftp.yaz
comparison src/gtk/options_dialog.c @ 136:84b3e69807a2
2003-4-18 Brian Masney <masneyb@gftp.org>
* lib/config_file.c lib/gftp.h - removed gftp_option_type_subtree,
gftp_option_type_table and gftp_option_type_newtable
* lib/config_file.c - implemented gftp_set_request_option()
* lib/gftp.h lib/config_file.c - changed declaration of
ui_print_function in struct gftp_option_type. Also added
ui_save_function field to this structure
* lib/gftp.h added local_options_vars num_local_options_vars variables
to gftp_request
* lib/local.c (local_set_directory) - small improvements to this
function
* lib/misc.c - added gftp_copy_local_options()
* lib/options.h - fix declaration of General tab
* lib/protocols.c - free local options
* lib/rfc2068.c - check to see if we're connecting to a FTP site via
proxy
* lib/rfc959.c lib/protocols.c - changes for CRAY directory listings
* src/gtk/gftp-gtk.h - added struct gftp_options_dialog_data and
struct gftp_textcomboedt_widget_data
* src/gtk/options_dialog.c - start to use new configuration interface
* src/gtk/transfer.c - remove FIXME note. This is already in
lib/gftp.h
author | masneyb |
---|---|
date | Fri, 18 Apr 2003 19:38:34 +0000 |
parents | fe0b21c006f6 |
children | c363b08e0118 |
comparison
equal
deleted
inserted
replaced
135:0261e7b5346c | 136:84b3e69807a2 |
---|---|
18 /*****************************************************************************/ | 18 /*****************************************************************************/ |
19 | 19 |
20 #include <gftp-gtk.h> | 20 #include <gftp-gtk.h> |
21 static const char cvsid[] = "$Id$"; | 21 static const char cvsid[] = "$Id$"; |
22 | 22 |
23 static GtkWidget * proxy_text, * proxy_list, * new_proxy_domain, * network1, | 23 static GtkWidget * proxy_list, * new_proxy_domain, * network1, |
24 * network2, * network3, * network4, * netmask1, * netmask2, | 24 * network2, * network3, * network4, * netmask1, * netmask2, |
25 * netmask3, * netmask4, * domain_active, * proxy_combo, | 25 * netmask3, * netmask4, * domain_active; |
26 * def_proto_combo; | |
27 static GList * new_proxy_hosts; | 26 static GList * new_proxy_hosts; |
28 static char *custom_proxy; | 27 |
29 | 28 static void |
30 | 29 _setup_option (gftp_option_type_enum otype, |
31 static void | 30 gftp_options_dialog_data * option_data, |
32 clean_old_changes (GtkWidget * widget, gpointer data) | 31 void * (*ui_print_function) (gftp_config_vars * cv, |
33 { | 32 void *user_data), |
34 gftp_proxy_hosts *hosts; | 33 void (*ui_save_function) (gftp_config_vars * cv, |
35 GList *templist; | 34 void *user_data)) |
36 | 35 { |
37 templist = new_proxy_hosts; | 36 gftp_option_types[otype].user_data = option_data; |
38 while (templist != NULL) | 37 gftp_option_types[otype].ui_print_function = ui_print_function; |
39 { | 38 gftp_option_types[otype].ui_save_function = ui_save_function; |
40 hosts = templist->data; | 39 } |
41 if (hosts->domain) | 40 |
42 g_free (hosts->domain); | 41 |
43 g_free (hosts); | 42 static void * |
44 templist = templist->next; | 43 _gen_input_widget (gftp_options_dialog_data * option_data, char *label) |
45 } | 44 { |
46 g_list_free (new_proxy_hosts); | 45 GtkWidget * tempwid; |
47 new_proxy_hosts = NULL; | 46 |
48 | 47 option_data->tbl_row_num++; |
49 if (custom_proxy != NULL) | 48 gtk_table_resize (GTK_TABLE (option_data->table), |
50 { | 49 option_data->tbl_row_num, 2); |
51 g_free (custom_proxy); | 50 |
52 custom_proxy = NULL; | 51 tempwid = gtk_label_new (_(label)); |
53 } | 52 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5); |
54 } | 53 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 0, 1, |
55 | 54 option_data->tbl_row_num - 1, |
56 | 55 option_data->tbl_row_num); |
57 static char * | 56 gtk_widget_show (tempwid); |
58 get_proxy_config (void) | 57 |
59 { | 58 tempwid = gtk_entry_new (); |
60 char *newstr, *oldstr, *pos, *endpos, *textstr; | 59 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 1, 2, |
60 option_data->tbl_row_num - 1, | |
61 option_data->tbl_row_num); | |
62 gtk_widget_show (tempwid); | |
63 return (tempwid); | |
64 } | |
65 | |
66 | |
67 static void * | |
68 _print_option_type_newtable (gftp_config_vars * cv, void *user_data) | |
69 { | |
70 gftp_options_dialog_data * option_data; | |
71 | |
72 option_data = user_data; | |
73 | |
74 option_data->table = gtk_table_new (1, 2, FALSE); | |
75 gtk_table_set_row_spacings (GTK_TABLE (option_data->table), 5); | |
76 gtk_table_set_col_spacings (GTK_TABLE (option_data->table), 5); | |
77 gtk_box_pack_start (GTK_BOX (option_data->box), option_data->table, FALSE, | |
78 FALSE, 0); | |
79 gtk_widget_show (option_data->table); | |
80 option_data->tbl_row_num = 0; | |
81 option_data->tbl_col_num = 0; | |
82 | |
83 return (NULL); | |
84 } | |
85 | |
86 | |
87 static void * | |
88 _print_option_type_text (gftp_config_vars * cv, void *user_data) | |
89 { | |
90 gftp_options_dialog_data * option_data; | |
91 GtkWidget * tempwid; | |
92 | |
93 option_data = user_data; | |
94 | |
95 tempwid = _gen_input_widget (option_data, cv->description); | |
96 gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) cv->value); | |
97 return (tempwid); | |
98 } | |
99 | |
100 | |
101 static void | |
102 _save_option_type_text (gftp_config_vars * cv, void *user_data) | |
103 { | |
104 gftp_options_dialog_data * option_data; | |
105 const char *tempstr; | |
106 | |
107 option_data = user_data; | |
108 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data)); | |
109 | |
110 if (cv->flags & GFTP_CVARS_FLAGS_DYNMEM) | |
111 g_free (cv->value); | |
112 | |
113 cv->value = g_strdup (tempstr); | |
114 cv->flags |= GFTP_CVARS_FLAGS_DYNMEM; | |
115 } | |
116 | |
117 | |
118 static GtkWidget * | |
119 _gen_combo_widget (gftp_options_dialog_data * option_data, char *label) | |
120 { | |
121 GtkWidget * tempwid, * combo; | |
122 | |
123 option_data->tbl_row_num++; | |
124 gtk_table_resize (GTK_TABLE (option_data->table), | |
125 option_data->tbl_row_num, 2); | |
126 | |
127 tempwid = gtk_label_new (_(label)); | |
128 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5); | |
129 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, 0, 1, | |
130 option_data->tbl_row_num - 1, | |
131 option_data->tbl_row_num); | |
132 gtk_widget_show (tempwid); | |
133 | |
134 combo = gtk_combo_new (); | |
135 gtk_table_attach_defaults (GTK_TABLE (option_data->table), combo, 1, 2, | |
136 option_data->tbl_row_num - 1, | |
137 option_data->tbl_row_num); | |
138 return (combo); | |
139 } | |
140 | |
141 | |
142 static void * | |
143 _print_option_type_textcombo (gftp_config_vars * cv, void *user_data) | |
144 { | |
145 gftp_options_dialog_data * option_data; | |
146 GList * widget_list; | |
147 GtkWidget * tempwid, * combo; | |
148 int selitem, i; | |
149 char **clist; | |
150 | |
151 option_data = user_data; | |
152 combo = _gen_combo_widget (option_data, cv->description); | |
153 | |
154 if (cv->listdata != NULL) | |
155 { | |
156 selitem = 0; | |
157 widget_list = NULL; | |
158 | |
159 clist = cv->listdata; | |
160 for (i=0; clist[i] != NULL; i++) | |
161 { | |
162 if (cv->value != NULL && | |
163 strcasecmp ((char *) cv->value, clist[i]) == 0) | |
164 selitem = i; | |
165 | |
166 tempwid = gtk_list_item_new_with_label (clist[i]); | |
167 gtk_widget_show (tempwid); | |
168 widget_list = g_list_append (widget_list, tempwid); | |
169 } | |
170 | |
171 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list), widget_list); | |
172 gtk_list_select_item (GTK_LIST (GTK_COMBO (combo)->list), selitem); | |
173 } | |
174 | |
175 gtk_widget_show (combo); | |
176 return (combo); | |
177 } | |
178 | |
179 | |
180 static void | |
181 _save_option_type_textcombo (gftp_config_vars * cv, void *user_data) | |
182 { | |
183 gftp_options_dialog_data * option_data; | |
184 const char *tempstr; | |
185 char **clist; | |
186 int i; | |
187 | |
188 option_data = user_data; | |
189 | |
190 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (cv->user_data)->entry)); | |
191 | |
192 if (cv->listdata != NULL && tempstr != NULL) | |
193 { | |
194 clist = cv->listdata; | |
195 for (i=0; clist[i] != NULL; i++) | |
196 { | |
197 if (strcasecmp (tempstr, clist[i]) == 0) | |
198 { | |
199 cv->value = clist[i]; | |
200 break; | |
201 } | |
202 } | |
203 } | |
204 } | |
205 | |
206 | |
207 static void | |
208 _textcomboedt_toggle (GtkList * list, GtkWidget * child, gpointer data) | |
209 { | |
210 gftp_textcomboedt_widget_data * widdata; | |
211 gftp_textcomboedt_data * tedata; | |
212 int num, isedit; | |
213 #if GTK_MAJOR_VERSION > 1 | |
214 GtkTextIter iter, iter2; | |
215 GtkTextBuffer * textbuf; | |
61 guint len; | 216 guint len; |
217 #endif | |
218 | |
219 widdata = data; | |
220 tedata = widdata->cv->listdata; | |
221 | |
222 num = gtk_list_child_position (list, child); | |
223 isedit = tedata[num].flags & GFTP_TEXTCOMBOEDT_EDITABLE; | |
224 #if GTK_MAJOR_VERSION == 1 | |
225 gtk_text_set_editable (GTK_TEXT (widdata->text), isedit); | |
226 #else | |
227 gtk_text_view_set_editable (GTK_TEXT_VIEW (widdata->text), isedit); | |
228 #endif | |
229 | |
230 if (isedit) | |
231 return; | |
232 | |
233 #if GTK_MAJOR_VERSION == 1 | |
234 gtk_text_set_point (GTK_TEXT (widdata->text), 0); | |
235 gtk_text_forward_delete (GTK_TEXT (widdata->text), | |
236 gtk_text_get_length (GTK_TEXT (widdata->text))); | |
237 | |
238 gtk_text_insert (GTK_TEXT (widdata->text), NULL, NULL, NULL, | |
239 tedata[num].text, -1); | |
240 #else | |
241 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widdata->text)); | |
242 len = gtk_text_buffer_get_char_count (textbuf); | |
243 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
244 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
245 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
246 | |
247 len = gtk_text_buffer_get_char_count (textbuf); | |
248 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len - 1); | |
249 gtk_text_buffer_insert (textbuf, &iter, tedata[num].text, -1); | |
250 #endif | |
251 } | |
252 | |
253 | |
254 static void * | |
255 _print_option_type_textcomboedt (gftp_config_vars * cv, void *user_data) | |
256 { | |
257 gftp_textcomboedt_widget_data * widdata; | |
258 GtkWidget * combo, * textwid, * tempwid; | |
259 gftp_options_dialog_data * option_data; | |
260 gftp_textcomboedt_data * tedata; | |
261 int i, selitem, edititem; | |
262 GList * widget_list; | |
263 char *tempstr; | |
264 | |
265 option_data = user_data; | |
266 combo = _gen_combo_widget (option_data, cv->description); | |
267 | |
268 edititem = selitem = -1; | |
269 if (cv->listdata != NULL) | |
270 { | |
271 widget_list = NULL; | |
272 | |
273 if (cv->value == NULL) | |
274 tempstr = ""; | |
275 else | |
276 tempstr = cv->value; | |
277 | |
278 tedata = cv->listdata; | |
279 for (i=0; tedata[i].description != NULL; i++) | |
280 { | |
281 if (tedata[i].flags & GFTP_TEXTCOMBOEDT_EDITABLE) | |
282 edititem = i; | |
283 | |
284 if (strcasecmp (tempstr, tedata[i].text) == 0) | |
285 selitem = i; | |
286 | |
287 tempwid = gtk_list_item_new_with_label (tedata[i].description); | |
288 gtk_widget_show (tempwid); | |
289 widget_list = g_list_append (widget_list, tempwid); | |
290 } | |
291 | |
292 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list), widget_list); | |
293 | |
294 gtk_list_select_item (GTK_LIST (GTK_COMBO (combo)->list), selitem); | |
295 } | |
296 | |
297 if (selitem == -1 && edititem != -1) | |
298 selitem = edititem; | |
299 else if (selitem == -1) | |
300 selitem = 0; | |
301 | |
302 option_data->tbl_row_num++; | |
303 gtk_table_resize (GTK_TABLE (option_data->table), | |
304 option_data->tbl_row_num, 2); | |
305 | |
306 #if GTK_MAJOR_VERSION == 1 | |
307 textwid = gtk_text_new (NULL, NULL); | |
308 gtk_text_set_editable (GTK_TEXT (textwid), TRUE); | |
309 #else | |
310 textwid = gtk_text_view_new (); | |
311 gtk_text_view_set_editable (GTK_TEXT_VIEW (textwid), TRUE); | |
312 #endif | |
313 gtk_widget_set_size_request (textwid, -1, 75); | |
314 gtk_table_attach_defaults (GTK_TABLE (option_data->table), textwid, 0, 2, | |
315 option_data->tbl_row_num - 1, | |
316 option_data->tbl_row_num); | |
317 gtk_widget_show (textwid); | |
318 | |
319 widdata = g_malloc0 (sizeof (*widdata)); | |
320 widdata->combo = combo; | |
321 widdata->text = textwid; | |
322 widdata->cv = cv; | |
323 | |
324 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->list), | |
325 "select_child", | |
326 GTK_SIGNAL_FUNC (_textcomboedt_toggle), widdata); | |
327 gtk_list_select_item (GTK_LIST (GTK_COMBO (combo)->list), selitem); | |
328 gtk_widget_show (combo); | |
329 | |
330 return (textwid); | |
331 } | |
332 | |
333 | |
334 static void | |
335 _save_option_type_textcomboedt (gftp_config_vars * cv, void *user_data) | |
336 { | |
337 gftp_options_dialog_data * option_data; | |
338 const char *textstr; | |
339 char *newstr; | |
62 #if GTK_MAJOR_VERSION == 1 | 340 #if GTK_MAJOR_VERSION == 1 |
63 char tmp[128]; | 341 char tmp[128]; |
64 #else | 342 #else |
65 GtkTextBuffer * textbuf; | 343 GtkTextBuffer * textbuf; |
66 GtkTextIter iter, iter2; | 344 GtkTextIter iter, iter2; |
345 size_t len; | |
67 #endif | 346 #endif |
68 | 347 |
69 textstr = NULL; | 348 option_data = user_data; |
70 newstr = g_malloc (1); | |
71 *newstr = '\0'; | |
72 | 349 |
73 #if GTK_MAJOR_VERSION == 1 | 350 #if GTK_MAJOR_VERSION == 1 |
74 /* | 351 /* |
75 GTK_TEXT uses wchar_t instead of char in environment of multibyte encoding | 352 GTK_TEXT uses wchar_t instead of char in environment of multibyte encoding |
76 locale (ex Japanese), so we must convert from wide character | 353 locale (ex Japanese), so we must convert from wide character |
77 to multibyte charator.... Yasuyuki Furukawa (yasu@on.cs.keio.ac.jp) | 354 to multibyte charator.... Yasuyuki Furukawa (yasu@on.cs.keio.ac.jp) |
78 */ | 355 */ |
79 if (GTK_TEXT (proxy_text)->use_wchar) | 356 if (GTK_TEXT (cv->user_data)->use_wchar) |
80 { | 357 { |
81 wcstombs (tmp, (wchar_t *) GTK_TEXT (proxy_text)->text.wc, | 358 wcstombs (tmp, (wchar_t *) GTK_TEXT (cv->user_data)->text.wc, sizeof (tmp)); |
82 sizeof (tmp)); | 359 newstr = g_strdup (tmp); |
83 pos = tmp; | |
84 } | 360 } |
85 else | 361 else |
86 { | 362 { |
87 oldstr = (char *) GTK_TEXT (proxy_text)->text.ch; | 363 textstr = (char *) GTK_TEXT (cv->user_data)->text.ch; |
88 len = gtk_text_get_length (GTK_TEXT (proxy_text)); | 364 newstr = g_strdup (textstr); |
89 textstr = g_malloc (len + 1); | |
90 strncpy (textstr, oldstr, len); | |
91 textstr[len] = '\0'; | |
92 pos = textstr; | |
93 } | 365 } |
94 #else | 366 #else |
95 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (proxy_text)); | 367 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (cv->user_data)); |
96 len = gtk_text_buffer_get_char_count (textbuf); | 368 len = gtk_text_buffer_get_char_count (textbuf); |
97 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | 369 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); |
98 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | 370 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); |
99 pos = textstr = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); | 371 newstr = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); |
100 #endif | 372 #endif |
101 | 373 |
102 do | 374 cv->value = newstr; |
103 { | 375 } |
104 if ((endpos = strchr (pos, '\n')) != NULL) | 376 |
105 *endpos = '\0'; | 377 |
106 oldstr = newstr; | 378 static void * |
107 if (endpos != NULL) | 379 _print_option_type_hidetext (gftp_config_vars * cv, void *user_data) |
108 newstr = g_strconcat (newstr, pos, "%n", NULL); | 380 { |
109 else | 381 gftp_options_dialog_data * option_data; |
110 newstr = g_strconcat (newstr, pos, NULL); | 382 GtkWidget * tempwid; |
111 g_free (oldstr); | 383 |
112 if (endpos != NULL) | 384 option_data = user_data; |
385 | |
386 tempwid = _gen_input_widget (option_data, cv->description); | |
387 gtk_entry_set_visibility (GTK_ENTRY (tempwid), 0); | |
388 gtk_entry_set_text (GTK_ENTRY (tempwid), (char *) cv->value); | |
389 return (tempwid); | |
390 } | |
391 | |
392 | |
393 static void * | |
394 _print_option_type_int (gftp_config_vars * cv, void *user_data) | |
395 { | |
396 gftp_options_dialog_data * option_data; | |
397 GtkWidget * tempwid; | |
398 char tempstr[20]; | |
399 | |
400 option_data = user_data; | |
401 | |
402 tempwid = _gen_input_widget (option_data, cv->description); | |
403 g_snprintf (tempstr, sizeof (tempstr), "%d", GPOINTER_TO_INT(cv->value)); | |
404 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr); | |
405 return (tempwid); | |
406 } | |
407 | |
408 | |
409 static void | |
410 _save_option_type_int (gftp_config_vars * cv, void *user_data) | |
411 { | |
412 gftp_options_dialog_data * option_data; | |
413 const char *tempstr; | |
414 | |
415 option_data = user_data; | |
416 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data)); | |
417 cv->value = GINT_TO_POINTER(strtol (tempstr, NULL, 10)); | |
418 } | |
419 | |
420 | |
421 static void * | |
422 _print_option_type_checkbox (gftp_config_vars * cv, void *user_data) | |
423 { | |
424 gftp_options_dialog_data * option_data; | |
425 GtkWidget * tempwid; | |
426 | |
427 option_data = user_data; | |
428 | |
429 if (option_data->last_option != gftp_option_type_checkbox) | |
430 _print_option_type_newtable (NULL, user_data); | |
431 | |
432 if (option_data->tbl_col_num == 0) | |
433 { | |
434 option_data->tbl_row_num++; | |
435 gtk_table_resize (GTK_TABLE (option_data->table), | |
436 option_data->tbl_row_num + 1, 2); | |
437 } | |
438 | |
439 tempwid = gtk_check_button_new_with_label (_(cv->description)); | |
440 gtk_table_attach_defaults (GTK_TABLE (option_data->table), tempwid, | |
441 option_data->tbl_col_num, | |
442 option_data->tbl_col_num + 1, | |
443 option_data->tbl_row_num, | |
444 option_data->tbl_row_num + 1); | |
445 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid), | |
446 GPOINTER_TO_INT(cv->value)); | |
447 gtk_widget_show (tempwid); | |
448 | |
449 option_data->tbl_col_num = (option_data->tbl_col_num + 1) % 2; | |
450 return (tempwid); | |
451 } | |
452 | |
453 | |
454 static void | |
455 _save_option_type_checkbox (gftp_config_vars * cv, void *user_data) | |
456 { | |
457 gftp_options_dialog_data * option_data; | |
458 | |
459 option_data = user_data; | |
460 cv->value = GINT_TO_POINTER (GTK_TOGGLE_BUTTON (cv->user_data)->active); | |
461 } | |
462 | |
463 | |
464 static void * | |
465 _print_option_type_float (gftp_config_vars * cv, void *user_data) | |
466 { | |
467 gftp_options_dialog_data * option_data; | |
468 GtkWidget * tempwid; | |
469 char tempstr[20]; | |
470 float f; | |
471 | |
472 option_data = user_data; | |
473 | |
474 tempwid = _gen_input_widget (option_data, cv->description); | |
475 memcpy (&f, &cv->value, sizeof (f)); | |
476 g_snprintf (tempstr, sizeof (tempstr), "%.2f", f); | |
477 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr); | |
478 return (tempwid); | |
479 } | |
480 | |
481 | |
482 static void | |
483 _save_option_type_float (gftp_config_vars * cv, void *user_data) | |
484 { | |
485 gftp_options_dialog_data * option_data; | |
486 const char *tempstr; | |
487 float f; | |
488 | |
489 option_data = user_data; | |
490 tempstr = gtk_entry_get_text (GTK_ENTRY (cv->user_data)); | |
491 f = strtod (tempstr, NULL); | |
492 memcpy (&cv->value, &f, sizeof (cv->value)); | |
493 } | |
494 | |
495 | |
496 static void * | |
497 _print_option_type_notebook (gftp_config_vars * cv, void *user_data) | |
498 { | |
499 gftp_options_dialog_data * option_data; | |
500 GtkWidget * tempwid; | |
501 | |
502 option_data = user_data; | |
503 | |
504 option_data->box = gtk_vbox_new (FALSE, 0); | |
505 gtk_container_border_width (GTK_CONTAINER (option_data->box), 10); | |
506 gtk_widget_show (option_data->box); | |
507 | |
508 tempwid = gtk_label_new (_(cv->description)); | |
509 gtk_widget_show (tempwid); | |
510 gtk_notebook_append_page (GTK_NOTEBOOK (option_data->notebook), | |
511 option_data->box, tempwid); | |
512 | |
513 _print_option_type_newtable (NULL, user_data); | |
514 | |
515 return (NULL); | |
516 } | |
517 | |
518 | |
519 static void | |
520 clean_old_changes (GtkWidget * widget, gpointer data) | |
521 { | |
522 gftp_proxy_hosts *hosts; | |
523 GList *templist; | |
524 | |
525 templist = new_proxy_hosts; | |
526 while (templist != NULL) | |
527 { | |
528 hosts = templist->data; | |
529 if (hosts->domain) | |
530 g_free (hosts->domain); | |
531 g_free (hosts); | |
532 templist = templist->next; | |
533 } | |
534 g_list_free (new_proxy_hosts); | |
535 new_proxy_hosts = NULL; | |
536 } | |
537 | |
538 | |
539 static void | |
540 apply_changes (GtkWidget * widget, gpointer data) | |
541 { | |
542 gftp_config_vars * cv; | |
543 GList * templist; | |
544 int i; | |
545 | |
546 for (templist = gftp_options_list; | |
547 templist != NULL; | |
548 templist = templist->next) | |
549 { | |
550 cv = templist->data; | |
551 | |
552 for (i=0; cv[i].key != NULL; i++) | |
113 { | 553 { |
114 *endpos = '\n'; | 554 if (!(cv[i].ports_shown & GFTP_PORT_GTK)) |
115 pos = endpos + 1; | 555 continue; |
556 | |
557 if (gftp_option_types[cv[i].otype].ui_save_function == NULL) | |
558 continue; | |
559 | |
560 gftp_option_types[cv[i].otype].ui_save_function (&cv[i], gftp_option_types[cv[i].otype].user_data); | |
116 } | 561 } |
117 } | 562 } |
118 while (endpos != NULL); | |
119 | |
120 #if GTK_MAJOR_VERSION == 1 | |
121 if (!GTK_TEXT (proxy_text)->use_wchar) | |
122 g_free (textstr); | |
123 #else | |
124 g_free (textstr); | |
125 #endif | |
126 | |
127 return (newstr); | |
128 } | |
129 | |
130 | |
131 static void | |
132 apply_changes (GtkWidget * widget, gpointer data) | |
133 { | |
134 #if 0 | |
135 FIXME | |
136 const char *tempstr; | |
137 int num, found, i; | |
138 GList *templist; | |
139 | |
140 for (num = 0; config_file_vars[num].var != NULL; num++) | |
141 { | |
142 if (config_file_vars[num].widget != NULL) | |
143 { | |
144 switch (config_file_vars[num].type) | |
145 { | |
146 case CONFIG_CHECKBOX: | |
147 *(int *) config_file_vars[num].var = | |
148 GTK_TOGGLE_BUTTON (config_file_vars[num].widget)->active; | |
149 break; | |
150 case CONFIG_INTTEXT: | |
151 case CONFIG_UINTTEXT: | |
152 tempstr = gtk_entry_get_text ( | |
153 GTK_ENTRY (config_file_vars[num].widget)); | |
154 *(int *) config_file_vars[num].var = strtol (tempstr, NULL, 10); | |
155 break; | |
156 case CONFIG_FLOATTEXT: | |
157 tempstr = gtk_entry_get_text ( | |
158 GTK_ENTRY (config_file_vars[num].widget)); | |
159 *(double *) config_file_vars[num].var = strtod (tempstr, NULL); | |
160 break; | |
161 case CONFIG_CHARTEXT: | |
162 case CONFIG_CHARPASS: | |
163 tempstr = gtk_entry_get_text ( | |
164 GTK_ENTRY (config_file_vars[num].widget)); | |
165 g_free (*(char **) config_file_vars[num].var); | |
166 *(char **) config_file_vars[num].var = | |
167 g_malloc (strlen (tempstr) + 1); | |
168 strcpy (*(char **) config_file_vars[num].var, tempstr); | |
169 break; | |
170 } | |
171 } | |
172 } | |
173 | |
174 tempstr = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (def_proto_combo)->entry)); | |
175 found = 0; | |
176 for (i = 0; gftp_protocols[i].name; i++) | |
177 { | |
178 if (strcmp (gftp_protocols[i].name, tempstr) == 0) | |
179 { | |
180 found = 1; | |
181 break; | |
182 } | |
183 } | |
184 | |
185 if (found) | |
186 { | |
187 g_free (default_protocol); | |
188 default_protocol = g_strconcat (tempstr, NULL); | |
189 } | |
190 | |
191 templist = proxy_hosts; | |
192 proxy_hosts = new_proxy_hosts; | |
193 new_proxy_hosts = templist; | |
194 clean_old_changes (NULL, NULL); | |
195 | |
196 if (proxy_config != NULL) | |
197 g_free (proxy_config); | |
198 proxy_config = get_proxy_config (); | |
199 | |
200 gftp_write_config_file (); | |
201 #endif | |
202 } | 563 } |
203 | 564 |
204 | 565 |
205 #if GTK_MAJOR_VERSION > 1 | 566 #if GTK_MAJOR_VERSION > 1 |
206 static void | 567 static void |
217 default: | 578 default: |
218 gtk_widget_destroy (widget); | 579 gtk_widget_destroy (widget); |
219 } | 580 } |
220 } | 581 } |
221 #endif | 582 #endif |
222 | |
223 | |
224 static void | |
225 proxy_toggle (GtkList * list, GtkWidget * child, gpointer data) | |
226 { | |
227 #if 0 | |
228 FIXME | |
229 int proxy_num; | |
230 char *str; | |
231 | |
232 #if GTK_MAJOR_VERSION > 1 | |
233 GtkTextIter iter, iter2; | |
234 GtkTextBuffer * textbuf; | |
235 guint len; | |
236 #endif | |
237 | |
238 proxy_num = gtk_list_child_position (list, child); | |
239 if (proxy_num == GFTP_CUSTOM_PROXY_NUM) | |
240 str = custom_proxy; | |
241 else | |
242 str = proxy_type[proxy_num].description; | |
243 | |
244 #if GTK_MAJOR_VERSION == 1 | |
245 gtk_text_set_point (GTK_TEXT (proxy_text), 0); | |
246 gtk_text_forward_delete (GTK_TEXT (proxy_text), | |
247 gtk_text_get_length (GTK_TEXT (proxy_text))); | |
248 | |
249 gtk_text_insert (GTK_TEXT (proxy_text), NULL, NULL, NULL, str, -1); | |
250 #else | |
251 textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (proxy_text)); | |
252 len = gtk_text_buffer_get_char_count (textbuf); | |
253 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); | |
254 gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, len - 1); | |
255 gtk_text_buffer_delete (textbuf, &iter, &iter2); | |
256 | |
257 len = gtk_text_buffer_get_char_count (textbuf); | |
258 gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len - 1); | |
259 gtk_text_buffer_insert (textbuf, &iter, str, -1); | |
260 #endif | |
261 #endif | |
262 } | |
263 | 583 |
264 | 584 |
265 static void | 585 static void |
266 add_host_to_listbox (GList * templist) | 586 add_host_to_listbox (GList * templist) |
267 { | 587 { |
648 | 968 |
649 static void | 969 static void |
650 make_proxy_hosts_tab (GtkWidget * notebook) | 970 make_proxy_hosts_tab (GtkWidget * notebook) |
651 { | 971 { |
652 GtkWidget *tempwid, *box, *hbox, *scroll; | 972 GtkWidget *tempwid, *box, *hbox, *scroll; |
653 gftp_proxy_hosts *hosts, *newhosts; | |
654 char *add_data[2]; | 973 char *add_data[2]; |
655 GList *templist; | |
656 | 974 |
657 add_data[0] = _("Network"); | 975 add_data[0] = _("Network"); |
658 add_data[1] = _("Netmask"); | 976 add_data[1] = _("Netmask"); |
659 | 977 |
660 box = gtk_vbox_new (FALSE, 5); | 978 box = gtk_vbox_new (FALSE, 5); |
699 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | 1017 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); |
700 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0); | 1018 gtk_box_pack_start (GTK_BOX (hbox), tempwid, TRUE, TRUE, 0); |
701 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", | 1019 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", |
702 GTK_SIGNAL_FUNC (delete_proxy_host), NULL); | 1020 GTK_SIGNAL_FUNC (delete_proxy_host), NULL); |
703 gtk_widget_show (tempwid); | 1021 gtk_widget_show (tempwid); |
704 | |
705 #if 0 | |
706 FIXME | |
707 new_proxy_hosts = NULL; | |
708 for (templist = proxy_hosts; templist != NULL; | |
709 templist = templist->next) | |
710 { | |
711 hosts = templist->data; | |
712 newhosts = g_malloc (sizeof (*newhosts)); | |
713 memcpy (newhosts, hosts, sizeof (*newhosts)); | |
714 if (newhosts->domain) | |
715 { | |
716 newhosts->domain = g_malloc (strlen (hosts->domain) + 1); | |
717 strcpy (newhosts->domain, hosts->domain); | |
718 } | |
719 new_proxy_hosts = g_list_prepend (new_proxy_hosts, newhosts); | |
720 add_host_to_listbox (new_proxy_hosts); | |
721 } | |
722 #endif | |
723 } | 1022 } |
724 | 1023 |
725 | 1024 |
726 void | 1025 void |
727 options_dialog (gpointer data) | 1026 options_dialog (gpointer data) |
728 { | 1027 { |
729 GtkWidget * dialog, * tempwid, * notebook, * table, * box; | 1028 gftp_options_dialog_data option_data; |
730 char tempstr[20], *pos, *endpos, *oldstr; | 1029 gftp_config_vars * cv; |
731 int i, tbl_col, tbl_num, combo_num; | 1030 GList * templist; |
732 GList * combo_list; | 1031 int i; |
1032 | |
1033 memset (&option_data, 0, sizeof (option_data)); | |
1034 _setup_option (gftp_option_type_text, &option_data, | |
1035 _print_option_type_text, _save_option_type_text); | |
1036 _setup_option (gftp_option_type_textcombo, &option_data, | |
1037 _print_option_type_textcombo, _save_option_type_textcombo); | |
1038 _setup_option (gftp_option_type_textcomboedt, &option_data, | |
1039 _print_option_type_textcomboedt, | |
1040 _save_option_type_textcomboedt); | |
1041 _setup_option (gftp_option_type_hidetext, &option_data, | |
1042 _print_option_type_hidetext, _save_option_type_text); | |
1043 _setup_option (gftp_option_type_int, &option_data, | |
1044 _print_option_type_int, _save_option_type_int); | |
1045 _setup_option (gftp_option_type_checkbox, &option_data, | |
1046 _print_option_type_checkbox, _save_option_type_checkbox); | |
1047 _setup_option (gftp_option_type_float, &option_data, | |
1048 _print_option_type_float, _save_option_type_float); | |
1049 _setup_option (gftp_option_type_notebook, &option_data, | |
1050 _print_option_type_notebook, NULL); | |
733 | 1051 |
734 #if GTK_MAJOR_VERSION == 1 | 1052 #if GTK_MAJOR_VERSION == 1 |
735 dialog = gtk_dialog_new (); | 1053 option_data.dialog = gtk_dialog_new (); |
736 gtk_window_set_title (GTK_WINDOW (dialog), _("Options")); | 1054 gtk_window_set_title (GTK_WINDOW (option_data.dialog), _("Options")); |
737 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), | 1055 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (option_data.dialog)->action_area), 5); |
738 5); | 1056 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (option_data.dialog)->action_area), 15); |
739 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); | 1057 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (option_data.dialog)->action_area), TRUE); |
740 gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dialog)->action_area), TRUE); | |
741 #else | 1058 #else |
742 dialog = gtk_dialog_new_with_buttons (_("Options"), NULL, 0, | 1059 option_data.dialog = gtk_dialog_new_with_buttons (_("Options"), NULL, 0, |
743 GTK_STOCK_SAVE, | 1060 GTK_STOCK_OK, |
744 GTK_RESPONSE_OK, | 1061 GTK_RESPONSE_OK, |
745 GTK_STOCK_CANCEL, | 1062 GTK_STOCK_CANCEL, |
746 GTK_RESPONSE_CANCEL, | 1063 GTK_RESPONSE_CANCEL, |
747 GTK_STOCK_APPLY, | 1064 GTK_STOCK_APPLY, |
748 GTK_RESPONSE_APPLY, | 1065 GTK_RESPONSE_APPLY, |
749 NULL); | 1066 NULL); |
750 #endif | 1067 #endif |
751 gtk_window_set_wmclass (GTK_WINDOW(dialog), "options", "gFTP"); | 1068 gtk_window_set_wmclass (GTK_WINDOW(option_data.dialog), "options", "gFTP"); |
752 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); | 1069 gtk_window_set_position (GTK_WINDOW (option_data.dialog), GTK_WIN_POS_MOUSE); |
753 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); | 1070 gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (option_data.dialog)->vbox), 10); |
754 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); | 1071 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (option_data.dialog)->vbox), 2); |
755 gtk_widget_realize (dialog); | 1072 gtk_widget_realize (option_data.dialog); |
756 | 1073 |
757 if (gftp_icon != NULL) | 1074 if (gftp_icon != NULL) |
758 { | 1075 { |
759 gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, | 1076 gdk_window_set_icon (option_data.dialog->window, NULL, gftp_icon->pixmap, |
760 gftp_icon->bitmap); | 1077 gftp_icon->bitmap); |
761 gdk_window_set_icon_name (dialog->window, _("gFTP Icon")); | 1078 gdk_window_set_icon_name (option_data.dialog->window, _("gFTP Icon")); |
762 } | 1079 } |
763 | 1080 |
764 notebook = gtk_notebook_new (); | 1081 option_data.notebook = gtk_notebook_new (); |
765 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, | 1082 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (option_data.dialog)->vbox), |
766 TRUE, 0); | 1083 option_data.notebook, TRUE, TRUE, 0); |
767 gtk_widget_show (notebook); | 1084 gtk_widget_show (option_data.notebook); |
768 | 1085 |
769 tbl_num = tbl_col = 0; | 1086 cv = gftp_options_list->data; |
770 table = box = NULL; | 1087 option_data.last_option = cv[0].otype; |
771 | 1088 for (templist = gftp_options_list; |
772 #if 0 | 1089 templist != NULL; |
773 FIXME | 1090 templist = templist->next) |
774 for (i=0; config_file_vars[i].key != NULL; i++) | 1091 { |
775 { | 1092 cv = templist->data; |
776 if (!(config_file_vars[i].ports_shown & GFTP_PORT_GTK)) | 1093 |
777 continue; | 1094 for (i=0; cv[i].key != NULL; i++) |
778 | |
779 switch (config_file_vars[i].type) | |
780 { | 1095 { |
781 case CONFIG_NOTEBOOK: | 1096 if (!(cv[i].ports_shown & GFTP_PORT_GTK)) |
782 box = gtk_vbox_new (FALSE, 0); | 1097 continue; |
783 gtk_container_border_width (GTK_CONTAINER (box), 10); | 1098 |
784 gtk_widget_show (box); | 1099 if (gftp_option_types[cv[i].otype].ui_print_function == NULL) |
785 | 1100 continue; |
786 tempwid = gtk_label_new (_(config_file_vars[i].description)); | 1101 |
787 gtk_widget_show (tempwid); | 1102 cv[i].user_data = gftp_option_types[cv[i].otype].ui_print_function (&cv[i], gftp_option_types[cv[i].otype].user_data); |
788 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, tempwid); | 1103 |
789 break; | 1104 option_data.last_option = cv[i].otype; |
790 case CONFIG_TABLE: | |
791 table = gtk_table_new (1, 2, FALSE); | |
792 gtk_table_set_row_spacings (GTK_TABLE (table), 5); | |
793 gtk_table_set_col_spacings (GTK_TABLE (table), 5); | |
794 gtk_box_pack_start (GTK_BOX (box), table, FALSE, FALSE, 0); | |
795 gtk_widget_show (table); | |
796 tbl_num = 1; | |
797 tbl_col = 0; | |
798 break; | |
799 case CONFIG_COMBO: | |
800 gtk_table_resize (GTK_TABLE (table), tbl_num, 2); | |
801 | |
802 tempwid = gtk_label_new (_(config_file_vars[i].description)); | |
803 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5); | |
804 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, | |
805 tbl_num - 1, tbl_num); | |
806 gtk_widget_show (tempwid); | |
807 | |
808 tempwid = gtk_combo_new (); | |
809 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 1, 2, | |
810 tbl_num - 1, tbl_num); | |
811 gtk_widget_show (tempwid); | |
812 config_file_vars[i].widget = tempwid; | |
813 | |
814 /* We only have Default Protocol and the Proxy type as the two | |
815 combo types. If I add more later on, I'll work on a better | |
816 interface for all this stuff */ | |
817 if (strcmp (config_file_vars[i].comment, "DP") == 0) | |
818 def_proto_combo = tempwid; | |
819 else | |
820 proxy_combo = tempwid; | |
821 | |
822 tbl_num++; | |
823 break; | |
824 case CONFIG_TEXT: | |
825 #if GTK_MAJOR_VERSION == 1 | |
826 proxy_text = gtk_text_new (NULL, NULL); | |
827 gtk_text_set_editable (GTK_TEXT (proxy_text), TRUE); | |
828 #else | |
829 proxy_text = gtk_text_view_new (); | |
830 gtk_text_view_set_editable (GTK_TEXT_VIEW (proxy_text), TRUE); | |
831 #endif | |
832 gtk_widget_set_size_request (proxy_text, -1, 75); | |
833 gtk_table_attach_defaults (GTK_TABLE (table), proxy_text, 0, 2, | |
834 tbl_num - 1, tbl_num); | |
835 gtk_widget_show (proxy_text); | |
836 config_file_vars[i].widget = proxy_text; | |
837 | |
838 tbl_num++; | |
839 break; | |
840 case CONFIG_CHARTEXT: | |
841 case CONFIG_CHARPASS: | |
842 case CONFIG_INTTEXT: | |
843 case CONFIG_UINTTEXT: | |
844 case CONFIG_FLOATTEXT: | |
845 gtk_table_resize (GTK_TABLE (table), tbl_num, 2); | |
846 | |
847 tempwid = gtk_label_new (_(config_file_vars[i].description)); | |
848 gtk_misc_set_alignment (GTK_MISC (tempwid), 1, 0.5); | |
849 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 0, 1, | |
850 tbl_num - 1, tbl_num); | |
851 gtk_widget_show (tempwid); | |
852 | |
853 tempwid = gtk_entry_new (); | |
854 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, 1, 2, | |
855 tbl_num - 1, tbl_num); | |
856 | |
857 switch (config_file_vars[i].type) | |
858 { | |
859 case CONFIG_INTTEXT: | |
860 case CONFIG_UINTTEXT: | |
861 g_snprintf (tempstr, sizeof (tempstr), "%d", | |
862 *(int *) config_file_vars[i].var); | |
863 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr); | |
864 break; | |
865 case CONFIG_FLOATTEXT: | |
866 g_snprintf (tempstr, sizeof (tempstr), "%.2f", | |
867 *(double *) config_file_vars[i].var); | |
868 gtk_entry_set_text (GTK_ENTRY (tempwid), tempstr); | |
869 break; | |
870 case CONFIG_CHARTEXT: | |
871 gtk_entry_set_text (GTK_ENTRY (tempwid), | |
872 *(char **) config_file_vars[i].var); | |
873 break; | |
874 case CONFIG_CHARPASS: | |
875 gtk_entry_set_text (GTK_ENTRY (tempwid), | |
876 *(char **) config_file_vars[i].var); | |
877 gtk_entry_set_visibility (GTK_ENTRY (tempwid), 0); | |
878 break; | |
879 } | |
880 gtk_widget_show (tempwid); | |
881 config_file_vars[i].widget = tempwid; | |
882 tbl_num++; | |
883 break; | |
884 case CONFIG_CHECKBOX: | |
885 tempwid = gtk_check_button_new_with_label ( | |
886 _(config_file_vars[i].description)); | |
887 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, | |
888 tbl_col, tbl_col + 1, tbl_num, tbl_num + 1); | |
889 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tempwid), | |
890 *(int *) config_file_vars[i].var); | |
891 gtk_widget_show (tempwid); | |
892 config_file_vars[i].widget = tempwid; | |
893 tbl_col++; | |
894 if (tbl_col == 2) | |
895 { | |
896 tbl_col = 0; | |
897 tbl_num++; | |
898 gtk_table_resize (GTK_TABLE (table), tbl_num + 1, 2); | |
899 } | |
900 break; | |
901 case CONFIG_LABEL: | |
902 tempwid = gtk_label_new (_(config_file_vars[i].description)); | |
903 gtk_misc_set_alignment (GTK_MISC (tempwid), tbl_col, 0.5); | |
904 gtk_table_attach_defaults (GTK_TABLE (table), tempwid, | |
905 tbl_col, tbl_col + 1, tbl_num, tbl_num + 1); | |
906 gtk_widget_show (tempwid); | |
907 config_file_vars[i].widget = tempwid; | |
908 tbl_col++; | |
909 if (tbl_col == 2) | |
910 { | |
911 tbl_col = 0; | |
912 tbl_num++; | |
913 gtk_table_resize (GTK_TABLE (table), tbl_num + 1, 2); | |
914 } | |
915 break; | |
916 } | 1105 } |
917 } | 1106 } |
918 | |
919 combo_num = 0; | |
920 combo_list = NULL; | |
921 for (i = 0; gftp_protocols[i].name != NULL; i++) | |
922 { | |
923 if (strcmp (default_protocol, gftp_protocols[i].name) == 0) | |
924 combo_num = i; | |
925 tempwid = gtk_list_item_new_with_label (gftp_protocols[i].name); | |
926 gtk_widget_show (tempwid); | |
927 combo_list = g_list_append (combo_list, tempwid); | |
928 } | |
929 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (def_proto_combo)->list), | |
930 combo_list); | |
931 gtk_list_select_item (GTK_LIST (GTK_COMBO (def_proto_combo)->list), | |
932 combo_num); | |
933 | |
934 combo_list = NULL; | |
935 for (i = 0; proxy_type[i].key != NULL; i++) | |
936 { | |
937 tempwid = gtk_list_item_new_with_label (_(proxy_type[i].key)); | |
938 gtk_widget_show (tempwid); | |
939 combo_list = g_list_append (combo_list, tempwid); | |
940 } | |
941 gtk_list_prepend_items (GTK_LIST (GTK_COMBO (proxy_combo)->list), combo_list); | |
942 combo_list = NULL; | |
943 | |
944 custom_proxy = g_malloc0 (1); | |
945 if (proxy_config == NULL || *proxy_config == '\0') | |
946 combo_num = 0; | |
947 else | |
948 { | |
949 pos = proxy_config; | |
950 while ((endpos = strstr (pos, "%n"))) | |
951 { | |
952 *endpos = '\0'; | |
953 oldstr = custom_proxy; | |
954 custom_proxy = g_strconcat (custom_proxy, pos, "\n", NULL); | |
955 g_free (oldstr); | |
956 *endpos = '%'; | |
957 pos = endpos + 2; | |
958 } | |
959 | |
960 for (combo_num = 1; combo_num < GFTP_CUSTOM_PROXY_NUM; combo_num++) | |
961 { | |
962 if (strcmp (proxy_type[combo_num].description, custom_proxy) == 0) | |
963 break; | |
964 } | |
965 } | |
966 | |
967 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (proxy_combo)->list), | |
968 "select_child", GTK_SIGNAL_FUNC (proxy_toggle), NULL); | |
969 gtk_list_select_item (GTK_LIST (GTK_COMBO (proxy_combo)->list), combo_num); | |
970 | |
971 make_proxy_hosts_tab (notebook); | |
972 #endif | |
973 | 1107 |
974 #if GTK_MAJOR_VERSION == 1 | 1108 #if GTK_MAJOR_VERSION == 1 |
975 tempwid = gtk_button_new_with_label (_("OK")); | 1109 tempwid = gtk_button_new_with_label (_("OK")); |
976 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | 1110 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); |
977 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | 1111 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (option_data.dialog)->action_area), |
978 TRUE, TRUE, 0); | 1112 tempwid, TRUE, TRUE, 0); |
979 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", | 1113 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", |
980 GTK_SIGNAL_FUNC (apply_changes), NULL); | 1114 GTK_SIGNAL_FUNC (apply_changes), NULL); |
981 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | 1115 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", |
982 GTK_SIGNAL_FUNC (gtk_widget_destroy), | 1116 GTK_SIGNAL_FUNC (gtk_widget_destroy), |
983 GTK_OBJECT (dialog)); | 1117 GTK_OBJECT (option_data.dialog)); |
984 gtk_widget_show (tempwid); | 1118 gtk_widget_show (tempwid); |
985 | 1119 |
986 tempwid = gtk_button_new_with_label (_(" Cancel ")); | 1120 tempwid = gtk_button_new_with_label (_(" Cancel ")); |
987 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | 1121 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); |
988 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | 1122 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (option_data.dialog)->action_area), |
989 TRUE, TRUE, 0); | 1123 tempwid, TRUE, TRUE, 0); |
990 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", | 1124 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", |
991 GTK_SIGNAL_FUNC (clean_old_changes), NULL); | 1125 GTK_SIGNAL_FUNC (clean_old_changes), NULL); |
992 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", | 1126 gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", |
993 GTK_SIGNAL_FUNC (gtk_widget_destroy), | 1127 GTK_SIGNAL_FUNC (gtk_widget_destroy), |
994 GTK_OBJECT (dialog)); | 1128 GTK_OBJECT (option_data.dialog)); |
995 gtk_widget_show (tempwid); | 1129 gtk_widget_show (tempwid); |
996 | 1130 |
997 tempwid = gtk_button_new_with_label (_("Apply")); | 1131 tempwid = gtk_button_new_with_label (_("Apply")); |
998 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); | 1132 GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); |
999 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, | 1133 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (option_data.dialog)->action_area), |
1000 TRUE, TRUE, 0); | 1134 tempwid, TRUE, TRUE, 0); |
1001 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", | 1135 gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", |
1002 GTK_SIGNAL_FUNC (apply_changes), NULL); | 1136 GTK_SIGNAL_FUNC (apply_changes), NULL); |
1003 gtk_widget_grab_default (tempwid); | 1137 gtk_widget_grab_default (tempwid); |
1004 gtk_widget_show (tempwid); | 1138 gtk_widget_show (tempwid); |
1005 #else | 1139 #else |
1006 g_signal_connect (GTK_OBJECT (dialog), "response", | 1140 g_signal_connect (GTK_OBJECT (option_data.dialog), "response", |
1007 G_CALLBACK (options_action), NULL); | 1141 G_CALLBACK (options_action), NULL); |
1008 #endif | 1142 #endif |
1009 | 1143 |
1010 gtk_widget_show (dialog); | 1144 gtk_widget_show (option_data.dialog); |
1011 } | 1145 } |
1012 | 1146 |