static void
nmt_mtu_entry_init (NmtMtuEntry *entry)
{

	NmtMtuEntryPrivate *priv = NMT_MTU_ENTRY_GET_PRIVATE (entry);
	NmtNewtGrid *grid = NMT_NEWT_GRID (entry);
	NmtNewtWidget *real_entry, *label;

	real_entry = nmt_newt_entry_numeric_new (10, 0, 65535);
	priv->entry = NMT_NEWT_ENTRY (real_entry);

	label = nmt_newt_label_new (_("bytes"));
	priv->label = NMT_NEWT_LABEL (label);

	nmt_newt_grid_add (grid, real_entry, 0, 0);
	nmt_newt_grid_add (grid, label, 1, 0);
	nmt_newt_widget_set_padding (label, 1, 0, 0, 0);

	nmt_newt_entry_set_validator (priv->entry, mtu_validator, entry);
	g_object_bind_property_full (entry, "mtu", real_entry, "text",
	                             G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
	                             mtu_transform_to_text,
	                             NULL,
	                             NULL, NULL);
}
Example #2
0
static void
nmt_newt_label_set_property (GObject      *object,
                             guint         prop_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
	NmtNewtLabel *label = NMT_NEWT_LABEL (object);

	switch (prop_id) {
	case PROP_TEXT:
		nmt_newt_label_set_text (label, g_value_get_string (value));
		break;
	case PROP_STYLE:
		nmt_newt_label_set_style (label, g_value_get_int (value));
		break;
	case PROP_HIGHLIGHT:
		nmt_newt_label_set_highlight (label, g_value_get_boolean (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}