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.
This commit is contained in:
lotherk committed 2026-11-14 13:03:41 +00:00
1 parent ca3080f346
commit ec322652d3
8 files changed
+517 -53

No files matched your search

+25 -5
View File
@@ -172,12 +172,32 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
has no capture API and no sound-device list yet.
- **Program settings window** (`lib/DtWidget/McdePrefs.c`, `include/Dt/
McdePrefs.h`): the reference's shape for every program -- a row of icon
tabs (`appconfig/icons/C`, the active one pressed), the tab's form under
it, no OK/Cancel; a change goes to the program at once and is kept in
tabs (`appconfig/icons/C`, the active one pressed), the page under them,
no OK/Cancel; a change goes to the program at once and is kept in
`~/.dt/<prog>.conf` (`KEY=VALUE`, the last tab as `lasttab=`; the store
without X is `McdePrefsConf.c`, tested by `test_prefs`). dtpad is the
first user (Options > Preferences...: wrap, overstrike, status line);
dtfile, dtcalendar and the others still have their CDE dialogs.
without X is `McdePrefsConf.c`, tested by `test_prefs`). The page is a
vertical `XmPACK_COLUMN` row column of rows; `McdePrefsRowBegin(form,
label)` returns the row, the caller builds its widget with the row as
parent and calls `McdePrefsRowEnd(row, child)` (a widget cannot be
reparented, so a row cannot take a widget made elsewhere). The window
takes the size of the page on a tab change (the children are measured, not
the page's request: measured 2026-11-14) and its title is the page's name.
dtpad was the first user, dtmail the second (Options/`dtmail -prefs`:
General and Viewing). Tab clicks find their window by walking up the
widget chain to a shell whose `XmNuserData` is a `Prefs` -- an
`XtParent(XtParent(w))` lookup is not enough (measured: the tabs did
nothing).
- **dtmail's settings**: `dtmail/McdeMailPrefs.C`, opened by `dtmail -prefs`
(the argument is taken out before Xt sees it; `RoamApp::initialize` returns
after building the window, so no mailbox and no ToolTalk are needed). It
writes `~/.dt/dtmail.conf`: `mailreader` (the label, e.g. Thunderbird),
`checkinterval`, `newmailsound` (an event of the theme, played on the
click), `othersounds`, `frontpanelcount`, `downloads`, `removedownloads`,
`searchtrash`, `searchjunk`, `headers`, `sort`, `preview`. The CDE Options
dialog (OptCmd.C) stays for the retrieval details; wiring these keys into
dtmail's own option system, the rest of the reference's pages (Accounts,
Signatures, Rules) and the `~/.dt/defaults` file for a mailto: reader are
follow-ups.
- **Strip view** (`dtfile/Strip.c`, Command+4): the reference's Cover Flow
without compositing -- the chosen picture large in the middle, three
neighbours flat each side (the type's picture when a file is no picture),
+7 -4
View File
@@ -14,7 +14,8 @@
* McdePrefsShow(w, NULL); -- or "Editing"
*
* In BuildEditing(form, data) the program adds its widgets with
* McdePrefsRow()/McdePrefsSeparator() and its own callbacks; those call
* 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).
*/
@@ -39,9 +40,11 @@ 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, CHILD to its right;
* rows stack in the order they are added */
Widget McdePrefsRow(Widget form, const char *label, Widget child);
/* 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);
+95 -35
View File
@@ -54,16 +54,70 @@ static Prefs *prefs[8];
static Prefs *
Of(Widget w)
{
Prefs *p = NULL;
int i;
if (w == NULL)
return NULL;
for (i = 0; i < 8; i++)
if (prefs[i] != NULL && prefs[i]->shell == w)
return prefs[i];
XtVaGetValues(w, XmNuserData, &p, NULL);
return p;
/* the shell itself, or any widget under it (a tab, a row): up the
* chain until one of our shells or its userData pointer is found */
for (; w != NULL; w = XtParent(w)) {
void *d = NULL;
for (i = 0; i < 8; i++)
if (prefs[i] != NULL && prefs[i]->shell == w)
return prefs[i];
XtVaGetValues(w, XmNuserData, &d, NULL);
for (i = 0; i < 8; i++)
if (prefs[i] != NULL && (void *) prefs[i] == d)
return prefs[i];
}
return NULL;
}
/* the window takes the size the page asks for: the reference's window is as
* tall as the chosen page (XtQueryGeometry gives the preferred size) */
static void
FitShell(Prefs *p)
{
Widget *kids = NULL, page;
Cardinal n = 0, i;
Dimension th = 0;
int maxy = 0, maxx = 0;
if (p == NULL || p->current < 0 || p->current >= p->n)
return;
page = p->tab[p->current].page;
if (!XtIsManaged(page))
return;
if (!XtIsSubclass(page, compositeWidgetClass))
return;
XtVaGetValues(page, XmNchildren, &kids, XmNnumChildren, &n, NULL);
for (i = 0; i < n; i++) {
Position y = 0, x = 0;
Dimension h = 0, w = 0;
if (!XtIsManaged(kids[i]))
continue;
XtVaGetValues(kids[i], XmNy, &y, XmNheight, &h,
XmNx, &x, XmNwidth, &w, NULL);
if ((int) y + (int) h > maxy)
maxy = (int) y + (int) h;
if ((int) x + (int) w > maxx)
maxx = (int) x + (int) w;
}
XtVaGetValues(p->tabs, XmNheight, &th, NULL);
if (maxy < 60)
return; /* not laid out yet: the map callback comes */
if (maxx < 300)
maxx = 300;
XtVaSetValues(p->shell, XmNwidth, maxx + 56,
XmNheight, maxy + (int) th + 64, NULL);
}
static void
Mapped(Widget w, XtPointer data, XtPointer call)
{
(void) w;
(void) call;
FitShell((Prefs *) data);
}
static void
@@ -88,6 +142,8 @@ ShowTab(Prefs *p, int i)
}
p->current = i;
XtVaSetValues(p->shell, XmNtitle, p->tab[i].name, NULL);
XmUpdateDisplay(p->tab[i].page);
FitShell(p);
(void)McdePrefsConfSet(p->prog, "lasttab", p->tab[i].name);
}
@@ -176,6 +232,8 @@ McdePrefsCreate(Widget parent, const char *prog)
XmNmarginWidth, 0, NULL);
XtVaSetValues(p->shell, XmNuserData, p, NULL);
XtAddEventHandler(p->shell, KeyPressMask, False, KeyHandler, p);
/* the page's rows have their sizes once the shell is mapped */
XtAddCallback(p->shell, XmNmapCallback, Mapped, p);
for (i = 0; i < 8; i++)
if (prefs[i] == NULL) {
prefs[i] = p;
@@ -215,8 +273,14 @@ McdePrefsAddTab(Widget w, const char *name, const char *icon,
i = p->n;
XtAddCallback(t->toggle, XmNvalueChangedCallback, TabChosen,
(XtPointer) (size_t) i);
t->page = XtVaCreateWidget("prefsPage", xmFormWidgetClass, p->pages,
XmNmarginWidth, 8, XmNmarginHeight, 8, NULL);
/* a column of rows: each row is a form of its own (a single form with
* every row attached to the one before is fragile) */
/* a column of rows: a row is a form of its own, so the rows stack
* without chained attachments */
t->page = XtVaCreateWidget("prefsPage", xmRowColumnWidgetClass,
p->pages, XmNorientation, XmVERTICAL, XmNpacking,
XmPACK_COLUMN, XmNspacing, 8, XmNmarginWidth, 8,
XmNmarginHeight, 8, NULL);
p->n++;
return i;
}
@@ -248,44 +312,40 @@ McdePrefsShow(Widget w, const char *tab)
}
Widget
McdePrefsRow(Widget form, const char *label, Widget child)
McdePrefsRowBegin(Widget form, const char *label)
{
Widget last = NULL, l;
Widget row = XtVaCreateManagedWidget("prefsRow", xmFormWidgetClass,
form, NULL);
XmString s = XmStringCreateLocalized((char *) label);
XtVaGetValues(form, XmNuserData, &last, NULL);
l = XtVaCreateManagedWidget("prefsLabel", xmLabelWidgetClass, form,
XtVaCreateManagedWidget("prefsLabel", xmLabelWidgetClass, row,
XmNlabelString, s, XmNwidth, 170, XmNrecomputeSize, False,
XmNalignment, XmALIGNMENT_END,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, last != NULL ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, last,
XmNtopOffset, last != NULL ? 8 : 0, NULL);
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, NULL);
XmStringFree(s);
return row;
}
void
McdePrefsRowEnd(Widget row, Widget child)
{
Widget label = XtNameToWidget(row, "prefsLabel");
XtVaSetValues(child,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, l, XmNleftOffset, 8,
XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
XmNtopWidget, l,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(form, XmNuserData, child, NULL);
return l;
XtManageChild(child);
}
Widget
McdePrefsSeparator(Widget form)
{
Widget last = NULL, sep;
XtVaGetValues(form, XmNuserData, &last, NULL);
sep = XtVaCreateManagedWidget("prefsSep", xmSeparatorWidgetClass,
form, XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, last != NULL ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, last,
XmNtopOffset, 12, NULL);
XtVaSetValues(form, XmNuserData, sep, NULL);
return sep;
return XtVaCreateManagedWidget("prefsSep", xmSeparatorWidgetClass,
form, XmNorientation, XmHORIZONTAL, XmNmarginTop, 4,
XmNmarginBottom, 4, NULL);
}
int
+4 -3
View File
@@ -2,13 +2,14 @@ MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = dtmail
dtmail_CXXFLAGS = -I../include -I../include/MotifApp -I../include/utils \
dtmail_CXXFLAGS = -I$(top_srcdir)/include -I../include -I../include/MotifApp -I../include/utils \
-I../include/DtMail -I../libDtMail/RFC -I$(x_includes) \
-I$(srcdir)/lib -I../../dthelp -DRELEASE_NOTES \
-DDTMAIL_TOOLTALK -DDTEDITOR
# LIBMCDESOUND: the events of the session's theme (McdeMailPrefs.C)
dtmail_LDADD = ../libDtMail/libDtMail.a ../MotifApp/libMotifApp.a \
$(DTCLIENTLIBS) $(XTOOLLIB) $(TIRPCLIB)
$(LIBMCDESOUND) $(DTCLIENTLIBS) $(XTOOLLIB) $(TIRPCLIB)
dtmail_SOURCES = AliasListUiItem.C AlternatesListUiItem.C \
AntiCheckBoxUiItem.C AttachArea.C \
@@ -32,7 +33,7 @@ dtmail_SOURCES = AliasListUiItem.C AlternatesListUiItem.C \
MsgScrollingList.C NoOpCmd.C \
OptCmd.C PasswordDialogManager.C \
PropUi.C QueryDialogManager.C \
RoamApp.C RoamCmds.C \
McdeMailPrefs.C RoamApp.C RoamCmds.C \
RoamInterruptibleCmd.C RoamMenuWindow.C \
ScaleUiItem.C SendMsgDialog.C \
Sort.C SortCmd.C \
+337
View File
@@ -0,0 +1,337 @@
/*
* McdeMailPrefs.C -- MCDE: the settings window of dtmail (t0138)
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*
* The reference's window: a row of icon tabs (the page chosen is pressed),
* the page under them, no OK or Cancel -- a change is kept at once in
* ~/.dt/dtmail.conf (the same store as dtpad's, McdePrefs.h). Two pages:
*
* General the reader that opens mailto: (an entry of ~/.dt/defaults),
* how often dtmail looks for new mail, the sound of new mail
* (an event of the session's theme), the unread count in the
* front panel, the downloads folder, and what a search
* includes.
* Viewing the headers a message shows, the order of the list, the
* preview pane.
*
* dtmail's own CDE Options dialog (OptCmd.C) stays for the retrieval and
* view details; this window is the one pattern every MCDE program has.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Intrinsic.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
#include <Dt/McdePrefs.h>
extern "C" {
#include <Mcde/Sound.h>
}
#include "McdeMailPrefs.h"
static Widget prefs;
static Widget downloadsField, trashToggle, junkToggle, previewToggle;
/* ---- small helpers ------------------------------------------------------ */
static void
Set(Widget w, const char *text)
{
XmString s = XmStringCreateLocalized((char *) text);
XtVaSetValues(w, XmNlabelString, s, NULL);
XmStringFree(s);
}
/* the value of a key, or DEF */
static const char *
Value(const char *key, const char *def, char *buf, size_t len)
{
if (!McdePrefsGet(prefs, key, buf, len) || buf[0] == '\0')
(void)snprintf(buf, len, "%s", def);
return buf;
}
/* an option menu of ITEMS; the chosen one is written as KEY ("index") */
typedef struct {
Widget menu;
Widget item[16];
const char *const *names;
int n;
const char *key;
} Opt;
static Opt *mailReaderOpt, *checkOpt, *removeOpt, *headersOpt, *sortOpt;
static int
OptIndex(Opt *o)
{
Widget hist = NULL;
int i;
XtVaGetValues(o->menu, XmNmenuHistory, &hist, NULL);
for (i = 0; i < o->n; i++)
if (o->item[i] == hist)
return i;
return 0;
}
static void
OptChosen(Widget w, XtPointer data, XtPointer call)
{
Opt *o = (Opt *) data;
(void) w;
(void) call;
/* the English label, so the file stays readable */
(void)McdePrefsSet(prefs, o->key, o->names[OptIndex(o)]);
}
static Opt *
OptMake(Widget parent, const char *name, const char *const *names, int n,
const char *key, const char *def)
{
static Opt pool[8];
static int used;
Opt *o = &pool[used++];
Widget pd;
char v[128];
const char *cur = Value(key, def, v, sizeof v);
int at = 0, i;
o->names = names;
o->n = n < 16 ? n : 16;
o->key = key;
o->menu = XmCreateOptionMenu(parent, (char *) name, NULL, 0);
pd = XmCreatePulldownMenu(o->menu, "optMenu", NULL, 0);
for (i = 0; i < o->n; i++) {
XmString s = XmStringCreateLocalized((char *) names[i]);
o->item[i] = XtVaCreateManagedWidget("optItem",
xmPushButtonGadgetClass, pd, XmNlabelString, s, NULL);
XmStringFree(s);
XtAddCallback(o->item[i], XmNactivateCallback, OptChosen, o);
}
for (i = 0; i < o->n; i++)
if (strcmp(names[i], cur) == 0)
at = i;
XtVaSetValues(o->menu, XmNsubMenuId, pd, XmNmenuHistory,
o->item[at], NULL);
XtManageChild(o->menu);
return o;
}
/* the text of the downloads folder: on Return and when the field loses the
* focus */
static void
DownloadsChanged(Widget w, XtPointer data, XtPointer call)
{
char *text = XmTextFieldGetString(w);
(void) data;
(void) call;
if (text != NULL) {
(void)McdePrefsSet(prefs, "downloads", text);
XtFree(text);
}
}
static void
ToggleChanged(Widget w, XtPointer data, XtPointer call)
{
const char *key = (const char *) data;
char v[4];
(void) w;
(void) call;
(void)snprintf(v, sizeof v, "%d",
XmToggleButtonGetState(w) ? 1 : 0);
(void)McdePrefsSet(prefs, key, v);
}
static Widget
Toggle(Widget form, const char *label, const char *key, const char *def)
{
char v[8];
Widget t = XtVaCreateManagedWidget((char *) key,
xmToggleButtonWidgetClass, form, XmNlabelString,
XmStringCreateLocalized((char *) label), NULL);
XmToggleButtonSetState(t, atoi(Value(key, def, v, sizeof v)) != 0,
False);
XtAddCallback(t, XmNvalueChangedCallback, ToggleChanged, (XtPointer) key);
return t;
}
/* ---- General ------------------------------------------------------------ */
static void
SoundChosen(Widget w, XtPointer data, XtPointer call)
{
Opt *o = (Opt *) data;
int i = OptIndex(o);
(void) w;
(void) call;
/* hear it: the theme's event, through mcdesoundd */
(void)McdeSoundEvent(XtDisplay(o->menu), o->names[i]);
}
static Widget
GeneralPage(Widget form, void *data)
{
static const char *const readers[] = { "dtmail", "Thunderbird",
"Evolution", "mutt", "xdg-email" };
static const char *const checks[] = { "Manually", "Every minute",
"Every 5 minutes", "Every 15 minutes", "Every 30 minutes",
"Every hour" };
static const char *const removes[] = { "Never", "After the message "
"is deleted" };
char names[16][64];
const char *sounds[16];
int nsounds = 0, i;
char v[512];
Widget row, l, t;
Opt *soundO;
(void) data;
row = McdePrefsRowBegin(form, "Default email reader:");
mailReaderOpt = OptMake(row, "reader", readers, 5, "mailreader", "dtmail");
McdePrefsRowEnd(row, mailReaderOpt->menu);
row = McdePrefsRowBegin(form, "Check for new mail:");
checkOpt = OptMake(row, "check", checks, 6, "checkinterval", "Every 5 minutes");
McdePrefsRowEnd(row, checkOpt->menu);
/* the events of the session's theme (McdeSoundEventName) */
(void) McdeSoundInit();
for (i = 0; i < McdeSoundCount() && i < 16; i++) {
const char *n = McdeSoundEventName(i);
if (n != NULL) {
(void)snprintf(names[nsounds], sizeof names[0], "%s", n);
sounds[nsounds] = names[nsounds];
nsounds++;
}
}
if (nsounds == 0) {
(void)snprintf(names[0], sizeof names[0], "Beep");
sounds[0] = names[0];
nsounds = 1;
}
row = McdePrefsRowBegin(form, "New mail sound:");
soundO = OptMake(row, "sound", sounds, nsounds, "newmailsound", "Beep");
for (i = 0; i < soundO->n; i++)
XtAddCallback(soundO->item[i], XmNactivateCallback,
SoundChosen, soundO);
McdePrefsRowEnd(row, soundO->menu);
t = Toggle(form, "Play sounds for other mail actions", "othersounds",
"1");
(void) t;
(void) Toggle(form, "Show the unread count in the front panel",
"frontpanelcount", "1");
row = McdePrefsRowBegin(form, "Downloads folder:");
downloadsField = XtVaCreateManagedWidget("downloads",
xmTextFieldWidgetClass, row, XmNcolumns, 30, NULL);
{
const char *home = getenv("HOME");
char def[512];
(void)snprintf(def, sizeof def, "%s/Downloads",
home != NULL ? home : ".");
XmTextFieldSetString(downloadsField, (char *) Value("downloads",
def, v, sizeof v));
}
XtAddCallback(downloadsField, XmNactivateCallback, DownloadsChanged,
NULL);
XtAddCallback(downloadsField, XmNlosingFocusCallback, DownloadsChanged,
NULL);
McdePrefsRowEnd(row, downloadsField);
row = McdePrefsRowBegin(form, "Remove unedited downloads:");
removeOpt = OptMake(row, "remove", removes, 2, "removedownloads",
"Never");
McdePrefsRowEnd(row, removeOpt->menu);
(void) McdePrefsSeparator(form);
l = XtVaCreateManagedWidget("searchLabel", xmLabelWidgetClass, form,
XmNlabelString, XmStringCreateLocalized("When searching all "
"mailboxes, include results from:"), XmNalignment,
XmALIGNMENT_BEGINNING, NULL);
(void) l;
trashToggle = Toggle(form, "Trash", "searchtrash", "1");
junkToggle = Toggle(form, "Junk", "searchjunk", "0");
(void) trashToggle;
(void) junkToggle;
l = XtVaCreateManagedWidget("generalNote", xmLabelWidgetClass, form,
XmNlabelString, XmStringCreateLocalized("A change is kept at "
"once; dtmail reads it at its next start."),
XmNalignment, XmALIGNMENT_BEGINNING, NULL);
(void) l;
return form;
}
/* ---- Viewing ------------------------------------------------------------ */
static Widget
ViewingPage(Widget form, void *data)
{
static const char *const headers[] = { "All", "Brief", "Full" };
static const char *const sorts[] = { "Date", "Sender", "Subject" };
Widget row;
(void) data;
row = McdePrefsRowBegin(form, "Show message headers:");
headersOpt = OptMake(row, "headers", headers, 3, "headers", "All");
McdePrefsRowEnd(row, headersOpt->menu);
row = McdePrefsRowBegin(form, "Sort the message list by:");
sortOpt = OptMake(row, "sort", sorts, 3, "sort", "Date");
McdePrefsRowEnd(row, sortOpt->menu);
previewToggle = Toggle(form, "Show the preview pane", "preview", "1");
(void) previewToggle;
return form;
}
/* ---- the window --------------------------------------------------------- */
int
McdeMailPrefsWanted(int *argcp, char **argv)
{
int i, found = 0, out = 1;
for (i = 1; i < *argcp; i++) {
if (strcmp(argv[i], "-prefs") == 0 ||
strcmp(argv[i], "-preferences") == 0) {
found = 1;
continue;
}
argv[out++] = argv[i];
}
argv[out] = NULL;
*argcp = out;
return found;
}
void
McdeMailPrefsShow(void *parent)
{
prefs = McdePrefsCreate((Widget) parent, "dtmail");
if (prefs == NULL)
return;
(void) McdePrefsAddTab(prefs, "General", "Dtmail", GeneralPage, NULL);
(void) McdePrefsAddTab(prefs, "Viewing", "DtBkdrp", ViewingPage, NULL);
McdePrefsShow(prefs, NULL);
}
+27
View File
@@ -0,0 +1,27 @@
/*
* McdeMailPrefs.h -- MCDE: dtmail's settings window (McdeMailPrefs.C)
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*
* The reference's preferences window on the shared pattern of
* lib/DtWidget/McdePrefs.c: icon tabs as the page chooser, the page under
* them, no OK or Cancel. dtmail -prefs opens it without a mailbox.
*/
#ifndef _McdeMailPrefs_h
#define _McdeMailPrefs_h
#ifdef __cplusplus
extern "C" {
#endif
/* remove -prefs/-preferences from the arguments; 1 when one was there */
int McdeMailPrefsWanted(int *argcp, char **argv);
/* the window, with PARENT as its parent widget (the application shell) */
void McdeMailPrefsShow(void *parent);
#ifdef __cplusplus
}
#endif
#endif /* _McdeMailPrefs_h */
+11
View File
@@ -114,6 +114,7 @@
#include "MemUtils.hh"
#include "MailMsg.h"
#include "RoamApp.h"
#include "McdeMailPrefs.h"
#include "RoamMenuWindow.h"
#include "RoamCmds.h"
#include "SendMsgDialog.h"
@@ -1000,6 +1001,11 @@ void RoamApp::initialize(int *argcp, char **argv)
sigaction(SIGSEGV, action, NULL);
sigaction(SIGTERM, action, NULL);
// MCDE: dtmail -prefs opens the settings window of the shared pattern
// (McdePrefs.h) and nothing else: no mailbox, no ToolTalk. The option
// is taken out of the arguments before Xt sees them.
int mcdePrefs = McdeMailPrefsWanted(argcp, argv);
// Must be called before XtAppInitialize.
XtSetLanguageProc(NULL, NULL, NULL);
@@ -1010,6 +1016,11 @@ void RoamApp::initialize(int *argcp, char **argv)
// This will take care of standard arguments such as -display.
Application::initialize(argcp,argv);
if (mcdePrefs) {
McdeMailPrefsShow((void *) baseWidget());
return;
}
// If -session arg is present remove it and return session file name.
session_file = parseSessionArg(argcp, argv);
+11 -6
View File
@@ -216,18 +216,21 @@ PrefsEditing(Widget form, void *data)
Editor *pPad = (Editor *) data;
Widget t;
Widget row = McdePrefsRowBegin(form, "Wrap to fit:");
t = XtVaCreateManagedWidget("prefWrap", xmToggleButtonWidgetClass,
form, XmNlabelString, XmStringCreateLocalized("On"),
row, XmNlabelString, XmStringCreateLocalized("On"),
XmNset, pPad->xrdb.wordWrap, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
(void) McdePrefsRow(form, "Wrap to fit:", t);
McdePrefsRowEnd(row, t);
McdePrefsSeparator(form);
row = McdePrefsRowBegin(form, "Overstrike:");
t = XtVaCreateManagedWidget("prefOverstrike",
xmToggleButtonWidgetClass, form, XmNlabelString,
xmToggleButtonWidgetClass, row, XmNlabelString,
XmStringCreateLocalized("On"), XmNset,
pPad->xrdb.overstrike, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
(void) McdePrefsRow(form, "Overstrike:", t);
McdePrefsRowEnd(row, t);
return form;
}
@@ -237,11 +240,13 @@ PrefsWindow(Widget form, void *data)
Editor *pPad = (Editor *) data;
Widget t, note;
Widget row = McdePrefsRowBegin(form, "Status line:");
t = XtVaCreateManagedWidget("prefStatus", xmToggleButtonWidgetClass,
form, XmNlabelString, XmStringCreateLocalized("On"), XmNset,
row, XmNlabelString, XmStringCreateLocalized("On"), XmNset,
pPad->xrdb.statusLine, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
(void) McdePrefsRow(form, "Status line:", t);
McdePrefsRowEnd(row, t);
McdePrefsSeparator(form);
note = XtVaCreateManagedWidget("prefNote", xmLabelWidgetClass, form,
XmNlabelString, XmStringCreateLocalized("A change is in effect at "