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

« back to all changes in this revision

Viewing changes to panels/network/net-device-mobile.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
 
 
27
#include <nm-client.h>
 
28
#include <nm-device.h>
 
29
#include <nm-device-modem.h>
 
30
#include <nm-remote-connection.h>
 
31
 
 
32
#include "panel-common.h"
 
33
#include "network-dialogs.h"
 
34
 
 
35
#include "net-device-mobile.h"
 
36
 
 
37
#define NET_DEVICE_MOBILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NET_TYPE_DEVICE_MOBILE, NetDeviceMobilePrivate))
 
38
 
 
39
static void nm_device_mobile_refresh_ui (NetDeviceMobile *device_mobile);
 
40
 
 
41
struct _NetDeviceMobilePrivate
 
42
{
 
43
        GtkBuilder              *builder;
 
44
        gboolean                 updating_device;
 
45
};
 
46
 
 
47
enum {
 
48
        COLUMN_ID,
 
49
        COLUMN_TITLE,
 
50
        COLUMN_LAST
 
51
};
 
52
 
 
53
G_DEFINE_TYPE (NetDeviceMobile, net_device_mobile, NET_TYPE_DEVICE)
 
54
 
 
55
static GtkWidget *
 
56
device_mobile_proxy_add_to_notebook (NetObject *object,
 
57
                                     GtkNotebook *notebook,
 
58
                                     GtkSizeGroup *heading_size_group)
 
59
{
 
60
        GtkWidget *widget;
 
61
        GtkWindow *window;
 
62
        NetDeviceMobile *device_mobile = NET_DEVICE_MOBILE (object);
 
63
 
 
64
        /* add widgets to size group */
 
65
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
66
                                                     "heading_imei"));
 
67
        gtk_size_group_add_widget (heading_size_group, widget);
 
68
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
69
                                                     "heading_network"));
 
70
        gtk_size_group_add_widget (heading_size_group, widget);
 
71
 
 
72
        /* reparent */
 
73
        window = GTK_WINDOW (gtk_builder_get_object (device_mobile->priv->builder,
 
74
                                                     "window_tmp"));
 
75
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
76
                                                     "vbox7"));
 
77
        g_object_ref (widget);
 
78
        gtk_container_remove (GTK_CONTAINER (window), widget);
 
79
        gtk_notebook_append_page (notebook, widget, NULL);
 
80
        g_object_unref (widget);
 
81
        return widget;
 
82
}
 
83
 
 
84
static void
 
85
connection_activate_cb (NMClient *client,
 
86
                        NMActiveConnection *connection,
 
87
                        GError *error,
 
88
                        gpointer user_data)
 
89
{
 
90
        NetDeviceMobile *device_mobile = NET_DEVICE_MOBILE (user_data);
 
91
 
 
92
        if (connection == NULL) {
 
93
                /* failed to activate */
 
94
                nm_device_mobile_refresh_ui (device_mobile);
 
95
        }
 
96
}
 
97
 
 
98
static void
 
99
mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mobile)
 
