Redtools requester library
Redtools requester library is a small library that offers simple requesters and dialogs for user disposal. Detroit engine has bindings to use Redtools library if it is compiled and installed.
Redtools library can be compiled along with the Detroit engine by giving --with-redtools parameter to configure script. Redtools library needs Motif (that is, libXm and libXt) in order to work. Also use of Xft fonts, its default typeface and size can be given as a configure parameter:
--with-redtools \ --with-redtools-xft \ --with-redtools-xft-typeface=Noto \ --with-redtools-xft-fontsize=12
When Redtools library is installed, any program using Detroit engine can use it to output messages when -pm command line switch is used.
-pm, --popup_messages Use graphical dialog popup messages if possible.
Redtools requester library can be used with any other program too, it is not bolted to Detroit engine too tight. Below is working example how to write standalone program that makes use one of the Redtools requesters. See engine/redtools/example.c how to use other dialogs offered by Redtools library. Example pops up a dialog which looks like this:
Simple Redtools dialog
|
Example source code:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "redtools.h" int main() { REDTOOLS rt; unsigned int c; /* Predefined dialog buttons */ char *buttons[] = { "Cheese", "Ham", "Prawn", "Tuna", "Plain green", NULL }; /* Initialize the redtools library, if returned handle is NULL, initialization was not succesful, and program must not call any redtools functions */ if((rt = red_initialize()) == NULL) { printf("!\n! failed to initialize redtools library\n!\n"); exit(1); } /* Add dialog title... */ (void) red_dialog_add_title(rt, "What kind of starter salad would you like?"); /* ...then the buttons... */ (void) red_dialog_add_buttons(rt, buttons); /* ...and display it to the user */ c = red_question_dialog(rt); if(c != 0) printf("select: %u (%s)\n", c, buttons[c - 1]); /* Free resources allocated by the redtools library, library is not useable after this */ (void) red_finalize(rt); exit(0); }
X resources
To get Redtools requesters and dialogs look like the screenshot above, following .Xresources can be used:
*background: #aeb2c3 *foreground: #000000 *XmList*background: #fff7e9 *XmText*background: #fff7e9 *XmTextField*background: #fff7e9 *.renderTable: variable *.renderTable.variable.fontName: Source Sans Pro *.renderTable.variable.fontSize: 12 *.renderTable.variable.fontType: FONT_IS_XFT Xft.antialias: 1 Xft.autohint: 0 Xft.dpi: 96 Xft.hinting: 1 Xft.hintstyle: hintfull Xft.lcdfilter: lcddefault Xft.rgba: rgb
Copyright © 2023, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.