示例#1
0
static void
nmt_page_team_constructed (GObject *object)
{
	NmtPageTeam *team = NMT_PAGE_TEAM (object);
	NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (team);
	NmtEditorSection *section;
	NmtNewtGrid *grid;
	NMSettingTeam *s_team;
	NmtNewtWidget *widget;
	NMConnection *conn;

	conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (team));
	s_team = nm_connection_get_setting_team (conn);
	if (!s_team) {
		nm_connection_add_setting (conn, nm_setting_team_new ());
		s_team = nm_connection_get_setting_team (conn);
	}
	priv->s_team = s_team;

	section = nmt_editor_section_new (_("TEAM"), NULL, TRUE);

	widget = nmt_newt_grid_new ();
	nmt_editor_grid_append (nmt_editor_section_get_body (section), NULL, widget, NULL);

	grid = NMT_NEWT_GRID (widget);

	widget = nmt_newt_label_new (_("Slaves"));
	nmt_newt_grid_add (grid, widget, 0, 0);

	widget = nmt_slave_list_new (conn, team_connection_type_filter, team);
	g_signal_connect (widget, "notify::connections",
	                  G_CALLBACK (slaves_changed), team);
	nmt_newt_grid_add (grid, widget, 0, 1);
	nmt_newt_widget_set_padding (widget, 0, 0, 0, 1);
	priv->slaves = NMT_SLAVE_LIST (widget);
	slaves_changed (G_OBJECT (priv->slaves), NULL, team);

	widget = nmt_newt_label_new (_("JSON configuration"));
	nmt_newt_grid_add (grid, widget, 0, 2);

	widget = nmt_newt_textbox_new (NMT_NEWT_TEXTBOX_SCROLLABLE | NMT_NEWT_TEXTBOX_SET_BACKGROUND, 60);
	g_object_bind_property (s_team, NM_SETTING_TEAM_CONFIG,
	                        widget, "text",
	                        G_BINDING_SYNC_CREATE);
	nmt_newt_grid_add (grid, widget, 0, 3);
	nmt_newt_widget_set_padding (widget, 2, 0, 2, 1);

	widget = nmt_newt_button_new (_("Edit..."));
	g_signal_connect (widget, "clicked", G_CALLBACK (edit_clicked), team);
	nmt_newt_grid_add (grid, widget, 0, 4);

	nmt_editor_page_add_section (NMT_EDITOR_PAGE (team), section);

	G_OBJECT_CLASS (nmt_page_team_parent_class)->constructed (object);
}
示例#2
0
static void
nmt_page_bond_constructed (GObject *object)
{
	NmtPageBond *bond = NMT_PAGE_BOND (object);
	NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond);
	NmtEditorSection *section;
	NmtEditorGrid *grid;
	NMSettingBond *s_bond;
	NmtNewtWidget *widget, *label;
	NMConnection *conn;

	conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (bond));
	s_bond = nm_connection_get_setting_bond (conn);
	if (!s_bond) {
		nm_connection_add_setting (conn, nm_setting_bond_new ());
		s_bond = nm_connection_get_setting_bond (conn);
	}
	priv->s_bond = s_bond;

	section = nmt_editor_section_new (_("BOND"), NULL, TRUE);
	grid = nmt_editor_section_get_body (section);

	widget = nmt_newt_separator_new ();
	nmt_editor_grid_append (grid, _("Slaves"), widget, NULL);
	nmt_editor_grid_set_row_flags (grid, widget, NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT);

	widget = nmt_slave_list_new (conn, bond_connection_type_filter, bond);
	g_signal_connect (widget, "notify::connections",
	                  G_CALLBACK (slaves_changed), bond);
	nmt_editor_grid_append (grid, NULL, widget, NULL);
	priv->slaves = NMT_SLAVE_LIST (widget);

	widget = nmt_newt_popup_new (bond_mode);
	g_signal_connect (widget, "notify::active-id",
	                  G_CALLBACK (mode_widget_changed), bond);
	nmt_editor_grid_append (grid, _("Mode"), widget, NULL);
	priv->mode = NMT_NEWT_POPUP (widget);

	widget = nmt_newt_entry_new (40, 0);
	g_signal_connect (widget, "notify::text",
	                  G_CALLBACK (primary_widget_changed), bond);
	nmt_editor_grid_append (grid, _("Primary"), widget, NULL);
	priv->primary = NMT_NEWT_ENTRY (widget);

	widget = nmt_newt_popup_new (bond_monitoring);
	g_signal_connect (widget, "notify::active",
	                  G_CALLBACK (monitoring_widget_changed), bond);
	nmt_editor_grid_append (grid, _("Link monitoring"), widget, NULL);
	priv->monitoring = NMT_NEWT_POPUP (widget);

	widget = nmt_newt_entry_numeric_new (10, 0, G_MAXINT);
	g_signal_connect (widget, "notify::text",
	                  G_CALLBACK (miimon_widget_changed), bond);
	label = nmt_newt_label_new (C_("milliseconds", "ms"));
	nmt_editor_grid_append (grid, _("Monitoring frequency"), widget, label);
	priv->miimon = NMT_NEWT_ENTRY (widget);

	widget = nmt_newt_entry_numeric_new (10, 0, G_MAXINT);
	g_signal_connect (widget, "notify::text",
	                  G_CALLBACK (updelay_widget_changed), bond);
	label = nmt_newt_label_new (C_("milliseconds", "ms"));
	nmt_editor_grid_append (grid, _("Link up delay"), widget, label);
	priv->updelay = NMT_NEWT_ENTRY (widget);

	widget = nmt_newt_entry_numeric_new (10, 0, G_MAXINT);
	g_signal_connect (widget, "notify::text",
	                  G_CALLBACK (downdelay_widget_changed), bond);
	label = nmt_newt_label_new (C_("milliseconds", "ms"));
	nmt_editor_grid_append (grid, _("Link down delay"), widget, label);
	priv->downdelay = NMT_NEWT_ENTRY (widget);

	widget = nmt_newt_entry_numeric_new (10, 0, G_MAXINT);
	g_signal_connect (widget, "notify::text",
	                  G_CALLBACK (arp_interval_widget_changed), bond);
	label = nmt_newt_label_new (C_("milliseconds", "ms"));
	nmt_editor_grid_append (grid, _("Monitoring frequency"), widget, label);
	priv->arp_interval = NMT_NEWT_ENTRY (widget);

	widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4);
	g_signal_connect (widget, "notify::strings",
	                  G_CALLBACK (arp_ip_target_widget_changed), bond);
	nmt_editor_grid_append (grid, _("ARP targets"), widget, NULL);
	priv->arp_ip_target = NMT_ADDRESS_LIST (widget);

	g_signal_connect (s_bond, "notify::" NM_SETTING_BOND_OPTIONS,
	                  G_CALLBACK (bond_options_changed), bond);
	bond_options_changed (G_OBJECT (s_bond), NULL, bond);
	slaves_changed (G_OBJECT (priv->slaves), NULL, bond);

	nmt_editor_page_add_section (NMT_EDITOR_PAGE (bond), section);

	G_OBJECT_CLASS (nmt_page_bond_parent_class)->constructed (object);
}