Esempio n. 1
0
char *TXT_SelectFile(char *window_title, char **extensions)
{
    unsigned int i;
    size_t len;
    char *result;
    char **argv;
    int argc;

    if (!ZenityAvailable())
    {
        return NULL;
    }

    argv = calloc(4 + NumExtensions(extensions), sizeof(char *));
    argv[0] = ZENITY_BINARY;
    argv[1] = "--file-selection";
    argc = 2;

    if (window_title != NULL)
    {
        len = 10 + strlen(window_title);
        argv[argc] = malloc(len);
        TXT_snprintf(argv[argc], len, "--title=%s", window_title);
        ++argc;
    }

    if (extensions == TXT_DIRECTORY)
    {
        argv[argc] = strdup("--directory");
        ++argc;
    }
    else if (extensions != NULL)
    {
        for (i = 0; extensions[i] != NULL; ++i)
        {
            len = 30 + strlen(extensions[i]) * 2;
            argv[argc] = malloc(len);
            TXT_snprintf(argv[argc], len, "--file-filter=.%s | *.%s",
                         extensions[i], extensions[i]);
            ++argc;
        }
    }

    argv[argc] = NULL;

    result = ExecReadOutput(argv);

    for (i = 2; i < argc; ++i)
    {
        free(argv[i]);
    }

    free(argv);

    return result;
}
Esempio n. 2
0
void UpdateInputBox(void)
{
    char buf[20];

    TXT_snprintf(buf, sizeof(buf), "  %i", input_value);
    TXT_SetLabel(input_box, buf);
}
Esempio n. 3
0
void TXT_DrawASCIITable(void)
{
    unsigned char *screendata;
    char buf[10];
    int x, y;
    int n;

    screendata = TXT_GetScreenData();

    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
    TXT_BGColor(TXT_COLOR_BLACK, 0);

    for (y=0; y<16; ++y)
    {
        for (x=0; x<16; ++x)
        {
            n = y * 16 + x;

            TXT_GotoXY(x * 5, y);
            TXT_snprintf(buf, sizeof(buf), "%02x   ", n);
            TXT_Puts(buf);

            // Write the character directly to the screen memory buffer:

            screendata[(y * TXT_SCREEN_W + x * 5 + 3) * 2] = n;
        }
    }

    TXT_UpdateScreen();
}
Esempio n. 4
0
void AddOperatorButton(txt_table_t *table, char *label, operator_t op)
{
    char buf[10];
    operator_t *op_copy;

    op_copy = malloc(sizeof(operator_t));
    *op_copy = op;

    TXT_snprintf(buf, sizeof(buf), "  %s  ", label);

    TXT_AddWidget(table, TXT_NewButton2(buf, Operator, op_copy));
}
Esempio n. 5
0
void AddNumberButton(txt_table_t *table, int value)
{
    char buf[10];
    int *val_copy;

    val_copy = malloc(sizeof(int));
    *val_copy = value;

    TXT_snprintf(buf, sizeof(buf), "  %i  ", value);

    TXT_AddWidget(table, TXT_NewButton2(buf, InsertNumber, val_copy));
}
Esempio n. 6
0
static char *GenerateAppleScript(char *window_title, char **extensions)
{
    char *selector, *result;
    size_t result_len;

    selector = GenerateSelector(window_title, extensions);

    result_len = strlen(APPLESCRIPT_WRAPPER) + strlen(selector);
    result = malloc(result_len);
    TXT_snprintf(result, result_len, APPLESCRIPT_WRAPPER, selector);
    free(selector);

    return result;
}
Esempio n. 7
0
static char *GenerateFilterString(char **extensions)
{
    unsigned int result_len = 1;
    unsigned int i;
    char *result, *out;
    size_t out_len, offset;

    if (extensions == NULL)
    {
        return NULL;
    }

    for (i = 0; extensions[i] != NULL; ++i)
    {
        result_len += 16 + strlen(extensions[i]) * 3;
    }

    result = malloc(result_len);
    out = result; out_len = result_len;

    for (i = 0; extensions[i] != NULL; ++i)
    {
        // .wad files (*.wad)\0
        offset = TXT_snprintf(out, out_len, "%s files (*.%s)",
                              extensions[i], extensions[i]);
        out += offset + 1; out_len -= offset + 1;

        // *.wad\0
        offset = TXT_snprintf(out, out_len, "*.%s", extensions[i]);
        out_len += offset + 1; out_len -= offset + 1;
    }

    *out = '\0';

    return result;
}
static void SetBufferFromValue(txt_inputbox_t *inputbox)
{
    if (inputbox->widget.widget_class == &txt_inputbox_class)
    {
        char **value = (char **) inputbox->value;

        if (*value != NULL)
        {
            TXT_StringCopy(inputbox->buffer, *value, inputbox->size);
        }
        else
        {
            TXT_StringCopy(inputbox->buffer, "", inputbox->buffer_len);
        }
    }
    else if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        int *value = (int *) inputbox->value;
        TXT_snprintf(inputbox->buffer, inputbox->buffer_len, "%i", *value);
    }
}