Index: gnome-control-center-3.6.3/panels/network/net-proxy.c
===================================================================
--- gnome-control-center-3.6.3.orig/panels/network/net-proxy.c	2013-04-16 16:14:41.159226157 +0200
+++ gnome-control-center-3.6.3/panels/network/net-proxy.c	2013-04-16 16:14:59.847226780 +0200
@@ -25,8 +25,14 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 
+#include <grp.h>
+#include <unistd.h>
+#include <gdesktop-enums.h>
+
 #include "net-proxy.h"
 
+
+
 #define NET_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_PROXY, NetProxyPrivate))
 
 struct _NetProxyPrivate
@@ -250,6 +256,148 @@
         g_type_class_add_private (klass, sizeof (NetProxyPrivate));
 }
 
+
+static gboolean
+ubuntu_is_in_admin_group (int id_group)
+{
+        gid_t groups [1024];
+       int i, ngroups;
+
+        ngroups = getgroups (1024, groups);
+        if (ngroups < 0) {
+                perror ("getgroups");
+                return FALSE;
+        }
+
+        for (i = 0; i < ngroups; ++i) {
+                if (groups[i] == id_group)
+                        return TRUE;
+        }
+
+        return FALSE;
+}
+
+static gboolean
+ubuntu_is_admin ()
+{
+        struct group *admin_group;
+
+        admin_group = getgrnam ("admin");
+        if (admin_group != NULL && ubuntu_is_in_admin_group (admin_group->gr_gid))
+                return TRUE;
+
+        admin_group = getgrnam ("sudo");
+        if (admin_group != NULL && ubuntu_is_in_admin_group (admin_group->gr_gid))
+                return TRUE;
+
+        return FALSE;
+}
+
+static void
+ubuntu_reset_system_proxy (GDBusProxy *proxy, const gchar *protocol)
+{
+        GVariant *result;
+        GError *error = NULL;
+
+        result = g_dbus_proxy_call_sync (proxy, "set_proxy",
+                                         g_variant_new ("(ss)", protocol, ""),
+                                         G_DBUS_CALL_FLAGS_NONE,
+                                         -1, NULL, &error);
+        if (result)
+                g_variant_unref (result);
+        else {
+                g_warning ("Error while calling set_proxy for %s protocol: %s", protocol, error->message);
+                g_error_free (error);
+        }
+}
+
+static void
+ubuntu_set_proxy_for_protocol (GDBusProxy *proxy, const gchar *protocol, GSettings *settings)
+{
+        GVariant *result;
+        gchar *proxy_str, *host;
+        GError *error = NULL;
+        gint port;
+
+        host = g_settings_get_string (settings, "host");
+        port = g_settings_get_int (settings, "port");
+
+        if (host && *host == '\0') {
+                ubuntu_reset_system_proxy (proxy, protocol);
+        } else {
+                proxy_str = g_strdup_printf ("%s://%s:%i/", protocol, host, port);
+
+                result = g_dbus_proxy_call_sync (proxy, "set_proxy",
+                                                 g_variant_new ("(ss)", protocol, proxy_str),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1, NULL, &error);
+                if (result)
+                        g_variant_unref (result);
+                else {
+                        g_warning ("Error while calling set_proxy for %s protocol: %s", protocol, error->message);
+                        g_error_free (error);
+                }
+                g_free (proxy_str);
+        }
+
+        /* Free memory */
+        g_free (host);
+        g_object_unref (settings);
+}
+
+static void
+ubuntu_on_proxy_apply_system_settings (GtkButton *button, gpointer user_data)
+{
+        GDBusConnection *bus;
+        GDBusProxy *dbus_proxy;
+        GError *error;
+        GDesktopProxyMode proxy_mode;
+        NetProxy *proxy = NET_PROXY (user_data);
+
+        error = NULL;
+        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+        if (!bus) {
+                g_warning ("Could not retrieve system bus: %s", error->message);
+                g_error_free (error);
+
+                return;
+        }
+
+        dbus_proxy = g_dbus_proxy_new_sync (bus, 0, NULL,
+                                       "com.ubuntu.SystemService",
+                                       "/",
+                                       "com.ubuntu.SystemService",
+                                       NULL,
+                                       &error);
+        if (!dbus_proxy) {
+                g_warning ("Could not retrieve bus object: %s", error->message);
+                g_error_free (error);
+
+                return;
+        }
+
+        /* Retrieve the current settings */
+        proxy_mode = g_settings_get_enum (proxy->priv->settings, "mode");
+        switch (proxy_mode) {
+        case G_DESKTOP_PROXY_MODE_AUTO:
+        case G_DESKTOP_PROXY_MODE_NONE:
+                ubuntu_reset_system_proxy (dbus_proxy, "http");
+                ubuntu_reset_system_proxy (dbus_proxy, "https");
+                ubuntu_reset_system_proxy (dbus_proxy, "ftp");
+                ubuntu_reset_system_proxy (dbus_proxy, "socks");
+                break;
+        case G_DESKTOP_PROXY_MODE_MANUAL:
+                ubuntu_set_proxy_for_protocol (dbus_proxy, "http", g_settings_get_child (proxy->priv->settings, "http"));
+                ubuntu_set_proxy_for_protocol (dbus_proxy, "https", g_settings_get_child (proxy->priv->settings, "https"));
+                ubuntu_set_proxy_for_protocol (dbus_proxy, "ftp", g_settings_get_child (proxy->priv->settings, "ftp"));
+                ubuntu_set_proxy_for_protocol (dbus_proxy, "socks", g_settings_get_child (proxy->priv->settings, "socks"));
+                break;
+        }
+
+        /* Free memory */
+        g_object_unref (dbus_proxy);
+}
+
 static void
 net_proxy_init (NetProxy *proxy)
 {
@@ -369,6 +517,13 @@
                                                      "label_proxy_status"));
         gtk_label_set_label (GTK_LABEL (widget), "");
 
+        /* Ubuntu button for system proxy settings */
+        if (ubuntu_is_admin ()) {
+                g_signal_connect (G_OBJECT (gtk_builder_get_object (proxy->priv->builder, "system_proxy_button")), "clicked",
+                                  G_CALLBACK (ubuntu_on_proxy_apply_system_settings), proxy);
+        } else
+                gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder, "system_proxy_button")));
+
         /* hide the switch until we get some more detail in the mockup */
         widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
                                                      "device_proxy_off_switch"));
Index: gnome-control-center-3.6.3/panels/network/network-proxy.ui
===================================================================
--- gnome-control-center-3.6.3.orig/panels/network/network-proxy.ui	2013-04-16 16:14:41.159226157 +0200
+++ gnome-control-center-3.6.3/panels/network/network-proxy.ui	2013-04-16 16:14:41.155226157 +0200
@@ -280,6 +280,21 @@
           </packing>
         </child>
         <child>
+          <object class="GtkButton" id="system_proxy_button">
+            <property name="label" translatable="yes">Apply system wide</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_action_appearance">False</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">7</property>
+            <property name="width">3</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkLabel" id="label_proxy_warning">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -290,7 +305,7 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">7</property>
+            <property name="top_attach">8</property>
             <property name="width">3</property>
             <property name="height">1</property>
           </packing>
