Ejemplo n.º 1
0
int main(void){
	radio_t * radio1 = radio_new();
	radio_changeName(radio1, "RADIO");
	printf("%s\n", radio_getName(radio1));
	track_t t1 = radio_newTrack();
	track_t t2 = radio_newTrack();
	track_t t3 = radio_newTrack();
	track_t t4 = radio_newTrack();
	trackList_t * trackList = radio_newTrackList(5);
	radio_addTrack(trackList, t1);
	radio_addTrack(trackList, t2);
	radio_addTrack(trackList, t3);
	radio_addTrack(trackList, t4);
	radio_trackDelete(trackList, 0);
	printf("%d\n", radio_length(trackList));
	radio_trackListFree(trackList);
	radio_free(radio1);
	
	getchar();
	return 0;
	}
Ejemplo n.º 2
0
static void init_layout (void)
{
    static int i18n_layt_flag = 0;
	static int b1, b2, b3;
    int i = sizeof (s_split_direction) / sizeof(char*) ;
	char* ok_button = _("&Ok");
	char* cancel_button = _("&Cancel");
	char* save_button = _("&Save");
    
    if (!i18n_layt_flag)
    {
		register int l1;
		
		first_width = 19; /* length of line with '<' '>' buttons */
		
		layout_title = _(" Layout ");
		title1 = _(" Panel split ");
		title2 = _(" Highlight... ");
		title3 = _(" Other options ");
		output_lines_label = _("output lines");
		
		while (i--)
		{
		    s_split_direction [i] = _(s_split_direction [i]);
			l1 = strlen (s_split_direction [i]) + 7;
			if (l1 > first_width)
				first_width = l1;
		}

		for (i = 0; i <= 8; i++)
		{
			check_options[i].text = _(check_options[i].text);
			l1 = strlen (check_options[i].text) + 7;
			if (l1 > first_width)
				first_width = l1;
		}

		l1 = strlen (title1) + 1;
		if (l1 > first_width)
			first_width = l1;
		
		l1 = strlen (title2) + 1;
		if (l1 > first_width)
			first_width = l1;
		

		second_width = strlen (title3) + 1;
		for (i = 0; i < 6; i++)
		{
			check_options[i].text = _(check_options[i].text);
			l1 = strlen (check_options[i].text) + 7;
			if (l1 > second_width)
				second_width = l1;
		}
		if (console_flag)
		{
			l1 = strlen (output_lines_label) + 13;
			if (l1 > second_width)
				second_width = l1;
		}

		/* 
		 * [email protected]:
		 * To be completely correct, one need to check if layout_title
		 * does not exceed dialog length and total length of 3 buttons
		 * allows their placement in one row. But assuming this dialog
		 * is wide enough, I don't include such a tests.
		 *
		 * Now the last thing to do - properly space buttons...
		 */
		l1 = 11 + strlen (ok_button)   /* 14 - all brackets and inner space */
		 	+ strlen (save_button)     /* notice: it is 3 char less because */
			+ strlen (cancel_button);  /* of '&' char in button text */
		
		i = (first_width + second_width - l1) / 4;
		b1 = 5 + i;
		b2 = b1 + strlen(ok_button) + i + 6;
		b3 = b2 + strlen(save_button) + i + 4;

		i18n_layt_flag = 1;
    }

    layout_dlg = create_dlg (0, 0, 15, first_width + second_width + 9, 
		dialog_colors, layout_callback,
		"[Layout]", "layout", DLG_CENTER | DLG_GRID);
			     
    x_set_dialog_title (layout_dlg, _("Layout"));

    add_widgetl (layout_dlg,
		button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0, "c"), 
		XV_WLAY_RIGHTOF);
    add_widgetl (layout_dlg,
		button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0, "s"),
		XV_WLAY_RIGHTOF);
    add_widgetl (layout_dlg,
		button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0, "o"),
		XV_WLAY_CENTERROW);
#ifndef HAVE_X
    if (console_flag){
	add_widget (layout_dlg,
		    button_new (9, 12 + first_width, B_MINUS, NARROW_BUTTON, "&-",
			bminus_cback, 0, NULL));
	add_widget (layout_dlg,
		    button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, "&+", 
			bplus_cback, 0, NULL));
    }
#endif    

#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options[i].tkname

    for (i = 0; i < 6; i++){
	check_options [i].widget = check_new (8 - i, 7 + first_width, XTRACT(i));
	add_widgetl (layout_dlg, check_options [i].widget, XV_WLAY_BELOWCLOSE);
    }
#ifdef HAVE_XVIEW
    add_widgetl (layout_dlg, label_new (2, 7 + first_width, _("Other options"), "oo"),
        XV_WLAY_NEXTCOLUMN);
    add_widgetl (layout_dlg, label_new (8, 5, _("Highlight..."), "hl"),
        XV_WLAY_NEXTCOLUMN);
    add_widgetl (layout_dlg, label_new (2, 5, _("Panel split"), "ps"),
        XV_WLAY_NEXTCOLUMN);
#endif        
    check_options [8].widget = check_new (10, 6, XTRACT(8));
    add_widgetl (layout_dlg, check_options [8].widget, XV_WLAY_BELOWCLOSE);
    check_options [7].widget = check_new (9, 6, XTRACT(7));
    add_widgetl (layout_dlg, check_options [7].widget, XV_WLAY_BELOWCLOSE);

    _filetype_mode = filetype_mode;
    _permission_mode = permission_mode;
    _equal_split = equal_split;
    _menubar_visible = menubar_visible;
    _command_prompt = command_prompt;
    _keybar_visible = keybar_visible;
    _message_visible = message_visible;
    _xterm_hintbar = xterm_hintbar;
#ifndef HAVE_X
    bright_widget = button_new(6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback, 0, ">");
    add_widgetl (layout_dlg, bright_widget, XV_WLAY_RIGHTOF);
    bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback, 0, "<");
    add_widgetl (layout_dlg, bleft_widget, XV_WLAY_RIGHTOF);
    check_options [6].widget = check_new (5, 6, XTRACT(6));
#endif
    old_first_panel_size = -1;
    old_horizontal_split = -1;
    old_output_lines     = -1;
    
    _first_panel_size = first_panel_size;
    _output_lines = output_lines;