100
{
 
101
        gboolean ret;
 
102
        gchar *object_path = NULL;
 
103
        GtkTreeIter iter;
 
104
        GtkTreeModel *model;
 
105
        NMConnection *connection;
 
106
        NMDevice *device;
 
107
        NMClient *client;
 
108
        NMRemoteSettings *remote_settings;
 
109
        CcNetworkPanel *panel;
 
110
 
 
111
        if (device_mobile->priv->updating_device)
 
112
                goto out;
 
113
 
 
114
        ret = gtk_combo_box_get_active_iter (combo_box, &iter);
 
115
        if (!ret)
 
116
                goto out;
 
117
 
 
118
        device = net_device_get_nm_device (NET_DEVICE (device_mobile));
 
119
        if (device == NULL)
 
120
                goto out;
 
121
        client = net_object_get_client (NET_OBJECT (device_mobile));
 
122
        remote_settings = net_object_get_remote_settings (NET_OBJECT (device_mobile));
 
123
 
 
124
        /* get entry */
 
125
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
 
126
        gtk_tree_model_get (model, &iter,
 
127
                            COLUMN_ID, &object_path,
 
128
                            -1);
 
129
        if (g_strcmp0 (object_path, NULL) == 0) {
 
130
                panel = net_object_get_panel (NET_OBJECT (device_mobile));
 
131
                cc_network_panel_connect_to_3g_network (panel,
 
132
                                                        client,
 
133
                                                        remote_settings,
 
134
                                                        device);
 
135
                goto out;
 
136
        }
 
137
 
 
138
        /* activate the connection */
 
139
        g_debug ("try to switch to connection %s", object_path);
 
140
        connection = (NMConnection*) nm_remote_settings_get_connection_by_path (remote_settings,
 
141
                                                                                object_path);
 
142
        if (connection != NULL) {
 
143
                nm_device_disconnect (device, NULL, NULL);
 
144
                nm_client_activate_connection (client,
 
145
                                               connection,
 
146
                                               device, NULL,
 
147
                                               connection_activate_cb,
 
148
                                               device_mobile);
 
149
                goto out;
 
150
        }
 
151
out:
 
152
        g_free (object_path);
 
153
}
 
154
 
 
155
static void
 
156
mobilebb_enabled_toggled (NMClient       *client,
 
157
                          GParamSpec     *pspec,
 
158
                          NetDeviceMobile *device_mobile)
 
159
{
 
160
        gboolean enabled;
 
161
        GtkSwitch *sw;
 
162
        NMDevice *device;
 
163
 
 
164
        device = net_device_get_nm_device (NET_DEVICE (device_mobile));
 
165
        if (nm_device_get_device_type (device) != NM_DEVICE_TYPE_MODEM)
 
166
                return;
 
167
 
 
168
        enabled = nm_client_wwan_get_enabled (client);
 
169
        sw = GTK_SWITCH (gtk_builder_get_object (device_mobile->priv->builder,
 
170
                                                 "device_off_switch"));
 
171
 
 
172
        device_mobile->priv->updating_device = TRUE;
 
173
        gtk_switch_set_active (sw, enabled);
 
174
        device_mobile->priv->updating_device = FALSE;
 
175
}
 
176
 
 
177
static void
 
178
device_add_device_connections (NetDeviceMobile *device_mobile,
 
179
                               NMDevice *nm_device,
 
180
                               GtkListStore *liststore,
 
181
                               GtkComboBox *combobox)
 
182
{
 
183
        NetDeviceMobilePrivate *priv = device_mobile->priv;
 
184
        GSList *filtered;
 
185
        GSList *list, *l;
 
186
        GtkTreeIter treeiter;
 
187
        NMActiveConnection *active_connection;
 
188
        NMConnection *connection;
 
189
        NMRemoteSettings *remote_settings;
 
190
 
 
191
        /* get the list of available connections for this device */
 
192
        remote_settings = net_object_get_remote_settings (NET_OBJECT (device_mobile));
 
193
        g_assert (remote_settings != NULL);
 
194
        list = nm_remote_settings_list_connections (remote_settings);
 
195
        filtered = nm_device_filter_connections (nm_device, list);
 
196
        gtk_list_store_clear (liststore);
 
197
        active_connection = nm_device_get_active_connection (nm_device);
 
198
        for (l = filtered; l; l = g_slist_next (l)) {
 
199
                connection = NM_CONNECTION (l->data);
 
200
                gtk_list_store_append (liststore, &treeiter);
 
201
                gtk_list_store_set (liststore,
 
202
                                    &treeiter,
 
203
                                    COLUMN_ID, nm_connection_get_uuid (connection),
 
204
                                    COLUMN_TITLE, nm_connection_get_id (connection),
 
205
                                    -1);
 
206
 
 
207
                /* is this already activated? */
 
208
                if (active_connection != NULL &&
 
209
                    g_strcmp0 (nm_connection_get_path (connection),
 
210
                               nm_active_connection_get_connection (active_connection)) == 0) {
 
211
                        priv->updating_device = TRUE;
 
212
                        gtk_combo_box_set_active_iter (combobox, &treeiter);
 
213
                        priv->updating_device = FALSE;
 
214
                }
 
215
        }
 
216
 
 
217
        /* add new connection entry */
 
218
        gtk_list_store_append (liststore, &treeiter);
 
219
        gtk_list_store_set (liststore,
 
220
                            &treeiter,
 
221
                            COLUMN_ID, NULL,
 
222
                            COLUMN_TITLE, _("Add new connection"),
 
223
                            -1);
 
224
 
 
225
        g_slist_free (list);
 
226
        g_slist_free (filtered);
 
227
}
 
