Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Maintenance:4948
gnome-control-center.openSUSE_Leap_42.1_Update
gnome-control-center-system-proxy-configuration...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-control-center-system-proxy-configuration.patch of Package gnome-control-center.openSUSE_Leap_42.1_Update
From 067cc33aba6eeaffd4efe1d8a8e838aa1a89476a Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero <federico@novell.com> Date: Mon, 25 May 2009 14:38:52 -0500 Subject: [PATCH] Integrate openSUSE's network proxy configuration with GNOME's. This is documented in http://en.opensuse.org/GNOME/Proxy_configuration We basically add a "use system settings" proxy mode. When it is active, gnome-settings-daemon will read /etc/sysconfig/proxy and mirror its values into GNOME's GConf space. Signed-off-by: Federico Mena Quintero <federico@novell.com> --- capplets/network/gnome-network-properties.c | 164 +++++++++++++++++------ capplets/network/gnome-network-properties.glade | 24 +++- 2 files changed, 143 insertions(+), 45 deletions(-) diff --git a/capplets/network/gnome-network-properties.c b/capplets/network/gnome-network-properties.c index f6ea0e6..0ea9945 100644 --- a/capplets/network/gnome-network-properties.c +++ b/capplets/network/gnome-network-properties.c @@ -32,19 +32,11 @@ #include "capplet-util.h" #include "gconf-property-editor.h" -enum ProxyMode -{ - PROXYMODE_NONE, - PROXYMODE_MANUAL, - PROXYMODE_AUTO -}; - -static GEnumValue proxytype_values[] = { - { PROXYMODE_NONE, "PROXYMODE_NONE", "none"}, - { PROXYMODE_MANUAL, "PROXYMODE_MANUAL", "manual"}, - { PROXYMODE_AUTO, "PROXYMODE_AUTO", "auto"}, - { 0, NULL, NULL } -}; +/* Novell extension */ +#define KEY_USE_SYSTEM_SETTINGS "/system/proxy/use_system_settings" /* string */ +#define VAL_USE_SYSTEM_SETTINGS_ONLY_IF_NOT_SET "only_if_mode_not_set" +#define VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES "system_values" +#define VAL_USE_SYSTEM_SETTINGS_USER_VALUES "user_values" enum { COL_NAME, @@ -1019,36 +1011,58 @@ extract_proxy_host (GConfPropertyEditor *peditor, const GConfValue *orig) } static void +set_sensitivity_based_on_active_radiobutton (GladeXML *dialog, GtkWidget *active_radio) +{ + gboolean manual_box_sensitive, auto_box_sensitive; + + g_assert (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (active_radio))); + + manual_box_sensitive = auto_box_sensitive = FALSE; + + if (active_radio == WID ("manual_radiobutton")) + manual_box_sensitive = TRUE; + else if (active_radio == WID ("auto_radiobutton")) + auto_box_sensitive = TRUE; + + gtk_widget_set_sensitive (WID ("manual_box"), manual_box_sensitive); + gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), manual_box_sensitive); + gtk_widget_set_sensitive (WID ("auto_box"), auto_box_sensitive); +} + +static void proxy_mode_radiobutton_clicked_cb (GtkWidget *widget, GladeXML *dialog) { - GSList *mode_group; - int mode; - GConfClient *client; + GConfClient *client; - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) - return; - - mode_group = g_slist_copy (gtk_radio_button_get_group - (GTK_RADIO_BUTTON (WID ("none_radiobutton")))); - mode_group = g_slist_reverse (mode_group); - mode = g_slist_index (mode_group, widget); - g_slist_free (mode_group); - - gtk_widget_set_sensitive (WID ("manual_box"), - mode == PROXYMODE_MANUAL); - gtk_widget_set_sensitive (WID ("same_proxy_checkbutton"), - mode == PROXYMODE_MANUAL); - gtk_widget_set_sensitive (WID ("auto_box"), - mode == PROXYMODE_AUTO); + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) + return; + client = gconf_client_get_default (); - gconf_client_set_bool (client, USE_PROXY_KEY, - mode == PROXYMODE_AUTO || mode == PROXYMODE_MANUAL, NULL); - g_object_unref (client); + + if (widget == WID ("system_radiobutton")) { + gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES, NULL); + } else if (widget == WID ("none_radiobutton")) { + gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); + gconf_client_set_string (client, PROXY_MODE_KEY, "none", NULL); + gconf_client_set_bool (client, USE_PROXY_KEY, FALSE, NULL); + } else if (widget == WID ("manual_radiobutton")) { + gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); + gconf_client_set_string (client, PROXY_MODE_KEY, "manual", NULL); + gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL); + } else if (widget == WID ("auto_radiobutton")) { + gconf_client_set_string (client, KEY_USE_SYSTEM_SETTINGS, VAL_USE_SYSTEM_SETTINGS_USER_VALUES, NULL); + gconf_client_set_string (client, PROXY_MODE_KEY, "auto", NULL); + gconf_client_set_bool (client, USE_PROXY_KEY, TRUE, NULL); + } + + set_sensitivity_based_on_active_radiobutton (dialog, widget); + + g_object_unref (client); } static void -connect_sensitivity_signals (GladeXML *dialog, GSList *mode_group) +connect_mode_radiobuttons (GladeXML *dialog, GSList *mode_group) { for (; mode_group != NULL; mode_group = mode_group->next) { @@ -1058,20 +1072,85 @@ connect_sensitivity_signals (GladeXML *dialog, GSList *mode_group) } } +static GtkWidget * +get_radio_for_mode (GladeXML *dialog, const char *mode_str) +{ + if (!mode_str) + return WID ("none_radiobutton"); + else if (strcmp (mode_str, "none") == 0) + return WID ("none_radiobutton"); + else if (strcmp (mode_str, "manual") == 0) + return WID ("manual_radiobutton"); + else if (strcmp (mode_str, "auto") == 0) + return WID ("auto_radiobutton"); + else + return WID ("none_radiobutton"); +} + +static void +mode_set_initial_value (GladeXML *dialog, GConfClient *client) +{ + char *use_system_settings; + GConfValue *mode_value; + gboolean use_system_if_mode_not_set; + gboolean use_mode; + GtkWidget *radiobutton; + + radiobutton = NULL; + + use_system_settings = gconf_client_get_string (client, KEY_USE_SYSTEM_SETTINGS, NULL); + mode_value = gconf_client_get_without_default (client, PROXY_MODE_KEY, NULL); + + use_system_if_mode_not_set = FALSE; + use_mode = FALSE; + + if (!use_system_settings) + use_system_if_mode_not_set = TRUE; + else { + if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_ONLY_IF_NOT_SET) == 0) + use_system_if_mode_not_set = TRUE; + else if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_SYSTEM_VALUES) == 0) + radiobutton = WID ("system_radiobutton"); + else if (strcmp (use_system_settings, VAL_USE_SYSTEM_SETTINGS_USER_VALUES) == 0) + use_mode = TRUE; + + g_free (use_system_settings); + } + + if (use_system_if_mode_not_set) { + if (mode_value) + use_mode = TRUE; + else + radiobutton = WID ("system_radiobutton"); + } + + if (use_mode) { + if (!mode_value || mode_value->type != GCONF_VALUE_STRING) + radiobutton = WID ("none_radiobutton"); + else + radiobutton = get_radio_for_mode (dialog, gconf_value_get_string (mode_value)); + } + + if (radiobutton) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton), TRUE); + set_sensitivity_based_on_active_radiobutton (dialog, radiobutton); + } + + if (mode_value) + gconf_value_free (mode_value); +} + static void setup_dialog (GladeXML *dialog) { GConfPropertyEditor *peditor; GSList *mode_group; - GType mode_type = 0; GConfClient *client; gint port_value; GtkWidget *location_box; GtkCellRenderer *location_renderer; GtkListStore *store; - mode_type = g_enum_register_static ("NetworkPreferencesProxyType", - proxytype_values); /* There's a bug in peditors that cause them to not initialize the entry * correctly. */ @@ -1100,17 +1179,16 @@ setup_dialog (GladeXML *dialog) "style", COL_STYLE, NULL); /* Hackety hack */ + gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("system_radiobutton"))->child), TRUE); gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("none_radiobutton"))->child), TRUE); gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("manual_radiobutton"))->child), TRUE); gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (WID ("auto_radiobutton"))->child), TRUE); /* Mode */ - mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("none_radiobutton"))); - connect_sensitivity_signals (dialog, mode_group); + mode_set_initial_value (dialog, client); + mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("system_radiobutton"))); + connect_mode_radiobuttons (dialog, mode_group); - peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_select_radio_with_enum (NULL, - PROXY_MODE_KEY, mode_group, mode_type, - TRUE, NULL)); /* Use same proxy for all protocols */ peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_boolean (NULL, diff --git a/capplets/network/gnome-network-properties.glade b/capplets/network/gnome-network-properties.glade index 656acb5..1147f17 100644 --- a/capplets/network/gnome-network-properties.glade +++ b/capplets/network/gnome-network-properties.glade @@ -130,6 +130,25 @@ <property name="spacing">18</property> <child> + <widget class="GtkRadioButton" id="system_radiobutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes"><b>Use the s_ystem's proxy settings</b></property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkRadioButton" id="none_radiobutton"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -140,6 +159,7 @@ <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> + <property name="group">system_radiobutton</property> </widget> <packing> <property name="padding">0</property> @@ -171,7 +191,7 @@ <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> - <property name="group">none_radiobutton</property> + <property name="group">system_radiobutton</property> </widget> <packing> <property name="padding">0</property> @@ -714,7 +734,7 @@ <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> - <property name="group">none_radiobutton</property> + <property name="group">system_radiobutton</property> </widget> <packing> <property name="padding">0</property> -- 1.6.0.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor