[network-manager-applet] connection-editor: add bond "primary" option
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] connection-editor: add bond "primary" option
- Date: Fri, 27 Sep 2013 13:35:17 +0000 (UTC)
commit a598843c04dc7b33abf5528d7020854f66a70370
Author: Dan Winship <danw gnome org>
Date: Wed Sep 25 12:54:53 2013 -0400
connection-editor: add bond "primary" option
src/connection-editor/ce-page-bond.ui | 84 +++++++++++++++++++++++++++-----
src/connection-editor/page-bond.c | 39 ++++++++++++---
2 files changed, 103 insertions(+), 20 deletions(-)
---
diff --git a/src/connection-editor/ce-page-bond.ui b/src/connection-editor/ce-page-bond.ui
index 8632d33..c541ffb 100644
--- a/src/connection-editor/ce-page-bond.ui
+++ b/src/connection-editor/ce-page-bond.ui
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.15.4 on Wed Sep 25 12:38:16 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="bond_downdelay_adjustment">
@@ -73,8 +74,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
- <property name="column_spacing">12</property>
<property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="master_connections_label">
<property name="visible">True</property>
@@ -102,6 +103,8 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -119,6 +122,8 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -220,6 +225,7 @@
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -233,7 +239,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -271,7 +279,9 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -286,6 +296,8 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -297,6 +309,8 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -310,7 +324,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -327,7 +343,9 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -341,7 +359,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -353,7 +373,9 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -367,7 +389,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -381,7 +405,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -394,7 +420,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
<property name="adjustment">bond_updelay_adjustment</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
@@ -421,7 +446,9 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -434,7 +461,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
<property name="adjustment">bond_downdelay_adjustment</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
@@ -461,7 +487,39 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="bond_primary_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Primary:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">bond_primary</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="bond_primary">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">The interface name of the primary device. If set,
this device will always be the active slave when it is available.</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
</object>
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index 5f09896..cf6abc3 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -46,6 +46,8 @@ typedef struct {
GtkWindow *toplevel;
GtkComboBox *mode;
+ GtkEntry *primary;
+ GtkWidget *primary_label;
GtkComboBox *monitoring;
GtkSpinButton *frequency;
GtkSpinButton *updelay;
@@ -78,6 +80,8 @@ bond_private_init (CEPageBond *self)
builder = CE_PAGE (self)->builder;
priv->mode = GTK_COMBO_BOX (gtk_builder_get_object (builder, "bond_mode"));
+ priv->primary = GTK_ENTRY (gtk_builder_get_object (builder, "bond_primary"));
+ priv->primary_label = GTK_WIDGET (gtk_builder_get_object (builder, "bond_primary_label"));
priv->monitoring = GTK_COMBO_BOX (gtk_builder_get_object (builder, "bond_monitoring"));
priv->frequency = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_frequency"));
priv->updelay = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_updelay"));
@@ -135,15 +139,24 @@ bonding_mode_changed (GtkComboBox *combo, gpointer user_data)
{
CEPageBond *self = user_data;
CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
+ int mode;
- /* balance-tlb and balance-alb work only with MII monitoring */
- if ( gtk_combo_box_get_active (combo) == MODE_BALANCE_TLB
- || gtk_combo_box_get_active (combo) == MODE_BALANCE_ALB) {
+ mode = gtk_combo_box_get_active (combo);
+
+ if (mode == MODE_BALANCE_TLB || mode == MODE_BALANCE_ALB) {
gtk_combo_box_set_active (priv->monitoring, MONITORING_MII);
gtk_widget_set_sensitive (GTK_WIDGET (priv->monitoring), FALSE);
} else {
gtk_widget_set_sensitive (GTK_WIDGET (priv->monitoring), TRUE);
}
+
+ if (mode == MODE_ACTIVE_BACKUP) {
+ gtk_widget_show (GTK_WIDGET (priv->primary));
+ gtk_widget_show (GTK_WIDGET (priv->primary_label));
+ } else {
+ gtk_widget_hide (GTK_WIDGET (priv->primary));
+ gtk_widget_hide (GTK_WIDGET (priv->primary_label));
+ }
}
static void
@@ -266,7 +279,7 @@ populate_ui (CEPageBond *self)
{
CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
NMSettingBond *setting = priv->setting;
- const char *mode, *frequency, *updelay, *downdelay, *raw_targets;
+ const char *mode, *primary, *frequency, *updelay, *downdelay, *raw_targets;
char *targets;
int mode_idx = MODE_BALANCE_RR;
@@ -294,6 +307,10 @@ populate_ui (CEPageBond *self)
self);
bonding_mode_changed (priv->mode, self);
+ /* Primary */
+ primary = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_PRIMARY);
+ gtk_entry_set_text (priv->primary, primary ? primary : "");
+
/* Monitoring mode/frequency */
frequency = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
if (frequency) {
@@ -384,6 +401,7 @@ finish_setup (CEPageBond *self, gpointer unused, GError *error, gpointer user_da
populate_ui (self);
g_signal_connect (priv->mode, "changed", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->primary, "changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->monitoring, "changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->frequency, "value-changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->updelay, "value-changed", G_CALLBACK (stuff_changed), self);
@@ -438,6 +456,7 @@ ui_to_setting (CEPageBond *self)
const char *frequency;
const char *updelay;
const char *downdelay;
+ const char *primary = NULL;
char *targets;
/* Mode */
@@ -447,6 +466,7 @@ ui_to_setting (CEPageBond *self)
break;
case MODE_ACTIVE_BACKUP:
mode = "active-backup";
+ primary = gtk_entry_get_text (priv->primary);
break;
case MODE_BALANCE_XOR:
mode = "balance-xor";
@@ -468,15 +488,20 @@ ui_to_setting (CEPageBond *self)
break;
}
+ /* Set bond mode and primary */
+ nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MODE, mode);
+
+ if (primary && *primary)
+ nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY, primary);
+ else
+ nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY);
+
/* Monitoring mode/frequency */
frequency = gtk_entry_get_text (GTK_ENTRY (priv->frequency));
updelay = gtk_entry_get_text (GTK_ENTRY (priv->updelay));
downdelay = gtk_entry_get_text (GTK_ENTRY (priv->downdelay));
targets = uglify_targets (gtk_entry_get_text (priv->arp_targets));
- /* Set bond mode */
- nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MODE, mode);
-
switch (gtk_combo_box_get_active (priv->monitoring)) {
case MONITORING_MII:
nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MIIMON, frequency);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]