summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-01-06 19:14:27 +0100
committerJiří Klimeš <jklimes@redhat.com>2015-08-27 09:53:31 +0200
commitf6fdb2a20ef1e91bcf39e836dc891e5fc0062b86 (patch)
tree1d72e259920307a8e25bee7a36bfbb95513199b8
parent4c5f7f848c6934faa46c14e818ed6ffd1cd47da0 (diff)
downloadnetwork-manager-applet-f6fdb2a20ef1e91bcf39e836dc891e5fc0062b86.tar.gz
editor: allow setting MTU for a team (rh #1255927)
MTU is the 802-3-ethernet.mtu key, make sure wired setting exists. The same change as for bond in commit b1c5b4096eded4e1c5ad2e6f12a9bc113fece6ec, but fixed saving MTU = 0. https://bugzilla.redhat.com/show_bug.cgi?id=1255927
-rw-r--r--src/connection-editor/ce-page-team.ui72
-rw-r--r--src/connection-editor/page-team.c38
2 files changed, 104 insertions, 6 deletions
diff --git a/src/connection-editor/ce-page-team.ui b/src/connection-editor/ce-page-team.ui
index 969d9655..dae440dd 100644
--- a/src/connection-editor/ce-page-team.ui
+++ b/src/connection-editor/ce-page-team.ui
@@ -9,6 +9,11 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkAdjustment" id="team_mtu_adjustment">
+ <property name="upper">10000</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkGrid" id="TeamPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -26,7 +31,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -42,7 +47,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -63,14 +68,14 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="import_config_button">
- <property name="label" translatable="yes">I_mport team configuration from a file...</property>
+ <property name="label" translatable="yes">Im_port team configuration from a file...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="use_underline">True</property>
@@ -78,7 +83,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
@@ -181,7 +186,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">2</property>
</packing>
</child>
@@ -211,5 +216,60 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="team_mtu_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_MTU:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">team_mtu</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="team_mtu_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkSpinButton" id="team_mtu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">team_mtu_adjustment</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label29">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">bytes</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</interface>
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 7438c3b5..910123be 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -37,6 +37,7 @@ G_DEFINE_TYPE (CEPageTeam, ce_page_team, CE_TYPE_PAGE_MASTER)
typedef struct {
NMSettingTeam *setting;
+ NMSettingWired *wired;
int slave_arptype;
@@ -44,6 +45,7 @@ typedef struct {
GtkTextView *json_config_widget;
GtkWidget *import_config_button;
+ GtkSpinButton *mtu;
} CEPageTeamPrivate;
static void
@@ -67,12 +69,19 @@ team_private_init (CEPageTeam *self)
priv->json_config_widget = GTK_TEXT_VIEW (gtk_builder_get_object (builder, "team_json_config"));
priv->import_config_button = GTK_WIDGET (gtk_builder_get_object (builder, "import_config_button"));
+ priv->mtu = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "team_mtu"));
/* Wait for widget to be realized to get toplevel window */
g_signal_connect (priv->json_config_widget, "realize", G_CALLBACK (widget_realized_cb), self);
}
static void
+stuff_changed (GtkWidget *w, gpointer user_data)
+{
+ ce_page_changed (CE_PAGE (user_data));
+}
+
+static void
json_config_changed (GObject *object, CEPageTeam *self)
{
ce_page_changed (CE_PAGE (self));
@@ -129,6 +138,7 @@ populate_ui (CEPageTeam *self)
NMSettingTeam *s_team = priv->setting;
GtkTextBuffer *buffer;
const char *json_config;
+ guint32 mtu_def, mtu_val;
buffer = gtk_text_view_get_buffer (priv->json_config_widget);
json_config = nm_setting_team_get_config (s_team);
@@ -136,6 +146,18 @@ populate_ui (CEPageTeam *self)
g_signal_connect (buffer, "changed", G_CALLBACK (json_config_changed), self);
g_signal_connect (priv->import_config_button, "clicked", G_CALLBACK (import_button_clicked_cb), self);
+
+ /* MTU */
+ if (priv->wired) {
+ mtu_def = ce_get_property_default (NM_SETTING (priv->wired), NM_SETTING_WIRED_MTU);
+ mtu_val = nm_setting_wired_get_mtu (priv->wired);
+ } else {
+ mtu_def = mtu_val = 0;
+ }
+ g_signal_connect (priv->mtu, "output",
+ G_CALLBACK (ce_spin_output_with_automatic),
+ GINT_TO_POINTER (mtu_def));
+ gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
}
static void
@@ -216,10 +238,14 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
static void
finish_setup (CEPageTeam *self, gpointer unused, GError *error, gpointer user_data)
{
+ CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
+
if (error)
return;
populate_ui (self);
+
+ g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);
}
CEPage *
@@ -253,6 +279,7 @@ ce_page_team_new (NMConnection *connection,
priv->setting = NM_SETTING_TEAM (nm_setting_team_new ());
nm_connection_add_setting (connection, NM_SETTING (priv->setting));
}
+ priv->wired = nm_connection_get_setting_wired (connection);
g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
@@ -263,9 +290,11 @@ static void
ui_to_setting (CEPageTeam *self)
{
CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self);
+ NMConnection *connection = CE_PAGE (self)->connection;
GtkTextBuffer *buffer;
GtkTextIter start, end;
char *json_config;
+ guint32 mtu;
buffer = gtk_text_view_get_buffer (priv->json_config_widget);
gtk_text_buffer_get_iter_at_offset (buffer, &start, 0);
@@ -278,6 +307,15 @@ ui_to_setting (CEPageTeam *self)
NM_SETTING_TEAM_CONFIG, json_config,
NULL);
g_free (json_config);
+
+ mtu = gtk_spin_button_get_value_as_int (priv->mtu);
+ if (mtu && !priv->wired) {
+ priv->wired = NM_SETTING_WIRED (nm_setting_wired_new ());
+ nm_connection_add_setting (connection, NM_SETTING (priv->wired));
+ }
+ if (priv->wired)
+ g_object_set (priv->wired, NM_SETTING_WIRED_MTU, mtu, NULL);
+
}
static gboolean