#ifndef HAVE_X
    add_widget (layout_dlg, check_options [6].widget);
    radio_widget = radio_new (3, 6, 2, s_split_direction, 1, "r");
    add_widget (layout_dlg, radio_widget);
    radio_widget->sel = horizontal_split;
#endif
}
Ejemplo n.º 3
0
static WDialog *
init_listmode (char *oldlistformat)
{
    int i;
    char *s;
    int format_width = 0;
    int format_columns = 0;
    WDialog *listmode_dlg;

    static struct listmode_label listmode_labels[] = {
        {UY + 13, UX + 22, "Item width:"}
    };

    static struct listmode_button listmode_but[] = {
        {B_CANCEL, NORMAL_BUTTON, BY, BX + 53, "&Cancel", NULL},
        {B_ADD, NORMAL_BUTTON, BY, BX + 22, "&Add item", badd_cback},
        {B_REMOVE, NORMAL_BUTTON, BY, BX + 10, "&Remove", bremove_cback},
        {B_ENTER, DEFPUSH_BUTTON, BY, BX, "&OK", NULL},
        {B_PLUS, NARROW_BUTTON, UY + 13, UX + 37, "&+", bplus_cback},
        {B_MINUS, NARROW_BUTTON, UY + 13, UX + 34, "&-", bminus_cback},
    };

    do_refresh ();

    listmode_dlg =
        dlg_create (TRUE, 0, 0, 22, 74, dialog_colors, NULL, NULL, listmode_section,
                    "Listing format edit", DLG_CENTER | DLG_REVERSE);

    add_widget (listmode_dlg, groupbox_new (UY, UX, 4, 63, "General options"));
    add_widget (listmode_dlg, groupbox_new (UY + 4, UX, 11, 18, "Items"));
    add_widget (listmode_dlg, groupbox_new (UY + 4, UX + 20, 11, 43, "Item options"));

    for (i = 0; i < sizeof (listmode_but) / sizeof (struct listmode_button); i++)
        add_widget (listmode_dlg,
                    button_new (listmode_but[i].y, listmode_but[i].x,
                                listmode_but[i].ret_cmd,
                                listmode_but[i].flags,
                                listmode_but[i].text, listmode_but[i].callback));

    /* We add the labels. */
    for (i = 0; i < sizeof (listmode_labels) / sizeof (struct listmode_label); i++)
    {
        pname = label_new (listmode_labels[i].y, listmode_labels[i].x, listmode_labels[i].text);
        add_widget (listmode_dlg, pname);
    }

    radio_itemwidth = radio_new (UY + 9, UX + 22, 3, s_itemwidth);
    add_widget (listmode_dlg, radio_itemwidth);
    radio_itemwidth = 0;
    radio_justify = radio_new (UY + 5, UX + 22, 3, s_justify);
    add_widget (listmode_dlg, radio_justify);
    radio_justify->sel = 1;

    /* get new listbox */
    l_listmode = listbox_new (UY + 5, UX + 1, 9, 16, FALSE, NULL);

    if (strncmp (oldlistformat, "full ", 5) == 0)
    {
        format_width = 1;
        oldlistformat += 5;
    }
    if (strncmp (oldlistformat, "half ", 5) == 0)
    {
        oldlistformat += 5;
    }
    if (strncmp (oldlistformat, "2 ", 2) == 0)
    {
        format_columns = 1;
        oldlistformat += 2;
    }
    if (strncmp (oldlistformat, "1 ", 2) == 0)
    {
        oldlistformat += 2;
    }
    s = strtok (oldlistformat, ",");

    while (s)
    {
        listbox_add_item (l_listmode, LISTBOX_APPEND_AT_END, 0, s, NULL, FALSE);
        s = strtok (NULL, ",");
    }

    /* add listbox to the dialogs */
    add_widget (listmode_dlg, l_listmode);

    radio_columns = radio_new (UY + 1, UX + 32, 2, s_columns);
    add_widget (listmode_dlg, radio_columns);
    radio_columns->sel = format_columns;
    radio_genwidth = radio_new (UY + 1, UX + 2, 2, s_genwidth);
    add_widget (listmode_dlg, radio_genwidth);
    radio_genwidth->sel = format_width;

    return listmode_dlg;
}
Ejemplo n.º 4
0
static Dlg_head *
display_init (int radio_sel, char *init_text, int _check_status, char **_status)
{
    int dlg_width = 48, dlg_height = 15;
    Dlg_head *dd;

    /* Controls whether the array strings have been translated */
    const char *displays[LIST_TYPES] = {
        N_("&Full file list"),
        N_("&Brief file list"),
        N_("&Long file list"),
        N_("&User defined:")
    };

    /* Index in displays[] for "user defined" */
    const int user_type_idx = 3;

    const char *display_title = N_("Listing mode");
    const char *user_mini_status = N_("User &mini status");
    const char *ok_name = N_("&OK");
    const char *cancel_name = N_("&Cancel");

    WButton *ok_button, *cancel_button;

    {
        int i, maxlen = 0;
        const char *cp;
        int ok_len, cancel_len, b_len, gap;

#ifdef ENABLE_NLS
        display_title = _(display_title);
        user_mini_status = _(user_mini_status);
        ok_name = _(ok_name);
        cancel_name = _(cancel_name);

        for (i = 0; i < LIST_TYPES; i++)
            displays[i] = _(displays[i]);
#endif

        /* get hotkey of user-defined format string */
        cp = strchr (displays[user_type_idx], '&');
        if (cp != NULL && *++cp != '\0')
            display_user_hotkey = g_ascii_tolower (*cp);

        /* xpos will be fixed later */
        ok_button = button_new (dlg_height - 3, 0, B_ENTER, DEFPUSH_BUTTON, ok_name, 0);
        ok_len = button_get_len (ok_button);
        cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0);
        cancel_len = button_get_len (cancel_button);
        b_len = ok_len + cancel_len + 2;

        dlg_width = max (dlg_width, str_term_width1 (display_title) + 10);
        /* calculate max width of radiobutons */
        for (i = 0; i < LIST_TYPES; i++)
            maxlen = max (maxlen, str_term_width1 (displays[i]));
        dlg_width = max (dlg_width, maxlen);
        dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13);

        /* buttons */
        dlg_width = max (dlg_width, b_len + 6);
        gap = (dlg_width - 6 - b_len) / 3;
        ok_button->widget.x = 3 + gap;
        cancel_button->widget.x = ok_button->widget.x + ok_len + gap + 2;
    }

    displays_status = _status;

    dd = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors,
                     display_callback, "[Listing Mode...]", display_title,
                     DLG_CENTER | DLG_REVERSE);

    add_widget (dd, cancel_button);
    add_widget (dd, ok_button);

    display_mini_status =
        input_new (10, 8, input_get_default_colors (), dlg_width - 12, _status[radio_sel],
                   "mini-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_mini_status);

    display_check_status = check_new (9, 4, _check_status, user_mini_status);
    add_widget (dd, display_check_status);

    display_user_format = input_new (7, 8, input_get_default_colors (), dlg_width - 12, init_text,
                                     "user-fmt-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_user_format);

    display_radio = radio_new (3, 4, LIST_TYPES, displays);
    display_radio->sel = display_radio->pos = radio_sel;
    add_widget (dd, display_radio);

    return dd;
}
Ejemplo n.º 5
0
Archivo: quick.c Proyecto: BrEacK/mc
int
quick_dialog_skip (QuickDialog * qd, int nskip)
{
#ifdef ENABLE_NLS
#define I18N(x) (x = !qd->i18n && x != NULL && *x != '\0' ? _(x): x)
#else
#define I18N(x) (x = x)
#endif
    Dlg_head *dd;
    QuickWidget *qw;
    WInput *in;
    WRadio *r;
    int return_val;

    I18N (qd->title);

    if ((qd->xpos == -1) || (qd->ypos == -1))
        dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen,
                         dialog_colors, qd->callback, qd->mouse, qd->help, qd->title,
                         DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
    else
        dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
                         dialog_colors, qd->callback, qd->mouse, qd->help, qd->title, DLG_REVERSE);

    for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
    {
        int xpos;
        int ypos;

        xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
        ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;

        switch (qw->widget_type)
        {
        case quick_checkbox:
            qw->widget =
                (Widget *) check_new (ypos, xpos, *qw->u.checkbox.state,
                                      I18N (qw->u.checkbox.text));
            break;

        case quick_button:
            qw->widget = (Widget *) button_new (ypos, xpos, qw->u.button.action,
                                                (qw->u.button.action ==
                                                 B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
                                                I18N (qw->u.button.text), qw->u.button.callback);
            break;

        case quick_input:
            in = input_new (ypos, xpos, input_get_default_colors (),
                            qw->u.input.len, qw->u.input.text, qw->u.input.histname,
                            INPUT_COMPLETE_DEFAULT);
            in->is_password = (qw->u.input.flags == 1);
            if ((qw->u.input.flags & 2) != 0)
                in->completion_flags |= INPUT_COMPLETE_CD;
            if ((qw->u.input.flags & 4) != 0)
                in->strip_password = TRUE;
            qw->widget = (Widget *) in;
            *qw->u.input.result = NULL;
            break;

        case quick_label:
            qw->widget = (Widget *) label_new (ypos, xpos, I18N (qw->u.label.text));
            break;

        case quick_groupbox:
            qw->widget = (Widget *) groupbox_new (ypos, xpos,
                                                  qw->u.groupbox.height,
                                                  qw->u.groupbox.width,
                                                  I18N (qw->u.groupbox.title));
            break;

        case quick_radio:
            {
                int i;
                char **items = NULL;

                /* create the copy of radio_items to avoid mwmory leak */
                items = g_new0 (char *, qw->u.radio.count + 1);

                if (!qd->i18n)
                    for (i = 0; i < qw->u.radio.count; i++)
                        items[i] = g_strdup (_(qw->u.radio.items[i]));
                else
                    for (i = 0; i < qw->u.radio.count; i++)
                        items[i] = g_strdup (qw->u.radio.items[i]);

                r = radio_new (ypos, xpos, qw->u.radio.count, (const char **) items);
                r->pos = r->sel = *qw->u.radio.value;
                qw->widget = (Widget *) r;
                g_strfreev (items);
                break;
            }

        default:
            qw->widget = NULL;
            fprintf (stderr, "QuickWidget: unknown widget type\n");
            break;
        }

        if (qw->widget != NULL)
        {
            qw->widget->options |= qw->options; /* FIXME: cannot reset flags, setup only */
            add_widget (dd, qw->widget);
        }
    }

    while (nskip-- != 0)
    {
        dd->current = g_list_next (dd->current);
        if (dd->current == NULL)
            dd->current = dd->widgets;
    }

    return_val = run_dlg (dd);

    /* Get the data if we found something interesting */
    if (return_val != B_CANCEL)
    {
        for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
        {
            switch (qw->widget_type)
            {
            case quick_checkbox:
                *qw->u.checkbox.state = ((WCheck *) qw->widget)->state & C_BOOL;
                break;

            case quick_input:
                if ((qw->u.input.flags & 2) != 0)
                    *qw->u.input.result = tilde_expand (((WInput *) qw->widget)->buffer);
                else
                    *qw->u.input.result = g_strdup (((WInput *) qw->widget)->buffer);
                break;

            case quick_radio:
                *qw->u.radio.value = ((WRadio *) qw->widget)->sel;
                break;

            default:
                break;
            }
        }
    }

    destroy_dlg (dd);

    return return_val;
#undef I18N
}
Ejemplo n.º 6
0
Archivo: quick.c Proyecto: rutsky/mc
int
quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
{
    int len;
    int blen = 0;
    int x, y;                   /* current positions */
    int y1 = 0;                 /* bottom of 1st column in case of two columns */
    int y2 = -1;                /* start of two columns */
    int width1 = 0;             /* width of single column */
    int width2 = 0;             /* width of each of two columns */
    gboolean have_groupbox = FALSE;
    gboolean two_columns = FALSE;
    gboolean put_buttons = FALSE;

    /* x position of 1st column is 3 */
    const int x1 = 3;
    /* x position of 2nd column is 4 and it will be fixed later, after creation of all widgets */
    int x2 = 4;

    GArray *widgets;
    size_t i;
    quick_widget_t *quick_widget;
    WGroupbox *g = NULL;
    WDialog *dd;
    int return_val;

    len = str_term_width1 (I18N (quick_dlg->title)) + 6;
    quick_dlg->cols = max (quick_dlg->cols, len);

    y = 1;
    x = x1;

    /* create widgets */
    widgets = g_array_sized_new (FALSE, FALSE, sizeof (quick_widget_item_t), 8);

    for (quick_widget = quick_dlg->widgets; quick_widget->widget_type != quick_end; quick_widget++)
    {
        quick_widget_item_t item = { NULL, quick_widget };
        int width = 0;

        switch (quick_widget->widget_type)
        {
        case quick_checkbox:
            item.widget =
                WIDGET (check_new
                        (++y, x, *quick_widget->u.checkbox.state,
                         I18N (quick_widget->u.checkbox.text)));
            g_array_append_val (widgets, item);
            width = item.widget->cols;
            if (g != NULL)
                width += 2;
            if (two_columns)
                width2 = max (width2, width);
            else
                width1 = max (width1, width);
            break;

        case quick_button:
            /* single button */
            item.widget = WIDGET (button_new (++y, x, quick_widget->u.button.action,
                                              quick_widget->u.button.action == B_ENTER ?
                                              DEFPUSH_BUTTON : NORMAL_BUTTON,
                                              I18N (quick_widget->u.button.text),
                                              quick_widget->u.button.callback));
            g_array_append_val (widgets, item);
            width = item.widget->cols;
            if (g != NULL)
                width += 2;
            if (two_columns)
                width2 = max (width2, width);
            else
                width1 = max (width1, width);
            break;

        case quick_input:
            *quick_widget->u.input.result = NULL;
            y++;
            if (quick_widget->u.input.label_location != input_label_none)
                quick_create_labeled_input (widgets, &y, x, quick_widget, &width);
            else
            {
                item.widget = WIDGET (quick_create_input (y, x, quick_widget));
                g_array_append_val (widgets, item);
                width = item.widget->cols;
            }
            if (g != NULL)
                width += 2;
            if (two_columns)
                width2 = max (width2, width);
            else
                width1 = max (width1, width);
            break;

        case quick_label:
            item.widget = WIDGET (label_new (++y, x, I18N (quick_widget->u.label.text)));
            g_array_append_val (widgets, item);
            y += item.widget->lines - 1;
            width = item.widget->cols;
            if (g != NULL)
                width += 2;
            if (two_columns)
                width2 = max (width2, width);
            else
                width1 = max (width1, width);
            break;

        case quick_radio:
        {
            WRadio *r;
            char **items = NULL;

            /* create the copy of radio_items to avoid mwmory leak */
            items = g_new (char *, quick_widget->u.radio.count + 1);
            for (i = 0; i < (size_t) quick_widget->u.radio.count; i++)
                items[i] = g_strdup (_(quick_widget->u.radio.items[i]));
            items[i] = NULL;

            r = radio_new (++y, x, quick_widget->u.radio.count, (const char **) items);
            r->pos = r->sel = *quick_widget->u.radio.value;
            g_strfreev (items);
            item.widget = WIDGET (r);
            g_array_append_val (widgets, item);
            y += item.widget->lines - 1;
            width = item.widget->cols;
            if (g != NULL)
                width += 2;
            if (two_columns)
                width2 = max (width2, width);
            else
                width1 = max (width1, width);
        }
        break;

        case quick_start_groupbox:
            I18N (quick_widget->u.groupbox.title);
            len = str_term_width1 (quick_widget->u.groupbox.title);
            g = groupbox_new (++y, x, 1, len + 4, quick_widget->u.groupbox.title);
            item.widget = WIDGET (g);
            g_array_append_val (widgets, item);
            have_groupbox = TRUE;
            break;

        case quick_stop_groupbox:
            if (g != NULL)
            {
                Widget *w = WIDGET (g);

                y++;
                w->lines = y + 1 - w->y;
                g = NULL;

                g_array_append_val (widgets, item);
            }
            break;

        case quick_separator:
            y++;
            if (quick_widget->u.separator.line)
            {
                item.widget = WIDGET (hline_new (y, x, 1));
                g_array_append_val (widgets, item);
            }
            break;

        case quick_start_columns:
            y2 = y;
            g_array_append_val (widgets, item);
            two_columns = TRUE;
            break;

        case quick_next_column:
            x = x2;
            y1 = y;
            y = y2;
            break;

        case quick_stop_columns:
            x = x1;
            y = max (y1, y);
            g_array_append_val (widgets, item);
            two_columns = FALSE;
            break;

        case quick_buttons:
            /* start put several buttons in bottom line */
            if (quick_widget->u.separator.space)
            {
                y++;

                if (quick_widget->u.separator.line)
                    item.widget = WIDGET (hline_new (y, 1, -1));
            }

            g_array_append_val (widgets, item);

            /* several buttons in bottom line */
            y++;
            quick_widget++;
            for (; quick_widget->widget_type == quick_button; quick_widget++)
            {
                item.widget = WIDGET (button_new (y, x++, quick_widget->u.button.action,
                                                  quick_widget->u.button.action == B_ENTER ?
                                                  DEFPUSH_BUTTON : NORMAL_BUTTON,
                                                  I18N (quick_widget->u.button.text),
                                                  quick_widget->u.button.callback));
                item.quick_widget = quick_widget;
                g_array_append_val (widgets, item);
                blen += item.widget->cols + 1;
            }

            /* stop dialog build here */
            blen--;
            quick_widget->widget_type = quick_end;
            quick_widget--;
            break;

        default:
            break;
        }
    }

    /* adjust dialog width */
    quick_dlg->cols = max (quick_dlg->cols, blen + 6);
    if (have_groupbox)
    {
        if (width1 != 0)
            width1 += 2;
        if (width2 != 0)
            width2 += 2;
    }
    if (width2 == 0)
        len = width1 + 6;
    else
    {
        len = width2 * 2 + 7;
        if (width1 != 0)
            len = max (len, width1 + 6);
    }

    quick_dlg->cols = max (quick_dlg->cols, len);
    width1 = quick_dlg->cols - 6;
    width2 = (quick_dlg->cols - 7) / 2;

    if (quick_dlg->x == -1 || quick_dlg->y == -1)
        dd = create_dlg (TRUE, 0, 0, y + 3, quick_dlg->cols,
                         dialog_colors, quick_dlg->callback, quick_dlg->mouse, quick_dlg->help,
                         quick_dlg->title, DLG_CENTER | DLG_TRYUP);
    else
        dd = create_dlg (TRUE, quick_dlg->y, quick_dlg->x, y + 3, quick_dlg->cols,
                         dialog_colors, quick_dlg->callback, quick_dlg->mouse, quick_dlg->help,
                         quick_dlg->title, DLG_NONE);

    /* add widgets into the dialog */
    x2 = x1 + width2 + 1;
    g = NULL;
    two_columns = FALSE;
    x = (WIDGET (dd)->cols - blen) / 2;

    for (i = 0; i < widgets->len; i++)
    {
        quick_widget_item_t *item;
        int column_width;

        item = &g_array_index (widgets, quick_widget_item_t, i);
        column_width = two_columns ? width2 : width1;

        /* adjust widget width and x position */
        switch (item->quick_widget->widget_type)
        {
        case quick_label:
        {
            quick_widget_t *input = item->quick_widget->u.label.input;

            if (input != NULL && input->u.input.label_location == input_label_right)
            {
                /* location of this label will be adjusted later */
                break;
            }
        }
        /* fall through */
        case quick_checkbox:
        case quick_radio:
            if (item->widget->x != x1)
                item->widget->x = x2;
            if (g != NULL)
                item->widget->x += 2;
            break;

        case quick_button:
            if (!put_buttons)
            {
                if (item->widget->x != x1)
                    item->widget->x = x2;
                if (g != NULL)
                    item->widget->x += 2;
            }
            else
            {
                item->widget->x = x;
                x += item->widget->cols + 1;
            }
            break;

        case quick_input:
        {
            Widget *label = WIDGET (INPUT (item->widget)->label);
            int width = column_width;

            if (g != NULL)
                width -= 4;

            switch (item->quick_widget->u.input.label_location)
            {
            case input_label_left:
                /* label was adjusted before; adjust input line */
                item->widget->x = label->x + label->cols + 1 - WIDGET (label->owner)->x;
                item->widget->cols = width - label->cols - 1;
                break;

            case input_label_right:
                label->x =
                    item->widget->x + item->widget->cols + 1 - WIDGET (item->widget->owner)->x;
                item->widget->cols = width - label->cols - 1;
                break;

            default:
                if (item->widget->x != x1)
                    item->widget->x = x2;
                if (g != NULL)
                    item->widget->x += 2;
                item->widget->cols = width;
                break;
            }

            /* forced update internal variables of inpuit line */
            input_set_origin (INPUT (item->widget), item->widget->x, item->widget->cols);
        }
        break;

        case quick_start_groupbox:
            g = GROUPBOX (item->widget);
            if (item->widget->x != x1)
                item->widget->x = x2;
            item->widget->cols = column_width;
            break;

        case quick_stop_groupbox:
            g = NULL;
            break;

        case quick_separator:
            if (item->widget != NULL)
            {
                if (g != NULL)
                {
                    Widget *wg = WIDGET (g);

                    HLINE (item->widget)->auto_adjust_cols = FALSE;
                    item->widget->x = wg->x + 1 - WIDGET (wg->owner)->x;
                    item->widget->cols = wg->cols;
                }
                else if (two_columns)
                {
                    HLINE (item->widget)->auto_adjust_cols = FALSE;
                    if (item->widget->x != x1)
                        item->widget->x = x2;
                    item->widget->x--;
                    item->widget->cols = column_width + 2;
                }
                else
                    HLINE (item->widget)->auto_adjust_cols = TRUE;
            }
            break;

        case quick_start_columns:
            two_columns = TRUE;
            break;

        case quick_stop_columns:
            two_columns = FALSE;
            break;

        case quick_buttons:
            /* several buttons in bottom line */
            put_buttons = TRUE;
            break;

        default:
            break;
        }

        if (item->widget != NULL)
        {
            unsigned long id;

            /* add widget into dialog */
            item->widget->options |= item->quick_widget->options;       /* FIXME: cannot reset flags, setup only */
            id = add_widget_autopos (dd, item->widget, item->quick_widget->pos_flags, NULL);
            if (item->quick_widget->id != NULL)
                *item->quick_widget->id = id;
        }
    }

    while (nskip-- != 0)
    {
        dd->current = g_list_next (dd->current);
        if (dd->current == NULL)
            dd->current = dd->widgets;
    }

    return_val = run_dlg (dd);

    /* Get the data if we found something interesting */
    if (return_val != B_CANCEL)
        for (i = 0; i < widgets->len; i++)
        {
            quick_widget_item_t *item;

            item = &g_array_index (widgets, quick_widget_item_t, i);

            switch (item->quick_widget->widget_type)
            {
            case quick_checkbox:
                *item->quick_widget->u.checkbox.state = CHECK (item->widget)->state & C_BOOL;
                break;

            case quick_input:
                if ((quick_widget->u.input.flags & 2) != 0)
                    *item->quick_widget->u.input.result =
                        tilde_expand (INPUT (item->widget)->buffer);
                else
                    *item->quick_widget->u.input.result = g_strdup (INPUT (item->widget)->buffer);
                break;

            case quick_radio:
                *item->quick_widget->u.radio.value = RADIO (item->widget)->sel;
                break;

            default:
                break;
            }
        }

    destroy_dlg (dd);

    /* destroy input labels created before */
    for (i = 0; i < widgets->len; i++)
    {
        quick_widget_item_t *item;

        item = &g_array_index (widgets, quick_widget_item_t, i);
        if (item->quick_widget->widget_type == quick_input)
            g_free (item->quick_widget->u.input.label);
    }

    g_array_free (widgets, TRUE);

    return return_val;
}
Ejemplo n.º 7
0
Archivo: layout.c Proyecto: m32/mc
static WDialog *
init_layout (void)
{
    WDialog *layout_dlg;
    int l1 = 0, width;
    int b1, b2, b;
    size_t i;

    const char *title1 = N_("Panel split");
    const char *title2 = N_("Console output");
    const char *title3 = N_("Other options");

    const char *s_split_direction[2] = {
        N_("&Vertical"),
        N_("&Horizontal")
    };

    const char *ok_button = N_("&OK");
    const char *cancel_button = N_("&Cancel");

    output_lines_label = _("Output lines:");

    /* save old params */
    _menubar_visible = menubar_visible;
    _command_prompt = command_prompt;
    _keybar_visible = mc_global.keybar_visible;
    _message_visible = mc_global.message_visible;
    _xterm_title = xterm_title;
    _free_space = free_space;
    old_output_lines = -1;
    _output_lines = output_lines;

#ifdef ENABLE_NLS
    {
        static gboolean i18n = FALSE;

        title1 = _(title1);
        title2 = _(title2);
        title3 = _(title3);

        i = G_N_ELEMENTS (s_split_direction);
        while (i-- != 0)
            s_split_direction[i] = _(s_split_direction[i]);

        if (!i18n)
        {
            for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
                check_options[i].text = _(check_options[i].text);
            i18n = TRUE;
        }

        ok_button = _(ok_button);
        cancel_button = _(cancel_button);
    }
#endif

    /* radiobuttons */
    i = G_N_ELEMENTS (s_split_direction);
    while (i-- != 0)
        l1 = max (l1, str_term_width1 (s_split_direction[i]) + 7);
    /* checkboxes */
    for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
        l1 = max (l1, str_term_width1 (check_options[i].text) + 7);
    /* groupboxes */
    l1 = max (l1, str_term_width1 (title1) + 4);
    l1 = max (l1, str_term_width1 (title2) + 4);
    l1 = max (l1, str_term_width1 (title3) + 4);
    /* label + "+"/"-" buttons */
    output_lines_label_len = str_term_width1 (output_lines_label);
    l1 = max (l1, output_lines_label_len + 12);
    /* buttons */
    b1 = str_term_width1 (ok_button) + 5;       /* default button */
    b2 = str_term_width1 (cancel_button) + 3;
    b = b1 + b2 + 1;
    /* dialog width */
    width = max (l1 * 2 + 7, b);

    layout_dlg =
        dlg_create (TRUE, 0, 0, 15, width, dialog_colors, layout_callback, NULL, "[Layout]",
                    _("Layout"), DLG_CENTER);

#define XTRACT(i) *check_options[i].variable, check_options[i].text

    /* "Panel split" groupbox */
    add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1));

    radio_widget = radio_new (3, 5, 2, s_split_direction);
    radio_widget->sel = panels_layout.horizontal_split;
    add_widget (layout_dlg, radio_widget);

    check_options[0].widget = check_new (5, 5, XTRACT (0));
    add_widget (layout_dlg, check_options[0].widget);

    equal_split = panels_layout.horizontal_split ?
                  panels_layout.horizontal_equal : panels_layout.vertical_equal;

    bleft_widget = button_new (6, 8, B_2LEFT, NARROW_BUTTON, "&<", b_left_right_cback);
    widget_disable (WIDGET (bleft_widget), equal_split);
    add_widget (layout_dlg, bleft_widget);

    bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
    widget_disable (WIDGET (bright_widget), equal_split);
    add_widget (layout_dlg, bright_widget);

    /* "Console output" groupbox */
    {
        const int disabled = mc_global.tty.console_flag != '\0' ? 0 : W_DISABLED;
        Widget *w;

        w = WIDGET (groupbox_new (8, 3, 3, l1, title2));
        w->options |= disabled;
        add_widget (layout_dlg, w);

        w = WIDGET (button_new (9, output_lines_label_len + 5, B_PLUS,
                                NARROW_BUTTON, "&+", bplus_cback));
        w->options |= disabled;
        add_widget (layout_dlg, w);

        w = WIDGET (button_new (9, output_lines_label_len + 5 + 5, B_MINUS,
                                NARROW_BUTTON, "&-", bminus_cback));
        w->options |= disabled;
        add_widget (layout_dlg, w);
    }

    /* "Other options" groupbox */
    add_widget (layout_dlg, groupbox_new (2, 4 + l1, 9, l1, title3));

    for (i = 1; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
    {
        check_options[i].widget = check_new (i + 2, 6 + l1, XTRACT (i));
        add_widget (layout_dlg, check_options[i].widget);
    }

#undef XTRACT

    add_widget (layout_dlg, hline_new (11, -1, -1));
    /* buttons */
    add_widget (layout_dlg,
                button_new (12, (width - b) / 2, B_ENTER, DEFPUSH_BUTTON, ok_button, 0));
    add_widget (layout_dlg,
                button_new (12, (width - b) / 2 + b1 + 1, B_CANCEL, NORMAL_BUTTON,
                            cancel_button, 0));

    dlg_select_widget (radio_widget);

    return layout_dlg;
}
static void init_configure (void)
{
    int i;
	static int i18n_config_flag = 0;
	static int b1, b2, b3;
	char* ok_button = _("&Ok");
	char* cancel_button = _("&Cancel");
	char* save_button = _("&Save");

	if (!i18n_config_flag)
	{
		register int l1;

		/* Similar code is in layout.c (init_layout())  */

		configure_title = _(" Configure options ");
		title1 = _(" Panel options ");
		title2 = _(" Pause after run... ");
		title3 = _(" Other options ");

		first_width = strlen (title1) + 1;
		for (i = 13; i < 18; i++)
		{
			check_options[i].text = _(check_options[i].text);
			l1 = strlen (check_options[i].text) + 7;
			if (l1 > first_width)
				first_width = l1;
		}

		i = sizeof(pause_options)/sizeof(char*);
		while (i--)
		{
			pause_options [i] = _(pause_options [i]);
			l1 = strlen (pause_options [i]) + 7;
			if (l1 > first_width)
				first_width = l1;
		}

		l1 = strlen (title2) + 1;
		if (l1 > first_width)
			first_width = l1;

		OX = first_width + 5;

		second_width = strlen (title3) + 1;
		for (i = 0; i < 13; i++)
		{
			check_options[i].text = _(check_options[i].text);
			l1 = strlen (check_options[i].text) + 7;
			if (l1 > second_width)
				second_width = l1;
		}

		l1 = 11 + strlen (ok_button)
		 	+ strlen (save_button)
			+ strlen (cancel_button);
		
		i = (first_width + second_width - l1) / 4;
		b1 = 5 + i;
		b2 = b1 + strlen(ok_button) + i + 6;
		b3 = b2 + strlen(save_button) + i + 4;

		i18n_config_flag = 1;
	}

    conf_dlg = create_dlg (0, 0, 20, first_width + second_width + 9,
		dialog_colors, configure_callback, "[Options Menu]",
		"option", DLG_CENTER | DLG_GRID);

    x_set_dialog_title (conf_dlg, _("Configure options"));

    add_widgetl (conf_dlg,
	button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0, 0, "button-cancel"),
	XV_WLAY_RIGHTOF);

    add_widgetl (conf_dlg,
	button_new (BY, b2, B_EXIT, NORMAL_BUTTON, save_button, 0, 0, "button-save"),
	XV_WLAY_RIGHTOF);
    
    add_widgetl (conf_dlg,
        button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0, 0, "button-ok"),
        XV_WLAY_CENTERROW);

