Add Detect proxy server automatically to Preferences
This commit is contained in:
parent
f1f27c9322
commit
0d73df50d2
3 changed files with 65 additions and 11 deletions
|
@ -1706,14 +1706,22 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
|
|||
GParamSpec* pspec,
|
||||
SoupSession* session)
|
||||
{
|
||||
gboolean auto_detect_proxy;
|
||||
gchar* http_proxy;
|
||||
SoupURI* proxy_uri;
|
||||
|
||||
http_proxy = katze_object_get_string (settings, "http-proxy");
|
||||
auto_detect_proxy = katze_object_get_boolean (settings, "auto-detect-proxy");
|
||||
if (auto_detect_proxy)
|
||||
http_proxy = g_strdup (g_getenv ("http_proxy"));
|
||||
else
|
||||
http_proxy = katze_object_get_string (settings, "http-proxy");
|
||||
g_debug (http_proxy);
|
||||
/* soup_uri_new expects a non-NULL string */
|
||||
proxy_uri = soup_uri_new (http_proxy ? http_proxy : "");
|
||||
g_free (http_proxy);
|
||||
g_object_set (session, "proxy-uri", proxy_uri, NULL);
|
||||
if (proxy_uri)
|
||||
soup_uri_free (proxy_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1748,6 +1756,8 @@ soup_session_constructed_cb (GObject* object)
|
|||
soup_session_settings_notify_ident_string_cb (settings, NULL, session);
|
||||
g_signal_connect (settings, "notify::http-proxy",
|
||||
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), object);
|
||||
g_signal_connect (settings, "notify::auto-detect-proxy",
|
||||
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), object);
|
||||
g_signal_connect (settings, "notify::ident-string",
|
||||
G_CALLBACK (soup_session_settings_notify_ident_string_cb), object);
|
||||
|
||||
|
|
|
@ -224,6 +224,17 @@ midori_preferences_notify_preferred_encoding_cb (MidoriWebSettings* settings,
|
|||
}
|
||||
|
||||
#if HAVE_LIBSOUP
|
||||
static void
|
||||
midori_preferences_notify_auto_detect_proxy_cb (MidoriWebSettings* settings,
|
||||
GParamSpec* pspec,
|
||||
GtkWidget* entry)
|
||||
{
|
||||
MidoriIdentity auto_detect_proxy = katze_object_get_enum (settings,
|
||||
"auto-detect-proxy");
|
||||
|
||||
gtk_widget_set_sensitive (entry, !auto_detect_proxy);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_preferences_notify_identify_as_cb (MidoriWebSettings* settings,
|
||||
GParamSpec* pspec,
|
||||
|
@ -543,30 +554,35 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
|
|||
{
|
||||
PAGE_NEW (GTK_STOCK_NETWORK, _("Network"));
|
||||
FRAME_NEW (_("Network"));
|
||||
TABLE_NEW (4, 2);
|
||||
TABLE_NEW (5, 2);
|
||||
label = katze_property_label (settings, "http-proxy");
|
||||
INDENTED_ADD (label, 0, 1, 0, 1);
|
||||
button = katze_property_proxy (settings, "http-proxy", NULL);
|
||||
FILLED_ADD (button, 1, 2, 0, 1);
|
||||
label = katze_property_label (settings, "identify-as");
|
||||
INDENTED_ADD (label, 0, 1, 1, 2);
|
||||
button = katze_property_proxy (settings, "identify-as", NULL);
|
||||
entry = katze_property_proxy (settings, "http-proxy", NULL);
|
||||
FILLED_ADD (entry, 1, 2, 0, 1);
|
||||
button = katze_property_proxy (settings, "auto-detect-proxy", NULL);
|
||||
FILLED_ADD (button, 1, 2, 1, 2);
|
||||
label = katze_property_label (settings, "ident-string");
|
||||
g_signal_connect (settings, "notify::auto-detect-proxy",
|
||||
G_CALLBACK (midori_preferences_notify_auto_detect_proxy_cb), entry);
|
||||
midori_preferences_notify_auto_detect_proxy_cb (settings, NULL, entry);
|
||||
label = katze_property_label (settings, "identify-as");
|
||||
INDENTED_ADD (label, 0, 1, 2, 3);
|
||||
button = katze_property_proxy (settings, "identify-as", NULL);
|
||||
FILLED_ADD (button, 1, 2, 2, 3);
|
||||
label = katze_property_label (settings, "ident-string");
|
||||
INDENTED_ADD (label, 0, 1, 3, 4);
|
||||
entry = katze_property_proxy (settings, "ident-string", NULL);
|
||||
g_signal_connect (settings, "notify::identify-as",
|
||||
G_CALLBACK (midori_preferences_notify_identify_as_cb), entry);
|
||||
midori_preferences_notify_identify_as_cb (settings, NULL, entry);
|
||||
FILLED_ADD (entry, 1, 2, 2, 3);
|
||||
FILLED_ADD (entry, 1, 2, 3, 4);
|
||||
label = katze_property_label (settings, "cache-size");
|
||||
INDENTED_ADD (label, 0, 1, 3, 4);
|
||||
INDENTED_ADD (label, 0, 1, 4, 5);
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
entry = katze_property_proxy (settings, "cache-size", NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("MB")),
|
||||
FALSE, FALSE, 0);
|
||||
FILLED_ADD (hbox, 1, 2, 3, 4);
|
||||
FILLED_ADD (hbox, 1, 2, 4, 5);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ struct _MidoriWebSettings
|
|||
gboolean remember_last_downloaded_files;
|
||||
|
||||
gchar* http_proxy;
|
||||
gboolean auto_detect_proxy;
|
||||
MidoriIdentity identify_as;
|
||||
gchar* ident_string;
|
||||
gint cache_size;
|
||||
|
@ -138,6 +139,7 @@ enum
|
|||
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
|
||||
|
||||
PROP_HTTP_PROXY,
|
||||
PROP_AUTO_DETECT_PROXY,
|
||||
PROP_IDENTIFY_AS,
|
||||
PROP_IDENT_STRING,
|
||||
PROP_CACHE_SIZE
|
||||
|
@ -763,6 +765,26 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MidoriWebSettings:auto-detect-proxy:
|
||||
*
|
||||
* Whether to detect the proxy server automatically from the environment
|
||||
*
|
||||
* Since: 0.1.3
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_AUTO_DETECT_PROXY,
|
||||
g_param_spec_boolean (
|
||||
"auto-detect-proxy",
|
||||
_("Detect proxy server automatically"),
|
||||
_("Whether to detect the proxy server automatically from the environment"),
|
||||
TRUE,
|
||||
#if HAVE_LIBSOUP
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
#else
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MidoriWebSettings:identify-as:
|
||||
*
|
||||
|
@ -1083,6 +1105,9 @@ midori_web_settings_set_property (GObject* object,
|
|||
case PROP_HTTP_PROXY:
|
||||
katze_assign (web_settings->http_proxy, g_value_dup_string (value));
|
||||
break;
|
||||
case PROP_AUTO_DETECT_PROXY:
|
||||
web_settings->auto_detect_proxy = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_IDENTIFY_AS:
|
||||
web_settings->identify_as = g_value_get_enum (value);
|
||||
if (web_settings->identify_as != MIDORI_IDENT_CUSTOM)
|
||||
|
@ -1250,6 +1275,9 @@ midori_web_settings_get_property (GObject* object,
|
|||
case PROP_HTTP_PROXY:
|
||||
g_value_set_string (value, web_settings->http_proxy);
|
||||
break;
|
||||
case PROP_AUTO_DETECT_PROXY:
|
||||
g_value_set_boolean (value, web_settings->auto_detect_proxy);
|
||||
break;
|
||||
case PROP_IDENTIFY_AS:
|
||||
g_value_set_enum (value, web_settings->identify_as);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue