View | Details | Raw Unified | Return to bug 350513
Collapse All | Expand All

(-)a/capplets/network/gnome-network-preferences.c (-42 / +107 lines)
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,
(-)a/capplets/network/gnome-network-preferences.glade (-4 / +22 lines)
Lines 85-90 Link Here
85
	      <property name="spacing">18</property>
85
	      <property name="spacing">18</property>
86
86
87
	      <child>
87
	      <child>
88
		<widget class="GtkRadioButton" id="system_radiobutton">
89
		  <property name="visible">True</property>
90
		  <property name="can_focus">True</property>
91
		  <property name="label" translatable="yes">&lt;b&gt;Use the s_ystem's proxy settings&lt;/b&gt;</property>
92
		  <property name="use_underline">True</property>
93
		  <property name="relief">GTK_RELIEF_NORMAL</property>
94
		  <property name="focus_on_click">True</property>
95
		  <property name="active">False</property>
96
		  <property name="inconsistent">False</property>
97
		  <property name="draw_indicator">True</property>
98
		</widget>
99
		<packing>
100
		  <property name="padding">0</property>
101
		  <property name="expand">False</property>
102
		  <property name="fill">False</property>
103
		</packing>
104
	      </child>
105
106
	      <child>
88
		<widget class="GtkRadioButton" id="none_radiobutton">
107
		<widget class="GtkRadioButton" id="none_radiobutton">
89
		  <property name="visible">True</property>
108
		  <property name="visible">True</property>
90
		  <property name="can_focus">True</property>
109
		  <property name="can_focus">True</property>
Lines 95-100 Link Here
95
		  <property name="active">False</property>
114
		  <property name="active">False</property>
96
		  <property name="inconsistent">False</property>
115
		  <property name="inconsistent">False</property>
97
		  <property name="draw_indicator">True</property>
116
		  <property name="draw_indicator">True</property>
117
		  <property name="group">system_radiobutton</property>
98
		</widget>
118
		</widget>
99
		<packing>
119
		<packing>
100
		  <property name="padding">0</property>
120
		  <property name="padding">0</property>
Lines 126-132 Link Here
126
			  <property name="active">False</property>
146
			  <property name="active">False</property>
127
			  <property name="inconsistent">False</property>
147
			  <property name="inconsistent">False</property>
128
			  <property name="draw_indicator">True</property>
148
			  <property name="draw_indicator">True</property>
129
			  <property name="group">none_radiobutton</property>
149
			  <property name="group">system_radiobutton</property>
130
			</widget>
150
			</widget>
131
			<packing>
151
			<packing>
132
			  <property name="padding">0</property>
152
			  <property name="padding">0</property>
Lines 669-675 Link Here
669
			  <property name="active">False</property>
689
			  <property name="active">False</property>
670
			  <property name="inconsistent">False</property>
690
			  <property name="inconsistent">False</property>
671
			  <property name="draw_indicator">True</property>
691
			  <property name="draw_indicator">True</property>
672
			  <property name="group">none_radiobutton</property>
692
			  <property name="group">system_radiobutton</property>
673
			</widget>
693
			</widget>
674
			<packing>
694
			<packing>
675
			  <property name="padding">0</property>
695
			  <property name="padding">0</property>
676
- 
677
2008-06-13  Federico Mena Quintero  <federico@novell.com>
696
2008-06-13  Federico Mena Quintero  <federico@novell.com>
678
--
679
capplets/network/gnome-network-preferences.c |   41 +++++++++++++++++---------
697
capplets/network/gnome-network-preferences.c |   41 +++++++++++++++++---------
680
1 files changed, 27 insertions(+), 14 deletions(-)
698
1 files changed, 27 insertions(+), 14 deletions(-)
(-)a/capplets/network/gnome-network-preferences.c (-15 / +27 lines)
Lines 352-368 extract_proxy_host (GConfPropertyEditor *peditor, const GConfValue *orig) Link Here
352
}
352
}
353
353
354
static void
354
static void
355
set_sensitivity_based_on_active_radiobutton (GladeXML *dialog, GtkWidget *active_radio)
356
{
357
 	gboolean manual_box_sensitive, auto_box_sensitive;
358
359
  	g_assert (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (active_radio)));
360
361
	manual_box_sensitive = auto_box_sensitive = FALSE;
362
363
	if (active_radio == WID ("manual_radiobutton"))
364
 		manual_box_sensitive = TRUE;
365
 	else if (active_radio == WID ("auto_radiobutton"))
366
 		auto_box_sensitive = TRUE;
367
368
 	gtk_widget_set_sensitive (WID ("manual_box"), manual_box_sensitive);
369
	gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), manual_box_sensitive);
