~ubuntu-branches/ubuntu/trusty/unity-control-center/trusty

« back to all changes in this revision

Viewing changes to panels/network/net-proxy.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-01-08 16:29:18 UTC
  • Revision ID: package-import@ubuntu.com-20140108162918-g29dd08tr913y2qh
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 *
 
3
 * Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
 
4
 *
 
5
 * Licensed under the GNU General Public License Version 2
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include <glib-object.h>
 
25
#include <glib/gi18n.h>
 
26
#include <gio/gio.h>
 
27
 
 
28
#include <grp.h>
 
29
#include <unistd.h>
 
30
#include <gdesktop-enums.h>
 
31
 
 
32
#include "net-proxy.h"
 
33
 
 
34
 
 
35
 
 
36
#define NET_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_PROXY, NetProxyPrivate))
 
37
 
 
38
struct _NetProxyPrivate
 
39
{
 
40
        GSettings        *settings;
 
41
        GtkBuilder       *builder;
 
42
};
 
43
 
 
44
G_DEFINE_TYPE (NetProxy, net_proxy, NET_TYPE_OBJECT)
 
45
 
 
46
static void
 
47
check_wpad_warning (NetProxy *proxy)
 
48
{
 
49
        GtkWidget *widget;
 
50
        gchar *autoconfig_url = NULL;
 
51
        GString *string = NULL;
 
52
        gboolean ret = FALSE;
 
53
        guint mode;
 
54
 
 
55
        string = g_string_new ("");
 
56
 
 
57
        /* check we're using 'Automatic' */
 
58
        mode = g_settings_get_enum (proxy->priv->settings, "mode");
 
59
        if (mode != 2)
 
60
                goto out;
 
61
 
 
62
        /* see if the PAC is blank */
 
63
        autoconfig_url = g_settings_get_string (proxy->priv->settings,
 
64
                                                "autoconfig-url");
 
65
        ret = autoconfig_url == NULL ||
 
66
              autoconfig_url[0] == '\0';
 
67
        if (!ret)
 
68
                goto out;
 
69
 
 
70
        g_string_append (string, "<small>");
 
71
 
 
72
        /* TRANSLATORS: this is when the use leaves the PAC textbox blank */
 
73
        g_string_append (string, _("Web Proxy Autodiscovery is used when a Configuration URL is not provided."));
 
74
 
 
75
        g_string_append (string, "\n");
 
76
 
 
77
        /* TRANSLATORS: WPAD is bad: if you enable it on an untrusted
 
78
         * network, then anyone else on that network can tell your
 
79
         * machine that it should proxy all of your web traffic
 
80
         * through them. */
 
81
        g_string_append (string, _("This is not recommended for untrusted public networks."));
 
82
        g_string_append (string, "</small>");
 
83
out:
 
84
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
85
                                                     "label_proxy_warning"));
 
86
        gtk_label_set_markup (GTK_LABEL (widget), string->str);
 
87
        g_free (autoconfig_url);
 
88
        g_string_free (string, TRUE);
 
89
}
 
90
 
 
91
static void
 
92
settings_changed_cb (GSettings *settings,
 
93
                     const gchar *key,
 
94
                     NetProxy *proxy)
 
95
{
 
96
        check_wpad_warning (proxy);
 
97
}
 
98
 
 
99
static void
 
100
panel_proxy_mode_combo_setup_widgets (NetProxy *proxy, guint value)
 
101
{
 
102
        GtkWidget *widget;
 
103
 
 
104
        /* hide or show the PAC text box */
 
105
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
106
                                                     "heading_proxy_url"));
 
107
        gtk_widget_set_visible (widget, value == 2);
 
108
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
109
                                                     "entry_proxy_url"));
 
110
        gtk_widget_set_visible (widget, value == 2);
 
111
 
 
112
        /* hide or show the manual entry text boxes */
 
113
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
114
                                                     "heading_proxy_http"));
 
115
        gtk_widget_set_visible (widget, value == 1);
 
116
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
117
                                                     "entry_proxy_http"));
 
118
        gtk_widget_set_visible (widget, value == 1);
 
119
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
120
                                                     "spinbutton_proxy_http"));
 
121
        gtk_widget_set_visible (widget, value == 1);
 
122
 
 
123
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
124
                                                     "heading_proxy_https"));
 
125
        gtk_widget_set_visible (widget, value == 1);
 
126
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
127
                                                     "entry_proxy_https"));
 
128
        gtk_widget_set_visible (widget, value == 1);
 