#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options [i].tk

    /* Add all the checkboxes */
    for (i = 0; i < 13; i++){
	check_options [i].widget = check_new (OY + (13-i), OX+2, XTRACT(i));
	add_widgetl (conf_dlg, check_options [i].widget,
	    XV_WLAY_BELOWCLOSE);
    }

    pause_radio = radio_new (RY+1, RX+2, 3, pause_options, 1, "pause-radio");
    pause_radio->sel = pause_after_run;
#ifndef HAVE_GNOME
    add_widgetl (conf_dlg, pause_radio, XV_WLAY_BELOWCLOSE);
#endif
    for (i = 0; i < 6; i++){
	check_options [i+13].widget = check_new (PY + (6-i), PX+2,
						  XTRACT(i+13));
	add_widgetl (conf_dlg, check_options [i+13].widget,
	    XV_WLAY_BELOWCLOSE);
    }
}
Ejemplo n.º 9
0
sortfn *
sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive)
{
    int i, r, l;
    sortfn *result;
    WCheck *c, *case_sense;

    const char *ok_button = _("&OK");
    const char *cancel_button = _("&Cancel");
    const char *reverse_label = _("&Reverse");
    const char *case_label = _("case sensi&tive");
    const char *sort_title = _("Sort order");

    static int i18n_sort_flag = 0, check_pos = 0, button_pos = 0;

    if (!i18n_sort_flag) {
	int maxlen = 0;
	for (i = SORT_TYPES - 1; i >= 0; i--) {
	    sort_orders_names[i] = _(sort_orders[i].sort_name);
	    r = strlen (sort_orders_names[i]);
	    if (r > maxlen)
		maxlen = r;
	}

	check_pos = maxlen + 9;

	r = strlen (reverse_label) + 4;
	i = strlen (case_label) + 4;
	if (i > r)
	    r = i;

	l = strlen (ok_button) + 6;
	i = strlen (cancel_button) + 4;
	if (i > l)
	    l = i;

	i = check_pos + max (r, l) + 2;

	if (i > SORT_X)
	    SORT_X = i;

	i = strlen (sort_title) + 6;
	if (i > SORT_X)
	    SORT_X = i;

	button_pos = SORT_X - l - 2;

	i18n_sort_flag = 1;
    }

    result = 0;

    for (i = 0; i < SORT_TYPES; i++)
	if ((sortfn *) (sort_orders[i].sort_fn) == sort_fn) {
	    current_mode = i;
	    break;
	}

    dd = create_dlg (0, 0, SORT_Y, SORT_X, dialog_colors, NULL,
		     "[Sort Order...]", sort_title, DLG_CENTER | DLG_REVERSE);

    add_widget (dd,
		button_new (10, button_pos, B_CANCEL, NORMAL_BUTTON,
			    cancel_button, 0));

    add_widget (dd,
		button_new (9, button_pos, B_ENTER, DEFPUSH_BUTTON,
			    ok_button, 0));

    case_sense = check_new (4, check_pos, *case_sensitive, case_label);
    add_widget (dd, case_sense);
    c = check_new (3, check_pos, *reverse, reverse_label);
    add_widget (dd, c);

    my_radio = radio_new (3, 3, SORT_TYPES, sort_orders_names, 1);
    my_radio->sel = my_radio->pos = current_mode;

    add_widget (dd, my_radio);
    run_dlg (dd);

    r = dd->ret_value;
    if (r != B_CANCEL) {
	result = (sortfn *) sort_orders[my_radio->sel].sort_fn;
	*reverse = c->state & C_BOOL;
	*case_sensitive = case_sense->state & C_BOOL;
    } else
	result = sort_fn;
    destroy_dlg (dd);

    return result;
}
Ejemplo n.º 10
0
static void
display_init (int radio_sel, char *init_text, int _check_status,
	      char **_status)
{
    static const char *display_title = N_("Listing mode");
    static int i18n_displays_flag;
    const char *user_mini_status = _("user &Mini status");
    const char *ok_button = _("&OK");
    const char *cancel_button = _("&Cancel");

    static int button_start = 30;

    displays_status = _status;

    if (!i18n_displays_flag) {
	int i, l, maxlen = 0;
	const char *cp;

	display_title = _(display_title);
	for (i = 0; i < LIST_TYPES; i++) {
	    displays[i] = _(displays[i]);
	    if ((l = strlen (displays[i])) > maxlen)
		maxlen = l;
	}

	i = strlen (ok_button) + 5;
	l = strlen (cancel_button) + 3;
	l = max (i, l);

	i = maxlen + l + 16;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (user_mini_status) + 13;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (display_title) + 10;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	button_start = DISPLAY_X - l - 5;

	/* get hotkey of user-defined format string */
	cp = strchr (displays[USER_TYPE], '&');
	if (cp != NULL && *++cp != '\0')
	    user_hotkey = tolower (*cp);

	i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Listing Mode...]", display_title,
		     DLG_CENTER | DLG_REVERSE);

    add_widget (dd,
		button_new (4, button_start, B_CANCEL, NORMAL_BUTTON,
			    cancel_button, 0));

    add_widget (dd,
		button_new (3, button_start, B_ENTER, DEFPUSH_BUTTON,
			    ok_button, 0));

    status =
	input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
		   "mini-input");
    add_widget (dd, status);
    input_set_point (status, 0);

    check_status =
	check_new (9, 5, _check_status, user_mini_status);
    add_widget (dd, check_status);

    user =
	input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
		   "user-fmt-input");
    add_widget (dd, user);
    input_set_point (user, 0);

    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1);
    my_radio->sel = my_radio->pos = current_mode;
    add_widget (dd, my_radio);
}
Ejemplo n.º 11
0
static void
display_init (int radio_sel, char *init_text,
	      int _check_status, char ** _status)
{
	char* user_mini_status = _("user &Mini status");
	char* ok_button = _("&Ok");
	char* cancel_button = _("&Cancel");
	
	static int button_start = 30;
	
    displays_status = _status;

    if (!i18n_displays_flag){
		int i, l, maxlen = 0;
		char* cp;

 		display_title = _(display_title);
		for (i = 0; i < LIST_TYPES; i++)
		{
		    displays [i] = _(displays [i]);
			if ((l = strlen(displays [i])) > maxlen)
				maxlen = l;
		}

		i = strlen (ok_button) + 5;
		l = strlen (cancel_button) + 3;
		l = max(i, l);

		i = maxlen + l + 16;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		i = strlen (user_mini_status) + 13;
		if (i > DISPLAY_X)
			DISPLAY_X = i;
			
		i = strlen (display_title) + 8;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		button_start = DISPLAY_X - l - 5;
		
		/* get hotkey of user-defined format string */
		cp = strchr(displays[LIST_TYPES-1],'&');
		if (cp != NULL && *++cp != '\0')
			user_hotkey = tolower(*cp);

        i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Left and Right Menus]", "display",
		     DLG_CENTER | DLG_GRID);

    x_set_dialog_title (dd, _("Listing mode"));
    add_widgetl (dd,
        button_new (4, button_start, B_CANCEL, 
			NORMAL_BUTTON, cancel_button, 0, 0, "cancel-button"),
	XV_WLAY_RIGHTOF);

    add_widgetl (dd,
		button_new (3, button_start, B_ENTER, 
			DEFPUSH_BUTTON, ok_button, 0, 0, "ok-button"),
	 XV_WLAY_CENTERROW);

    status = input_new (10, 9, INPUT_COLOR, DISPLAY_X-14, _status [radio_sel], "mini-input");
    add_widgetl (dd, status, XV_WLAY_RIGHTDOWN);
    input_set_point (status, 0);

    check_status = check_new (9, 5, _check_status, user_mini_status, "mini-status");
    add_widgetl (dd, check_status, XV_WLAY_NEXTROW);
    
    user = input_new  (7, 9, INPUT_COLOR, DISPLAY_X-14, init_text, "user-fmt-input");
    add_widgetl (dd, user, XV_WLAY_RIGHTDOWN);
    input_set_point (user, 0);

