MCDE dtsystemsettings: System Information from McdeSys (t0188)

This commit is contained in:
lotherk committed 2026-11-14 14:36:41 +00:00
1 parent b912458ef5
commit 131f12ed69
6 files changed
+224 -1

No files matched your search

+5
View File
@@ -155,6 +155,11 @@ 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).
- **System Information**: `dtsystemsettings/sysinfo.c` -- the sections
Hardware, Network and Software in a list on the left, the values on the
right from McdeSys (`mcde_sys_info`: model, processor, memory, startup
disk, system, kernel; `mcde_sys_interfaces` and the host name). "Refresh"
reads again; nothing runs a program for a value.
- **Default programs**: `dtsystemsettings/defaults.c` -- web browser, mail,
images, video and text, each a menu of the programs that are on this
computer ($PATH; "(none on this computer)" otherwise), and how a link from
+1 -1
View File
@@ -7,7 +7,7 @@ bin_PROGRAMS = dtsystemsettings
dtsystemsettings_SOURCES = main.c panes.c panes.h ui.h accounts.c update.c \
network.c \
input.c appearance.c desktop.c timezone.c wifi.c \
startup.c sharing.c backup.c displays.c language.c sound.c printers.c parental.c cds.c energy.c internet.c defaults.c \
startup.c sharing.c backup.c displays.c language.c sound.c printers.c parental.c cds.c energy.c internet.c defaults.c sysinfo.c \
security.c
dtsystemsettings_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) \
-I$(top_builddir)/include $(XFT_CFLAGS) \
+4
View File
@@ -1044,6 +1044,10 @@ ShowPane(const Pane *p)
w = MakePrinters(paneArea);
XtVaSetValues(shell, XmNheight, 640, XmNwidth, 760, NULL);
}
else if (strcmp(p->id, "sysinfo") == 0) {
w = MakeSysinfo(paneArea);
XtVaSetValues(shell, XmNheight, 520, XmNwidth, 700, NULL);
}
else if (strcmp(p->id, "defaults") == 0) {
w = MakeDefaults(paneArea);
XtVaSetValues(shell, XmNheight, 560, XmNwidth, 640, NULL);
+3
View File
@@ -62,6 +62,9 @@ const Pane panes[] = {
{ "sharing", "Sharing", CAT_NETWORK, "Dtlink.m.pm", PANE_OWN, NULL,
"sharing freigaben smb afp nfs ssh dateien" },
{ "sysinfo", "System Information", CAT_SYSTEM, "DtSystem.m.pm",
PANE_OWN, NULL, "system information hardware network software "
"about ueber rechner" },
{ "datetime", "Date & Time", CAT_SYSTEM, "Dtdate.m.pm", PANE_OWN, NULL,
"date time uhr zeit timezone zeitzone ntp" },
{ "startup", "Startup", CAT_SYSTEM, "DtStart.pm", PANE_OWN, NULL,
+209
View File
@@ -0,0 +1,209 @@
/*
* sysinfo.c -- dtsystemsettings: what this computer is (t0188)
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*
* The reference's window with a tree on the left and the details on the
* right: Hardware, Network and Software, each filled from what the system
* tells through McdeSys (mcde_sys_info, mcde_sys_interfaces, the disks) --
* no probing of the firmware, no program run for each value. It is the
* content of "About this computer" with room for the parts that do not fit
* in the box.
*
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
*/
#define _POSIX_C_SOURCE 200809L
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Intrinsic.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrolledW.h>
#include <Xm/Text.h>
#include <Mcde/McdeSys.h>
#include "ui.h"
static Widget sectionList, detailText, statusLine;
static void
Size(unsigned long long b, char *buf, size_t len)
{
if (b >= 1000000000000ULL)
(void)snprintf(buf, len, "%.1f TB", b / 1e12);
else if (b >= 1000000000ULL)
(void)snprintf(buf, len, "%.1f GB", b / 1e9);
else if (b >= 1000000ULL)
(void)snprintf(buf, len, "%.0f MB", b / 1e6);
else
(void)snprintf(buf, len, "%llu bytes", b);
}
static void
Append(char *buf, size_t len, const char *fmt, ...)
{
va_list ap;
size_t at = strlen(buf);
if (at >= len - 1)
return;
va_start(ap, fmt);
(void)vsnprintf(buf + at, len - at, fmt, ap);
va_end(ap);
}
static void
Hardware(char *buf, size_t len)
{
McdeSysInfo info;
char size[32], freeb[32];
(void)snprintf(buf, len, "");
if (mcde_sys_info(&info) != MCDE_SYS_OK) {
Append(buf, len, "%s\n", mcde_sys_error());
return;
}
Append(buf, len, "Model:\t%s\n", info.model[0] != '\0' ? info.model :
"(the firmware does not say)");
Append(buf, len, "Processor:\t%s (%d)\n", info.cpu[0] != '\0' ?
info.cpu : "(unknown)", info.cpus);
Size(info.memory, size, sizeof size);
Append(buf, len, "Memory:\t%s\n", size);
if (info.disk[0] != '\0') {
Size(info.diskSize, size, sizeof size);
Size(info.diskFree, freeb, sizeof freeb);
Append(buf, len, "Startup disk:\t%s, %s (%s free)\n",
info.disk, size, freeb);
}
}
static void
Network(char *buf, size_t len)
{
McdeSysInterface ifs[16];
char host[256];
int n, i;
(void)snprintf(buf, len, "");
if (mcde_sys_hostname_get(host, sizeof host) == MCDE_SYS_OK)
Append(buf, len, "Name:\t%s\n", host);
n = mcde_sys_interfaces(ifs, 16);
if (n <= 0) {
Append(buf, len, "No network interface answered.\n");
return;
}
Append(buf, len, "\n");
for (i = 0; i < n; i++)
Append(buf, len, "%s\t%s%s\n", ifs[i].name,
ifs[i].address[0] != '\0' ? ifs[i].address : "no address",
ifs[i].ssid[0] != '\0' ? ifs[i].ssid : "");
}
static void
Software(char *buf, size_t len)
{
McdeSysInfo info;
(void)snprintf(buf, len, "");
if (mcde_sys_info(&info) != MCDE_SYS_OK) {
Append(buf, len, "%s\n", mcde_sys_error());
return;
}
Append(buf, len, "System:\t%s %s\n", info.system, info.version);
Append(buf, len, "Kernel:\t%s\n", info.kernel);
Append(buf, len, "Desktop:\tMCDE (Motif)\n");
}
static void
Show(int which)
{
char text[4096];
if (which == 1)
Network(text, sizeof text);
else if (which == 2)
Software(text, sizeof text);
else
Hardware(text, sizeof text);
SetText(detailText, text);
XtVaSetValues(detailText, XmNvalue, text, NULL);
SetText(statusLine, which == 1 ? "The interfaces the system "
"reports." : which == 2 ? "What the system calls itself." :
"What the firmware and the kernel say.");
}
static void
Chosen(Widget w, XtPointer data, XtPointer call)
{
(void) w;
(void) data;
if (((XmListCallbackStruct *) call)->item_position > 0)
Show(((XmListCallbackStruct *) call)->item_position - 1);
}
static void
RefreshCB(Widget w, XtPointer data, XtPointer call)
{
int *pos = NULL, n = 0, at = 0;
(void) w;
(void) data;
(void) call;
if (XmListGetSelectedPos(sectionList, &pos, &n) && n > 0) {
at = pos[0] - 1;
XtFree((char *) pos);
}
Show(at);
}
Widget
MakeSysinfo(Widget parent)
{
Widget box = XtVaCreateWidget("sysinfo", xmRowColumnWidgetClass,
parent, XmNorientation, XmVERTICAL, XmNspacing, 8, NULL);
Widget body, sw, buttons;
static const char *const sections[3] = { "Hardware", "Network",
"Software" };
int i;
body = XtVaCreateManagedWidget("sysinfoBody", xmRowColumnWidgetClass,
box, XmNorientation, XmHORIZONTAL, XmNspacing, 16,
XmNmarginWidth, 0, NULL);
sectionList = XmCreateScrolledList(body, "sections", NULL, 0);
XtVaSetValues(sectionList, XmNvisibleItemCount, 6, NULL);
XtVaSetValues(XtParent(sectionList), XmNwidth, 200, XmNheight, 220,
NULL);
for (i = 0; i < 3; i++) {
XmString s = XmStringCreateLocalized((char *) sections[i]);
XmListAddItemUnselected(sectionList, s, 0);
XmStringFree(s);
}
XtManageChild(sectionList);
XtAddCallback(sectionList, XmNbrowseSelectionCallback, Chosen, NULL);
sw = XtVaCreateManagedWidget("detailBox", xmScrolledWindowWidgetClass,
body, XmNscrollingPolicy, XmAUTOMATIC, XmNwidth, 380,
XmNheight, 260, NULL);
detailText = XtVaCreateManagedWidget("detailText", xmTextWidgetClass,
sw, XmNeditable, False, XmNcursorPositionVisible, False,
XmNwordWrap, False, NULL);
buttons = XtVaCreateManagedWidget("sysinfoButtons",
xmRowColumnWidgetClass, box, XmNorientation, XmHORIZONTAL,
XmNspacing, 8, XmNmarginWidth, 0, NULL);
(void) Button(buttons, "Refresh", RefreshCB, NULL);
statusLine = Text(box, "sysinfoStatus", "");
XmListSelectPos(sectionList, 1, False);
Show(0);
return box;
}
+2
View File
@@ -83,6 +83,8 @@ Widget MakeEnergy(Widget parent);
Widget MakeInternet(Widget parent);
/* the default programs (defaults.c), ~/.dt/defaults */
Widget MakeDefaults(Widget parent);
/* what this computer is (sysinfo.c): Hardware | Network | Software */
Widget MakeSysinfo(Widget parent);
int SetDefaultPrinterCommand(const char *name);
int AddPrinterCommand(const char *name, const char *uri);
int RemovePrinterCommand(const char *name);