228
 
 
229
static void
 
230
nm_device_mobile_refresh_ui (NetDeviceMobile *device_mobile)
 
231
{
 
232
        const char *str;
 
233
        gboolean is_connected;
 
234
        GString *status;
 
235
        GtkListStore *liststore;
 
236
        GtkWidget *widget;
 
237
        guint speed = 0;
 
238
        NetDeviceMobilePrivate *priv = device_mobile->priv;
 
239
        NMClient *client;
 
240
        NMDeviceModemCapabilities caps;
 
241
        NMDevice *nm_device;
 
242
 
 
243
        /* set device kind */
 
244
        nm_device = net_device_get_nm_device (NET_DEVICE (device_mobile));
 
245
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder, "label_device"));
 
246
        gtk_label_set_label (GTK_LABEL (widget),
 
247
                             panel_device_to_localized_string (nm_device));
 
248
 
 
249
        /* set up the device on/off switch */
 
250
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder, "device_off_switch"));
 
251
        gtk_widget_show (widget);
 
252
        client = net_object_get_client (NET_OBJECT (device_mobile));
 
253
        mobilebb_enabled_toggled (client, NULL, device_mobile);
 
254
 
 
255
        /* set device state, with status and optionally speed */
 
256
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder, "label_status"));
 
257
        status = g_string_new (panel_device_state_to_localized_string (nm_device));
 
258
        if (speed  > 0) {
 
259
                g_string_append (status, " - ");
 
260
                /* Translators: network device speed */
 
261
                g_string_append_printf (status, _("%d Mb/s"), speed);
 
262
        }
 
263
        gtk_label_set_label (GTK_LABEL (widget), status->str);
 
264
        g_string_free (status, TRUE);
 
265
        gtk_widget_set_tooltip_text (widget, panel_device_state_reason_to_localized_string (nm_device));
 
266
 
 
267
        /* sensitive for other connection types if the device is currently connected */
 
268
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
269
                                                     "button_options"));
 
270
        is_connected = net_device_get_find_connection (NET_DEVICE (device_mobile)) != NULL;
 
271
        gtk_widget_set_sensitive (widget, is_connected);
 
272
 
 
273
        caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (nm_device));
 
274
        if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
 
275
            (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
 
276
                /* IMEI */
 
277
                str = g_object_get_data (G_OBJECT (nm_device),
 
278
                                         "ControlCenter::EquipmentIdentifier");
 
279
                panel_set_device_widget_details (device_mobile->priv->builder,
 
280
                                                 "imei",
 
281
                                                 str);
 
282
 
 
283
                /* operator name */
 
284
                str = g_object_get_data (G_OBJECT (nm_device),
 
285
                                         "ControlCenter::OperatorName");
 
286
                panel_set_device_widget_details (device_mobile->priv->builder,
 
287
                                                 "provider",
 
288
                                                 str);
 
289
        }
 
290
 
 
291
        /* add possible connections to device */
 
292
        liststore = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
 
