static newtComponent * nmt_newt_section_get_components (NmtNewtWidget *widget) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE (widget); newtComponent *child_cos; GPtrArray *cos; int i; g_return_val_if_fail (priv->header != NULL && priv->body != NULL, NULL); cos = g_ptr_array_new (); if (priv->show_border) { child_cos = nmt_newt_widget_get_components (priv->border_grid); for (i = 0; child_cos[i]; i++) g_ptr_array_add (cos, child_cos[i]); g_free (child_cos); } child_cos = nmt_newt_widget_get_components (priv->header); for (i = 0; child_cos[i]; i++) g_ptr_array_add (cos, child_cos[i]); g_free (child_cos); if (priv->open) { child_cos = nmt_newt_widget_get_components (priv->body); for (i = 0; child_cos[i]; i++) g_ptr_array_add (cos, child_cos[i]); g_free (child_cos); } g_ptr_array_add (cos, NULL); return (newtComponent *) g_ptr_array_free (cos, FALSE); }
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); }
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); } }
static void nmt_newt_form_build (NmtNewtForm *form) { NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE (form); int screen_height, screen_width, form_height, form_width; newtComponent *cos; int i; priv->dirty = FALSE; nmt_newt_widget_realize (NMT_NEWT_WIDGET (form)); nmt_newt_widget_size_request (priv->content, &form_width, &form_height); newtGetScreenSize (&screen_width, &screen_height); if (!priv->fixed_width) priv->width = MIN (form_width + 2 * priv->padding, screen_width - 2); if (!priv->fixed_height) priv->height = MIN (form_height + 2 * priv->padding, screen_height - 2); if (!priv->fixed_x) priv->x = (screen_width - form_width) / 2; if (!priv->fixed_y) priv->y = (screen_height - form_height) / 2; nmt_newt_widget_size_allocate (priv->content, priv->padding, priv->padding, priv->width - 2 * priv->padding, priv->height - 2 * priv->padding); if (priv->height - 2 * priv->padding < form_height) { newtComponent scroll_bar = newtVerticalScrollbar (priv->width - 1, 0, priv->height, NEWT_COLORSET_WINDOW, NEWT_COLORSET_ACTCHECKBOX); priv->form = newtForm (scroll_bar, NULL, NEWT_FLAG_NOF12); newtFormAddComponent (priv->form, scroll_bar); newtFormSetHeight (priv->form, priv->height - 2); } else priv->form = newtForm (NULL, NULL, NEWT_FLAG_NOF12); if (priv->escape_exits) newtFormAddHotKey (priv->form, NEWT_KEY_ESCAPE); cos = nmt_newt_widget_get_components (priv->content); for (i = 0; cos[i]; i++) newtFormAddComponent (priv->form, cos[i]); g_free (cos); if (priv->focus) { newtComponent fco; fco = nmt_newt_widget_get_focus_component (priv->focus); if (fco) newtFormSetCurrent (priv->form, fco); } #ifdef HAVE_NEWTFORMGETSCROLLPOSITION if (priv->scroll_position) newtFormSetScrollPosition (priv->form, priv->scroll_position); #endif newtOpenWindow (priv->x, priv->y, priv->width, priv->height, priv->title_lc); }