コード例 #1
0
static void
nmt_newt_container_real_child_validity_changed (NmtNewtContainer *container,
                                                NmtNewtWidget    *widget)
{
	NmtNewtContainerPrivate *priv;
	int i;

	if (widget) {
		if (!nmt_newt_widget_get_visible (widget))
			return;
		if (!nmt_newt_widget_get_valid (widget)) {
			nmt_newt_widget_set_valid (NMT_NEWT_WIDGET (container), FALSE);
			return;
		}
	}

	priv = NMT_NEWT_CONTAINER_GET_PRIVATE (container);
	for (i = 0; i < priv->children->len; i++) {
		widget = priv->children->pdata[i];
		if (   nmt_newt_widget_get_visible (widget)
		       && !nmt_newt_widget_get_valid (widget)) {
			nmt_newt_widget_set_valid (NMT_NEWT_WIDGET (container), FALSE);
			return;
		}
	}

	nmt_newt_widget_set_valid (NMT_NEWT_WIDGET (container), TRUE);
}
コード例 #2
0
static void
nmt_editor_grid_size_request (NmtNewtWidget *widget,
                            int           *width,
                            int           *height)
{
	NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (widget);
	NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
	NmtEditorGridFormState *state = get_form_state (widget);
	gboolean add_padding = FALSE;
	int i;

	g_free (priv->row_heights);
	priv->row_heights = g_new0 (int, priv->rows->len);

	*height = 0;
	for (i = 0; i < priv->rows->len; i++) {
		int lwidth, lheight, wwidth, wheight, ewidth, eheight;

		if (!nmt_newt_widget_get_visible (rows[i].widget))
			continue;

		if (rows[i].label) {
			nmt_newt_widget_size_request (rows[i].label, &lwidth, &lheight);
			lwidth += priv->indent;
			state->col_widths[0] = MAX (state->col_widths[0], lwidth);

			nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight);
			state->col_widths[1] = MAX (state->col_widths[1], wwidth);
			priv->row_heights[i] = wheight;

			add_padding = TRUE;
		} else {
			nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight);
			priv->row_heights[i] = wheight;
		}

		if (rows[i].extra) {
			nmt_newt_widget_size_request (rows[i].extra, &ewidth, &eheight);
			state->col_widths[2] = MAX (state->col_widths[2], ewidth);
			priv->row_heights[i] = MAX (priv->row_heights[i], eheight);
		}

		*height += priv->row_heights[i];
	}

	*width = state->col_widths[0] + state->col_widths[1] + state->col_widths[2];
	if (add_padding)
		*width += 2;
}
コード例 #3
0
static void
add_buttons (GPtrArray *buttons, GPtrArray *cos)
{
	NmtNewtWidget *child;
	newtComponent *child_cos;
	int i, c;

	for (i = 0; i < buttons->len; i++) {
		child = buttons->pdata[i];

		if (!nmt_newt_widget_get_visible (child))
			continue;

		child_cos = nmt_newt_widget_get_components (child);
		for (c = 0; child_cos[c]; c++)
			g_ptr_array_add (cos, child_cos[c]);
		g_free (child_cos);
	}
}
コード例 #4
0
static newtComponent *
nmt_editor_grid_get_components (NmtNewtWidget *widget)
{
	NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (widget);
	NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
	newtComponent *child_cos;
	GPtrArray *cos;
	int i, c;

	cos = g_ptr_array_new ();

	for (i = 0; i < priv->rows->len; i++) {
		if (!nmt_newt_widget_get_visible (rows[i].widget))
			continue;

		if (rows[i].label) {
			child_cos = nmt_newt_widget_get_components (rows[i].label);
			g_assert (child_cos[0] && !child_cos[1]);
			g_ptr_array_add (cos, child_cos[0]);
			g_free (child_cos);
		}

		child_cos = nmt_newt_widget_get_components (rows[i].widget);
		for (c = 0; child_cos[c]; c++)
			g_ptr_array_add (cos, child_cos[c]);
		g_free (child_cos);

		if (rows[i].extra) {
			child_cos = nmt_newt_widget_get_components (rows[i].extra);
			for (c = 0; child_cos[c]; c++)
				g_ptr_array_add (cos, child_cos[c]);
			g_free (child_cos);
		}
	}

	g_ptr_array_add (cos, NULL);
	return (newtComponent *) g_ptr_array_free (cos, FALSE);
}
コード例 #5
0
static void
nmt_editor_grid_size_allocate (NmtNewtWidget *widget,
                             int            x,
                             int            y,
                             int            width,
                             int            height)
{
	NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (widget);
	NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
	NmtEditorGridFormState *state = get_form_state (widget);
	int col0_width, col1_width, col2_width;
	int i, row;

	col0_width = state->col_widths[0] - priv->indent;
	col1_width = state->col_widths[1];
	col2_width = state->col_widths[2];

	for (i = row = 0; i < priv->rows->len; i++) {
		if (!nmt_newt_widget_get_visible (rows[i].widget))
			continue;

		if (rows[i].label) {
			int lwidth, lheight, lx;

			if (rows[i].flags & NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT)
				lx = x;
			else {
				nmt_newt_widget_size_request (rows[i].label, &lwidth, &lheight);
				lx = x + col0_width - lwidth;
			}

			nmt_newt_widget_size_allocate (rows[i].label,
			                               lx,
			                               y + row,
			                               col0_width,
			                               priv->row_heights[i]);

			nmt_newt_widget_size_allocate (rows[i].widget,
			                               x + col0_width + 1,
			                               y + row,
			                               col1_width,
			                               priv->row_heights[i]);
		} else {
			nmt_newt_widget_size_allocate (rows[i].widget,
			                               x,
			                               y + row,
			                               col0_width + col1_width + 1,
			                               priv->row_heights[i]);
		}

		if (rows[i].extra) {
			int wwidth, wheight, ex;

			if (rows[i].flags & NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT)
				ex = x + col0_width + col1_width + 2;
			else {
				nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight);
				ex = x + col0_width + wwidth + 2;
			}

			nmt_newt_widget_size_allocate (rows[i].extra,
			                               ex,
			                               y + row,
			                               col2_width,
			                               priv->row_heights[i]);
		}

		row += priv->row_heights[i];
	}
}