static void slaves_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NmtPageBond *bond = NMT_PAGE_BOND (user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); GPtrArray *slaves; g_object_get (object, "connections", &slaves, NULL); if (slaves->len == 0) { if (priv->slave_type == G_TYPE_NONE) return; priv->slave_type = G_TYPE_NONE; } else { NMConnection *slave = slaves->pdata[0]; if (priv->slave_type != G_TYPE_NONE) return; if (nm_connection_is_type (slave, NM_SETTING_INFINIBAND_SETTING_NAME)) priv->slave_type = NM_TYPE_SETTING_INFINIBAND; else priv->slave_type = NM_TYPE_SETTING_WIRED; } if (priv->slave_type == NM_TYPE_SETTING_INFINIBAND) { nmt_newt_popup_set_active_id (priv->mode, "active-backup"); nmt_newt_component_set_sensitive (NMT_NEWT_COMPONENT (priv->mode), FALSE); } else nmt_newt_component_set_sensitive (NMT_NEWT_COMPONENT (priv->mode), TRUE); }
static void mode_widget_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NmtPageBond *bond = NMT_PAGE_BOND (user_data); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); const char *mode; if (priv->updating) return; mode = nmt_newt_popup_get_active_id (priv->mode); priv->updating = TRUE; nm_setting_bond_add_option (priv->s_bond, NM_SETTING_BOND_OPTION_MODE, mode); priv->updating = FALSE; if (!strcmp (mode, "balance-tlb") || !strcmp (mode, "balance-alb")) { nmt_newt_popup_set_active (priv->monitoring, NMT_PAGE_BOND_MONITORING_MII); nmt_newt_component_set_sensitive (NMT_NEWT_COMPONENT (priv->monitoring), FALSE); } else nmt_newt_component_set_sensitive (NMT_NEWT_COMPONENT (priv->monitoring), TRUE); if (!strcmp (mode, "active-backup")) { nmt_newt_widget_set_visible (NMT_NEWT_WIDGET (priv->primary), TRUE); nm_setting_bond_add_option (priv->s_bond, NM_SETTING_BOND_OPTION_PRIMARY, nmt_newt_entry_get_text (priv->primary)); } else { nmt_newt_widget_set_visible (NMT_NEWT_WIDGET (priv->primary), FALSE); nm_setting_bond_remove_option (priv->s_bond, NM_SETTING_BOND_OPTION_PRIMARY); } }
static void listbox_active_changed (GObject *object, GParamSpec *pspec, gpointer button) { NmtConnectConnectionList *list = NMT_CONNECT_CONNECTION_LIST (object); static const char *activate, *deactivate; static int deactivate_padding, activate_padding; NMActiveConnection *ac; gboolean has_selection; if (G_UNLIKELY (activate == NULL)) { int activate_width, deactivate_width; activate = _("Activate"); activate_width = nmt_newt_text_width (activate); deactivate = _("Deactivate"); deactivate_width = nmt_newt_text_width (deactivate); activate_padding = MAX (0, deactivate_width - activate_width); deactivate_padding = MAX (0, activate_width - deactivate_width); } has_selection = nmt_connect_connection_list_get_selection (list, NULL, NULL, NULL, &ac); nmt_newt_component_set_sensitive (button, has_selection); if (has_selection && ac) { nmt_newt_button_set_label (button, deactivate); nmt_newt_widget_set_padding (button, 0, 0, deactivate_padding, 0); } else { nmt_newt_button_set_label (button, activate); nmt_newt_widget_set_padding (button, 0, 0, activate_padding, 0); } }