129
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
130
                                                     "spinbutton_proxy_https"));
 
131
        gtk_widget_set_visible (widget, value == 1);
 
132
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
133
                                                     "heading_proxy_ftp"));
 
134
        gtk_widget_set_visible (widget, value == 1);
 
135
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
136
                                                     "entry_proxy_ftp"));
 
137
        gtk_widget_set_visible (widget, value == 1);
 
138
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
139
                                                     "spinbutton_proxy_ftp"));
 
140
        gtk_widget_set_visible (widget, value == 1);
 
141
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
142
                                                     "heading_proxy_socks"));
 
143
        gtk_widget_set_visible (widget, value == 1);
 
144
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
145
                                                     "entry_proxy_socks"));
 
146
        gtk_widget_set_visible (widget, value == 1);
 
147
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
148
                                                     "spinbutton_proxy_socks"));
 
149
        gtk_widget_set_visible (widget, value == 1);
 
150
 
 
151
        /* perhaps show the wpad warning */
 
152
        check_wpad_warning (proxy);
 
153
}
 
154
 
 
155
static void
 
156
panel_set_value_for_combo (NetProxy *proxy, GtkComboBox *combo_box, gint value)
 
157
{
 
158
        gboolean ret;
 
159
        gint value_tmp;
 
160
        GtkTreeIter iter;
 
161
        GtkTreeModel *model;
 
162
 
 
163
        /* get entry */
 
164
        model = gtk_combo_box_get_model (combo_box);
 
165
        ret = gtk_tree_model_get_iter_first (model, &iter);
 
166
        if (!ret)
 
167
                return;
 
168
 
 
169
        /* try to make the UI match the setting */
 
170
        do {
 
171
                gtk_tree_model_get (model, &iter,
 
172
                                    1, &value_tmp,
 
173
                                    -1);
 
174
                if (value == value_tmp) {
 
175
                        gtk_combo_box_set_active_iter (combo_box, &iter);
 
176
                        break;
 
177
                }
 
178
        } while (gtk_tree_model_iter_next (model, &iter));
 
179
 
 
180
        /* hide or show the correct widgets */
 
181
        panel_proxy_mode_combo_setup_widgets (proxy, value);
 
182
}
 
183
 
 
184
static void
 
185
panel_proxy_mode_combo_changed_cb (GtkWidget *widget, NetProxy *proxy)
 
186
{
 
187
        gboolean ret;
 
188
        gint value;
 
189
        GtkTreeIter iter;
 
190
        GtkTreeModel *model;
 
191
 
 
192
        /* no selection */
 
193
        ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
 
194
        if (!ret)
 
195
                return;
 
196
 
 
197
        /* get entry */
 
198
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
 
199
        gtk_tree_model_get (model, &iter,
 
200
                            1, &value,
 
201
                            -1);
 
202
 
 
203
        /* set */
 
204
        g_settings_set_enum (proxy->priv->settings, "mode", value);
 
205
 
 
206
        /* hide or show the correct widgets */
 
207
        panel_proxy_mode_combo_setup_widgets (proxy, value);
 
208
}
 
209
 
 
210
static GtkWidget *
 
211
net_proxy_add_to_notebook (NetObject *object,
 
212
                           GtkNotebook *notebook,
 
213
                           GtkSizeGroup *heading_size_group)
 
214
{
 
215
        GtkWidget *widget;
 
216
        GtkWindow *window;
 
217
        NetProxy *proxy = NET_PROXY (object);
 
218
 
 
219
        /* add widgets to size group */
 
220
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
221
                                                     "heading_proxy_method"));
 
222
        gtk_size_group_add_widget (heading_size_group, widget);
 
223
 
 
224
        /* reparent */
 
225
        window = GTK_WINDOW (gtk_builder_get_object (proxy->priv->builder,
 
226
                                                     "window_tmp"));
 
227
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
228
                                                     "grid5"));
 
229
        g_object_ref (widget);
 
230
        gtk_container_remove (GTK_CONTAINER (window), widget);
 
231
        gtk_notebook_append_page (notebook, widget, NULL);
 
232
        g_object_unref (widget);
 
233
        return widget;
 
234
}
 
235
 
 
236
static void
 
237
net_proxy_finalize (GObject *object)
 
238
{
 
239
        NetProxy *proxy = NET_PROXY (object);
 
240
        NetProxyPrivate *priv = proxy->priv;
 
241
 
 
242
        g_clear_object (&priv->settings);
 
243
        g_clear_object (&priv->builder);
 
244
 
 
245
        G_OBJECT_CLASS (net_proxy_parent_class)->finalize (object);
 
246
}
 
