static void
populate_ui (CEPageInfiniband *self)
{
	CEPageInfinibandPrivate *priv = CE_PAGE_INFINIBAND_GET_PRIVATE (self);
	NMSettingInfiniband *setting = priv->setting;
	const char *mode;
	int mode_idx = TRANSPORT_MODE_DATAGRAM;
	int mtu_def;
	char **mac_list;
	const GByteArray *s_mac;
	char *s_mac_str;

	/* Port */
	mode = nm_setting_infiniband_get_transport_mode (setting);
	if (mode) {
		if (!strcmp (mode, "datagram"))
			mode_idx = TRANSPORT_MODE_DATAGRAM;
		else if (!strcmp (mode, "connected"))
			mode_idx = TRANSPORT_MODE_CONNECTED;
	}
	gtk_combo_box_set_active (priv->transport_mode, mode_idx);

	/* Device MAC address */
	mac_list = ce_page_get_mac_list (CE_PAGE (self), NM_TYPE_DEVICE_INFINIBAND,
	                                 NM_DEVICE_INFINIBAND_HW_ADDRESS);
	s_mac = nm_setting_infiniband_get_mac_address (setting);
	s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_INFINIBAND) : NULL;
	ce_page_setup_mac_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->device_mac),
	                         s_mac_str, mac_list);
	g_free (s_mac_str);
	g_strfreev (mac_list);
	g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* MTU */
	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_INFINIBAND_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));

	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_infiniband_get_mtu (setting));
}
예제 #2
0
static void
populate_ui (CEPageBond *self)
{
	CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
	NMSettingBond *setting = priv->setting;
	const char *mode, *primary, *frequency, *updelay, *downdelay, *raw_targets;
	char *targets;
	int mode_idx = MODE_BALANCE_RR;
	guint32 mtu_def, mtu_val;

	/* Mode */
	mode = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_MODE);
	if (mode) {
		if (!strcmp (mode, "balance-rr"))
			mode_idx = MODE_BALANCE_RR;
		else if (!strcmp (mode, "active-backup"))
			mode_idx = MODE_ACTIVE_BACKUP;
		else if (!strcmp (mode, "balance-xor"))
			mode_idx = MODE_BALANCE_XOR;
		else if (!strcmp (mode, "broadcast"))
			mode_idx = MODE_BROADCAST;
		else if (!strcmp (mode, "802.3ad"))
			mode_idx = MODE_802_3AD;
		else if (!strcmp (mode, "balance-tlb"))
			mode_idx = MODE_BALANCE_TLB;
		else if (!strcmp (mode, "balance-alb"))
			mode_idx = MODE_BALANCE_ALB;
	}
	gtk_combo_box_set_active (priv->mode, mode_idx);
	g_signal_connect (priv->mode, "changed",
	                  G_CALLBACK (bonding_mode_changed),
	                  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) {
		gtk_combo_box_set_active (priv->monitoring, MONITORING_ARP);
	} else {
		gtk_combo_box_set_active (priv->monitoring, MONITORING_MII);
		frequency = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_MIIMON);
	}
	g_signal_connect (priv->monitoring, "changed",
	                  G_CALLBACK (monitoring_mode_changed),
	                  self);
	monitoring_mode_changed (priv->monitoring, self);

	if (frequency)
		gtk_spin_button_set_value (priv->frequency, (gdouble) atoi (frequency));
	else
		gtk_spin_button_set_value (priv->frequency, 0.0);
	g_signal_connect (priv->frequency, "value-changed",
	                  G_CALLBACK (frequency_changed),
	                  self);

	updelay = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_UPDELAY);
	if (updelay)
		gtk_spin_button_set_value (priv->updelay, (gdouble) atoi (updelay));
	else
		gtk_spin_button_set_value (priv->updelay, 0.0);
	g_signal_connect (priv->updelay, "value-changed",
	                  G_CALLBACK (delay_changed),
	                  self);
	downdelay = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_DOWNDELAY);
	if (downdelay)
		gtk_spin_button_set_value (priv->downdelay, (gdouble) atoi (downdelay));
	else
		gtk_spin_button_set_value (priv->downdelay, 0.0);
	g_signal_connect (priv->downdelay, "value-changed",
	                  G_CALLBACK (delay_changed),
	                  self);

	/* ARP targets */
	raw_targets = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
	targets = prettify_targets (raw_targets);
	if (targets) {
		gtk_entry_set_text (priv->arp_targets, targets);
		g_free (targets);
	}

	/* 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);
}
예제 #3
0
static void
populate_ui (CEPageWired *self)
{
	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
	NMSettingWired *setting = priv->setting;
	const char *port;
	const char *duplex;
	int port_idx = PORT_DEFAULT;
	int speed_idx;
	int mtu_def;
	char **mac_list, **iter;
	const GByteArray *s_mac;
	char *s_mac_str;
	char *active_mac = NULL;
	GtkWidget *entry;

	/* Port */
	port = nm_setting_wired_get_port (setting);
	if (port) {
		if (!strcmp (port, "tp"))
			port_idx = PORT_TP;
		else if (!strcmp (port, "aui"))
			port_idx = PORT_AUI;
		else if (!strcmp (port, "bnc"))
			port_idx = PORT_BNC;
		else if (!strcmp (port, "mii"))
			port_idx = PORT_MII;
	}
	gtk_combo_box_set_active (priv->port, port_idx);

	/* Speed */
	switch (nm_setting_wired_get_speed (setting)) {
	case 10:
		speed_idx = SPEED_10;
		break;
	case 100:
		speed_idx = SPEED_100;
		break;
	case 1000:
		speed_idx = SPEED_1000;
		break;
	case 10000:
		speed_idx = SPEED_10000;
		break;
	default:
		speed_idx = SPEED_DEFAULT;
		break;
	}
	gtk_combo_box_set_active (priv->speed, speed_idx);

	/* Duplex */
	duplex = nm_setting_wired_get_duplex (setting);
	if (duplex && !strcmp (duplex, "half"))
		gtk_toggle_button_set_active (priv->duplex, FALSE);
	else
		gtk_toggle_button_set_active (priv->duplex, TRUE);

	/* Autonegotiate */
	gtk_toggle_button_set_active (priv->autonegotiate, 
	                              nm_setting_wired_get_auto_negotiate (setting));

	/* Device MAC address */
	mac_list = ce_page_get_mac_list (CE_PAGE (self));
	s_mac = nm_setting_wired_get_mac_address (setting);
	s_mac_str = s_mac ? g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
	                                     s_mac->data[0], s_mac->data[1], s_mac->data[2],
	                                     s_mac->data[3], s_mac->data[4], s_mac->data[5]):
	                    NULL;

	for (iter = mac_list; iter && *iter; iter++) {
#if GTK_CHECK_VERSION (2,24,0)
		gtk_combo_box_text_append_text (priv->device_mac, *iter);
#else
		gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_mac), *iter);
