MCDE dtcmprefs: the calendar's settings on the shared pattern (t0149)
This commit is contained in:
1 parent
eee4501874
commit
fef820cb25
6 files changed
+249
-3
No files matched your search
@@ -155,6 +155,14 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
|
||||
toggle and the text field exist unmanaged (`G_rename_toggle`,
|
||||
`G_rename_text`). The multi-collision and the folder-merge dialog are
|
||||
unchanged (follow-up).
|
||||
- **dtcmprefs** (`programs/dtcmprefs`): the calendar's settings window on
|
||||
the shared McdePrefs pattern -- General (first day of the week, week
|
||||
numbers, default appointment length), Accounts (a read-only note: the
|
||||
session's rpc.cmsd holds the appointments, a CalDAV account comes from
|
||||
~/.dt/accounts.conf once the connection part exists) and Advanced (remind
|
||||
this many minutes before). Kept in `~/.dt/dtcm.conf`. dtcm's
|
||||
File > Options... starts it (calendarA.c, `edit_cb`, fork/exec, no shell)
|
||||
-- measured: the binary carries the name and the window runs on its own.
|
||||
- **dtimage** (`programs/dtimage`): the picture viewer of the reference --
|
||||
toolbar Previous/Next, Zoom -/+, Slideshow, the picture in a scrolled
|
||||
canvas, the folder's pictures on the right, the name, size and zoom in the
|
||||
|
||||
@@ -901,6 +901,7 @@ programs/dtphoto/Makefile
|
||||
programs/dtconsole/Makefile
|
||||
programs/dtnetutility/Makefile
|
||||
programs/dtimage/Makefile
|
||||
programs/dtcmprefs/Makefile
|
||||
programs/dtpaint/Makefile
|
||||
programs/dttoolbox/Makefile
|
||||
programs/mcdesoundd/Makefile
|
||||
|
||||
@@ -6,7 +6,7 @@ SUBDIRS = backdrops icons dsdm dtmail dtpad dtfile dterror dtwm dtlogin \
|
||||
palettes dtappintegrate dtprintegrate dtconfig \
|
||||
dtcreate dtprintinfo fontaliases dtdspmsg dtimsstart \
|
||||
dtpdm dtsr dtpdmd dtinfo types tttypes util dtopen localized \
|
||||
dthelp dtdocbook dtlaunch dtbar dtsystemsettings dtdiskutility dtbackup dtappscan dtkeys dtthemesync dtphoto dtpaint dttoolbox mcdesoundd dtconsole dtnetutility dtimage
|
||||
dthelp dtdocbook dtlaunch dtbar dtsystemsettings dtdiskutility dtbackup dtappscan dtkeys dtthemesync dtphoto dtpaint dttoolbox mcdesoundd dtconsole dtnetutility dtimage dtcmprefs
|
||||
|
||||
# The application builder and ttsnoop, its demonstration, need dtcodegen, a
|
||||
# program the build runs: not in a cross build (--disable-appbuilder; the native
|
||||
|
||||
@@ -54,6 +54,7 @@ static char sccsid[] = "@(#)calendarA.c 1.196 95/04/12 Copyr 1991 Sun Microsyst
|
||||
#include <EUSCompat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h> /* MAXPATHLEN defined here */
|
||||
@@ -1112,8 +1113,15 @@ edit_cb( Widget w, XtPointer item_no, XtPointer cbs)
|
||||
Calendar *c = calendar;
|
||||
|
||||
_DtTurnOnHourGlass(c->frame);
|
||||
if ((intptr_t) item_no == 1)
|
||||
show_props_pu(c);
|
||||
if ((intptr_t) item_no == 1) {
|
||||
/* MCDE: the settings window on the shared pattern (t0149) */
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid == 0) {
|
||||
execlp("dtcmprefs", "dtcmprefs", (char *) NULL);
|
||||
_exit(127);
|
||||
}
|
||||
}
|
||||
else if ((intptr_t) item_no == 3)
|
||||
make_find(c);
|
||||
_DtTurnOffHourGlass(c->frame);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
bin_PROGRAMS = dtcmprefs
|
||||
|
||||
dtcmprefs_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
|
||||
|
||||
dtcmprefs_LDADD = $(DTCLIENTLIBS) $(XTOOLLIB)
|
||||
|
||||
dtcmprefs_SOURCES = dtcmprefs.c
|
||||
|
||||
if SOLARIS
|
||||
dtcmprefs_LDADD += -lintl
|
||||
endif
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* dtcmprefs.c -- MCDE: the calendar's settings window (t0149)
|
||||
*
|
||||
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
||||
*
|
||||
* The reference's preferences window for the calendar, on the shared pattern
|
||||
* (lib/DtWidget/McdePrefs.c): icon tabs with the page under them, no OK or
|
||||
* Cancel, a change kept at once in ~/.dt/dtcm.conf. Three pages:
|
||||
*
|
||||
* General the first day of the week, week numbers, the default length of
|
||||
* an appointment.
|
||||
* Accounts what the calendar keeps its appointments in (read-only: the
|
||||
* rpc.cmsd server of the session; a CalDAV account is one of the
|
||||
* Internet accounts the desktop knows).
|
||||
* Advanced the reminder, in minutes before an appointment.
|
||||
*
|
||||
* dtcm's own Options... menu starts this window (programs/dtcm/calendarA.c).
|
||||
*
|
||||
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
|
||||
*/
|
||||
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#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/Scale.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Dt/McdePrefs.h>
|
||||
|
||||
static Widget prefs, mondayToggle, sundayToggle, weeksToggle, lengthScale,
|
||||
remindScale;
|
||||
|
||||
static void
|
||||
Set(Widget w, const char *text)
|
||||
{
|
||||
XmString s = XmStringCreateLocalized((char *) text);
|
||||
|
||||
XtVaSetValues(w, XmNlabelString, s, NULL);
|
||||
XmStringFree(s);
|
||||
}
|
||||
|
||||
static void
|
||||
Kept(const char *key, const char *value)
|
||||
{
|
||||
(void)McdePrefsConfSet("dtcm", key, value);
|
||||
}
|
||||
|
||||
static void
|
||||
DayChosen(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
(void) w;
|
||||
if (((XmToggleButtonCallbackStruct *) call)->set)
|
||||
Kept("weekstarts", (const char *) data);
|
||||
}
|
||||
|
||||
static void
|
||||
WeeksChosen(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
(void) w;
|
||||
(void) data;
|
||||
Kept("weeknumbers", XmToggleButtonGetState(weeksToggle) ? "1" : "0");
|
||||
}
|
||||
|
||||
static void
|
||||
LengthChosen(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
int v = 0;
|
||||
|
||||
(void) w;
|
||||
(void) data;
|
||||
XmScaleGetValue(lengthScale, &v);
|
||||
{
|
||||
char s[16];
|
||||
|
||||
(void)snprintf(s, sizeof s, "%d", v);
|
||||
Kept("length", s);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RemindChosen(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
int v = 0;
|
||||
|
||||
(void) w;
|
||||
(void) data;
|
||||
XmScaleGetValue(remindScale, &v);
|
||||
{
|
||||
char s[16];
|
||||
|
||||
(void)snprintf(s, sizeof s, "%d", v);
|
||||
Kept("remind", s);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
GetInt(const char *key, int def)
|
||||
{
|
||||
char v[32];
|
||||
|
||||
if (!McdePrefsConfGet("dtcm", key, v, sizeof v) || v[0] == '\0')
|
||||
return def;
|
||||
return atoi(v);
|
||||
}
|
||||
|
||||
static Widget
|
||||
GeneralPage(Widget form, void *data)
|
||||
{
|
||||
Widget row, radio, label;
|
||||
char v[32];
|
||||
XmString s;
|
||||
|
||||
(void) data;
|
||||
row = McdePrefsRowBegin(form, "First day of the week:");
|
||||
radio = XtVaCreateManagedWidget("days", xmRowColumnWidgetClass, row,
|
||||
XmNorientation, XmHORIZONTAL, XmNradioBehavior, True,
|
||||
XmNspacing, 10, XmNmarginWidth, 0, NULL);
|
||||
mondayToggle = XtVaCreateManagedWidget("Monday",
|
||||
xmToggleButtonWidgetClass, radio, NULL);
|
||||
sundayToggle = XtVaCreateManagedWidget("Sunday",
|
||||
xmToggleButtonWidgetClass, radio, NULL);
|
||||
XtAddCallback(mondayToggle, XmNvalueChangedCallback, DayChosen,
|
||||
(XtPointer) "monday");
|
||||
XtAddCallback(sundayToggle, XmNvalueChangedCallback, DayChosen,
|
||||
(XtPointer) "sunday");
|
||||
McdePrefsConfGet("dtcm", "weekstarts", v, sizeof v);
|
||||
XmToggleButtonSetState(strcmp(v, "sunday") == 0 ? sundayToggle :
|
||||
mondayToggle, True, False);
|
||||
McdePrefsRowEnd(row, radio);
|
||||
|
||||
weeksToggle = XtVaCreateManagedWidget("Show the week numbers",
|
||||
xmToggleButtonWidgetClass, form, NULL);
|
||||
XmToggleButtonSetState(weeksToggle, GetInt("weeknumbers", 1) != 0,
|
||||
False);
|
||||
XtAddCallback(weeksToggle, XmNvalueChangedCallback, WeeksChosen, NULL);
|
||||
|
||||
McdePrefsSeparator(form);
|
||||
label = XtVaCreateManagedWidget("lengthLabel", xmLabelWidgetClass,
|
||||
form, NULL);
|
||||
Set(label, "Default length of an appointment (minutes):");
|
||||
lengthScale = XtVaCreateManagedWidget("length", xmScaleWidgetClass,
|
||||
form, XmNorientation, XmHORIZONTAL, XmNminimum, 15,
|
||||
XmNmaximum, 120, XmNshowValue, True, XmNscaleWidth, 260, NULL);
|
||||
XmScaleSetValue(lengthScale, GetInt("length", 30));
|
||||
XtAddCallback(lengthScale, XmNvalueChangedCallback, LengthChosen, NULL);
|
||||
(void) s;
|
||||
return form;
|
||||
}
|
||||
|
||||
static Widget
|
||||
AccountsPage(Widget form, void *data)
|
||||
{
|
||||
Widget label;
|
||||
|
||||
(void) data;
|
||||
label = XtVaCreateManagedWidget("accountsNote", xmLabelWidgetClass,
|
||||
form, NULL);
|
||||
Set(label, "The appointments live in the session's calendar server "
|
||||
"(rpc.cmsd).");
|
||||
label = XtVaCreateManagedWidget("accountsNote2", xmLabelWidgetClass,
|
||||
form, NULL);
|
||||
Set(label, "A CalDAV account is one of the Internet accounts of the "
|
||||
"desktop; the calendar");
|
||||
label = XtVaCreateManagedWidget("accountsNote3", xmLabelWidgetClass,
|
||||
form, NULL);
|
||||
Set(label, "reads it from ~/.dt/accounts.conf once the connection part "
|
||||
"is built.");
|
||||
return form;
|
||||
}
|
||||
|
||||
static Widget
|
||||
AdvancedPage(Widget form, void *data)
|
||||
{
|
||||
Widget label;
|
||||
|
||||
(void) data;
|
||||
label = XtVaCreateManagedWidget("remindLabel", xmLabelWidgetClass,
|
||||
form, NULL);
|
||||
Set(label, "Remind me this many minutes before an appointment:");
|
||||
remindScale = XtVaCreateManagedWidget("remind", xmScaleWidgetClass,
|
||||
form, XmNorientation, XmHORIZONTAL, XmNminimum, 0,
|
||||
XmNmaximum, 60, XmNshowValue, True, XmNscaleWidth, 260, NULL);
|
||||
XmScaleSetValue(remindScale, GetInt("remind", 10));
|
||||
XtAddCallback(remindScale, XmNvalueChangedCallback, RemindChosen, NULL);
|
||||
return form;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
static String fallback[] = { "*renderTable: mcde", NULL };
|
||||
Widget shell;
|
||||
XtAppContext app;
|
||||
|
||||
XtSetLanguageProc(NULL, NULL, NULL);
|
||||
shell = XtVaAppInitialize(&app, "Dtcmprefs", NULL, 0, &argc, argv,
|
||||
(String *) fallback, XmNtitle, "Calendar Settings", NULL);
|
||||
prefs = McdePrefsCreate(shell, "dtcm");
|
||||
(void) McdePrefsAddTab(prefs, "General", "Dtdate.m.pm", GeneralPage,
|
||||
NULL);
|
||||
(void) McdePrefsAddTab(prefs, "Accounts", "Dtmail.t.pm",
|
||||
AccountsPage, NULL);
|
||||
(void) McdePrefsAddTab(prefs, "Advanced", "Dtstyle.m.pm",
|
||||
AdvancedPage, NULL);
|
||||
McdePrefsShow(prefs, NULL);
|
||||
XtAppMainLoop(app);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user