247
 
 
248
static void
 
249
net_proxy_class_init (NetProxyClass *klass)
 
250
{
 
251
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
252
        NetObjectClass *parent_class = NET_OBJECT_CLASS (klass);
 
253
 
 
254
        object_class->finalize = net_proxy_finalize;
 
255
        parent_class->add_to_notebook = net_proxy_add_to_notebook;
 
256
        g_type_class_add_private (klass, sizeof (NetProxyPrivate));
 
257
}
 
258
 
 
259
 
 
260
static gboolean
 
261
ubuntu_is_in_admin_group (int id_group)
 
262
{
 
263
        gid_t groups [1024];
 
264
       int i, ngroups;
 
265
 
 
266
        ngroups = getgroups (1024, groups);
 
267
        if (ngroups < 0) {
 
268
                perror ("getgroups");
 
269
                return FALSE;
 
270
        }
 
271
 
 
272
        for (i = 0; i < ngroups; ++i) {
 
273
                if (groups[i] == id_group)
 
274
                        return TRUE;
 
275
        }
 
276
 
 
277
        return FALSE;
 
278
}
 
279
 
 
280
static gboolean
 
281
ubuntu_is_admin ()
 
282
{
 
283
        struct group *admin_group;
 
284
 
 
285
        admin_group = getgrnam ("admin");
 
286
        if (admin_group != NULL && ubuntu_is_in_admin_group (admin_group->gr_gid))
 
287
                return TRUE;
 
288
 
 
289
        admin_group = getgrnam ("sudo");
 
290
        if (admin_group != NULL && ubuntu_is_in_admin_group (admin_group->gr_gid))
 
291
                return TRUE;
 
292
 
 
293
        return FALSE;
 
294
}
 
295
 
 
296
static void
 
297
ubuntu_reset_system_proxy (GDBusProxy *proxy, const gchar *protocol)
 
298
{
 
299
        GVariant *result;
 
300
        GError *error = NULL;
 
301
 
 
302
        result = g_dbus_proxy_call_sync (proxy, "set_proxy",
 
303
                                         g_variant_new ("(ss)", protocol, ""),
 
304
                                         G_DBUS_CALL_FLAGS_NONE,
 
305
                                         -1, NULL, &error);
 
306
        if (result)
 
307
                g_variant_unref (result);
 
308
        else {
 
309
                g_warning ("Error while calling set_proxy for %s protocol: %s", protocol, error->message);
 
310
                g_error_free (error);
 
311
        }
 
312
}
 
313
 
 
314
static void
 
315
ubuntu_set_proxy_for_protocol (GDBusProxy *proxy, const gchar *protocol, GSettings *settings)
 
316
{
 
317
        GVariant *result;
 
318
        gchar *proxy_str, *host;
 
319
        GError *error = NULL;
 
320
        gint port;
 
321
 
 
322
        host = g_settings_get_string (settings, "host");
 
323
        port = g_settings_get_int (settings, "port");
 
324
 
 
325
        if (host && *host == '\0') {
 
326
                ubuntu_reset_system_proxy (proxy, protocol);
 
327
        } else {
 
328
                proxy_str = g_strdup_printf ("%s://%s:%i/", protocol, host, port);
 
329
 
 
330
                result = g_dbus_proxy_call_sync (proxy, "set_proxy",
 
331
                                                 g_variant_new ("(ss)", protocol, proxy_str),
 
332
                                                 G_DBUS_CALL_FLAGS_NONE,
 
333
                                                 -1, NULL, &error);
 
334
                if (result)
 
335
                        g_variant_unref (result);
 
336
                else {
 
337
                        g_warning ("Error while calling set_proxy for %s protocol: %s", protocol, error->message);
 
338
                        g_error_free (error);
 
339
                }
 
340
                g_free (proxy_str);
 
341
        }
 
342
 
 
343
        /* Free memory */
 
344
        g_free (host);
 
345
        g_object_unref (settings);
 
346
}
 
347
 
 
348
static void
 
349
ubuntu_on_proxy_apply_system_settings (GtkButton *button, gpointer user_data)
 
