Files
mcde/programs/dtpad/optionsCB.c
T
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

275 lines
9.2 KiB
C

/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: optionsCB.c /main/3 1995/11/01 10:39:09 rswiston $ */
/**********************************<+>*************************************
***************************************************************************
**
** File: optionsCB.c
**
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
** widget.
**
** Description:
** -----------
**
** This file contains the callbacks for the [Options] menu items.
**
*******************************************************************
** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
** reserved. Copying or other reproduction of this program
** except for archival purposes is prohibited without prior
** written consent of Hewlett-Packard Company.
********************************************************************
**
********************************************************************
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Novell, Inc.
********************************************************************
**
**
**************************************************************************
**********************************<+>*************************************/
#include "dtpad.h"
#include <Dt/HourGlass.h>
#include <Dt/McdePrefs.h>
#include <Xm/Label.h>
/************************************************************************
* OverstrikeCB - set Editor widget overstike and "Options" menu
* "Overstrike" radio button state based on value passed in
* call_data->set.
*
* NOTE: The default overstrike state for the entire (pPad) edit
* session is also reset.
************************************************************************/
/* ARGSUSED */
void
OverstrikeCB(
Widget w,
caddr_t client_data,
caddr_t call_data)
{
Arg al[1];
Editor *pPad = (Editor *)client_data;
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
call_data;
XtSetArg(al[0], DtNoverstrike, (Boolean) cb->set);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.overstrike = (Boolean) cb->set; /* reset edit session default */
}
/************************************************************************
* WordWrapCB - set Editor widget word wrap state and the default state
* for the new line radio button in the "Save As" File menu dialog
* based on value passed in call_data->set.
*
* NOTE: The default word wrap state for the entire (pPad) edit
* session is also reset.
************************************************************************/
/* ARGSUSED */
void
WordWrapCB(
Widget w,
caddr_t client_data,
caddr_t call_data)
{
Arg al[1];
Editor *pPad = (Editor *)client_data;
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
call_data;
SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
XtSetArg(al[0], DtNwordWrap, (Boolean) cb->set);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.wordWrap = (Boolean) cb->set; /* reset edit session default */
/* -----> set the default state for the "add new lines?" radio boxes in the
* "Save As" file selection box and the "Save" prompt dialog
* (these radio boxes are included only if word wrap is on) */
if (pSaveAs->toggleWidgets.newl_radio != (Widget) 0) {
if (pPad->xrdb.wordWrap == True) {
XtManageChild(pSaveAs->toggleWidgets.newl_radio);
} else {
XtUnmanageChild(pSaveAs->toggleWidgets.newl_radio);
}
}
if (pSelect->toggleWidgets.newl_radio != (Widget) 0) {
if (pPad->xrdb.wordWrap == True) {
XtManageChild(pSelect->separator);
XtManageChild(pSelect->toggleWidgets.newl_radio);
} else {
XtUnmanageChild(pSelect->separator);
XtUnmanageChild(pSelect->toggleWidgets.newl_radio);
}
}
}
/************************************************************************
* StatusLineCB - set Editor widget statusLine based on value passed in
* call_data->set.
*
* NOTE: The default statusLine state for the entire (pPad) edit
* session is also reset.
************************************************************************/
/* ARGSUSED */
void
StatusLineCB(
Widget w,
caddr_t client_data,
caddr_t call_data)
{
Arg al[1];
Editor *pPad = (Editor *)client_data;
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
call_data;
XtSetArg(al[0], DtNshowStatusLine, (Boolean) cb->set);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.statusLine = (Boolean) cb->set; /* reset edit session default */
/* Reset the resize increment and minimum window size properties. */
SetAppShellResizeHints(pPad);
}
/************************************************************************
* MCDE: the settings window (Dt/McdePrefs.h), icon tabs as the reference
* shows them. A change goes to the editor at once and is kept in
* ~/.dt/dtpad.conf, so the next start has it.
************************************************************************/
static void
PrefToggle(Widget w, XtPointer data, XtPointer call)
{
Editor *pPad = (Editor *) data;
const char *key = (const char *) XtName(w);
Boolean on = XmToggleButtonGetState(w);
char v[4];
(void) call;
(void)snprintf(v, sizeof v, "%d", on ? 1 : 0);
if (strcmp(key, "prefWrap") == 0) {
Arg al[1];
XtSetArg(al[0], DtNwordWrap, on);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.wordWrap = on;
if (pPad->optionsStuff.widgets.wordWrapBtn != NULL)
XmToggleButtonSetState(pPad->optionsStuff.widgets.
wordWrapBtn, on, False);
(void)McdePrefsSet(pPad->prefs, "wrap", v);
} else if (strcmp(key, "prefOverstrike") == 0) {
Arg al[1];
XtSetArg(al[0], DtNoverstrike, on);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.overstrike = on;
if (pPad->optionsStuff.widgets.overstrikeBtn != NULL)
XmToggleButtonSetState(pPad->optionsStuff.widgets.
overstrikeBtn, on, False);
(void)McdePrefsSet(pPad->prefs, "overstrike", v);
} else if (strcmp(key, "prefStatus") == 0) {
Arg al[1];
XtSetArg(al[0], DtNshowStatusLine, on);
XtSetValues(pPad->editor, al, 1);
pPad->xrdb.statusLine = on;
if (pPad->optionsStuff.widgets.statusLineBtn != NULL)
XmToggleButtonSetState(pPad->optionsStuff.widgets.
statusLineBtn, on, False);
(void)McdePrefsSet(pPad->prefs, "status", v);
}
}
static Widget
PrefsEditing(Widget form, void *data)
{
Editor *pPad = (Editor *) data;
Widget t;
Widget row = McdePrefsRowBegin(form, "Wrap to fit:");
t = XtVaCreateManagedWidget("prefWrap", xmToggleButtonWidgetClass,
row, XmNlabelString, XmStringCreateLocalized("On"),
XmNset, pPad->xrdb.wordWrap, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
McdePrefsRowEnd(row, t);
McdePrefsSeparator(form);
row = McdePrefsRowBegin(form, "Overstrike:");
t = XtVaCreateManagedWidget("prefOverstrike",
xmToggleButtonWidgetClass, row, XmNlabelString,
XmStringCreateLocalized("On"), XmNset,
pPad->xrdb.overstrike, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
McdePrefsRowEnd(row, t);
return form;
}
static Widget
PrefsWindow(Widget form, void *data)
{
Editor *pPad = (Editor *) data;
Widget t, note;
Widget row = McdePrefsRowBegin(form, "Status line:");
t = XtVaCreateManagedWidget("prefStatus", xmToggleButtonWidgetClass,
row, XmNlabelString, XmStringCreateLocalized("On"), XmNset,
pPad->xrdb.statusLine, NULL);
XtAddCallback(t, XmNvalueChangedCallback, PrefToggle, (XtPointer) pPad);
McdePrefsRowEnd(row, t);
McdePrefsSeparator(form);
note = XtVaCreateManagedWidget("prefNote", xmLabelWidgetClass, form,
XmNlabelString, XmStringCreateLocalized("A change is in effect at "
"once and is kept for the next start."),
XmNalignment, XmALIGNMENT_BEGINNING, NULL);
(void) note;
return form;
}
void
PreferencesCB(Widget w, XtPointer data, XtPointer call)
{
Editor *pPad = (Editor *) data;
(void) w;
(void) call;
if (pPad->prefs == NULL) {
pPad->prefs = McdePrefsCreate(pPad->mainWindow, "dtpad");
(void) McdePrefsAddTab(pPad->prefs, "Editing", "DtKeybd",
PrefsEditing, pPad);
(void) McdePrefsAddTab(pPad->prefs, "Window", "DtBkdrp",
PrefsWindow, pPad);
}
McdePrefsShow(pPad->prefs, NULL);
}