[network-manager-applet/jklimes/team: 8/8] editor: only allow adding slaves of the same type to master Team
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jklimes/team: 8/8] editor: only allow adding slaves of the same type to master Team
- Date: Thu, 3 Oct 2013 16:23:37 +0000 (UTC)
commit 25a6d1e64f47d5d6cbf3a8de26144ab9aadbb2fb
Author: Jiří Klimeš <jklimes redhat com>
Date: Thu Oct 3 18:15:20 2013 +0200
editor: only allow adding slaves of the same type to master Team
It is not possible to mix e.g. ethernet with InfiniBand.
src/connection-editor/page-team.c | 62 ++++++++++++++++++++++++++++++++++---
1 files changed, 57 insertions(+), 5 deletions(-)
---
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 88f83ff..637c669 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -27,6 +27,10 @@
#include <nm-setting-team.h>
#include "page-team.h"
+#include "page-ethernet.h"
+#include "page-wifi.h"
+#include "page-infiniband.h"
+#include "page-vlan.h"
#include "nm-connection-editor.h"
#include "new-connection.h"
@@ -37,6 +41,9 @@ G_DEFINE_TYPE (CEPageTeam, ce_page_team, CE_TYPE_PAGE_MASTER)
typedef struct {
NMSettingTeam *setting;
+ GType slave_type;
+ PageNewConnectionFunc new_slave_func;
+
GtkWindow *toplevel;
GtkWidget *json_config_label;
@@ -135,6 +142,40 @@ populate_ui (CEPageTeam *self)
}
static void
+connection_removed (CEPageMaster *master, NMConnection *connection)
+{
+ CEPageTeam *self = CE_PAGE_TEAM (master);
+ CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
+
+ if (!ce_page_master_has_slaves (master)) {
+ priv->slave_type = G_TYPE_INVALID;
+ priv->new_slave_func = NULL;
+ }
+}
+
+static void
+connection_added (CEPageMaster *master, NMConnection *connection)
+{
+ CEPageTeam *self = CE_PAGE_TEAM (master);
+ CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
+
+ /* A bit kludgy... */
+ if (nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {
+ priv->slave_type = NM_TYPE_SETTING_INFINIBAND;
+ priv->new_slave_func = infiniband_connection_new;
+ } else if (nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)) {
+ priv->slave_type = NM_TYPE_SETTING_WIRED;
+ priv->new_slave_func = ethernet_connection_new;
+ } else if (nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
+ priv->slave_type = NM_TYPE_SETTING_WIRELESS;
+ priv->new_slave_func = wifi_connection_new;
+ } else {
+ priv->slave_type = NM_TYPE_SETTING_VLAN;
+ priv->new_slave_func = vlan_connection_new;
+ }
+}
+
+static void
create_connection (CEPageMaster *master, NMConnection *connection)
{
NMSetting *s_port;
@@ -164,11 +205,20 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
CEPageTeam *self = CE_PAGE_TEAM (master);
CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
- new_connection_dialog (priv->toplevel,
- CE_PAGE (self)->settings,
- connection_type_filter,
- result_func,
- master);
+ if (priv->new_slave_func) {
+ new_connection_of_type (priv->toplevel,
+ NULL,
+ CE_PAGE (self)->settings,
+ priv->new_slave_func,
+ result_func,
+ master);
+ } else {
+ new_connection_dialog (priv->toplevel,
+ CE_PAGE (self)->settings,
+ connection_type_filter,
+ result_func,
+ master);
+ }
}
static void
@@ -270,6 +320,8 @@ ce_page_team_class_init (CEPageTeamClass *team_class)
/* virtual methods */
parent_class->validate = validate;
master_class->create_connection = create_connection;
+ master_class->connection_added = connection_added;
+ master_class->connection_removed = connection_removed;
master_class->add_slave = add_slave;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]