293
                                                            "liststore_mobile_connections"));
 
294
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "combobox_network"));
 
295
        device_add_device_connections (device_mobile,
 
296
                                       nm_device,
 
297
                                       liststore,
 
298
                                       GTK_COMBO_BOX (widget));
 
299
 
 
300
        /* set IP entries */
 
301
        panel_set_device_widgets (priv->builder, nm_device);
 
302
}
 
303
 
 
304
static void
 
305
device_mobile_refresh (NetObject *object)
 
306
{
 
307
        NetDeviceMobile *device_mobile = NET_DEVICE_MOBILE (object);
 
308
        nm_device_mobile_refresh_ui (device_mobile);
 
309
}
 
310
 
 
311
static void
 
312
device_off_toggled (GtkSwitch *sw,
 
313
                    GParamSpec *pspec,
 
314
                    NetDeviceMobile *device_mobile)
 
315
{
 
316
        const gchar *path;
 
317
        const GPtrArray *acs;
 
318
        gboolean active;
 
319
        gint i;
 
320
        NMActiveConnection *a;
 
321
        NMConnection *connection;
 
322
        NMClient *client;
 
323
 
 
324
        if (device_mobile->priv->updating_device)
 
325
                return;
 
326
 
 
327
        active = gtk_switch_get_active (sw);
 
328
        if (active) {
 
329
                client = net_object_get_client (NET_OBJECT (device_mobile));
 
330
                connection = net_device_get_find_connection (NET_DEVICE (device_mobile));
 
331
                if (connection == NULL)
 
332
                        return;
 
333
                nm_client_activate_connection (client,
 
334
                                               connection,
 
335
                                               net_device_get_nm_device (NET_DEVICE (device_mobile)),
 
336
                                               NULL, NULL, NULL);
 
337
        } else {
 
338
                connection = net_device_get_find_connection (NET_DEVICE (device_mobile));
 
339
                if (connection == NULL)
 
340
                        return;
 
341
                path = nm_connection_get_path (connection);
 
342
                client = net_object_get_client (NET_OBJECT (device_mobile));
 
343
                acs = nm_client_get_active_connections (client);
 
344
                for (i = 0; i < acs->len; i++) {
 
345
                        a = (NMActiveConnection*)acs->pdata[i];
 
346
                        if (strcmp (nm_active_connection_get_connection (a), path) == 0) {
 
347
                                nm_client_deactivate_connection (client, a);
 
348
                                break;
 
349
                        }
 
350
                }
 
351
        }
 
352
}
 
353
 
 
354
static void
 
355
edit_connection (GtkButton *button, NetDeviceMobile *device_mobile)
 
356
{
 
357
        net_object_edit (NET_OBJECT (device_mobile));
 
358
}
 
359
 
 
360
static void
 
361
device_mobile_device_got_modem_manager_cb (GObject *source_object,
 
362
                                   GAsyncResult *res,
 
363
                                   gpointer user_data)
 
364
{
 
365
        GError *error = NULL;
 
366
        GVariant *result = NULL;
 
367
        GDBusProxy *proxy;
 
368
        NMDevice *device = (NMDevice *) user_data;
 
369
 
 
370
        proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
 
371
        if (proxy == NULL) {
 
372
                g_warning ("Error creating ModemManager proxy: %s",
 
373
                           error->message);
 
374
                g_error_free (error);
 
375
                goto out;
 
376
        }
 
377
 
 
378
        /* get the IMEI */
 
379
        result = g_dbus_proxy_get_cached_property (proxy,
 
380
                                                   "EquipmentIdentifier");
 
381
 
 
382
        /* save */
 
383
        g_object_set_data_full (G_OBJECT (device),
 
384
                                "ControlCenter::EquipmentIdentifier",
 
385
                                g_variant_dup_string (result, NULL),
 
386
                                g_free);
 
387
out:
 
388
        if (result != NULL)
 
389
                g_variant_unref (result);
 
390
        if (proxy != NULL)
 
391
                g_object_unref (proxy);
 
392
}
 