350
{
 
351
        GDBusConnection *bus;
 
352
        GDBusProxy *dbus_proxy;
 
353
        GError *error;
 
354
        GDesktopProxyMode proxy_mode;
 
355
        NetProxy *proxy = NET_PROXY (user_data);
 
356
 
 
357
        error = NULL;
 
358
        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
 
359
        if (!bus) {
 
360
                g_warning ("Could not retrieve system bus: %s", error->message);
 
361
                g_error_free (error);
 
362
 
 
363
                return;
 
364
        }
 
365
 
 
366
        dbus_proxy = g_dbus_proxy_new_sync (bus, 0, NULL,
 
367
                                       "com.ubuntu.SystemService",
 
368
                                       "/",
 
369
                                       "com.ubuntu.SystemService",
 
370
                                       NULL,
 
371
                                       &error);
 
372
        if (!dbus_proxy) {
 
373
                g_warning ("Could not retrieve bus object: %s", error->message);
 
374
                g_error_free (error);
 
375
 
 
376
                return;
 
377
        }
 
378
 
 
379
        /* Retrieve the current settings */
 
380
        proxy_mode = g_settings_get_enum (proxy->priv->settings, "mode");
 
381
        switch (proxy_mode) {
 
382
        case G_DESKTOP_PROXY_MODE_AUTO:
 
383
        case G_DESKTOP_PROXY_MODE_NONE:
 
384
                ubuntu_reset_system_proxy (dbus_proxy, "http");
 
385
                ubuntu_reset_system_proxy (dbus_proxy, "https");
 
386
                ubuntu_reset_system_proxy (dbus_proxy, "ftp");
 
387
                ubuntu_reset_system_proxy (dbus_proxy, "socks");
 
388
                break;
 
389
        case G_DESKTOP_PROXY_MODE_MANUAL:
 
390
                ubuntu_set_proxy_for_protocol (dbus_proxy, "http", g_settings_get_child (proxy->priv->settings, "http"));
 
391
                ubuntu_set_proxy_for_protocol (dbus_proxy, "https", g_settings_get_child (proxy->priv->settings, "https"));
 
392
                ubuntu_set_proxy_for_protocol (dbus_proxy, "ftp", g_settings_get_child (proxy->priv->settings, "ftp"));
 
393
                ubuntu_set_proxy_for_protocol (dbus_proxy, "socks", g_settings_get_child (proxy->priv->settings, "socks"));
 
394
                break;
 
395
        }
 
396
 
 
397
        /* Free memory */
 
398
        g_object_unref (dbus_proxy);
 
399
}
 
400
 
 
401
static void
 
402
net_proxy_init (NetProxy *proxy)
 
403
{
 
404
        GError *error = NULL;
 
405
        gint value;
 
406
        GSettings *settings_tmp;
 
407
        GtkAdjustment *adjustment;
 
408
        GtkWidget *widget;
 
409
 
 
410
        proxy->priv = NET_PROXY_GET_PRIVATE (proxy);
 
411
 
 
412
        proxy->priv->builder = gtk_builder_new ();
 
413
        gtk_builder_add_from_file (proxy->priv->builder,
 
414
                                   GNOMECC_UI_DIR "/network-proxy.ui",
 
415
                                   &error);
 
416
        if (error != NULL) {
 
417
                g_warning ("Could not load interface file: %s", error->message);
 
418
                g_error_free (error);
 
419
                return;
 
420
        }
 
421
 
 
422
        proxy->priv->settings = g_settings_new ("org.gnome.system.proxy");
 
423
        g_signal_connect (proxy->priv->settings,
 
424
                          "changed",
 
425
                          G_CALLBACK (settings_changed_cb),
 
426
                          proxy);
 
427
 
 
428
        /* explicitly set this to false as the panel has no way of
 
429
         * linking the http and https proxies them together */
 
430
        g_settings_set_boolean (proxy->priv->settings,
 
431
                                "use-same-proxy",
 
432
                                FALSE);
 
433
 
 
434
        /* actions */
 
435
        value = g_settings_get_enum (proxy->priv->settings, "mode");
 
436
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
437
                                                     "combobox_proxy_mode"));
 
438
        panel_set_value_for_combo (proxy, GTK_COMBO_BOX (widget), value);
 
439
        g_signal_connect (widget, "changed",
 
440
                          G_CALLBACK (panel_proxy_mode_combo_changed_cb),
 
441
                          proxy);
 
442
 
 
443
        /* bind the proxy values */
 
444
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
445
                                                     "entry_proxy_url"));
 
446
        g_settings_bind (proxy->priv->settings, "autoconfig-url",
 
447
                         widget, "text",
 
448
                         G_SETTINGS_BIND_DEFAULT);
 
