Implement 'Proxy type' preference which can be Auto, HTTP or None

This commit is contained in:
Christian Dywan 2010-04-02 20:41:39 +02:00
parent 476f64e9bc
commit e886293ebf
4 changed files with 87 additions and 26 deletions

View file

@ -759,10 +759,10 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
SoupSession* session)
{
gboolean auto_detect_proxy;
MidoriProxy proxy_type;
auto_detect_proxy = katze_object_get_boolean (settings, "auto-detect-proxy");
if (auto_detect_proxy)
proxy_type = katze_object_get_enum (settings, "proxy-type");
if (proxy_type == MIDORI_PROXY_AUTOMATIC)
{
gboolean gnome_supported = FALSE;
GModule* module;
@ -780,12 +780,14 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
if (!gnome_supported)
midori_soup_session_set_proxy_uri (session, g_getenv ("http_proxy"));
}
else
else if (proxy_type == MIDORI_PROXY_HTTP)
{
gchar* http_proxy = katze_object_get_string (settings, "http-proxy");
midori_soup_session_set_proxy_uri (session, http_proxy);
g_free (http_proxy);
}
else
midori_soup_session_set_proxy_uri (session, NULL);
}
#if !WEBKIT_CHECK_VERSION (1, 1, 11)

View file

@ -183,14 +183,13 @@ midori_preferences_homepage_current_clicked_cb (GtkWidget* button,
#if !HAVE_HILDON
static void
midori_preferences_notify_auto_detect_proxy_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
GtkWidget* entry)
midori_preferences_notify_proxy_type_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
GtkWidget* entry)
{
MidoriIdentity auto_detect_proxy = katze_object_get_enum (settings,
"auto-detect-proxy");
MidoriProxy proxy_type = katze_object_get_enum (settings, "proxy-type");
gtk_widget_set_sensitive (entry, !auto_detect_proxy);
gtk_widget_set_sensitive (entry, proxy_type == MIDORI_PROXY_HTTP);
}
#endif
@ -486,16 +485,17 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
PAGE_NEW (GTK_STOCK_NETWORK, _("Network"));
FRAME_NEW (_("Network"));
#if !HAVE_HILDON
label = katze_property_label (settings, "http-proxy");
label = katze_property_label (settings, "proxy-type");
INDENTED_ADD (label);
button = katze_property_proxy (settings, "proxy-type", NULL);
SPANNED_ADD (button);
label = gtk_label_new (_("Hostname"));
INDENTED_ADD (label);
entry = katze_property_proxy (settings, "http-proxy", NULL);
SPANNED_ADD (entry);
INDENTED_ADD (gtk_event_box_new ());
button = katze_property_proxy (settings, "auto-detect-proxy", NULL);
SPANNED_ADD (button);
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);
g_signal_connect (settings, "notify::proxy-type",
G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry);
midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
#endif
label = katze_property_label (settings, "identify-as");
INDENTED_ADD (label);

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -85,6 +85,7 @@ struct _MidoriWebSettings
gint maximum_history_age;
gboolean remember_last_downloaded_files;
MidoriProxy proxy_type;
gchar* http_proxy;
gchar* http_accept_language;
gboolean auto_detect_proxy;
@ -170,6 +171,7 @@ enum
PROP_MAXIMUM_HISTORY_AGE,
PROP_REMEMBER_LAST_DOWNLOADED_FILES,
PROP_PROXY_TYPE,
PROP_HTTP_PROXY,
PROP_AUTO_DETECT_PROXY,
PROP_IDENTIFY_AS,
@ -272,6 +274,23 @@ midori_toolbar_style_get_type (void)
return type;
}
GType
midori_proxy_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_PROXY_AUTOMATIC, "MIDORI_PROXY_AUTOMATIC", N_("Automatic (GNOME or environment)") },
{ MIDORI_PROXY_HTTP, "MIDORI_PROXY_HTTP", N_("HTTP proxy server") },
{ MIDORI_PROXY_NONE, "MIDORI_PROXY_NONE", N_("No proxy server") },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriProxy", values);
}
return type;
}
GType
midori_accept_cookies_get_type (void)
{
@ -1019,22 +1038,39 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
/**
* MidoriWebSettings:proxy-type:
*
* The type of proxy server to use.
*
* Since: 0.2.5
*/
g_object_class_install_property (gobject_class,
PROP_PROXY_TYPE,
g_param_spec_enum (
"proxy-type",
_("Proxy server"),
_("The type of proxy server to use"),
MIDORI_TYPE_PROXY,
MIDORI_PROXY_AUTOMATIC,
flags));
g_object_class_install_property (gobject_class,
PROP_HTTP_PROXY,
g_param_spec_string (
"http-proxy",
_("Proxy Server"),
_("HTTP Proxy Server"),
_("The proxy server used for HTTP connections"),
NULL,
flags));
/**
* MidoriWebSettings:auto-detect-proxy:
*
* Whether to detect the proxy server automatically from the environment
*
* Since: 0.1.3
*/
* MidoriWebSettings:auto-detect-proxy:
*
* Whether to detect the proxy server automatically from the environment
*
* Deprecated: 0.2.5
*/
g_object_class_install_property (gobject_class,
PROP_AUTO_DETECT_PROXY,
g_param_spec_boolean (
@ -1491,6 +1527,13 @@ midori_web_settings_set_property (GObject* object,
web_settings->remember_last_downloaded_files = g_value_get_boolean (value);
break;
case PROP_PROXY_TYPE:
web_settings->proxy_type = g_value_get_enum (value);
web_settings->auto_detect_proxy =
web_settings->proxy_type == MIDORI_PROXY_AUTOMATIC
? TRUE : FALSE;
g_object_notify (object, "auto-detect-proxy");
break;
case PROP_HTTP_PROXY:
katze_assign (web_settings->http_proxy, g_value_dup_string (value));
break;
@ -1735,6 +1778,9 @@ midori_web_settings_get_property (GObject* object,
g_value_set_boolean (value, web_settings->remember_last_downloaded_files);
break;
case PROP_PROXY_TYPE:
g_value_set_enum (value, web_settings->proxy_type);
break;
case PROP_HTTP_PROXY:
g_value_set_string (value, web_settings->http_proxy);
break;

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -119,6 +119,19 @@ midori_toolbar_style_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_TOOLBAR_STYLE \
(midori_toolbar_style_get_type ())
typedef enum
{
MIDORI_PROXY_AUTOMATIC,
MIDORI_PROXY_HTTP,
MIDORI_PROXY_NONE
} MidoriProxy;
GType
midori_proxy_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_PROXY \
(midori_proxy_get_type ())
typedef enum
{
MIDORI_ACCEPT_COOKIES_ALL,