|
Lines 32-50
Link Here
|
| 32 |
#include "capplet-util.h" |
32 |
#include "capplet-util.h" |
| 33 |
#include "gconf-property-editor.h" |
33 |
#include "gconf-property-editor.h" |
| 34 |
|
34 |
|
| 35 |
enum ProxyMode |
35 |
/* Novell extension */ |
| 36 |
{ |
36 |
#define KEY_USE_SYSTEM_SETTINGS "/system/proxy/use_system_settings" /* string */ |
| 37 |
PROXYMODE_NONE, |
37 |
#define VAL_USE_SYSTEM_SETTINGS_ONLY_IF_NOT_SET "only_if_mode_not_set" |
| 38 |
PROXYMODE_MANUAL, |
38 |
#define VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES "system_values" |
| 39 |
PROXYMODE_AUTO |
39 |
#define VAL_USE_SYSTEM_SETTINGS_USER_VALUES "user_values" |
| 40 |
}; |
|
|
| 41 |
|
| 42 |
static GEnumValue proxytype_values[] = { |
| 43 |
{ PROXYMODE_NONE, "PROXYMODE_NONE", "none"}, |
| 44 |
{ PROXYMODE_MANUAL, "PROXYMODE_MANUAL", "manual"}, |
| 45 |
{ PROXYMODE_AUTO, "PROXYMODE_AUTO", "auto"}, |
| 46 |
{ 0, NULL, NULL } |
| 47 |
}; |
| 48 |
|
40 |
|
| 49 |
#define USE_PROXY_KEY "/system/http_proxy/use_http_proxy" |
41 |
#define USE_PROXY_KEY "/system/http_proxy/use_http_proxy" |
| 50 |
#define USE_SAME_PROXY_KEY "/system/http_proxy/use_same_proxy" |
42 |
#define USE_SAME_PROXY_KEY "/system/http_proxy/use_same_proxy" |
|
Lines 363-391
static void
Link Here
|
| 363 |
proxy_mode_radiobutton_clicked_cb (GtkWidget *widget, |
355 |
proxy_mode_radiobutton_clicked_cb (GtkWidget *widget, |
| 364 |
GladeXML *dialog) |
356 |
GladeXML *dialog) |
| 365 |
{ |
357 |
{ |
| 366 |
GSList *mode_group; |
358 |
GConfClient *client; |
| 367 |
int mode; |
359 |
gboolean manual_box_sensitive, auto_box_sensitive; |
| 368 |
GConfClient *client; |
360 |
|
| 369 |
|
361 |
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) |
| 370 |
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) |
362 |
return; |
| 371 |
return; |
363 |
|
| 372 |
|
|
|
| 373 |
mode_group = g_slist_copy (gtk_radio_button_get_group |
| 374 |
(GTK_RADIO_BUTTON (WID ("none_radiobutton")))); |
| 375 |
mode_group = g_slist_reverse (mode_group); |
| 376 |
mode = g_slist_index (mode_group, widget); |
| 377 |
g_slist_free (mode_group); |
| 378 |
|
| 379 |
gtk_widget_set_sensitive (WID ("manual_box"), |
| 380 |
mode == PROXYMODE_MANUAL); |
| 381 |
gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), |
| 382 |
mode == PROXYMODE_MANUAL); |
| 383 |
gtk_widget_set_sensitive (WID ("auto_box"), |
| 384 |
mode == PROXYMODE_AUTO); |
| 385 |
client = gconf_client_get_default (); |
364 |
client = gconf_client_get_default (); |
| 386 |
gconf_client_set_bool (client, USE_PROXY_KEY, |
365 |
manual_box_sensitive = auto_box_sensitive = FALSE; |
| 387 |
mode == PROXYMODE_AUTO || mode == PROXYMODE_MANUAL, NULL); |
366 |
|
| 388 |
g_object_unref (client); |
367 |
if (widget == WID ("system_radiobutton")) { |
|
|
368 |
gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES, NULL); |
| 369 |
} else if (widget == WID ("none_radiobutton")) { |
| 370 |
gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); |
| 371 |
gconf_client_set_string (client, PROXY_MODE_KEY, "none", NULL); |
| 372 |
gconf_client_set_bool (client, USE_PROXY_KEY, FALSE, NULL); |
| 373 |
} else if (widget == WID ("manual_radiobutton")) { |
| 374 |
manual_box_sensitive = TRUE; |
| 375 |
|
| 376 |
gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); |
| 377 |
gconf_client_set_string (client, PROXY_MODE_KEY, "manual", NULL); |
| 378 |
gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL); |
| 379 |
} else if (widget == WID ("auto_radiobutton")) { |
| 380 |
auto_box_sensitive = TRUE; |
| 381 |
|
| 382 |
gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); |
| 383 |
gconf_client_set_string (client, PROXY_MODE_KEY, "auto", NULL); |
| 384 |
gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL); |
| 385 |
} |
| 386 |
|
| 387 |
gtk_widget_set_sensitive (WID ("manual_box"), manual_box_sensitive); |
| 388 |
gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), manual_box_sensitive); |
| 389 |
gtk_widget_set_sensitive (WID ("auto_box"), auto_box_sensitive); |
| 390 |
|
| 391 |
g_object_unref (client); |
| 389 |
} |
392 |
} |
| 390 |
|
393 |
|
| 391 |
static void |
394 |
static void |
|
Lines 399-432
connect_sensitivity_signals (GladeXML *dialog, GSList *mode_group)
Link Here
|
| 399 |
} |
402 |
} |
| 400 |
} |
403 |
} |
| 401 |
|
404 |
|
|
|
405 |
static GtkWidget * |
| 406 |
get_radio_for_mode (GladeXML *dialog, const char *mode_str) |
| 407 |
{ |
| 408 |
if (!mode_str) |
| 409 |
return WID ("none_radiobutton"); |
| 410 |
else if (strcmp (mode_str, "none") == 0) |
| 411 |
return WID ("none_radiobutton"); |
| 412 |
else if (strcmp (mode_str, "manual") == 0) |
| 413 |
return WID ("manual_radiobutton"); |
| 414 |
else if (strcmp (mode_str, "auto") == 0) |
| 415 |
return WID ("auto_radiobutton"); |
| 416 |
else |
| 417 |
return WID ("none_radiobutton"); |
| 418 |
} |
| 419 |
|
| 420 |
static void |
| 421 |
mode_set_initial_value (GladeXML *dialog, GConfClient *client) |
| 422 |
{ |
| 423 |
char *use_system_settings; |
| 424 |
GConfValue *mode_value; |
| 425 |
gboolean use_system_if_mode_not_set; |
| 426 |
gboolean use_mode; |
| 427 |
GtkWidget *radiobutton; |
| 428 |
|
| 429 |
radiobutton = NULL; |
| 430 |
|
| 431 |
use_system_settings = gconf_client_get_string (client, KEY_USE_SYSTEM_SETTINGS, NULL); |
| 432 |
mode_value = gconf_client_get_without_default (client, PROXY_MODE_KEY, NULL); |
| 433 |
|
| 434 |
use_system_if_mode_not_set = FALSE; |
| 435 |
use_mode = FALSE; |
| 436 |
|
| 437 |
if (!use_system_settings) |
| 438 |
use_system_if_mode_not_set = TRUE; |
| 439 |
else { |
| 440 |
if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_ONLY_IF_NOT_SET) == 0) |
| 441 |
use_system_if_mode_not_set = TRUE; |
| 442 |
else if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES) == 0) |
| 443 |
radiobutton = WID ("system_radiobutton"); |
| 444 |
else if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_USER_VALUES) == 0) |
| 445 |
use_mode = TRUE; |
| 446 |
|
| 447 |
g_free (use_system_settings); |
| 448 |
} |
| 449 |
|
| 450 |
if (use_system_if_mode_not_set) { |
| 451 |
if (mode_value) |
| 452 |
use_mode = TRUE; |
| 453 |
else |
| 454 |
radiobutton = WID ("system_radiobutton"); |
| 455 |
} |
| 456 |
|
| 457 |
if (use_mode) { |
| 458 |
if (!mode_value || mode_value->type != GCONF_VALUE_STRING) |
| 459 |
radiobutton = WID ("none_radiobutton"); |
| 460 |
else |
| 461 |
radiobutton = get_radio_for_mode (dialog, gconf_value_get_string (mode_value)); |
| 462 |
} |
| 463 |
|
| 464 |
if (radiobutton) |
| 465 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton), TRUE); |
| 466 |
|
| 467 |
if (mode_value) |
| 468 |
gconf_value_free (mode_value); |
| 469 |
} |
| 470 |
|
| 402 |
static void |
471 |
static void |
| 403 |
setup_dialog (GladeXML *dialog) |
472 |
setup_dialog (GladeXML *dialog) |
| 404 |
{ |
473 |
{ |
| 405 |
GConfPropertyEditor *peditor; |
474 |
GConfPropertyEditor *peditor; |
| 406 |
GSList *mode_group; |
475 |
GSList *mode_group; |
| 407 |
GType mode_type = 0; |
|
|
| 408 |
GConfClient *client; |
476 |
GConfClient *client; |
| 409 |
gint port_value; |
477 |
gint port_value; |
| 410 |
|
478 |
|
| 411 |
mode_type = g_enum_register_static ("NetworkPreferencesProxyType", |
|
|
| 412 |
proxytype_values); |
| 413 |
|
479 |
|
| 414 |
/* There's a bug in peditors that cause them to not initialize the entry |
480 |
/* There's a bug in peditors that cause them to not initialize the entry |
| 415 |
* correctly. */ |
481 |
* correctly. */ |
| 416 |
client = gconf_client_get_default (); |
482 |
client = gconf_client_get_default (); |
| 417 |
|
483 |
|
| 418 |
/* Hackety hack */ |
484 |
/* Hackety hack */ |
|
|
485 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("system_radiobutton"))->child), TRUE); |
| 419 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("none_radiobutton"))->child), TRUE); |
486 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("none_radiobutton"))->child), TRUE); |
| 420 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("manual_radiobutton"))->child), TRUE); |
487 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("manual_radiobutton"))->child), TRUE); |
| 421 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("auto_radiobutton"))->child), TRUE); |
488 |
gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("auto_radiobutton"))->child), TRUE); |
| 422 |
|
489 |
|
| 423 |
/* Mode */ |
490 |
/* Mode */ |
| 424 |
mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("none_radiobutton"))); |
491 |
mode_set_initial_value (dialog, client); |
|
|
492 |
mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("system_radiobutton"))); |
| 425 |
connect_sensitivity_signals (dialog, mode_group); |
493 |
connect_sensitivity_signals (dialog, mode_group); |
| 426 |
|
494 |
|
| 427 |
peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_select_radio_with_enum (NULL, |
|
|
| 428 |
PROXY_MODE_KEY, mode_group, mode_type, |
| 429 |
TRUE, NULL)); |
| 430 |
|
495 |
|
| 431 |
/* Use same proxy for all protocols */ |
496 |
/* Use same proxy for all protocols */ |
| 432 |
peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_boolean (NULL, |
497 |
peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_boolean (NULL, |