Files
lotherk ec322652d3 MCDE dtmail: the settings window, General and Viewing (t0138)
dtmail opens the shared settings window (lib/DtWidget/McdePrefs.c) with
`dtmail -prefs`: a row of icon tabs, the page under them, no OK or Cancel.
The argument is taken out of argv before Xt sees it, and RoamApp::initialize
returns after building the window -- no mailbox and no ToolTalk are needed
for it.

  General  Default email reader (dtmail, Thunderbird, Evolution, mutt,
           xdg-email), Check for new mail (Manually, 1, 5, 15, 30, 60
           minutes), New mail sound (the events of the session's theme, a
           click plays it), Play sounds for other mail actions, Show the
           unread count in the front panel, Downloads folder, Remove
           unedited downloads, and what a search includes (Trash, Junk).
  Viewing  Show message headers (All/Brief/Full), the order of the list,
           the preview pane.

Values are kept as English KEY=VALUE in ~/.dt/dtmail.conf (McdePrefsConf),
the labels themselves (mailreader=Thunderbird), so the file stays readable.
dtmail's CDE Options dialog stays for the retrieval details; these keys are
the one pattern every MCDE program has, and wiring each into dtmail's own
option system is a follow-up.

McdePrefs grew what dtmail needed and the measurements found:

  * the page is a vertical XmPACK_COLUMN row column of rows; a row is a form
    of its own, made by McdePrefsRowBegin()/McdePrefsRowEnd() -- a widget
    cannot be reparented, so a row cannot take one made elsewhere (the old
    chained-form rows overlapped with many rows);
  * the window takes the size of the chosen page (its children are measured
    after the page is managed) and the title is the page's name;
  * a tab click finds its window by walking up the widget chain to a shell
    whose XmNuserData is a Prefs -- XtParent(XtParent(w)) alone found
    nothing, so no tab did anything before (measured).

dtpad's settings use the same two calls now; its window still writes
~/.dt/dtpad.conf.

Measured under Xvfb with xdotool:

  - dtmail -prefs: the General page -- docs/screenshots/leopard/
    Mail-Preferences-mcde.png -- and after a click on the Viewing tab the
    title is "Viewing" and the window 356x275 instead of 430x634
    (docs/screenshots/leopard/Mail-Preferences-Viewing-mcde.png);
  - Default email reader -> Thunderbird: ~/.dt/dtmail.conf has
    "mailreader=Thunderbird";
  - the Downloads field typed to /tmp/Downloads and Return:
    "downloads=/tmp/Downloads";
  - "Play sounds for other mail actions" off and on again: "othersounds=0"
    then "othersounds=1";
  - dtpad's Wrap to fit: "wrap=1" in ~/.dt/dtpad.conf;
  - make check lib/DtWidget: test_prefs PASS; make lib/DtWidget, dtpad,
    dtmail exit=0.

Open (follow-up): the reference's other pages (Accounts, Signatures, Rules),
wiring the keys into dtmail's own options, and ~/.dt/defaults with a
mailto: action -- choosing Thunderbird here stores the choice, but the
mailto: link still goes to dtmail's own action.
2026-11-14 13:03:41 +00:00

65 lines
2.6 KiB
C

/*
* McdePrefs.h -- MCDE: the settings window of a program (McdePrefs.c)
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*
* The reference's preferences window, one for every MCDE program: a row of
* icon tabs (the active one pressed), the tab's form under it, no OK or
* Cancel -- a change goes to the program when it is made. Values that are
* to survive a restart are kept in ~/.dt/<prog>.conf as KEY=VALUE (English,
* one a line), the tab shown last in "lasttab=".
*
* Widget w = McdePrefsCreate(toplevel, "dtpad");
* McdePrefsAddTab(w, "Editing", "DtKeybd", BuildEditing, pPad);
* McdePrefsShow(w, NULL); -- or "Editing"
*
* In BuildEditing(form, data) the program adds its widgets with
* McdePrefsRowBegin()/McdePrefsRowEnd()/McdePrefsSeparator() and its own
* callbacks; those call
* McdePrefsSet() to keep a value. McdePrefsConfGet/_Set are the same store
* without a widget, for the program's start (McdePrefsConf.c has no X).
*/
#ifndef _Dt_McdePrefs_h
#define _Dt_McdePrefs_h
#include <stddef.h>
#include <X11/Intrinsic.h>
#ifdef __cplusplus
extern "C" {
#endif
/* the settings window of PROG; its toplevel is PARENT's */
Widget McdePrefsCreate(Widget parent, const char *prog);
/* a tab: its name (also the window's title), an icon of
* appconfig/icons/C (its .m.pm or .pm), the builder of its form and its
* data; the form is built the first time the tab is shown */
int McdePrefsAddTab(Widget prefs, const char *name, const char *icon,
Widget (*build)(Widget form, void *data), void *data);
/* show the window on TAB (NULL: the tab shown last, else the first) */
void McdePrefsShow(Widget prefs, const char *tab);
/* a row of a form: LABEL right-aligned at the left; the row is returned so
* the caller creates its widget with the row as parent, then hands it to
* McdePrefsRowEnd() (rows stack in the order they are added) */
Widget McdePrefsRowBegin(Widget form, const char *label);
void McdePrefsRowEnd(Widget row, Widget child);
/* a separator across the form, under the rows so far */
Widget McdePrefsSeparator(Widget form);
/* a value of the program's conf file: 1 and BUF when KEY is there, 0 when
* not; and writing one (0 on success, -1) */
int McdePrefsConfGet(const char *prog, const char *key, char *buf,
size_t len);
int McdePrefsConfSet(const char *prog, const char *key, const char *value);
/* the same store for the window's PROG */
int McdePrefsGet(Widget prefs, const char *key, char *buf, size_t len);
int McdePrefsSet(Widget prefs, const char *key, const char *value);
#ifdef __cplusplus
}
#endif
#endif /* _Dt_McdePrefs_h */