Konrad, 2026-11-13: "panel fehlt, top leiste is lila", the network settings "zu rudimentaer, keine ip config, kein dns", the global menu only while a program that has one is in front. The bar (and the launcher, the drop-down terminal, the login items) came from Xsession.d, before dtsession had loaded the session's resources and the colour server: dtbar took *background from ~/.Xdefaults (#6e1e7d, the user's base16 theme; dtbar PID 1270788 started before dtsession 1270795). Restarting dtbar in the running session gave the palette's colours. Now dtsession runs sys.sessionetc -- the first of CDE_CONFIGURATION_TOP/config and CDE_INSTALLATION_TOP/config, as sys.session is found -- before the user's sessionetc (SmRestore.c, StartEtc); it sources config/sessionetc.d, where 0080.dtlaunch, 0085.dtdropdown, 0090.dtbar and 0095.loginitems moved. The bar takes colour set 5, the programs' background, not set 6 of a menu bar (Dtbar*secondaryColorSetId: 5; measured #c6b2a8 with Default.dp). dtwm publishes the focused client as _NET_ACTIVE_WINDOW (EWMH, WmEwmh.c SetNetActiveWindow from SetKeyboardFocus and where the focus is dropped); dtbar shows a program's menus only while the active window is the menus' owner, a dialog of it (WM_TRANSIENT_FOR) or a window of the same program (WM_CLIENT_LEADER). Measured on Xvfb with dtwm, dtbar, dtpad and xterm, clicking: dtpad -> its menus, xterm -> M only, dtpad -> its menus again. Network (dtsystemsettings/network.c, docs/reference/netconfig.txt): Show: Network Status (a light and a sentence per card, Configure...) or one card with the tabs TCP/IP (Using DHCP, with manual address, Manually, Off; address, mask, router, DHCP client ID, Renew DHCP Lease; IPv6), DNS (servers, search domains, what resolv.conf has now), Wi-Fi and Ethernet; the lock and Apply Now as Accounts. McdeSys mcde_sys_net_config, _configure, _renew (replacing mcde_sys_net_dhcp, which was declared and implemented nowhere): NetBSD one block per interface in dhcpcd.conf, as ifconfig.if(5) recommends, sysinst's static address in ifconfig.IF read and moved there, applied with dhcpcd -n IF (cross-compiled with the tree's x86_64--netbsd-gcc, not run); Linux the NetworkManager profile (nmcli). mcde_sys_interfaces took the last IPv4 address (the secondary one), now the first. Measured on this host, read only: the pane shows the three cards, 172.20.10.2/28 by DHCP, router 172.20.10.1, DNS 1.1.1.1, MAC, MTU 1500; test_sysinfo (new checks: settings read, 300.1.2.3 refused) exit 0. Nothing was applied on the development host. From the review of 2026-11-12's commits: libDtTerm links libMcdeSound (977a7347c made the bell call McdeSoundEvent; dtcodegen did not link); the PLIST lacked dtphoto, dtpaint, dttoolbox, mcdesoundd, libMcdeSound, their data and the sound themes (51 entries, from the installed tree); mcdesoundd was started by nothing (sessionetc.d/0075.mcdesoundd) and took the selection from a running server; dttoolbox kept only the first line of the Selected menu and rebuilt it every 500 ms, and NewMenu returned an uninitialised pointer past 64 menus. Built and installed with make mcde-host MCDE_DIRS=install, exit 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
702 lines
19 KiB
C
702 lines
19 KiB
C
/*
|
|
* main.c -- dtsystemsettings: the settings of the computer in one window
|
|
*
|
|
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
|
*
|
|
* The window shows every pane as an icon, in four bands (panes.c): Personal,
|
|
* Hardware, Internet & Network, System. A click opens the pane in the same
|
|
* window, "Show All" goes back. Panes drawn here take what they show and
|
|
* change from McdeSys (include/Mcde/McdeSys.h) and never run a system tool;
|
|
* the others start the program that has them (CDE's style manager, the
|
|
* printer tool). dtsystemsettings -pane ID opens a pane at once (the menus
|
|
* of the top bar do that).
|
|
*
|
|
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
|
|
*/
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
|
|
#include <X11/Intrinsic.h>
|
|
#include <X11/Shell.h>
|
|
#include <Xm/Xm.h>
|
|
#include <Xm/Form.h>
|
|
#include <Xm/Frame.h>
|
|
#include <Xm/Label.h>
|
|
#include <Xm/MessageB.h>
|
|
#include <Xm/PushB.h>
|
|
#include <Xm/RowColumn.h>
|
|
#include <Xm/Scale.h>
|
|
#include <Xm/Separator.h>
|
|
#include <Xm/ToggleB.h>
|
|
#include <Dt/Dt.h>
|
|
|
|
#include <Mcde/McdeSys.h>
|
|
#include <dirent.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include <Mcde/Sound.h>
|
|
|
|
#include "panes.h"
|
|
#include "ui.h"
|
|
|
|
XtAppContext app;
|
|
static Widget shell, title, showAll, overview, paneArea, current;
|
|
static const Pane *shown;
|
|
static XtIntervalId clockTimer;
|
|
|
|
static const char *fallback[] = {
|
|
"Dtsystemsettings*overview*category.marginHeight: 6",
|
|
"Dtsystemsettings*paneArea.marginWidth: 20",
|
|
"Dtsystemsettings*paneArea.marginHeight: 16",
|
|
NULL
|
|
};
|
|
|
|
/* ---- small helpers ------------------------------------------------------ */
|
|
|
|
XmRenderTable
|
|
PaneFont(Widget w, int size, Boolean bold)
|
|
{
|
|
XmRendition r;
|
|
XmRenderTable rt;
|
|
Arg a[4];
|
|
int n = 0;
|
|
|
|
XtSetArg(a[n], XmNfontType, XmFONT_IS_XFT); n++;
|
|
XtSetArg(a[n], XmNfontName, "Hack"); n++;
|
|
XtSetArg(a[n], XmNfontSize, size); n++;
|
|
if (bold) {
|
|
XtSetArg(a[n], XmNfontStyle, "Bold"); n++;
|
|
}
|
|
r = XmRenditionCreate(w, XmFONTLIST_DEFAULT_TAG, a, n);
|
|
rt = XmRenderTableAddRenditions(NULL, &r, 1, XmMERGE_REPLACE);
|
|
XmRenditionFree(r);
|
|
return rt;
|
|
}
|
|
|
|
Widget
|
|
Text(Widget parent, const char *name, const char *text)
|
|
{
|
|
XmString s = XmStringCreateLocalized((char *) text);
|
|
Widget w = XtVaCreateManagedWidget(name, xmLabelWidgetClass, parent,
|
|
XmNlabelString, s, XmNalignment, XmALIGNMENT_BEGINNING, NULL);
|
|
|
|
XmStringFree(s);
|
|
return w;
|
|
}
|
|
|
|
void
|
|
SetText(Widget w, const char *text)
|
|
{
|
|
XmString s = XmStringCreateLocalized((char *) text);
|
|
|
|
XtVaSetValues(w, XmNlabelString, s, NULL);
|
|
XmStringFree(s);
|
|
}
|
|
|
|
Widget
|
|
Button(Widget parent, const char *label, XtCallbackProc cb, XtPointer data)
|
|
{
|
|
XmString s = XmStringCreateLocalized((char *) label);
|
|
Widget b = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass,
|
|
parent, XmNlabelString, s, NULL);
|
|
|
|
XmStringFree(s);
|
|
if (cb != NULL)
|
|
XtAddCallback(b, XmNactivateCallback, cb, data);
|
|
return b;
|
|
}
|
|
|
|
/* a button in a pane, its own width (a column would stretch it across) */
|
|
Widget
|
|
PaneButton(Widget parent, const char *label, XtCallbackProc cb, XtPointer data)
|
|
{
|
|
Widget row = XtVaCreateManagedWidget("buttonRow", xmRowColumnWidgetClass,
|
|
parent, XmNorientation, XmHORIZONTAL, XmNmarginWidth, 0, NULL);
|
|
|
|
return Button(row, label, cb, data);
|
|
}
|
|
|
|
/* a column of KEY VALUE lines; the keys right and bold */
|
|
Widget
|
|
Table(Widget parent, const char *const *rows, int n, Widget *values)
|
|
{
|
|
Widget rc = XtVaCreateManagedWidget("table", xmRowColumnWidgetClass,
|
|
parent, XmNorientation, XmVERTICAL, XmNpacking, XmPACK_COLUMN,
|
|
XmNnumColumns, 2, XmNisAligned, False, XmNspacing, 3, NULL);
|
|
XmRenderTable bold = PaneFont(parent, 10, True);
|
|
int i;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
Widget k = Text(rc, "key", rows[2 * i]);
|
|
|
|
XtVaSetValues(k, XmNalignment, XmALIGNMENT_END,
|
|
XmNrenderTable, bold, NULL);
|
|
}
|
|
for (i = 0; i < n; i++) {
|
|
Widget v = Text(rc, "value", rows[2 * i + 1]);
|
|
|
|
if (values != NULL)
|
|
values[i] = v;
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
Pixmap
|
|
Icon(Widget w, const char *file)
|
|
{
|
|
char path[512];
|
|
Pixel fg, bg;
|
|
|
|
XtVaGetValues(w, XmNforeground, &fg, XmNbackground, &bg, NULL);
|
|
snprintf(path, sizeof path, "%s/appconfig/icons/C/%s",
|
|
CDE_INSTALLATION_TOP, file);
|
|
return XmGetPixmap(XtScreen(w), path, fg, bg);
|
|
}
|
|
|
|
/* start a command line in a session of its own, no zombie: the child
|
|
* forks the program and ends at once */
|
|
void
|
|
Spawn(const char *command)
|
|
{
|
|
pid_t pid = fork();
|
|
|
|
if (pid == 0) {
|
|
if (fork() == 0) {
|
|
setsid();
|
|
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
|
_exit(127);
|
|
}
|
|
_exit(0);
|
|
}
|
|
if (pid > 0)
|
|
while (waitpid(pid, NULL, 0) < 0 && errno == EINTR)
|
|
;
|
|
}
|
|
|
|
static void
|
|
MessageClosed(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) data;
|
|
(void) call;
|
|
XtDestroyWidget(XtParent(w));
|
|
}
|
|
|
|
void
|
|
Message(Widget parent, const char *text, int error)
|
|
{
|
|
XmString m = XmStringCreateLocalized((char *) text);
|
|
Arg a[2];
|
|
Widget d;
|
|
|
|
XtSetArg(a[0], XmNmessageString, m);
|
|
d = error ? XmCreateErrorDialog(parent, "message", a, 1) :
|
|
XmCreateInformationDialog(parent, "message", a, 1);
|
|
XtUnmanageChild(XmMessageBoxGetChild(d, XmDIALOG_CANCEL_BUTTON));
|
|
XtUnmanageChild(XmMessageBoxGetChild(d, XmDIALOG_HELP_BUTTON));
|
|
XtAddCallback(d, XmNokCallback, MessageClosed, NULL);
|
|
XtManageChild(d);
|
|
XmStringFree(m);
|
|
}
|
|
|
|
/* su -m keeps DISPLAY and XAUTHORITY: the program as root shows on this
|
|
* display; su(1) asks for the password in the terminal */
|
|
void
|
|
AsRoot(const char *title, const char *command, char *buf, size_t len)
|
|
{
|
|
snprintf(buf, len, "dtterm -title '%s' -geometry 70x12 -e su -m root "
|
|
"-c '%s'", title, command);
|
|
}
|
|
|
|
/* ---- the sound pane ----------------------------------------------------- */
|
|
|
|
static Widget soundState, soundScale, soundMute;
|
|
|
|
static void
|
|
SoundRead(void)
|
|
{
|
|
int vol = 0, muted = 0;
|
|
|
|
if (mcde_sys_volume_get(&vol, &muted) != MCDE_SYS_OK) {
|
|
SetText(soundState, "There is no sound output.");
|
|
XtSetSensitive(soundScale, False);
|
|
XtSetSensitive(soundMute, False);
|
|
return;
|
|
}
|
|
SetText(soundState, "The volume of the sound output:");
|
|
XmScaleSetValue(soundScale, vol > 100 ? 100 : vol);
|
|
XmToggleButtonSetState(soundMute, muted, False);
|
|
}
|
|
|
|
static void
|
|
SoundVolume(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) mcde_sys_volume_set(((XmScaleCallbackStruct *) call)->value);
|
|
}
|
|
|
|
static void
|
|
SoundMute(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) mcde_sys_volume_mute(((XmToggleButtonCallbackStruct *) call)->set);
|
|
}
|
|
|
|
static void
|
|
SoundPreview(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) call;
|
|
(void) McdeSoundEvent(XtDisplay(w), (const char *) data);
|
|
}
|
|
|
|
static void
|
|
SoundTheme(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) call;
|
|
(void) McdeSoundSetTheme(XtDisplay(w), (const char *) data);
|
|
}
|
|
|
|
/* the themes are directories next to the current one */
|
|
static void
|
|
MakeThemes(Widget box)
|
|
{
|
|
char root[512], path[768], *slash;
|
|
DIR *d;
|
|
struct dirent *e;
|
|
Widget row;
|
|
|
|
(void) McdeSoundInit();
|
|
snprintf(root, sizeof root, "%s", McdeSoundThemeDir());
|
|
if ((slash = strrchr(root, '/')) == NULL)
|
|
return;
|
|
*slash = '\0';
|
|
if ((d = opendir(root)) == NULL)
|
|
return;
|
|
XtVaCreateManagedWidget("themeLabel", xmLabelWidgetClass, box,
|
|
XmNlabelString, XmStringCreateLocalized("Sound theme:"), NULL);
|
|
row = XtVaCreateManagedWidget("themes", xmRowColumnWidgetClass, box,
|
|
XmNorientation, XmHORIZONTAL, XmNspacing, 4, NULL);
|
|
while ((e = readdir(d)) != NULL) {
|
|
struct stat st;
|
|
Widget b;
|
|
char *dir;
|
|
|
|
if (e->d_name[0] == '.')
|
|
continue;
|
|
snprintf(path, sizeof path, "%s/%s", root, e->d_name);
|
|
if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode))
|
|
continue;
|
|
b = XtVaCreateManagedWidget(e->d_name, xmPushButtonWidgetClass,
|
|
row, NULL);
|
|
dir = strdup(path);
|
|
XtAddCallback(b, XmNactivateCallback, SoundTheme,
|
|
(XtPointer) dir);
|
|
}
|
|
closedir(d);
|
|
}
|
|
|
|
static Widget
|
|
MakeSound(Widget parent)
|
|
{
|
|
Widget box = XtVaCreateWidget("sound", xmRowColumnWidgetClass, parent,
|
|
XmNspacing, 10, NULL);
|
|
|
|
soundState = Text(box, "state", "");
|
|
soundScale = XtVaCreateManagedWidget("volume", xmScaleWidgetClass, box,
|
|
XmNorientation, XmHORIZONTAL, XmNminimum, 0, XmNmaximum, 100,
|
|
XmNshowValue, True, XmNscaleWidth, 320, NULL);
|
|
XtAddCallback(soundScale, XmNvalueChangedCallback, SoundVolume, NULL);
|
|
soundMute = XtVaCreateManagedWidget("Mute", xmToggleButtonWidgetClass,
|
|
box, NULL);
|
|
XtAddCallback(soundMute, XmNvalueChangedCallback, SoundMute, NULL);
|
|
|
|
XtVaCreateManagedWidget("eventsLabel", xmLabelWidgetClass, box,
|
|
XmNlabelString,
|
|
XmStringCreateLocalized("Desktop events (click to hear):"), NULL);
|
|
{
|
|
Widget row;
|
|
int i, n;
|
|
|
|
(void) McdeSoundInit();
|
|
n = McdeSoundCount();
|
|
row = XtVaCreateManagedWidget("events", xmRowColumnWidgetClass,
|
|
box, XmNorientation, XmHORIZONTAL, XmNpacking,
|
|
XmPACK_COLUMN, XmNnumColumns, 4, XmNspacing, 4, NULL);
|
|
for (i = 0; i < n; i++) {
|
|
const char *name = McdeSoundEventName(i);
|
|
Widget b;
|
|
|
|
if (name == NULL)
|
|
continue;
|
|
b = XtVaCreateManagedWidget(name,
|
|
xmPushButtonWidgetClass, row, NULL);
|
|
XtAddCallback(b, XmNactivateCallback, SoundPreview,
|
|
(XtPointer) name);
|
|
}
|
|
}
|
|
MakeThemes(box);
|
|
SoundRead();
|
|
return box;
|
|
}
|
|
|
|
/* ---- the network pane: network.c ---------------------------------------- */
|
|
|
|
/* ---- the Bluetooth pane ------------------------------------------------- */
|
|
|
|
static Widget btState, btButton;
|
|
static McdeSysBluetooth bt;
|
|
|
|
static void
|
|
BluetoothRead(void)
|
|
{
|
|
char text[96];
|
|
|
|
(void) mcde_sys_bluetooth(&bt);
|
|
if (!bt.present) {
|
|
SetText(btState, "This computer has no Bluetooth controller.");
|
|
SetText(btButton, "Turn Bluetooth On");
|
|
XtSetSensitive(btButton, False);
|
|
return;
|
|
}
|
|
snprintf(text, sizeof text, "Bluetooth is %s (%s).", bt.on ? "on" :
|
|
"off", bt.name);
|
|
SetText(btState, text);
|
|
SetText(btButton, bt.on ? "Turn Bluetooth Off" : "Turn Bluetooth On");
|
|
XtSetSensitive(btButton, True);
|
|
}
|
|
|
|
static void
|
|
BluetoothPower(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) call;
|
|
if (mcde_sys_bluetooth_power(!bt.on) != MCDE_SYS_OK)
|
|
SetText(btState, mcde_sys_error());
|
|
else
|
|
BluetoothRead();
|
|
}
|
|
|
|
static Widget
|
|
MakeBluetooth(Widget parent)
|
|
{
|
|
Widget box = XtVaCreateWidget("bluetooth", xmRowColumnWidgetClass,
|
|
parent, XmNspacing, 10, NULL);
|
|
|
|
btState = Text(box, "state", "");
|
|
btButton = PaneButton(box, "Turn Bluetooth Off", BluetoothPower, NULL);
|
|
BluetoothRead();
|
|
return box;
|
|
}
|
|
|
|
/* ---- the date and time pane --------------------------------------------- */
|
|
|
|
static Widget dtTime, dtDate, dtZone;
|
|
|
|
static void
|
|
ClockTick(XtPointer data, XtIntervalId *id)
|
|
{
|
|
char buf[96];
|
|
time_t now = time(NULL);
|
|
struct tm tm;
|
|
|
|
(void) data;
|
|
(void) id;
|
|
clockTimer = 0;
|
|
if (dtTime == NULL)
|
|
return;
|
|
localtime_r(&now, &tm);
|
|
strftime(buf, sizeof buf, "%H:%M:%S", &tm);
|
|
SetText(dtTime, buf);
|
|
strftime(buf, sizeof buf, "%A, %e %B %Y", &tm);
|
|
SetText(dtDate, buf);
|
|
strftime(buf, sizeof buf, "Time zone: %Z (UTC%z)", &tm);
|
|
SetText(dtZone, buf);
|
|
clockTimer = XtAppAddTimeOut(app, 1000, ClockTick, NULL);
|
|
}
|
|
|
|
static void
|
|
ClockGone(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) call;
|
|
dtTime = dtDate = dtZone = NULL;
|
|
if (clockTimer != 0)
|
|
XtRemoveTimeOut(clockTimer);
|
|
clockTimer = 0;
|
|
}
|
|
|
|
static Widget
|
|
MakeDateTime(Widget parent)
|
|
{
|
|
Widget box = XtVaCreateWidget("datetime", xmRowColumnWidgetClass,
|
|
parent, XmNspacing, 8, NULL);
|
|
|
|
dtTime = Text(box, "time", "");
|
|
XtVaSetValues(dtTime, XmNrenderTable, PaneFont(box, 28, True), NULL);
|
|
dtDate = Text(box, "date", "");
|
|
dtZone = Text(box, "zone", "");
|
|
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, box, NULL);
|
|
(void) MakeZoneChooser(box);
|
|
XtAddCallback(box, XmNdestroyCallback, ClockGone, NULL);
|
|
ClockTick(NULL, NULL);
|
|
return box;
|
|
}
|
|
|
|
/* ---- the about pane ----------------------------------------------------- */
|
|
|
|
static Widget
|
|
MakeAbout(Widget parent)
|
|
{
|
|
Widget box = XtVaCreateWidget("about", xmRowColumnWidgetClass, parent,
|
|
XmNspacing, 8, NULL);
|
|
McdeSysInfo i;
|
|
char version[128], cpu[200], mem[32], disk[200];
|
|
const char *rows[18];
|
|
|
|
(void) mcde_sys_info(&i);
|
|
snprintf(version, sizeof version, "%s %s", i.system, i.version);
|
|
snprintf(cpu, sizeof cpu, "%s (%d)", i.cpu, i.cpus);
|
|
snprintf(mem, sizeof mem, "%llu MB", i.memory >> 20);
|
|
snprintf(disk, sizeof disk, "%s, %llu of %llu MB free", i.disk,
|
|
i.diskFree >> 20, i.diskSize >> 20);
|
|
rows[0] = "System"; rows[1] = version;
|
|
rows[2] = "Kernel"; rows[3] = i.kernel;
|
|
rows[4] = "Computer"; rows[5] = i.model;
|
|
rows[6] = "Processor"; rows[7] = cpu;
|
|
rows[8] = "Memory"; rows[9] = mem;
|
|
rows[10] = "Startup Disk"; rows[11] = disk;
|
|
rows[12] = "Host Name"; rows[13] = i.hostname;
|
|
rows[14] = "Desktop"; rows[15] = DtVERSION_STRING;
|
|
rows[16] = "System Layer"; rows[17] = mcde_sys_backend();
|
|
Table(box, rows, 9, NULL);
|
|
return box;
|
|
}
|
|
|
|
/* ---- the window --------------------------------------------------------- */
|
|
|
|
static void
|
|
ShowOverview(void)
|
|
{
|
|
if (current != NULL) {
|
|
XtDestroyWidget(current);
|
|
current = NULL;
|
|
}
|
|
shown = NULL;
|
|
XtUnmanageChild(paneArea);
|
|
XtManageChild(overview);
|
|
SetText(title, "System Settings");
|
|
XtVaSetValues(shell, XmNtitle, "System Settings", NULL);
|
|
XtSetSensitive(showAll, False);
|
|
}
|
|
|
|
static void
|
|
ShowPane(const Pane *p)
|
|
{
|
|
Widget w = NULL;
|
|
|
|
if (p == NULL || p->kind == PANE_LATER)
|
|
return;
|
|
if (p->kind == PANE_COMMAND) {
|
|
Spawn(p->command);
|
|
return;
|
|
}
|
|
if (current != NULL)
|
|
XtDestroyWidget(current);
|
|
if (strcmp(p->id, "sound") == 0)
|
|
w = MakeSound(paneArea);
|
|
else if (strcmp(p->id, "network") == 0)
|
|
w = MakeNetwork(paneArea);
|
|
else if (strcmp(p->id, "bluetooth") == 0)
|
|
w = MakeBluetooth(paneArea);
|
|
else if (strcmp(p->id, "datetime") == 0)
|
|
w = MakeDateTime(paneArea);
|
|
else if (strcmp(p->id, "about") == 0)
|
|
w = MakeAbout(paneArea);
|
|
else if (strcmp(p->id, "accounts") == 0)
|
|
w = MakeAccounts(paneArea);
|
|
else if (strcmp(p->id, "update") == 0)
|
|
w = MakeUpdate(paneArea);
|
|
else if (strcmp(p->id, "appearance") == 0)
|
|
w = MakeAppearance(paneArea);
|
|
else if (strcmp(p->id, "backup") == 0)
|
|
w = MakeBackup(paneArea);
|
|
else if (strcmp(p->id, "sharing") == 0)
|
|
w = MakeSharing(paneArea);
|
|
else if (strcmp(p->id, "startup") == 0)
|
|
w = MakeStartup(paneArea);
|
|
else if (strcmp(p->id, "desktop") == 0)
|
|
w = MakeDesktop(paneArea);
|
|
else if (strcmp(p->id, "screensaver") == 0)
|
|
w = MakeScreenSaver(paneArea);
|
|
else if (strcmp(p->id, "fonts") == 0)
|
|
w = MakeFonts(paneArea);
|
|
else if (strcmp(p->id, "keyboard") == 0)
|
|
w = MakeKeyboard(paneArea);
|
|
else if (strcmp(p->id, "mouse") == 0)
|
|
w = MakeMouse(paneArea);
|
|
else if (strcmp(p->id, "displays") == 0)
|
|
w = MakeDisplays(paneArea);
|
|
if (w == NULL)
|
|
return;
|
|
current = w;
|
|
shown = p;
|
|
XtManageChild(w);
|
|
XtUnmanageChild(overview);
|
|
XtManageChild(paneArea);
|
|
SetText(title, p->label);
|
|
XtVaSetValues(shell, XmNtitle, p->label, NULL);
|
|
XtSetSensitive(showAll, True);
|
|
}
|
|
|
|
static void
|
|
PaneClicked(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) call;
|
|
ShowPane((const Pane *) data);
|
|
}
|
|
|
|
static void
|
|
ShowAllClicked(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) w;
|
|
(void) data;
|
|
(void) call;
|
|
ShowOverview();
|
|
}
|
|
|
|
/* the overview: one band a category, its panes as icons with their names */
|
|
static Widget
|
|
MakeOverview(Widget parent)
|
|
{
|
|
Widget box = XtVaCreateWidget("overview", xmRowColumnWidgetClass, parent,
|
|
XmNspacing, 4, NULL);
|
|
XmRenderTable bold = PaneFont(box, 11, True);
|
|
int c, i;
|
|
|
|
for (c = 0; c < CAT_COUNT; c++) {
|
|
Widget band, inner, row, l;
|
|
|
|
band = XtVaCreateManagedWidget("category", xmFrameWidgetClass,
|
|
box, XmNshadowType, XmSHADOW_ETCHED_IN, NULL);
|
|
inner = XtVaCreateManagedWidget("inner", xmRowColumnWidgetClass,
|
|
band, XmNspacing, 2, NULL);
|
|
l = Text(inner, "name", categoryNames[c]);
|
|
XtVaSetValues(l, XmNrenderTable, bold, NULL);
|
|
row = XtVaCreateManagedWidget("panes", xmRowColumnWidgetClass,
|
|
inner, XmNorientation, XmHORIZONTAL, XmNspacing, 8, NULL);
|
|
for (i = 0; i < paneCount; i++) {
|
|
const Pane *p = &panes[i];
|
|
Widget item, b;
|
|
|
|
if (p->category != c)
|
|
continue;
|
|
/* the icon in a field of one size, the name under it:
|
|
* the CDE icons are 16 to 37 pixels high, the names
|
|
* stand on one line all the same */
|
|
item = XtVaCreateManagedWidget("item",
|
|
xmRowColumnWidgetClass, row, XmNspacing, 0,
|
|
XmNmarginWidth, 0, XmNmarginHeight, 0,
|
|
XmNentryAlignment, XmALIGNMENT_CENTER, NULL);
|
|
b = XtVaCreateManagedWidget(p->id, xmPushButtonWidgetClass,
|
|
item, XmNlabelType, XmPIXMAP,
|
|
XmNlabelPixmap, Icon(row, p->icon),
|
|
XmNshadowThickness, 0, XmNrecomputeSize, False,
|
|
XmNwidth, 112, XmNheight, 44, NULL);
|
|
l = Text(item, "label", p->label);
|
|
XtVaSetValues(l, XmNalignment, XmALIGNMENT_CENTER, NULL);
|
|
if (p->kind == PANE_LATER) {
|
|
XtSetSensitive(b, False);
|
|
XtSetSensitive(l, False);
|
|
} else
|
|
XtAddCallback(b, XmNactivateCallback, PaneClicked,
|
|
(XtPointer) p);
|
|
}
|
|
}
|
|
return box;
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
Widget form, bar, sep;
|
|
const char *start = NULL;
|
|
int i;
|
|
|
|
XtSetLanguageProc(NULL, NULL, NULL);
|
|
shell = XtVaAppInitialize(&app, "Dtsystemsettings", NULL, 0, &argc,
|
|
argv, (String *) fallback, XmNtitle, "System Settings", NULL);
|
|
for (i = 1; i < argc; i++) {
|
|
if (strcmp(argv[i], "-pane") == 0 && i + 1 < argc)
|
|
start = argv[++i];
|
|
else if (strcmp(argv[i], "-apply-update") == 0)
|
|
return ApplyUpdate();
|
|
else if (strcmp(argv[i], "-apply-displays") == 0)
|
|
return ApplyDisplaysCommand(XtDisplay(shell));
|
|
else if (strcmp(argv[i], "-set-timezone") == 0 && i + 1 < argc)
|
|
return SetTimezoneCommand(argv[i + 1]);
|
|
else if (strcmp(argv[i], "-join-wifi") == 0 && i + 1 < argc)
|
|
return JoinWifiCommand(argv[i + 1],
|
|
i + 2 < argc ? argv[i + 2] : NULL);
|
|
else if (strcmp(argv[i], "-renew-dhcp") == 0 && i + 1 < argc)
|
|
return RenewDhcpCommand(argv[i + 1]);
|
|
else {
|
|
fprintf(stderr, "usage: dtsystemsettings [-pane ID | "
|
|
"-apply-update | -apply-displays | -set-timezone ZONE | -join-wifi IF "
|
|
"[SSID-HEX] | -renew-dhcp IF]\n");
|
|
return 1;
|
|
}
|
|
}
|
|
/* a CDE program: its menus would go to the top bar, and it is one */
|
|
(void) DtInitialize(XtDisplay(shell), shell, argv[0], "Dtsystemsettings");
|
|
|
|
form = XtVaCreateManagedWidget("form", xmFormWidgetClass, shell,
|
|
XmNmarginWidth, 8, XmNmarginHeight, 8, NULL);
|
|
bar = XtVaCreateManagedWidget("toolbar", xmRowColumnWidgetClass, form,
|
|
XmNorientation, XmHORIZONTAL, XmNspacing, 12,
|
|
XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM,
|
|
XmNrightAttachment, XmATTACH_FORM, NULL);
|
|
showAll = Button(bar, "Show All", ShowAllClicked, NULL);
|
|
title = Text(bar, "title", "System Settings");
|
|
XtVaSetValues(title, XmNrenderTable, PaneFont(bar, 12, True), NULL);
|
|
sep = XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form,
|
|
XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, bar,
|
|
XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
|
|
NULL);
|
|
overview = MakeOverview(form);
|
|
XtVaSetValues(overview, XmNtopAttachment, XmATTACH_WIDGET,
|
|
XmNtopWidget, sep, XmNleftAttachment, XmATTACH_FORM,
|
|
XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment,
|
|
XmATTACH_FORM, NULL);
|
|
paneArea = XtVaCreateWidget("paneArea", xmRowColumnWidgetClass, form,
|
|
XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep,
|
|
XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
|
|
XmNbottomAttachment, XmATTACH_FORM, NULL);
|
|
XtManageChild(overview);
|
|
XtSetSensitive(showAll, False);
|
|
XtRealizeWidget(shell);
|
|
if (start != NULL) {
|
|
const Pane *p = PaneFind(start);
|
|
|
|
if (p == NULL)
|
|
fprintf(stderr, "dtsystemsettings: no pane \"%s\"\n", start);
|
|
else
|
|
ShowPane(p);
|
|
}
|
|
XtAppMainLoop(app);
|
|
return 0;
|
|
}
|