#ifdef PORT_HAS_ICON_VIEW
    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1, "radio");
#else
    my_radio = radio_new (3, 5, LIST_TYPES-1, displays, 1, "radio");
#endif
    my_radio->sel = my_radio->pos = current_mode;
    add_widgetl (dd, my_radio, XV_WLAY_BELOWCLOSE);
}
static void init_listmode (char *oldlistformat)
{
    int i;
    char *s;
    int format_width = 0;
    int format_columns = 0;

    do_refresh ();

    listmode_dlg = create_dlg (0, 0, 22, 74, dialog_colors,
			      listmode_callback, listmode_section, "listmode",
			      DLG_CENTER);
    x_set_dialog_title (listmode_dlg, "Listing format edit");	    

#define XTRACT(i) BY+listmode_but[i].y, BX+listmode_but[i].x, listmode_but[i].ret_cmd, listmode_but[i].flags, listmode_but[i].text, 0, 0, NULL

    for (i = 0; i < BUTTONS; i++)
	add_widgetl (listmode_dlg, button_new (XTRACT (i)), (i == BUTTONS - 1) ?
	    XV_WLAY_CENTERROW : XV_WLAY_RIGHTOF);

    /* We add the labels. */
    for (i = 0; i < LABELS; i++){
	pname = label_new (listmode_text [i].y,
			   listmode_text [i].x, listmode_text [i].text, NULL);
	add_widget (listmode_dlg, pname);
    }

    add_widget (listmode_dlg, button_new (UY+13, UX+37, B_MINUS, NORMAL_BUTTON,
					  "&-", bminus_cback, 0, NULL));
    add_widget (listmode_dlg, button_new (UY+13, UX+34, B_PLUS, NORMAL_BUTTON,
					  "&+", bplus_cback, 0, NULL));
    radio_itemwidth = radio_new (UY+9, UX+22, 3, s_itemwidth, 1, NULL);
    add_widget (listmode_dlg, radio_itemwidth);
    radio_itemwidth = 0;
    radio_justify = radio_new (UY+5, UX+22, 3, s_justify, 1, NULL);
    add_widget (listmode_dlg, radio_justify);
    radio_justify->sel = 1;

    /* get new listbox */
    l_listmode = listbox_new (UY + 5, UX + 1, 16, 9, 0, l_call, NULL);

    if (strncmp (oldlistformat, "full ", 5) == 0){
	format_width = 1;
	oldlistformat += 5;
    }
    if (strncmp (oldlistformat, "half ", 5) == 0){
	oldlistformat += 5;
    }
    if (strncmp (oldlistformat, "2 ", 2) == 0){
	format_columns = 1;
	oldlistformat += 2;
    }
    if (strncmp (oldlistformat, "1 ", 2) == 0){
	oldlistformat += 2;
    }
    s = strtok (oldlistformat, ",");

    while (s){
	listbox_add_item (l_listmode, 0, 0, s, NULL);
	s = strtok (NULL, ",");
    }

    /* add listbox to the dialogs */
    add_widgetl (listmode_dlg, l_listmode, XV_WLAY_EXTENDWIDTH);

    radio_columns = radio_new (UY+1, UX+32, 2, s_columns, 1, NULL);
    add_widget (listmode_dlg, radio_columns);
    radio_columns->sel = format_columns;
    radio_genwidth = radio_new (UY+1, UX+2, 2, s_genwidth, 1, NULL);
    add_widget (listmode_dlg, radio_genwidth);
    radio_genwidth->sel = format_width;
}