370
 	gtk_widget_set_sensitive (WID ("auto_box"), auto_box_sensitive);
371
}
372
 
373
static void
355
proxy_mode_radiobutton_clicked_cb (GtkWidget *widget,
374
proxy_mode_radiobutton_clicked_cb (GtkWidget *widget,
356
				   GladeXML *dialog)
375
				   GladeXML *dialog)
357
{
376
{
358
  	GConfClient *client;
377
  	GConfClient *client;
359
 	gboolean manual_box_sensitive, auto_box_sensitive;
378
360
     
361
  	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
379
  	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
362
  		return;
380
  		return;
363
     
381
     
364
	client = gconf_client_get_default ();
382
	client = gconf_client_get_default ();
365
	manual_box_sensitive = auto_box_sensitive = FALSE;
366
     
383
     
367
 	if (widget == WID ("system_radiobutton")) {
384
 	if (widget == WID ("system_radiobutton")) {
368
 		gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES, NULL);
385
 		gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES, NULL);
Lines 371-398 proxy_mode_radiobutton_clicked_cb (GtkWidget *widget, Link Here
371
 		gconf_client_set_string (client, PROXY_MODE_KEY, "none", NULL);
388
 		gconf_client_set_string (client, PROXY_MODE_KEY, "none", NULL);
372
 		gconf_client_set_bool (client, USE_PROXY_KEY, FALSE, NULL);
389
 		gconf_client_set_bool (client, USE_PROXY_KEY, FALSE, NULL);
373
 	} else if (widget == WID ("manual_radiobutton")) {
390
 	} 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);
391
 		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);
392
 		gconf_client_set_string (client, PROXY_MODE_KEY, "manual", NULL);
378
 		gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL);
393
 		gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL);
379
 	} else if (widget == WID ("auto_radiobutton")) {
394
 	} 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);
395
 		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);
396
 		gconf_client_set_string (client, PROXY_MODE_KEY, "auto", NULL);
384
 		gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL);
397
 		gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL);
385
 	}
398
 	}
386
     
399
     
387
 	gtk_widget_set_sensitive (WID ("manual_box"), manual_box_sensitive);
400
	set_sensitivity_based_on_active_radiobutton (dialog, widget);
388
	gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), manual_box_sensitive);
389
 	gtk_widget_set_sensitive (WID ("auto_box"), auto_box_sensitive);
390
 
401
 
391
  	g_object_unref (client);
402
  	g_object_unref (client);
392
}
403
}
393
404
394
static void
405
static void
395
connect_sensitivity_signals (GladeXML *dialog, GSList *mode_group)
406
connect_mode_radiobuttons (GladeXML *dialog, GSList *mode_group)
396
{
407
{
397
	for (; mode_group != NULL; mode_group = mode_group->next)
408
	for (; mode_group != NULL; mode_group = mode_group->next)
398
	{
409
	{
Lines 416-422 get_radio_for_mode (GladeXML *dialog, const char *mode_str) Link Here
416
 	else
427
 	else
417
 		return WID ("none_radiobutton");
428
 		return WID ("none_radiobutton");
418
}
429
}
419
 
430
420
static void
431
static void
421
mode_set_initial_value (GladeXML *dialog, GConfClient *client)
432
mode_set_initial_value (GladeXML *dialog, GConfClient *client)
422
{
433
{
Lines 461-468 mode_set_initial_value (GladeXML *dialog, GConfClient *client) Link Here
461
 			radiobutton = get_radio_for_mode (dialog, gconf_value_get_string (mode_value));
472
 			radiobutton = get_radio_for_mode (dialog, gconf_value_get_string (mode_value));
462
 	}
473
 	}
463
 
474
 
464
 	if (radiobutton)
475
 	if (radiobutton) {
465
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton), TRUE);
476
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton), TRUE);
477
		set_sensitivity_based_on_active_radiobutton (dialog, radiobutton);
478
	}
466
 
479
 
467
 	if (mode_value)
480
 	if (mode_value)
468
 		gconf_value_free (mode_value);
481
 		gconf_value_free (mode_value);
Lines 490-496 setup_dialog (GladeXML *dialog) Link Here
490
	/* Mode */
503
	/* Mode */
491
 	mode_set_initial_value (dialog, client);
504
 	mode_set_initial_value (dialog, client);
492
 	mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("system_radiobutton")));
505
 	mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("system_radiobutton")));
493
	connect_sensitivity_signals (dialog, mode_group);
506
	connect_mode_radiobuttons (dialog, mode_group);
494
507
495
508
496
	/* Use same proxy for all protocols */
509
	/* Use same proxy for all protocols */
497
- 

Return to bug 350513