#endif
		if (s_mac_str && g_ascii_strncasecmp (*iter, s_mac_str, 17) == 0)
			active_mac = *iter;
	}

	if (s_mac_str) {
		if (!active_mac) {
#if GTK_CHECK_VERSION (2,24,0)
			gtk_combo_box_text_prepend_text (priv->device_mac, s_mac_str);
#else
			gtk_combo_box_prepend_text (GTK_COMBO_BOX (priv->device_mac), s_mac_str);
#endif
		}

		entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
		if (entry)
			gtk_entry_set_text (GTK_ENTRY (entry), active_mac ? active_mac : s_mac_str);
	}
	g_strfreev (mac_list);
	g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* Cloned MAC address */
	ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting), priv->cloned_mac);
	g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* MTU */
	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));

	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
}
static void
populate_ui (CEPageEthernet *self)
{
	CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
	NMSettingWired *setting = priv->setting;
	const char *port;
	const char *duplex;
	int port_idx = PORT_DEFAULT;
	int speed_idx;
	int mtu_def;
	char **mac_list;
	const GByteArray *s_mac;
	char *s_mac_str;

	/* Port */
	port = nm_setting_wired_get_port (setting);
	if (port) {
		if (!strcmp (port, "tp"))
			port_idx = PORT_TP;
		else if (!strcmp (port, "aui"))
			port_idx = PORT_AUI;
		else if (!strcmp (port, "bnc"))
			port_idx = PORT_BNC;
		else if (!strcmp (port, "mii"))
			port_idx = PORT_MII;
	}
	gtk_combo_box_set_active (priv->port, port_idx);

	/* Speed */
	switch (nm_setting_wired_get_speed (setting)) {
	case 10:
		speed_idx = SPEED_10;
		break;
	case 100:
		speed_idx = SPEED_100;
		break;
	case 1000:
		speed_idx = SPEED_1000;
		break;
	case 10000:
		speed_idx = SPEED_10000;
		break;
	default:
		speed_idx = SPEED_DEFAULT;
		break;
	}
	gtk_combo_box_set_active (priv->speed, speed_idx);

	/* Duplex */
	duplex = nm_setting_wired_get_duplex (setting);
	if (duplex && !strcmp (duplex, "half"))
		gtk_toggle_button_set_active (priv->duplex, FALSE);
	else
		gtk_toggle_button_set_active (priv->duplex, TRUE);

	/* Autonegotiate */
	gtk_toggle_button_set_active (priv->autonegotiate, 
	                              nm_setting_wired_get_auto_negotiate (setting));

	/* Device MAC address */
	mac_list = ce_page_get_mac_list (CE_PAGE (self), NM_TYPE_DEVICE_ETHERNET,
	                                 NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
	s_mac = nm_setting_wired_get_mac_address (setting);
	s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
	ce_page_setup_mac_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->device_mac),
	                         s_mac_str, mac_list);
	g_free (s_mac_str);
	g_strfreev (mac_list);
	g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* Cloned MAC address */
	ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting),
	                      ARPHRD_ETHER, priv->cloned_mac);
	g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self);

	/* MTU */
	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));

	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
}
예제 #5
0
static void
populate_ui (CEPageWired *self)
{
	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
	NMSettingWired *setting = priv->setting;
	const char *port;
	const char *duplex;
	int port_idx = PORT_DEFAULT;
	int speed_idx;
	int mtu_def;

	/* Port */
	port = nm_setting_wired_get_port (setting);
	if (port) {
		if (!strcmp (port, "tp"))
			port_idx = PORT_TP;
		else if (!strcmp (port, "aui"))
			port_idx = PORT_AUI;
		else if (!strcmp (port, "bnc"))
			port_idx = PORT_BNC;
		else if (!strcmp (port, "mii"))
			port_idx = PORT_MII;
	}
	gtk_combo_box_set_active (priv->port, port_idx);

	/* Speed */
	switch (nm_setting_wired_get_speed (setting)) {
	case 10:
		speed_idx = SPEED_10;
		break;
	case 100:
		speed_idx = SPEED_100;
		break;
	case 1000:
		speed_idx = SPEED_1000;
		break;
	case 10000:
		speed_idx = SPEED_10000;
		break;
	default:
		speed_idx = SPEED_DEFAULT;
		break;
	}
	gtk_combo_box_set_active (priv->speed, speed_idx);

	/* Duplex */
	duplex = nm_setting_wired_get_duplex (setting);
	if (duplex && !strcmp (duplex, "half"))
		gtk_toggle_button_set_active (priv->duplex, FALSE);
	else
		gtk_toggle_button_set_active (priv->duplex, TRUE);

	/* Autonegotiate */
	gtk_toggle_button_set_active (priv->autonegotiate, 
	                              nm_setting_wired_get_auto_negotiate (setting));

	/* MAC address */
	ce_page_mac_to_entry (nm_setting_wired_get_mac_address (setting), priv->mac);
	g_signal_connect (priv->mac, "changed", G_CALLBACK (stuff_changed), self);

	/* MTU */
	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));

	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
}
예제 #6
0
static void
populate_ui (CEPageVlan *self)
{
    CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self);
    GSList *devices, *d_iter;
    NMConnection *parent_connection = NULL;
    NMDevice *device, *parent_device = NULL;
    const char *parent, *iface, *current_parent;
    int i, mtu_def, mtu_val;

    devices = get_vlan_devices (self);

    /* Parent */
    build_vlan_parent_list (self, devices);

    parent = nm_setting_vlan_get_parent (priv->setting);
    if (parent) {
        /* UUID? */
        parent_connection = (NMConnection *)nm_remote_settings_get_connection_by_uuid (CE_PAGE (self)->settings, parent);
        if (!parent_connection) {
            /* Interface name? */
            for (d_iter = devices; d_iter; d_iter = d_iter->next) {
                device = d_iter->data;

                if (!g_strcmp0 (parent, nm_device_get_iface (device))) {
                    parent_device = device;
                    break;
                }
            }
        }
    }

    /* If NMSettingVlan:parent didn't indicate a device, but we have a
     * wired setting, figure out the device from that.
     */
    if (priv->s_hw && !parent_device) {
        const GByteArray *mac;
        const char *device_mac_str;
        char *mac_str;

        if (NM_IS_SETTING_WIRED (priv->s_hw))
            mac = nm_setting_wired_get_mac_address (NM_SETTING_WIRED (priv->s_hw));
        else
            mac = NULL;

        if (mac) {
            mac_str = nm_utils_hwaddr_ntoa (mac->data, ARPHRD_ETHER);

            for (d_iter = devices; d_iter; d_iter = d_iter->next) {
                device = d_iter->data;

                if (NM_IS_DEVICE_ETHERNET (device))
                    device_mac_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device));
                else
                    device_mac_str = NULL;

                if (!g_strcmp0 (mac_str, device_mac_str)) {
                    parent_device = device;
                    break;
                }
            }
        }
    }

    current_parent = parent;
    if (parent_device || parent_connection) {
        for (i = 0; priv->parents[i]; i++) {
            if (parent_device && parent_device != priv->parents[i]->device)
                continue;
            if (parent_connection != priv->parents[i]->connection)
                continue;

            current_parent = priv->parents[i]->label;
            break;
        }
    }
    ce_page_setup_mac_combo (CE_PAGE (self), priv->parent, current_parent, priv->parent_labels);
    g_signal_connect (priv->parent, "changed", G_CALLBACK (parent_changed), self);

    if (current_parent)
        priv->last_parent = g_strndup (current_parent, strcspn (current_parent, " "));

    /* Name */
    iface = nm_setting_vlan_get_interface_name (priv->setting);
    if (iface)
        gtk_entry_set_text (priv->name_entry, iface);
    g_signal_connect (priv->name_entry, "changed", G_CALLBACK (name_changed), self);

    /* ID */
    priv->last_id = nm_setting_vlan_get_id (priv->setting);
    gtk_spin_button_set_value (priv->id_entry, priv->last_id);
    g_signal_connect (priv->id_entry, "value-changed", G_CALLBACK (id_changed), self);

    /* Cloned MAC address */
    if (NM_IS_SETTING_WIRED (priv->s_hw)) {
        ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (NM_SETTING_WIRED (priv->s_hw)),
                              ARPHRD_ETHER, priv->cloned_mac);
    }
    g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self);

    /* MTU */
    if (NM_IS_SETTING_WIRED (priv->s_hw)) {
        mtu_def = ce_get_property_default (priv->s_hw, NM_SETTING_WIRED_MTU);
        mtu_val = nm_setting_wired_get_mtu (NM_SETTING_WIRED (priv->s_hw));
    } else {
        mtu_def = mtu_val = 1500;
    }
    g_signal_connect (priv->mtu, "output",
                      G_CALLBACK (ce_spin_output_with_default),
                      GINT_TO_POINTER (mtu_def));

    gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
    g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);

    g_slist_free (devices);
}
예제 #7
0
static void
populate_ui (CEPageWifi *self)
{
	CEPageWifiPrivate *priv = CE_PAGE_WIFI_GET_PRIVATE (self);
	NMSettingWireless *setting = priv->setting;
	GBytes *ssid;
	const char *mode;
	const char *band;
	int band_idx = 0;
	int rate_def;
	int tx_power_def;
	int mtu_def;
	char *utf8_ssid;
	const char *s_ifname, *s_mac, *s_bssid;
	GPtrArray *bssid_array;
	char **bssid_list;
	guint32 idx;

	rate_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_RATE);
	g_signal_connect (priv->rate, "output",
	                  G_CALLBACK (ce_spin_output_with_automatic),
	                  GINT_TO_POINTER (rate_def));
	g_signal_connect_swapped (priv->rate, "value-changed", G_CALLBACK (ce_page_changed), self);

	tx_power_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_TX_POWER);
	g_signal_connect (priv->tx_power, "output",
	                  G_CALLBACK (ce_spin_output_with_automatic),
	                  GINT_TO_POINTER (tx_power_def));
	g_signal_connect_swapped (priv->tx_power, "value-changed", G_CALLBACK (ce_page_changed), self);

	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_automatic),
	                  GINT_TO_POINTER (mtu_def));
	g_signal_connect_swapped (priv->mtu, "value-changed", G_CALLBACK (ce_page_changed), self);

	ssid = nm_setting_wireless_get_ssid (setting);
	mode = nm_setting_wireless_get_mode (setting);
	band = nm_setting_wireless_get_band (setting);

	if (ssid)
		utf8_ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
		                                   g_bytes_get_size (ssid));
	else
		utf8_ssid = g_strdup ("");
	gtk_entry_set_text (priv->ssid, utf8_ssid);
	g_signal_connect_swapped (priv->ssid, "changed", G_CALLBACK (ce_page_changed), self);
	g_free (utf8_ssid);

	/* Default to Infrastructure */
	gtk_combo_box_set_active (priv->mode, 0);
	if (!g_strcmp0 (mode, "ap"))
		gtk_combo_box_set_active (priv->mode, 1);
	if (!g_strcmp0 (mode, "adhoc"))
		gtk_combo_box_set_active (priv->mode, 2);
	mode_combo_changed_cb (priv->mode, self);
	g_signal_connect (priv->mode, "changed", G_CALLBACK (mode_combo_changed_cb), self);

	g_signal_connect (priv->channel, "output",
	                  G_CALLBACK (channel_spin_output_cb),
	                  self);
	g_signal_connect (priv->channel, "input",
	                  G_CALLBACK (channel_spin_input_cb),
	                  self);

	gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), FALSE);
	if (band) {
		if (!strcmp (band, "a")) {
			band_idx = 1;
			gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
		} else if (!strcmp (band, "bg")) {
			band_idx = 2;
			gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
		}
	}

	gtk_combo_box_set_active (priv->band, band_idx);
	g_signal_connect (priv->band, "changed",
	                  G_CALLBACK (band_value_changed_cb),
	                  self);

	/* Update the channel _after_ the band has been set so that it gets
	 * the right values */
	priv->last_channel = nm_setting_wireless_get_channel (setting);
	gtk_spin_button_set_value (priv->channel, (gdouble) priv->last_channel);
	g_signal_connect_swapped (priv->channel, "value-changed", G_CALLBACK (ce_page_changed), self);

	/* BSSID */
	bssid_array = g_ptr_array_new ();
	for (idx = 0; idx < nm_setting_wireless_get_num_seen_bssids (setting); idx++)
		g_ptr_array_add (bssid_array, g_strdup (nm_setting_wireless_get_seen_bssid (setting, idx)));
	g_ptr_array_add (bssid_array, NULL);
	bssid_list = (char **) g_ptr_array_free (bssid_array, FALSE);
	s_bssid = nm_setting_wireless_get_bssid (setting);
	ce_page_setup_mac_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->bssid),
	                         s_bssid, bssid_list);
	g_strfreev (bssid_list);
	g_signal_connect_swapped (priv->bssid, "changed", G_CALLBACK (ce_page_changed), self);

	/* Device MAC address */
        s_ifname = nm_connection_get_interface_name (CE_PAGE (self)->connection);
	s_mac = nm_setting_wireless_get_mac_address (setting);
	ce_page_setup_device_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->device_combo),
	                            NM_TYPE_DEVICE_WIFI, s_ifname,
	                            s_mac, NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, TRUE);
	g_signal_connect_swapped (priv->device_combo, "changed", G_CALLBACK (ce_page_changed), self);

	/* Cloned MAC address */
	s_mac = nm_setting_wireless_get_cloned_mac_address (setting);
	if (s_mac)
		gtk_entry_set_text (priv->cloned_mac, s_mac);
	g_signal_connect_swapped (priv->cloned_mac, "changed", G_CALLBACK (ce_page_changed), self);

	gtk_spin_button_set_value (priv->rate, (gdouble) nm_setting_wireless_get_rate (setting));
	gtk_spin_button_set_value (priv->tx_power, (gdouble) nm_setting_wireless_get_tx_power (setting));
	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wireless_get_mtu (setting));
}
static void
connect_ethernet_page (CEPageEthernet *page)
{
        NMSettingWired *setting = page->setting_wired;
        NMSettingConnection *sc;
        int mtu_def;
        char **mac_list;
        const GByteArray *s_mac;
        char *s_mac_str;
        GtkWidget *widget;
        const gchar *name;

        name = nm_setting_connection_get_id (page->setting_connection);
        gtk_entry_set_text (page->name, name);

        /* Device MAC address */
        mac_list = ce_page_get_mac_list (CE_PAGE (page)->client, NM_TYPE_DEVICE_ETHERNET,
                                         NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
        s_mac = nm_setting_wired_get_mac_address (setting);
        s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
        ce_page_setup_mac_combo (page->device_mac, s_mac_str, mac_list);
        g_free (s_mac_str);
        g_strfreev (mac_list);
        g_signal_connect_swapped (page->device_mac, "changed", G_CALLBACK (ce_page_changed), page);

        /* Cloned MAC address */
        ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting),
                              ARPHRD_ETHER, page->cloned_mac);
        g_signal_connect_swapped (page->cloned_mac, "changed", G_CALLBACK (ce_page_changed), page);

        /* MTU */
        mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRED_MTU);
        g_signal_connect (page->mtu, "output",
                          G_CALLBACK (ce_spin_output_with_default),
                          GINT_TO_POINTER (mtu_def));
        gtk_spin_button_set_value (page->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
        g_signal_connect (page->mtu, "value-changed",
                          G_CALLBACK (mtu_changed), page);
        mtu_changed (page->mtu, page);

        g_signal_connect_swapped (page->name, "changed", G_CALLBACK (ce_page_changed), page);
        g_signal_connect_swapped (page->mtu, "value-changed", G_CALLBACK (ce_page_changed), page);

        widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
                                                     "auto_connect_check"));
        sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
        g_object_bind_property (sc, "autoconnect",
                                widget, "active",
                                G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
        g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ce_page_changed), page);

        widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
                                                     "all_user_check"));
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
                                      nm_setting_connection_get_num_permissions (sc) == 0);
        g_signal_connect (widget, "toggled",
                          G_CALLBACK (all_user_changed), page);
        g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ce_page_changed), page);

        widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_zone"));
        firewall_ui_setup (sc, widget, CE_PAGE (page)->cancellable);
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);

}
예제 #9
0
static void
populate_ui (CEPageWireless *self)
{
	CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
	NMSettingWireless *setting = priv->setting;
	const GByteArray *ssid = NULL;
	const char *mode = NULL;
	const char *band = NULL;
	int band_idx = 0;
	int rate_def;
	int tx_power_def;
	int mtu_def;
	char *utf8_ssid;

	rate_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_RATE);
	g_signal_connect (priv->rate, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (rate_def));
	g_signal_connect_swapped (priv->rate, "value-changed", G_CALLBACK (ce_page_changed), self);

	tx_power_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_TX_POWER);
	g_signal_connect (priv->tx_power, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (tx_power_def));
	g_signal_connect_swapped (priv->tx_power, "value-changed", G_CALLBACK (ce_page_changed), self);

	mtu_def = ce_get_property_default (NM_SETTING (setting), NM_SETTING_WIRELESS_MTU);
	g_signal_connect (priv->mtu, "output",
	                  G_CALLBACK (ce_spin_output_with_default),
	                  GINT_TO_POINTER (mtu_def));
	g_signal_connect_swapped (priv->mtu, "value-changed", G_CALLBACK (ce_page_changed), self);

	g_object_get (setting,
				  NM_SETTING_WIRELESS_SSID, &ssid,
				  NM_SETTING_WIRELESS_MODE, &mode,
				  NM_SETTING_WIRELESS_BAND, &band,
				  NULL);

	if (ssid)
		utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
	else
		utf8_ssid = g_strdup ("");
	gtk_entry_set_text (priv->ssid, utf8_ssid);
	g_signal_connect_swapped (priv->ssid, "changed", G_CALLBACK (ce_page_changed), self);
	g_free (utf8_ssid);

	/* Default to Infrastructure */
	gtk_combo_box_set_active (priv->mode, 0);
	if (mode && !strcmp (mode, "adhoc"))
		gtk_combo_box_set_active (priv->mode, 1);
	g_signal_connect_swapped (priv->mode, "changed", G_CALLBACK (ce_page_changed), self);

	g_signal_connect (priv->channel, "output",
	                  G_CALLBACK (channel_spin_output_cb),
	                  self);
	g_signal_connect (priv->channel, "input",
	                  G_CALLBACK (channel_spin_input_cb),
	                  self);

	gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), FALSE);
	if (band) {
		if (!strcmp (band ? band : "", "a")) {
			band_idx = 1;
			gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
		} else if (!strcmp (band ? band : "", "bg")) {
			band_idx = 2;
			gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
		}
	}

	gtk_combo_box_set_active (priv->band, band_idx);
	g_signal_connect (priv->band, "changed",
	                  G_CALLBACK (band_value_changed_cb),
	                  self);

	/* Update the channel _after_ the band has been set so that it gets
	 * the right values */
	priv->last_channel = nm_setting_wireless_get_channel (setting);
	gtk_spin_button_set_value (priv->channel, (gdouble) priv->last_channel);
	g_signal_connect_swapped (priv->channel, "value-changed", G_CALLBACK (ce_page_changed), self);

	/* BSSID */
	ce_page_mac_to_entry (nm_setting_wireless_get_bssid (setting), priv->bssid);
	g_signal_connect_swapped (priv->bssid, "changed", G_CALLBACK (ce_page_changed), self);

	/* MAC address */
	ce_page_mac_to_entry (nm_setting_wireless_get_mac_address (setting), priv->mac);
	g_signal_connect_swapped (priv->mac, "changed", G_CALLBACK (ce_page_changed), self);

	gtk_spin_button_set_value (priv->rate, (gdouble) nm_setting_wireless_get_rate (setting));
	gtk_spin_button_set_value (priv->tx_power, (gdouble) nm_setting_wireless_get_tx_power (setting));
	gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wireless_get_mtu (setting));
}