393
 
 
394
static void
 
395
device_mobile_get_registration_info_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 
396
{
 
397
        gchar *operator_code = NULL;
 
398
        GError *error = NULL;
 
399
        guint registration_status;
 
400
        GVariant *result = NULL;
 
401
        gchar *operator_name = NULL;
 
402
        gchar *operator_name_safe = NULL;
 
403
        NMDevice *device = (NMDevice *) user_data;
 
404
 
 
405
        result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
 
406
        if (result == NULL) {
 
407
                g_warning ("Error getting registration info: %s\n",
 
408
                           error->message);
 
409
                g_error_free (error);
 
410
                return;
 
411
        }
 
412
 
 
413
        /* get values */
 
414
        g_variant_get (result, "((uss))",
 
415
                       &registration_status,
 
416
                       &operator_code,
 
417
                       &operator_name);
 
418
        if (operator_name != NULL && operator_name[0] != '\0')
 
419
                operator_name_safe = g_strescape (operator_name, NULL);
 
420
 
 
421
        /* save */
 
422
        g_object_set_data_full (G_OBJECT (device),
 
423
                                "ControlCenter::OperatorName",
 
424
                                operator_name_safe,
 
425
                                g_free);
 
426
 
 
427
        g_free (operator_name);
 
428
        g_free (operator_code);
 
429
        g_variant_unref (result);
 
430
}
 
431
 
 
432
static void
 
433
device_mobile_device_got_modem_manager_gsm_cb (GObject *source_object,
 
434
                                       GAsyncResult *res,
 
435
                                       gpointer user_data)
 
436
{
 
437
        GError *error = NULL;
 
438
        GDBusProxy *proxy;
 
439
        NMDevice *device = (NMDevice *) user_data;
 
440
 
 
441
        proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
 
442
        if (proxy == NULL) {
 
443
                g_warning ("Error creating ModemManager GSM proxy: %s\n",
 
444
                           error->message);
 
445
                g_error_free (error);
 
446
                goto out;
 
447
        }
 
448
 
 
449
        g_dbus_proxy_call (proxy,
 
450
                           "GetRegistrationInfo",
 
451
                           NULL,
 
452
                           G_DBUS_CALL_FLAGS_NONE,
 
453
                           -1,
 
454
                           NULL,
 
455
                           device_mobile_get_registration_info_cb,
 
456
                           device);
 
457
out:
 
458
        if (proxy != NULL)
 
459
                g_object_unref (proxy);
 
460
}
 
461
 
 
462
static void
 
463
net_device_mobile_constructed (GObject *object)
 
464
{
 
465
        GCancellable *cancellable;
 
466
        NetDeviceMobile *device_mobile = NET_DEVICE_MOBILE (object);
 
467
        NMClient *client;
 
468
        NMDevice *device;
 
469
 
 
470
        G_OBJECT_CLASS (net_device_mobile_parent_class)->constructed (object);
 
471
 
 
472
        device = net_device_get_nm_device (NET_DEVICE (device_mobile));
 
473
        cancellable = net_object_get_cancellable (NET_OBJECT (device_mobile));
 
474
        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
 
475
                                  G_DBUS_PROXY_FLAGS_NONE,
 
476
                                  NULL,
 
477
                                  "org.freedesktop.ModemManager",
 
478
                                  nm_device_get_udi (device),
 
479
                                  "org.freedesktop.ModemManager.Modem",
 
480
                                  cancellable,
 
481
                                  device_mobile_device_got_modem_manager_cb,
 
482
                                  device);
 
483
        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
 
484
                                  G_DBUS_PROXY_FLAGS_NONE,
 
485
                                  NULL,
 
486
                                  "org.freedesktop.ModemManager",
 
487
                                  nm_device_get_udi (device),
 