449
 
 
450
        /* bind the HTTP proxy values */
 
451
        settings_tmp = g_settings_get_child (proxy->priv->settings, "http");
 
452
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
453
                                                     "entry_proxy_http"));
 
454
        g_settings_bind (settings_tmp, "host",
 
455
                         widget, "text",
 
456
                         G_SETTINGS_BIND_DEFAULT);
 
457
        adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->priv->builder,
 
458
                                                             "adjustment_proxy_port_http"));
 
459
        g_settings_bind (settings_tmp, "port",
 
460
                         adjustment, "value",
 
461
                         G_SETTINGS_BIND_DEFAULT);
 
462
        g_object_unref (settings_tmp);
 
463
 
 
464
        /* bind the HTTPS proxy values */
 
465
        settings_tmp = g_settings_get_child (proxy->priv->settings, "https");
 
466
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
467
                                                     "entry_proxy_https"));
 
468
        g_settings_bind (settings_tmp, "host",
 
469
                         widget, "text",
 
470
                         G_SETTINGS_BIND_DEFAULT);
 
471
        adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->priv->builder,
 
472
                                                             "adjustment_proxy_port_https"));
 
473
        g_settings_bind (settings_tmp, "port",
 
474
                         adjustment, "value",
 
475
                         G_SETTINGS_BIND_DEFAULT);
 
476
        g_object_unref (settings_tmp);
 
477
 
 
478
        /* bind the FTP proxy values */
 
479
        settings_tmp = g_settings_get_child (proxy->priv->settings, "ftp");
 
480
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
481
                                                     "entry_proxy_ftp"));
 
482
        g_settings_bind (settings_tmp, "host",
 
483
                         widget, "text",
 
484
                         G_SETTINGS_BIND_DEFAULT);
 
485
        adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->priv->builder,
 
486
                                                             "adjustment_proxy_port_ftp"));
 
487
        g_settings_bind (settings_tmp, "port",
 
488
                         adjustment, "value",
 
489
                         G_SETTINGS_BIND_DEFAULT);
 
490
        g_object_unref (settings_tmp);
 
491
 
 
492
        /* bind the SOCKS proxy values */
 
493
        settings_tmp = g_settings_get_child (proxy->priv->settings, "socks");
 
494
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
495
                                                     "entry_proxy_socks"));
 
496
        g_settings_bind (settings_tmp, "host",
 
497
                         widget, "text",
 
498
                         G_SETTINGS_BIND_DEFAULT);
 
499
        adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->priv->builder,
 
500
                                                             "adjustment_proxy_port_socks"));
 
501
        g_settings_bind (settings_tmp, "port",
 
502
                         adjustment, "value",
 
503
                         G_SETTINGS_BIND_DEFAULT);
 
504
        g_object_unref (settings_tmp);
 
505
 
 
506
        /* set header to something sane */
 
507
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
508
                                                     "image_proxy_device"));
 
509
        gtk_image_set_from_icon_name (GTK_IMAGE (widget),
 
510
                                      "preferences-system-network",
 
511
                                      GTK_ICON_SIZE_DIALOG);
 
512
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
513
                                                     "label_proxy_device"));
 
514
        gtk_label_set_label (GTK_LABEL (widget),
 
515
                             _("Proxy"));
 
516
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
517
                                                     "label_proxy_status"));
 
518
        gtk_label_set_label (GTK_LABEL (widget), "");
 
519
 
 
520
        /* Ubuntu button for system proxy settings */
 
521
        if (ubuntu_is_admin ()) {
 
522
                g_signal_connect (G_OBJECT (gtk_builder_get_object (proxy->priv->builder, "system_proxy_button")), "clicked",
 
523
                                  G_CALLBACK (ubuntu_on_proxy_apply_system_settings), proxy);
 
524
        } else
 
525
                gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder, "system_proxy_button")));
 
526
 
 
527
        /* hide the switch until we get some more detail in the mockup */
 
528
        widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
 
529
                                                     "device_proxy_off_switch"));
 
530
        if (widget != NULL)
 
531
                gtk_widget_hide (widget);
 
532
}
 
533
 
 
534
NetProxy *
 
535
net_proxy_new (void)
 
536
{
 
537
        NetProxy *proxy;
 
538
        proxy = g_object_new (NET_TYPE_PROXY,
 
539
                              "removable", FALSE,
 
540
                              "id", "proxy",
 
541
                              NULL);
 
542
        return NET_PROXY (proxy);
 
543
}