[Xfce4-commits] <midori:master> Implement 'Proxy type' preference which can be Auto, HTTP or None

Christian Dywan noreply at xfce.org
Fri Apr 2 20:38:01 CEST 2010


Updating branch refs/heads/master
         to e886293ebfd77a4088feba91a28915ee12b320cd (commit)
       from 476f64e9bcfcdfdc04c28663ee25bde898ecb7a6 (commit)

commit e886293ebfd77a4088feba91a28915ee12b320cd
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Apr 2 20:41:39 2010 +0200

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

 midori/main.c               |   10 ++++---
 midori/midori-preferences.c |   26 +++++++++---------
 midori/midori-websettings.c |   62 +++++++++++++++++++++++++++++++++++++-----
 midori/midori-websettings.h |   15 +++++++++-
 4 files changed, 87 insertions(+), 26 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index 47a3ba3..42fa742 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -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)
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index f8820aa..80b207e 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -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);
diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c
index d07baa0..5bbb204 100644
--- a/midori/midori-websettings.c
+++ b/midori/midori-websettings.c
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2008-2009 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2008-2010 Christian Dywan <christian at 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,
@@ -273,6 +275,23 @@ midori_toolbar_style_get_type (void)
 }
 
 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)
 {
     static GType type = 0;
@@ -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;
diff --git a/midori/midori-websettings.h b/midori/midori-websettings.h
index ca9f3c9..05ad0f7 100644
--- a/midori/midori-websettings.h
+++ b/midori/midori-websettings.h
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2008 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2008-2010 Christian Dywan <christian at twotoasts.de>
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -121,6 +121,19 @@ midori_toolbar_style_get_type (void) G_GNUC_CONST;
 
 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,
     MIDORI_ACCEPT_COOKIES_SESSION,
     MIDORI_ACCEPT_COOKIES_NONE



More information about the Xfce4-commits mailing list