488
                                  "org.freedesktop.ModemManager.Modem.Gsm.Network",
 
489
                                  cancellable,
 
490
                                  device_mobile_device_got_modem_manager_gsm_cb,
 
491
                                  device);
 
492
 
 
493
        client = net_object_get_client (NET_OBJECT (device_mobile));
 
494
        g_signal_connect (client, "notify::wwan-enabled",
 
495
                          G_CALLBACK (mobilebb_enabled_toggled),
 
496
                          device_mobile);
 
497
        nm_device_mobile_refresh_ui (device_mobile);
 
498
}
 
499
 
 
500
static void
 
501
net_device_mobile_finalize (GObject *object)
 
502
{
 
503
        NetDeviceMobile *device_mobile = NET_DEVICE_MOBILE (object);
 
504
        NetDeviceMobilePrivate *priv = device_mobile->priv;
 
505
 
 
506
        g_object_unref (priv->builder);
 
507
 
 
508
        G_OBJECT_CLASS (net_device_mobile_parent_class)->finalize (object);
 
509
}
 
510
 
 
511
static void
 
512
net_device_mobile_class_init (NetDeviceMobileClass *klass)
 
513
{
 
514
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
515
        NetObjectClass *parent_class = NET_OBJECT_CLASS (klass);
 
516
 
 
517
        object_class->finalize = net_device_mobile_finalize;
 
518
        object_class->constructed = net_device_mobile_constructed;
 
519
        parent_class->add_to_notebook = device_mobile_proxy_add_to_notebook;
 
520
        parent_class->refresh = device_mobile_refresh;
 
521
        g_type_class_add_private (klass, sizeof (NetDeviceMobilePrivate));
 
522
}
 
523
 
 
524
static void
 
525
net_device_mobile_init (NetDeviceMobile *device_mobile)
 
526
{
 
527
        GError *error = NULL;
 
528
        GtkWidget *widget;
 
529
        GtkCellRenderer *renderer;
 
530
        GtkComboBox *combobox;
 
531
 
 
532
        device_mobile->priv = NET_DEVICE_MOBILE_GET_PRIVATE (device_mobile);
 
533
 
 
534
        device_mobile->priv->builder = gtk_builder_new ();
 
535
        gtk_builder_add_from_file (device_mobile->priv->builder,
 
536
                                   GNOMECC_UI_DIR "/network-mobile.ui",
 
537
                                   &error);
 
538
        if (error != NULL) {
 
539
                g_warning ("Could not load interface file: %s", error->message);
 
540
                g_error_free (error);
 
541
                return;
 
542
        }
 
543
 
 
544
        /* setup mobile combobox model */
 
545
        combobox = GTK_COMBO_BOX (gtk_builder_get_object (device_mobile->priv->builder,
 
546
                                                          "combobox_network"));
 
547
        g_signal_connect (combobox, "changed",
 
548
                          G_CALLBACK (mobile_connection_changed_cb),
 
549
                          device_mobile);
 
550
        renderer = gtk_cell_renderer_text_new ();
 
551
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
 
552
                                    renderer,
 
553
                                    FALSE);
 
554
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
 
555
                                        "text", COLUMN_TITLE,
 
556
                                        NULL);
 
557
 
 
558
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
559
                                                     "device_off_switch"));
 
560
        g_signal_connect (widget, "notify::active",
 
561
                          G_CALLBACK (device_off_toggled), device_mobile);
 
562
 
 
563
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
564
                                                     "button_options"));
 
565
        g_signal_connect (widget, "clicked",
 
566
                          G_CALLBACK (edit_connection), device_mobile);
 
567
 
 
568
        widget = GTK_WIDGET (gtk_builder_get_object (device_mobile->priv->builder,
 
569
                                                     "device_off_switch"));
 
570
        g_signal_connect (widget, "notify::active",
 
571
                          G_CALLBACK (device_off_toggled), device_mobile);
 
572
}