2011-02-02 01:38:33 -05:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
2010-12-14 10:23:26 +00:00
|
|
|
*
|
2012-07-16 17:34:24 +01:00
|
|
|
* Copyright (C) 2010-2012 Richard Hughes <richard@hughsie.com>
|
2012-06-12 00:56:37 +02:00
|
|
|
* Copyright (C) 2012 Thomas Bechtold <thomasbechtold@jpberlin.de>
|
2013-02-04 15:41:37 +01:00
|
|
|
* Copyright (C) 2013 Aleksander Morgado <aleksander@gnu.org>
|
2010-12-14 10:23:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-12-14 10:23:26 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-03-02 18:40:44 +01:00
|
|
|
#include <config.h>
|
2010-12-14 10:23:26 +00:00
|
|
|
#include <glib/gi18n.h>
|
2011-02-21 10:05:22 +00:00
|
|
|
#include <stdlib.h>
|
2010-12-14 10:23:26 +00:00
|
|
|
|
2018-03-27 18:00:43 -03:00
|
|
|
#include "shell/cc-object-storage.h"
|
|
|
|
|
2010-12-14 10:23:26 +00:00
|
|
|
#include "cc-network-panel.h"
|
2013-01-04 15:34:11 +01:00
|
|
|
#include "cc-network-resources.h"
|
2010-12-14 10:23:26 +00:00
|
|
|
|
2016-04-29 16:05:54 +02:00
|
|
|
#include <NetworkManager.h>
|
2011-02-21 10:05:22 +00:00
|
|
|
|
2011-03-11 12:28:14 +00:00
|
|
|
#include "net-device.h"
|
2012-07-20 09:21:57 +01:00
|
|
|
#include "net-device-mobile.h"
|
2012-07-20 12:05:10 +01:00
|
|
|
#include "net-device-wifi.h"
|
2012-08-29 14:39:52 -04:00
|
|
|
#include "net-device-ethernet.h"
|
2012-07-20 12:05:10 +01:00
|
|
|
#include "net-object.h"
|
2012-07-12 14:07:54 +01:00
|
|
|
#include "net-proxy.h"
|
2011-03-11 12:28:14 +00:00
|
|
|
#include "net-vpn.h"
|
|
|
|
|
2011-02-21 10:05:22 +00:00
|
|
|
#include "panel-common.h"
|
2010-12-15 19:22:15 +00:00
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
#include "network-dialogs.h"
|
2013-01-09 17:41:48 -05:00
|
|
|
#include "connection-editor/net-connection-editor.h"
|
2011-08-22 18:12:00 +02:00
|
|
|
|
2013-02-04 15:41:37 +01:00
|
|
|
#include <libmm-glib.h>
|
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
typedef enum {
|
|
|
|
OPERATION_NULL,
|
|
|
|
OPERATION_SHOW_DEVICE,
|
|
|
|
OPERATION_CONNECT_MOBILE
|
|
|
|
} CmdlineOperation;
|
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
struct _CcNetworkPanel
|
2010-12-14 10:23:26 +00:00
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
CcPanel parent;
|
|
|
|
|
2011-03-15 16:33:01 -04:00
|
|
|
GCancellable *cancellable;
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GHashTable *device_to_stack;
|
|
|
|
GPtrArray *devices;
|
2011-03-15 16:33:01 -04:00
|
|
|
NMClient *client;
|
2013-02-04 15:41:37 +01:00
|
|
|
MMManager *modem_manager;
|
2017-07-12 11:08:39 -03:00
|
|
|
GtkSizeGroup *sizegroup;
|
2011-03-15 16:33:01 -04:00
|
|
|
gboolean updating_device;
|
2012-11-09 11:16:07 +01:00
|
|
|
|
2017-07-12 11:08:39 -03:00
|
|
|
/* widgets */
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *box_proxy;
|
2017-08-22 23:04:52 -03:00
|
|
|
GtkWidget *box_simple;
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *box_vpn;
|
|
|
|
GtkWidget *box_wired;
|
2017-08-22 23:04:52 -03:00
|
|
|
GtkWidget *container_simple;
|
2017-07-21 14:39:27 -03:00
|
|
|
GtkWidget *empty_listbox;
|
2017-07-12 11:08:39 -03:00
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
/* wireless dialog stuff */
|
|
|
|
CmdlineOperation arg_operation;
|
|
|
|
gchar *arg_device;
|
|
|
|
gchar *arg_access_point;
|
|
|
|
gboolean operation_done;
|
2010-12-14 10:23:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2011-01-24 15:46:58 -05:00
|
|
|
PANEL_DEVICES_COLUMN_ICON,
|
2011-03-16 17:27:24 +00:00
|
|
|
PANEL_DEVICES_COLUMN_OBJECT,
|
2011-01-24 15:46:58 -05:00
|
|
|
PANEL_DEVICES_COLUMN_LAST
|
2010-12-14 14:04:40 +00:00
|
|
|
};
|
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
2013-03-01 11:18:08 +01:00
|
|
|
PROP_PARAMETERS
|
2011-08-22 18:12:00 +02:00
|
|
|
};
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
static NetObject *find_net_object_by_id (CcNetworkPanel *panel, const gchar *id);
|
2012-09-27 21:07:53 +02:00
|
|
|
static void handle_argv (CcNetworkPanel *panel);
|
2010-12-16 10:33:38 +00:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
CC_PANEL_REGISTER (CcNetworkPanel, cc_network_panel)
|
|
|
|
|
2010-12-14 10:23:26 +00:00
|
|
|
static void
|
|
|
|
cc_network_panel_get_property (GObject *object,
|
2011-01-24 15:46:58 -05:00
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-12-14 10:23:26 +00:00
|
|
|
{
|
2011-01-24 15:46:58 -05:00
|
|
|
switch (property_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
static CmdlineOperation
|
|
|
|
cmdline_operation_from_string (const gchar *string)
|
|
|
|
{
|
|
|
|
if (g_strcmp0 (string, "connect-3g") == 0)
|
|
|
|
return OPERATION_CONNECT_MOBILE;
|
|
|
|
if (g_strcmp0 (string, "show-device") == 0)
|
|
|
|
return OPERATION_SHOW_DEVICE;
|
|
|
|
|
|
|
|
g_warning ("Invalid additional argument %s", string);
|
|
|
|
return OPERATION_NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-27 20:22:57 +02:00
|
|
|
static void
|
|
|
|
reset_command_line_args (CcNetworkPanel *self)
|
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
self->arg_operation = OPERATION_NULL;
|
|
|
|
g_clear_pointer (&self->arg_device, g_free);
|
|
|
|
g_clear_pointer (&self->arg_access_point, g_free);
|
2012-09-27 20:22:57 +02:00
|
|
|
}
|
|
|
|
|
2012-10-03 14:49:23 +02:00
|
|
|
static gboolean
|
|
|
|
verify_argv (CcNetworkPanel *self,
|
|
|
|
const char **args)
|
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
switch (self->arg_operation) {
|
2012-10-03 14:49:23 +02:00
|
|
|
case OPERATION_CONNECT_MOBILE:
|
|
|
|
case OPERATION_SHOW_DEVICE:
|
2017-07-12 10:16:12 -03:00
|
|
|
if (self->arg_device == NULL) {
|
2012-10-03 14:49:23 +02:00
|
|
|
g_warning ("Operation %s requires an object path", args[0]);
|
2012-10-16 14:36:16 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-10-03 14:49:23 +02:00
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 11:18:08 +01:00
|
|
|
static GPtrArray *
|
|
|
|
variant_av_to_string_array (GVariant *array)
|
|
|
|
{
|
|
|
|
GVariantIter iter;
|
|
|
|
GVariant *v;
|
|
|
|
GPtrArray *strv;
|
|
|
|
gsize count;
|
|
|
|
count = g_variant_iter_init (&iter, array);
|
|
|
|
strv = g_ptr_array_sized_new (count + 1);
|
|
|
|
while (g_variant_iter_next (&iter, "v", &v)) {
|
2017-07-21 11:52:13 -03:00
|
|
|
g_ptr_array_add (strv, (gpointer)g_variant_get_string (v, NULL));
|
2013-03-01 11:18:08 +01:00
|
|
|
g_variant_unref (v);
|
|
|
|
}
|
|
|
|
g_ptr_array_add (strv, NULL); /* NULL-terminate the strv data array */
|
|
|
|
return strv;
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:23:26 +00:00
|
|
|
static void
|
|
|
|
cc_network_panel_set_property (GObject *object,
|
2011-01-24 15:46:58 -05:00
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-12-14 10:23:26 +00:00
|
|
|
{
|
2011-08-22 18:12:00 +02:00
|
|
|
CcNetworkPanel *self = CC_NETWORK_PANEL (object);
|
|
|
|
|
2011-01-24 15:46:58 -05:00
|
|
|
switch (property_id) {
|
2013-03-01 11:18:08 +01:00
|
|
|
case PROP_PARAMETERS: {
|
|
|
|
GVariant *parameters;
|
2011-09-08 15:43:23 +01:00
|
|
|
|
2012-09-27 20:22:57 +02:00
|
|
|
reset_command_line_args (self);
|
2011-09-08 15:43:23 +01:00
|
|
|
|
2013-03-01 11:18:08 +01:00
|
|
|
parameters = g_value_get_variant (value);
|
|
|
|
if (parameters) {
|
|
|
|
GPtrArray *array;
|
|
|
|
const gchar **args;
|
|
|
|
array = variant_av_to_string_array (parameters);
|
2013-09-09 15:52:21 +02:00
|
|
|
args = (const gchar **) array->pdata;
|
2011-09-08 15:43:23 +01:00
|
|
|
|
2011-08-22 18:12:00 +02:00
|
|
|
g_debug ("Invoked with operation %s", args[0]);
|
|
|
|
|
|
|
|
if (args[0])
|
2017-07-12 10:16:12 -03:00
|
|
|
self->arg_operation = cmdline_operation_from_string (args[0]);
|
2011-08-22 18:12:00 +02:00
|
|
|
if (args[0] && args[1])
|
2017-07-12 10:16:12 -03:00
|
|
|
self->arg_device = g_strdup (args[1]);
|
2011-08-22 18:12:00 +02:00
|
|
|
if (args[0] && args[1] && args[2])
|
2017-07-12 10:16:12 -03:00
|
|
|
self->arg_access_point = g_strdup (args[2]);
|
2012-09-27 21:07:53 +02:00
|
|
|
|
2012-10-03 14:49:23 +02:00
|
|
|
if (verify_argv (self, (const char **) args) == FALSE) {
|
|
|
|
reset_command_line_args (self);
|
2013-03-01 11:18:08 +01:00
|
|
|
g_ptr_array_unref (array);
|
2012-10-03 14:49:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-03-01 11:18:08 +01:00
|
|
|
g_ptr_array_unref (array);
|
2012-10-01 23:05:29 +02:00
|
|
|
g_debug ("Calling handle_argv() after setting property");
|
2012-09-27 21:07:53 +02:00
|
|
|
handle_argv (self);
|
2011-08-22 18:12:00 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-01-24 15:46:58 -05:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_network_panel_dispose (GObject *object)
|
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
CcNetworkPanel *self = CC_NETWORK_PANEL (object);
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2018-05-31 10:16:54 +12:00
|
|
|
g_cancellable_cancel (self->cancellable);
|
2012-06-13 23:18:39 -04:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
g_clear_object (&self->cancellable);
|
|
|
|
g_clear_object (&self->client);
|
|
|
|
g_clear_object (&self->modem_manager);
|
2012-06-13 23:18:39 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
g_clear_pointer (&self->device_to_stack, g_hash_table_destroy);
|
|
|
|
g_clear_pointer (&self->devices, g_ptr_array_unref);
|
|
|
|
|
2011-01-24 15:46:58 -05:00
|
|
|
G_OBJECT_CLASS (cc_network_panel_parent_class)->dispose (object);
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cc_network_panel_finalize (GObject *object)
|
|
|
|
{
|
2012-09-27 20:26:50 +02:00
|
|
|
CcNetworkPanel *panel = CC_NETWORK_PANEL (object);
|
|
|
|
|
|
|
|
reset_command_line_args (panel);
|
2011-08-22 18:12:00 +02:00
|
|
|
|
2011-01-24 15:46:58 -05:00
|
|
|
G_OBJECT_CLASS (cc_network_panel_parent_class)->finalize (object);
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2012-05-18 17:04:58 +02:00
|
|
|
static const char *
|
|
|
|
cc_network_panel_get_help_uri (CcPanel *panel)
|
|
|
|
{
|
|
|
|
return "help:gnome-help/net";
|
|
|
|
}
|
|
|
|
|
2011-03-16 17:27:24 +00:00
|
|
|
static void
|
|
|
|
object_removed_cb (NetObject *object, CcNetworkPanel *panel)
|
|
|
|
{
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *stack;
|
2011-03-16 17:27:24 +00:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
/* remove device */
|
|
|
|
stack = g_hash_table_lookup (panel->device_to_stack, object);
|
|
|
|
if (stack != NULL)
|
|
|
|
gtk_widget_destroy (stack);
|
2011-03-16 17:27:24 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 07:23:42 -04:00
|
|
|
GPtrArray *
|
|
|
|
cc_network_panel_get_devices (CcNetworkPanel *panel)
|
2012-09-27 16:15:19 -04:00
|
|
|
{
|
2012-10-18 07:23:42 -04:00
|
|
|
GPtrArray *devices;
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
guint i;
|
2012-10-18 07:23:42 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
g_return_val_if_fail (CC_IS_NETWORK_PANEL (panel), NULL);
|
2012-09-27 16:15:19 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
devices = g_ptr_array_new_with_free_func (g_object_unref);
|
2012-10-18 07:23:42 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
for (i = 0; i < panel->devices->len; i++) {
|
|
|
|
NetObject *object = g_ptr_array_index (panel->devices, i);
|
2012-09-27 16:15:19 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (!NET_IS_DEVICE (object))
|
|
|
|
continue;
|
2012-10-18 07:23:42 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
g_ptr_array_add (devices, g_object_ref (object));
|
2017-02-13 21:39:18 +01:00
|
|
|
}
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return devices;
|
2017-02-13 21:36:55 +01:00
|
|
|
}
|
|
|
|
|
2012-10-18 07:23:42 -04:00
|
|
|
static void
|
|
|
|
panel_refresh_device_titles (CcNetworkPanel *panel)
|
|
|
|
{
|
|
|
|
GPtrArray *ndarray, *nmdarray;
|
|
|
|
NetDevice **devices;
|
2013-02-04 16:53:00 -05:00
|
|
|
NMDevice **nm_devices, *nm_device;
|
2012-10-18 07:23:42 -04:00
|
|
|
gchar **titles;
|
|
|
|
gint i, num_devices;
|
|
|
|
|
|
|
|
ndarray = cc_network_panel_get_devices (panel);
|
2012-09-27 16:15:19 -04:00
|
|
|
if (!ndarray->len) {
|
|
|
|
g_ptr_array_free (ndarray, TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-18 07:23:42 -04:00
|
|
|
nmdarray = g_ptr_array_new ();
|
2013-02-04 16:53:00 -05:00
|
|
|
for (i = 0; i < ndarray->len; i++) {
|
|
|
|
nm_device = net_device_get_nm_device (ndarray->pdata[i]);
|
|
|
|
if (nm_device)
|
|
|
|
g_ptr_array_add (nmdarray, nm_device);
|
|
|
|
else
|
|
|
|
g_ptr_array_remove_index (ndarray, i--);
|
|
|
|
}
|
2012-10-18 07:23:42 -04:00
|
|
|
|
2012-09-27 16:15:19 -04:00
|
|
|
devices = (NetDevice **)ndarray->pdata;
|
|
|
|
nm_devices = (NMDevice **)nmdarray->pdata;
|
|
|
|
num_devices = ndarray->len;
|
|
|
|
|
2016-04-29 16:05:54 +02:00
|
|
|
titles = nm_device_disambiguate_names (nm_devices, num_devices);
|
2012-09-27 16:15:19 -04:00
|
|
|
for (i = 0; i < num_devices; i++) {
|
|
|
|
net_object_set_title (NET_OBJECT (devices[i]), titles[i]);
|
|
|
|
g_free (titles[i]);
|
|
|
|
}
|
|
|
|
g_free (titles);
|
|
|
|
g_ptr_array_free (ndarray, TRUE);
|
|
|
|
g_ptr_array_free (nmdarray, TRUE);
|
|
|
|
}
|
|
|
|
|
2012-09-27 21:07:53 +02:00
|
|
|
static gboolean
|
2017-07-12 10:16:12 -03:00
|
|
|
handle_argv_for_device (CcNetworkPanel *self,
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
NMDevice *device)
|
2012-09-27 21:07:53 +02:00
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
GtkWidget *toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self)));
|
2012-09-27 21:07:53 +02:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
if (self->arg_operation == OPERATION_NULL)
|
2012-09-27 21:07:53 +02:00
|
|
|
return TRUE;
|
|
|
|
|
2017-07-12 10:22:46 -03:00
|
|
|
if (g_strcmp0 (nm_object_get_path (NM_OBJECT (device)), self->arg_device) == 0) {
|
2017-07-12 10:16:12 -03:00
|
|
|
if (self->arg_operation == OPERATION_CONNECT_MOBILE) {
|
|
|
|
cc_network_panel_connect_to_3g_network (toplevel, self->client, device);
|
2012-09-27 21:07:53 +02:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
reset_command_line_args (self); /* done */
|
2012-09-27 21:07:53 +02:00
|
|
|
return TRUE;
|
2017-07-12 10:22:46 -03:00
|
|
|
} else if (self->arg_operation == OPERATION_SHOW_DEVICE) {
|
2017-07-12 10:16:12 -03:00
|
|
|
reset_command_line_args (self); /* done */
|
2012-09-27 21:07:53 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-02-17 14:50:51 +01:00
|
|
|
static gboolean
|
|
|
|
handle_argv_for_connection (CcNetworkPanel *panel,
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
NMConnection *connection)
|
2014-02-17 14:50:51 +01:00
|
|
|
{
|
2017-07-12 10:16:12 -03:00
|
|
|
if (panel->arg_operation == OPERATION_NULL)
|
2014-02-17 14:50:51 +01:00
|
|
|
return TRUE;
|
2017-07-12 10:16:12 -03:00
|
|
|
if (panel->arg_operation != OPERATION_SHOW_DEVICE)
|
2014-02-17 14:50:51 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
if (g_strcmp0 (nm_connection_get_path (connection), panel->arg_device) == 0) {
|
2014-02-17 14:50:51 +01:00
|
|
|
reset_command_line_args (panel);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-27 21:07:53 +02:00
|
|
|
static void
|
|
|
|
handle_argv (CcNetworkPanel *panel)
|
|
|
|
{
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
gint i;
|
2012-09-27 21:07:53 +02:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
if (panel->arg_operation == OPERATION_NULL)
|
2012-09-27 21:07:53 +02:00
|
|
|
return;
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
for (i = 0; i < panel->devices->len; i++) {
|
2012-09-27 21:07:53 +02:00
|
|
|
GObject *object_tmp;
|
|
|
|
NMDevice *device;
|
2014-02-17 14:50:51 +01:00
|
|
|
NMConnection *connection;
|
2012-10-01 23:03:54 +02:00
|
|
|
gboolean done = FALSE;
|
2012-09-27 21:07:53 +02:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
object_tmp = g_ptr_array_index (panel->devices, i);
|
|
|
|
|
2014-02-17 14:50:51 +01:00
|
|
|
if (NET_IS_DEVICE (object_tmp)) {
|
2012-10-01 21:16:05 +02:00
|
|
|
g_object_get (object_tmp, "nm-device", &device, NULL);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
done = handle_argv_for_device (panel, device);
|
2012-10-01 21:16:05 +02:00
|
|
|
g_object_unref (device);
|
2016-04-29 14:20:02 +02:00
|
|
|
} else if (NET_IS_VPN (object_tmp)) {
|
2014-02-17 14:50:51 +01:00
|
|
|
g_object_get (object_tmp, "connection", &connection, NULL);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
done = handle_argv_for_connection (panel, connection);
|
2014-02-17 14:50:51 +01:00
|
|
|
g_object_unref (connection);
|
2012-10-01 21:16:05 +02:00
|
|
|
}
|
2012-09-27 21:07:53 +02:00
|
|
|
|
|
|
|
if (done)
|
2012-10-01 23:03:54 +02:00
|
|
|
return;
|
2012-09-27 21:07:53 +02:00
|
|
|
}
|
2012-10-01 23:05:29 +02:00
|
|
|
|
|
|
|
g_debug ("Could not handle argv operation, no matching device yet?");
|
2012-09-27 21:07:53 +02:00
|
|
|
}
|
|
|
|
|
2017-07-21 14:39:27 -03:00
|
|
|
/* HACK: this function is basically a workaround. We don't have a single
|
|
|
|
* listbox in the VPN section, thus we need to track the separators and the
|
|
|
|
* stub row manually.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
update_vpn_section (CcNetworkPanel *self)
|
|
|
|
{
|
|
|
|
guint i, n_vpns;
|
|
|
|
|
|
|
|
for (i = 0, n_vpns = 0; i < self->devices->len; i++) {
|
|
|
|
NetObject *net_object = g_ptr_array_index (self->devices, i);
|
|
|
|
|
|
|
|
if (!NET_IS_VPN (net_object))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
net_vpn_set_show_separator (NET_VPN (net_object), n_vpns > 0);
|
|
|
|
n_vpns++;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_visible (self->empty_listbox, n_vpns == 0);
|
|
|
|
}
|
|
|
|
|
2017-08-22 23:04:52 -03:00
|
|
|
static void
|
|
|
|
update_simple_section (CcNetworkPanel *self)
|
|
|
|
{
|
|
|
|
guint i, n_simple;
|
|
|
|
|
|
|
|
for (i = 0, n_simple = 0; i < self->devices->len; i++) {
|
|
|
|
NetObject *net_object = g_ptr_array_index (self->devices, i);
|
|
|
|
|
2018-05-24 18:06:23 +02:00
|
|
|
/* NetDeviceSimple but none of the subclasses */
|
|
|
|
if (G_OBJECT_TYPE (net_object) != NET_TYPE_DEVICE_SIMPLE)
|
2017-08-22 23:04:52 -03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
net_device_simple_set_show_separator (NET_DEVICE_SIMPLE (net_object), n_simple > 0);
|
|
|
|
n_simple++;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_visible (self->container_simple, n_simple > 0);
|
|
|
|
}
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
static GtkWidget *
|
|
|
|
add_device_stack (CcNetworkPanel *self, NetObject *object)
|
2013-01-07 00:07:38 -05:00
|
|
|
{
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *stack;
|
2013-01-07 00:07:38 -05:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
stack = gtk_stack_new ();
|
|
|
|
gtk_widget_show (stack);
|
|
|
|
g_hash_table_insert (self->device_to_stack, object, stack);
|
|
|
|
|
|
|
|
net_object_add_to_stack (object, GTK_STACK (stack), self->sizegroup);
|
2013-01-07 00:07:38 -05:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return stack;
|
2013-01-07 00:07:38 -05:00
|
|
|
}
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
static void
|
2011-02-21 10:05:22 +00:00
|
|
|
panel_add_device (CcNetworkPanel *panel, NMDevice *device)
|
2010-12-14 10:23:26 +00:00
|
|
|
{
|
2011-02-21 10:05:22 +00:00
|
|
|
NMDeviceType type;
|
2011-03-11 12:28:14 +00:00
|
|
|
NetDevice *net_device;
|
2012-07-18 15:08:07 +01:00
|
|
|
GType device_g_type;
|
2014-09-08 14:29:21 +02:00
|
|
|
const char *udi;
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2013-09-10 08:49:36 -04:00
|
|
|
if (!nm_device_get_managed (device))
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return;
|
2013-09-10 08:49:36 -04:00
|
|
|
|
2011-03-28 16:46:32 +01:00
|
|
|
/* do we have an existing object with this id? */
|
2014-09-08 14:29:21 +02:00
|
|
|
udi = nm_device_get_udi (device);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (find_net_object_by_id (panel, udi) != NULL)
|
|
|
|
return;
|
2014-09-08 14:29:21 +02:00
|
|
|
|
2011-03-31 16:05:12 +01:00
|
|
|
type = nm_device_get_device_type (device);
|
|
|
|
|
2012-09-21 16:07:46 -04:00
|
|
|
g_debug ("device %s type %i path %s",
|
2014-09-08 14:29:21 +02:00
|
|
|
udi, type, nm_object_get_path (NM_OBJECT (device)));
|
2011-02-21 10:05:22 +00:00
|
|
|
|
2017-06-20 15:40:51 +02:00
|
|
|
/* map the NMDeviceType to the GType, or ignore */
|
2012-07-18 15:08:07 +01:00
|
|
|
switch (type) {
|
|
|
|
case NM_DEVICE_TYPE_ETHERNET:
|
2012-08-29 14:39:52 -04:00
|
|
|
device_g_type = NET_TYPE_DEVICE_ETHERNET;
|
2012-07-18 15:08:07 +01:00
|
|
|
break;
|
2012-07-20 09:21:57 +01:00
|
|
|
case NM_DEVICE_TYPE_MODEM:
|
|
|
|
device_g_type = NET_TYPE_DEVICE_MOBILE;
|
|
|
|
break;
|
2017-07-11 13:11:52 -03:00
|
|
|
/* Let the wi-fi panel take care of wifi devices */
|
2012-07-20 12:05:10 +01:00
|
|
|
case NM_DEVICE_TYPE_WIFI:
|
2017-06-20 15:40:51 +02:00
|
|
|
/* not going to set up a cluster in GNOME */
|
|
|
|
case NM_DEVICE_TYPE_VETH:
|
|
|
|
/* enterprise features */
|
|
|
|
case NM_DEVICE_TYPE_BOND:
|
|
|
|
case NM_DEVICE_TYPE_TEAM:
|
|
|
|
/* Don't need the libvirtd bridge */
|
|
|
|
case NM_DEVICE_TYPE_BRIDGE:
|
|
|
|
/* Don't add VPN devices */
|
|
|
|
case NM_DEVICE_TYPE_TUN:
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return;
|
2012-07-18 15:08:07 +01:00
|
|
|
default:
|
2012-10-02 15:51:27 -04:00
|
|
|
device_g_type = NET_TYPE_DEVICE_SIMPLE;
|
|
|
|
break;
|
2012-07-18 15:08:07 +01:00
|
|
|
}
|
|
|
|
|
2012-07-16 17:34:24 +01:00
|
|
|
/* create device */
|
2012-07-18 15:08:07 +01:00
|
|
|
net_device = g_object_new (device_g_type,
|
2012-07-20 09:28:26 +01:00
|
|
|
"panel", panel,
|
2012-07-16 17:34:24 +01:00
|
|
|
"removable", FALSE,
|
2017-07-12 10:16:12 -03:00
|
|
|
"cancellable", panel->cancellable,
|
|
|
|
"client", panel->client,
|
2012-07-16 17:34:24 +01:00
|
|
|
"nm-device", device,
|
|
|
|
"id", nm_device_get_udi (device),
|
|
|
|
NULL);
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2013-02-04 15:41:37 +01:00
|
|
|
if (type == NM_DEVICE_TYPE_MODEM &&
|
|
|
|
g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/")) {
|
|
|
|
GDBusObject *modem_object;
|
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
if (panel->modem_manager == NULL) {
|
2013-02-04 15:41:37 +01:00
|
|
|
g_warning ("Cannot grab information for modem at %s: No ModemManager support",
|
|
|
|
nm_device_get_udi (device));
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return;
|
2013-02-04 15:41:37 +01:00
|
|
|
}
|
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
modem_object = g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (panel->modem_manager),
|
2013-02-04 15:41:37 +01:00
|
|
|
nm_device_get_udi (device));
|
|
|
|
if (modem_object == NULL) {
|
|
|
|
g_warning ("Cannot grab information for modem at %s: Not found",
|
|
|
|
nm_device_get_udi (device));
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
return;
|
2013-02-04 15:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the modem object in the NetDeviceMobile */
|
|
|
|
g_object_set (net_device,
|
|
|
|
"mm-object", modem_object,
|
|
|
|
NULL);
|
|
|
|
g_object_unref (modem_object);
|
|
|
|
}
|
|
|
|
|
2012-07-18 15:08:07 +01:00
|
|
|
/* add as a panel */
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (device_g_type != NET_TYPE_DEVICE) {
|
|
|
|
GtkWidget *stack;
|
|
|
|
|
|
|
|
stack = add_device_stack (panel, NET_OBJECT (net_device));
|
2017-08-22 23:04:52 -03:00
|
|
|
|
|
|
|
if (device_g_type == NET_TYPE_DEVICE_SIMPLE)
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->box_simple), stack);
|
|
|
|
else
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->box_wired), stack);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add to the devices array */
|
|
|
|
g_ptr_array_add (panel->devices, net_device);
|
2012-07-18 15:08:07 +01:00
|
|
|
|
2017-08-22 23:04:52 -03:00
|
|
|
/* Update the device_simple section if we're adding a simple
|
|
|
|
* device. This is a temporary solution though, for these will
|
|
|
|
* be handled by the future Mobile Broadband panel */
|
|
|
|
if (device_g_type == NET_TYPE_DEVICE_SIMPLE)
|
|
|
|
update_simple_section (panel);
|
|
|
|
|
2012-07-23 10:43:02 +01:00
|
|
|
g_signal_connect_object (net_device, "removed",
|
|
|
|
G_CALLBACK (object_removed_cb), panel, 0);
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2010-12-16 10:33:38 +00:00
|
|
|
static void
|
2011-02-21 10:05:22 +00:00
|
|
|
panel_remove_device (CcNetworkPanel *panel, NMDevice *device)
|
2012-09-27 16:15:19 -04:00
|
|
|
{
|
|
|
|
NetObject *object;
|
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
/* remove device from array */
|
|
|
|
object = find_net_object_by_id (panel, nm_device_get_udi (device));
|
2012-07-23 10:43:02 +01:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (object == NULL)
|
2017-07-11 13:02:51 -03:00
|
|
|
return;
|
|
|
|
|
2018-03-28 01:35:28 +02:00
|
|
|
/* NMObject will not fire the "removed" signal, so handle the UI removal explicitly */
|
|
|
|
object_removed_cb (object, panel);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
g_ptr_array_remove (panel->devices, object);
|
2017-07-21 14:39:27 -03:00
|
|
|
|
|
|
|
/* update vpn widgets */
|
|
|
|
update_vpn_section (panel);
|
2017-08-22 23:04:52 -03:00
|
|
|
|
|
|
|
/* update device_simple widgets */
|
|
|
|
update_simple_section (panel);
|
2011-03-15 21:30:32 -04:00
|
|
|
}
|
|
|
|
|
2011-03-14 19:21:54 -04:00
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
panel_add_proxy_device (CcNetworkPanel *panel)
|
2011-03-14 19:21:54 -04:00
|
|
|
{
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *stack;
|
2012-07-20 12:05:10 +01:00
|
|
|
NetProxy *proxy;
|
2011-03-14 19:21:54 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
proxy = net_proxy_new ();
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
|
|
|
|
/* add proxy to stack */
|
|
|
|
stack = add_device_stack (panel, NET_OBJECT (proxy));
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->box_proxy), stack);
|
2011-03-25 20:08:48 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
/* add proxy to device list */
|
2015-03-18 18:16:26 +01:00
|
|
|
net_object_set_title (NET_OBJECT (proxy), _("Network proxy"));
|
2017-02-13 21:36:55 +01:00
|
|
|
|
|
|
|
/* NOTE: No connect to notify::title here as it is guaranteed to not
|
|
|
|
* be changed by anyone.*/
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
g_ptr_array_add (panel->devices, proxy);
|
2011-03-14 19:21:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
connection_state_changed (NMActiveConnection *c, GParamSpec *pspec, CcNetworkPanel *panel)
|
2011-03-14 19:21:54 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
static void
|
|
|
|
active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_data)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
CcNetworkPanel *panel = user_data;
|
|
|
|
const GPtrArray *connections;
|
|
|
|
int i, j;
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("Active connections changed:");
|
|
|
|
connections = nm_client_get_active_connections (client);
|
|
|
|
for (i = 0; connections && (i < connections->len); i++) {
|
|
|
|
NMActiveConnection *connection;
|
|
|
|
const GPtrArray *devices;
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
connection = g_ptr_array_index (connections, i);
|
|
|
|
g_debug (" %s", nm_object_get_path (NM_OBJECT (connection)));
|
|
|
|
devices = nm_active_connection_get_devices (connection);
|
|
|
|
for (j = 0; devices && j < devices->len; j++)
|
|
|
|
g_debug (" %s", nm_device_get_udi (g_ptr_array_index (devices, j)));
|
|
|
|
if (NM_IS_VPN_CONNECTION (connection))
|
2016-04-29 16:05:54 +02:00
|
|
|
g_debug (" VPN base connection: %s", nm_active_connection_get_specific_object_path (connection));
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
if (g_object_get_data (G_OBJECT (connection), "has-state-changed-handler") == NULL) {
|
|
|
|
g_signal_connect_object (connection, "notify::state",
|
|
|
|
G_CALLBACK (connection_state_changed), panel, 0);
|
|
|
|
g_object_set_data (G_OBJECT (connection), "has-state-changed-handler", GINT_TO_POINTER (TRUE));
|
|
|
|
}
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
static void
|
|
|
|
device_added_cb (NMClient *client, NMDevice *device, CcNetworkPanel *panel)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("New device added");
|
|
|
|
panel_add_device (panel, device);
|
2012-09-27 16:15:19 -04:00
|
|
|
panel_refresh_device_titles (panel);
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
device_removed_cb (NMClient *client, NMDevice *device, CcNetworkPanel *panel)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("Device removed");
|
|
|
|
panel_remove_device (panel, device);
|
2012-09-27 16:15:19 -04:00
|
|
|
panel_refresh_device_titles (panel);
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
manager_running (NMClient *client, GParamSpec *pspec, gpointer user_data)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
const GPtrArray *devices;
|
|
|
|
int i;
|
|
|
|
NMDevice *device_tmp;
|
|
|
|
CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
/* clear all devices we added */
|
2016-04-29 16:05:54 +02:00
|
|
|
if (!nm_client_get_nm_running (client)) {
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("NM disappeared");
|
|
|
|
panel_add_proxy_device (panel);
|
2011-03-26 16:45:08 -04:00
|
|
|
goto out;
|
2011-03-16 23:41:56 -04:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("coldplugging devices");
|
|
|
|
devices = nm_client_get_devices (client);
|
|
|
|
if (devices == NULL) {
|
|
|
|
g_debug ("No devices to add");
|
|
|
|
return;
|
2011-03-16 23:41:56 -04:00
|
|
|
}
|
2012-07-20 12:05:10 +01:00
|
|
|
for (i = 0; i < devices->len; i++) {
|
|
|
|
device_tmp = g_ptr_array_index (devices, i);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
panel_add_device (panel, device_tmp);
|
2011-02-08 12:00:19 +00:00
|
|
|
}
|
2012-07-20 12:05:10 +01:00
|
|
|
out:
|
2012-09-27 16:15:19 -04:00
|
|
|
panel_refresh_device_titles (panel);
|
|
|
|
|
2012-10-01 23:05:29 +02:00
|
|
|
g_debug ("Calling handle_argv() after cold-plugging devices");
|
2012-09-27 21:07:53 +02:00
|
|
|
handle_argv (panel);
|
2012-07-12 14:07:54 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
static NetObject *
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
find_net_object_by_id (CcNetworkPanel *panel, const gchar *id)
|
2010-12-16 10:33:38 +00:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
NetObject *object_tmp;
|
2011-03-16 17:27:24 +00:00
|
|
|
NetObject *object = NULL;
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
guint i;
|
2011-03-15 21:08:53 -04:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
for (i = 0; i < panel->devices->len; i++) {
|
|
|
|
object_tmp = g_ptr_array_index (panel->devices, i);
|
2011-01-24 15:46:58 -05:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (g_strcmp0 (net_object_get_id (object_tmp), id) == 0) {
|
|
|
|
object = object_tmp;
|
|
|
|
break;
|
2012-07-20 12:05:10 +01:00
|
|
|
}
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
return object;
|
2011-03-15 21:08:53 -04:00
|
|
|
}
|
|
|
|
|
2010-12-14 10:23:26 +00:00
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
|
2010-12-14 10:23:26 +00:00
|
|
|
{
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
GtkWidget *stack;
|
2011-01-24 15:46:58 -05:00
|
|
|
gchar *title;
|
2012-07-20 12:05:10 +01:00
|
|
|
NetVpn *net_vpn;
|
|
|
|
const gchar *id;
|
2012-06-27 22:42:19 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
/* does already exist */
|
|
|
|
id = nm_connection_get_path (connection);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
if (find_net_object_by_id (panel, id) != NULL)
|
2012-07-20 12:05:10 +01:00
|
|
|
return;
|
2012-06-27 22:42:19 -04:00
|
|
|
|
2016-04-29 14:20:02 +02:00
|
|
|
/* add as a VPN object */
|
2012-07-20 12:05:10 +01:00
|
|
|
net_vpn = g_object_new (NET_TYPE_VPN,
|
|
|
|
"panel", panel,
|
|
|
|
"removable", TRUE,
|
|
|
|
"id", id,
|
|
|
|
"connection", connection,
|
2017-07-12 10:16:12 -03:00
|
|
|
"client", panel->client,
|
2012-07-20 12:05:10 +01:00
|
|
|
NULL);
|
2012-07-23 10:43:02 +01:00
|
|
|
g_signal_connect_object (net_vpn, "removed",
|
|
|
|
G_CALLBACK (object_removed_cb), panel, 0);
|
2011-04-06 14:46:23 +01:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
/* add as a panel */
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
stack = add_device_stack (panel, NET_OBJECT (net_vpn));
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->box_vpn), stack);
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (connection));
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
net_object_set_title (NET_OBJECT (net_vpn), title);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
|
|
|
|
/* store in the devices array */
|
|
|
|
g_ptr_array_add (panel->devices, net_vpn);
|
2017-02-13 21:36:55 +01:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
g_free (title);
|
2017-07-21 14:39:27 -03:00
|
|
|
|
|
|
|
/* update vpn widgets */
|
|
|
|
update_vpn_section (panel);
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
add_connection (CcNetworkPanel *panel,
|
|
|
|
NMConnection *connection)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
NMSettingConnection *s_con;
|
2013-01-08 08:47:14 -05:00
|
|
|
const gchar *type, *iface;
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection,
|
|
|
|
NM_TYPE_SETTING_CONNECTION));
|
|
|
|
type = nm_setting_connection_get_connection_type (s_con);
|
2016-04-29 16:05:54 +02:00
|
|
|
iface = nm_connection_get_interface_name (connection);
|
2013-01-08 08:47:14 -05:00
|
|
|
if (g_strcmp0 (type, "vpn") != 0 && iface == NULL)
|
2012-07-20 12:05:10 +01:00
|
|
|
return;
|
2013-01-08 08:47:14 -05:00
|
|
|
|
2014-05-19 17:55:47 +02:00
|
|
|
/* Don't add the libvirtd bridge to the UI */
|
|
|
|
if (g_strcmp0 (nm_setting_connection_get_interface_name (s_con), "virbr0") == 0)
|
|
|
|
return;
|
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
g_debug ("add %s/%s remote connection: %s",
|
|
|
|
type, g_type_name_from_instance ((GTypeInstance*)connection),
|
|
|
|
nm_connection_get_path (connection));
|
2016-04-29 14:20:02 +02:00
|
|
|
if (!iface)
|
2013-01-08 08:47:14 -05:00
|
|
|
panel_add_vpn_device (panel, connection);
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-29 16:05:54 +02:00
|
|
|
notify_connection_added_cb (NMClient *client,
|
|
|
|
NMRemoteConnection *connection,
|
|
|
|
CcNetworkPanel *panel)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2012-07-20 12:05:10 +01:00
|
|
|
add_connection (panel, NM_CONNECTION (connection));
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
|
2014-12-05 18:53:11 +01:00
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
panel_check_network_manager_version (CcNetworkPanel *panel)
|
2011-05-24 07:28:31 -04:00
|
|
|
{
|
2014-12-05 18:53:11 +01:00
|
|
|
GtkWidget *box;
|
|
|
|
GtkWidget *label;
|
|
|
|
gchar *markup;
|
2012-07-20 12:05:10 +01:00
|
|
|
const gchar *version;
|
2011-05-24 07:28:31 -04:00
|
|
|
|
2012-07-20 12:05:10 +01:00
|
|
|
/* parse running version */
|
2017-07-12 10:16:12 -03:00
|
|
|
version = nm_client_get_version (panel->client);
|
2014-12-18 08:04:00 +01:00
|
|
|
if (version == NULL) {
|
2014-12-05 18:53:11 +01:00
|
|
|
gtk_container_remove (GTK_CONTAINER (panel), gtk_bin_get_child (GTK_BIN (panel)));
|
|
|
|
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
|
|
|
|
gtk_widget_set_vexpand (box, TRUE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel), box);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Oops, something has gone wrong. Please contact your software vendor."));
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_END);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
markup = g_strdup_printf ("<small><tt>%s</tt></small>",
|
|
|
|
_("NetworkManager needs to be running."));
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_START);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (box);
|
|
|
|
g_free (markup);
|
|
|
|
} else {
|
2017-07-12 10:16:12 -03:00
|
|
|
manager_running (panel->client, NULL, panel);
|
2011-05-24 07:28:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 11:52:57 -03:00
|
|
|
static void
|
|
|
|
create_connection_cb (GtkWidget *button,
|
|
|
|
CcNetworkPanel *self)
|
|
|
|
{
|
|
|
|
NetConnectionEditor *editor;
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
|
|
|
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
|
|
|
editor = net_connection_editor_new (toplevel, NULL, NULL, NULL, self->client);
|
|
|
|
net_connection_editor_run (editor);
|
|
|
|
}
|
|
|
|
|
2011-05-26 18:47:27 -04:00
|
|
|
static void
|
2012-07-20 12:05:10 +01:00
|
|
|
on_toplevel_map (GtkWidget *widget,
|
|
|
|
CcNetworkPanel *panel)
|
2011-05-26 18:47:27 -04:00
|
|
|
{
|
2014-12-18 08:04:00 +01:00
|
|
|
/* is the user compiling against a new version, but not running
|
|
|
|
* the daemon? */
|
2014-12-05 18:53:11 +01:00
|
|
|
panel_check_network_manager_version (panel);
|
2011-05-26 18:47:27 -04:00
|
|
|
}
|
|
|
|
|
2017-07-12 11:08:39 -03:00
|
|
|
|
|
|
|
static void
|
|
|
|
cc_network_panel_class_init (CcNetworkPanelClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
|
|
|
|
|
|
|
panel_class->get_help_uri = cc_network_panel_get_help_uri;
|
|
|
|
|
|
|
|
object_class->get_property = cc_network_panel_get_property;
|
|
|
|
object_class->set_property = cc_network_panel_set_property;
|
|
|
|
object_class->dispose = cc_network_panel_dispose;
|
|
|
|
object_class->finalize = cc_network_panel_finalize;
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
|
|
|
|
|
2018-07-22 12:46:15 -03:00
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/cc-network-panel.ui");
|
2017-07-12 11:08:39 -03:00
|
|
|
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_proxy);
|
2017-08-22 23:04:52 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_simple);
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_vpn);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_wired);
|
2017-08-22 23:04:52 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, container_simple);
|
2017-07-21 14:39:27 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, empty_listbox);
|
2017-07-12 11:08:39 -03:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, sizegroup);
|
2017-07-21 11:52:57 -03:00
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, create_connection_cb);
|
2017-07-12 11:08:39 -03:00
|
|
|
}
|
|
|
|
|
2010-12-14 10:23:26 +00:00
|
|
|
static void
|
|
|
|
cc_network_panel_init (CcNetworkPanel *panel)
|
|
|
|
{
|
2011-02-21 10:05:22 +00:00
|
|
|
GError *error = NULL;
|
2011-03-16 19:30:29 -04:00
|
|
|
GtkWidget *toplevel;
|
2013-02-04 15:41:37 +01:00
|
|
|
GDBusConnection *system_bus;
|
2016-04-29 16:05:54 +02:00
|
|
|
const GPtrArray *connections;
|
|
|
|
guint i;
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2013-01-04 15:34:11 +01:00
|
|
|
g_resources_register (cc_network_get_resource ());
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2017-07-12 11:08:39 -03:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (panel));
|
2011-01-24 15:46:58 -05:00
|
|
|
|
2017-07-12 10:16:12 -03:00
|
|
|
panel->cancellable = g_cancellable_new ();
|
network: Add connections and devices to different stack
The current Network panel is composed of a single stack and
a treeview to select the currently visible stack page. Each
stack page represents a connection or device.
The new Network panel, however, has none of the concept of
selectable pages. In the new layout, all connections and
devices appear all at once in a more compact and simpler
fashion.
This commit, then, starts moving towards a unified, pageless
panel by adding all the connections and devices to different
stacks. These different stacks are transient to the network
object, and are added at appropriate boxes, giving the panel
a unified layout.
This has some serious implications in the design of the
current code. Most of the code removals were related to the
treeview and different pages handling. No more tree model
madness is present, and the devices are now stored in a
plain simple GPtrArray.
After this patch, NetObject:add_to_stack isn't a good code
design choice anymore. This will be addressed in a future
patch.
https://bugzilla.gnome.org/show_bug.cgi?id=785581
2017-07-15 21:24:07 -03:00
|
|
|
panel->devices = g_ptr_array_new_with_free_func (g_object_unref);
|
|
|
|
panel->device_to_stack = g_hash_table_new (g_direct_hash, g_direct_equal);
|
2011-01-24 15:46:58 -05:00
|
|
|
|
|
|
|
/* add the virtual proxy device */
|
|
|
|
panel_add_proxy_device (panel);
|
|
|
|
|
2018-03-27 18:00:43 -03:00
|
|
|
/* Create and store a NMClient instance if it doesn't exist yet */
|
|
|
|
if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) {
|
|
|
|
NMClient *client = nm_client_new (NULL, NULL);
|
|
|
|
cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client);
|
|
|
|
g_object_unref (client);
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:05:22 +00:00
|
|
|
/* use NetworkManager client */
|
2018-03-27 18:00:43 -03:00
|
|
|
panel->client = cc_object_storage_get_object (CC_OBJECT_NMCLIENT);
|
|
|
|
|
|
|
|
g_signal_connect_object (panel->client, "notify::nm-running" ,
|
|
|
|
G_CALLBACK (manager_running), panel, 0);
|
|
|
|
g_signal_connect_object (panel->client, "notify::active-connections",
|
|
|
|
G_CALLBACK (active_connections_changed), panel, 0);
|
|
|
|
g_signal_connect_object (panel->client, "device-added",
|
|
|
|
G_CALLBACK (device_added_cb), panel, 0);
|
|
|
|
g_signal_connect_object (panel->client, "device-removed",
|
|
|
|
G_CALLBACK (device_removed_cb), panel, 0);
|
2011-02-21 10:05:22 +00:00
|
|
|
|
2013-02-04 15:41:37 +01:00
|
|
|
/* Setup ModemManager client */
|
|
|
|
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
|
|
|
if (system_bus == NULL) {
|
|
|
|
g_warning ("Error connecting to system D-Bus: %s",
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
} else {
|
2017-07-12 10:16:12 -03:00
|
|
|
panel->modem_manager = mm_manager_new_sync (system_bus,
|
|
|
|
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
if (panel->modem_manager == NULL) {
|
2013-02-04 15:41:37 +01:00
|
|
|
g_warning ("Error connecting to ModemManager: %s",
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
g_object_unref (system_bus);
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:05:22 +00:00
|
|
|
/* add remote settings such as VPN settings as virtual devices */
|
2018-03-27 18:00:43 -03:00
|
|
|
g_signal_connect_object (panel->client, NM_CLIENT_CONNECTION_ADDED,
|
|
|
|
G_CALLBACK (notify_connection_added_cb), panel, 0);
|
2011-02-21 10:05:22 +00:00
|
|
|
|
2011-03-16 19:30:29 -04:00
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
|
|
|
|
g_signal_connect_after (toplevel, "map", G_CALLBACK (on_toplevel_map), panel);
|
2011-02-21 10:05:22 +00:00
|
|
|
|
2016-04-29 16:05:54 +02:00
|
|
|
/* Cold-plug existing connections */
|
2017-07-12 10:16:12 -03:00
|
|
|
connections = nm_client_get_connections (panel->client);
|
2017-11-01 16:45:46 +01:00
|
|
|
if (connections) {
|
|
|
|
for (i = 0; i < connections->len; i++)
|
|
|
|
add_connection (panel, connections->pdata[i]);
|
|
|
|
}
|
2016-04-29 16:05:54 +02:00
|
|
|
|
|
|
|
g_debug ("Calling handle_argv() after cold-plugging connections");
|
|
|
|
handle_argv (panel);
|
2010-12-14 10:23:26 +00:00
|
|
|
}
|