MCDE dtsystemsettings: the Startup Disk pane, the volume in use marked (t0174)
This commit is contained in:
1 parent
967e11246d
commit
3dbdafdaa8
7 files changed
+164
-3
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -168,6 +168,12 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
|
||||
Makefile.am, `programs/Makefile.am`'s SUBDIRS and `configure.ac`'s
|
||||
AC_CONFIG_FILES (the build regenerates configure and config.status by
|
||||
itself, measured).
|
||||
- **Startup Disk**: `dtsystemsettings/startupdisk.c` -- the volumes from
|
||||
mcde_sys_disks, the one the system started from marked with * (the device
|
||||
of / from mcde_sys_info), its type, size and mount point, and
|
||||
"Restart..." (the bar's power dialog, so it asks). Choosing another
|
||||
startup volume writes the boot loader's configuration (grub on Linux,
|
||||
boot.cfg on NetBSD) and needs root -- the follow-up; the pane says so.
|
||||
- **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
|
||||
|
||||
@@ -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 sysinfo.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 startupdisk.c \
|
||||
security.c
|
||||
dtsystemsettings_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) \
|
||||
-I$(top_builddir)/include $(XFT_CFLAGS) \
|
||||
|
||||
@@ -1044,6 +1044,10 @@ ShowPane(const Pane *p)
|
||||
w = MakePrinters(paneArea);
|
||||
XtVaSetValues(shell, XmNheight, 640, XmNwidth, 760, NULL);
|
||||
}
|
||||
else if (strcmp(p->id, "startupdisk") == 0) {
|
||||
w = MakeStartupDisk(paneArea);
|
||||
XtVaSetValues(shell, XmNheight, 560, XmNwidth, 680, NULL);
|
||||
}
|
||||
else if (strcmp(p->id, "sysinfo") == 0) {
|
||||
w = MakeSysinfo(paneArea);
|
||||
XtVaSetValues(shell, XmNheight, 520, XmNwidth, 700, NULL);
|
||||
|
||||
@@ -78,8 +78,8 @@ const Pane panes[] = {
|
||||
NULL, "update software aktualisierung pakete packages" },
|
||||
{ "backup", "Backup", CAT_SYSTEM, "DtSystem.m.pm", PANE_OWN, NULL,
|
||||
"backup sicherung" },
|
||||
{ "startupdisk", "Startup Disk", CAT_SYSTEM, "Dtdisk.m.pm", PANE_LATER,
|
||||
NULL, "startup disk startvolume" },
|
||||
{ "startupdisk", "Startup Disk", CAT_SYSTEM, "Dtdisk.m.pm", PANE_OWN,
|
||||
NULL, "startup disk startvolume boot volume" },
|
||||
{ "accessibility", "Accessibility", CAT_SYSTEM, "Dtmouse.m.pm",
|
||||
PANE_LATER, NULL, "accessibility bedienungshilfen" },
|
||||
{ "about", "About", CAT_SYSTEM, "MakronixDtlogo.m.pm", PANE_OWN, NULL,
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* startupdisk.c -- dtsystemsettings: the startup volume (t0174)
|
||||
*
|
||||
* Copyright (c) 2006 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
||||
*
|
||||
* The reference's window: the volumes of the computer, the one it starts
|
||||
* from marked, and "Restart...". The volumes come from mcde_sys_disks and
|
||||
* mcde_sys_info (the device of /); restarting goes through the bar's power
|
||||
* dialog, so it asks before anything happens. Choosing another startup
|
||||
* volume means writing the boot loader's configuration (root: grub on
|
||||
* Linux, boot.cfg on NetBSD) -- that is the follow-up, and the pane says so
|
||||
* instead of pretending.
|
||||
*
|
||||
* 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/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Text.h>
|
||||
|
||||
#include <Mcde/McdeSys.h>
|
||||
|
||||
#include "ui.h"
|
||||
|
||||
static Widget list, detail, status;
|
||||
static McdeSysDisk disks[32];
|
||||
static int ndisks, current = -1;
|
||||
|
||||
static void
|
||||
Size(unsigned long long b, char *buf, size_t len)
|
||||
{
|
||||
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
|
||||
Show(int at)
|
||||
{
|
||||
char text[512], size[32];
|
||||
|
||||
if (at < 0 || at >= ndisks) {
|
||||
SetText(detail, "Choose a volume.");
|
||||
return;
|
||||
}
|
||||
Size(disks[at].bytes, size, sizeof size);
|
||||
(void)snprintf(text, sizeof text, "%s\nType: %s\nSize: %s\nMounted at: %s",
|
||||
disks[at].label[0] != '\0' ? disks[at].label : disks[at].name,
|
||||
disks[at].fstype[0] != '\0' ? disks[at].fstype : "unknown",
|
||||
size, disks[at].mountpoint[0] != '\0' ? disks[at].mountpoint :
|
||||
"not mounted");
|
||||
SetText(detail, text);
|
||||
}
|
||||
|
||||
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
|
||||
Restart(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
(void) w;
|
||||
(void) data;
|
||||
(void) call;
|
||||
/* the bar's power dialog: it asks, and only then restarts */
|
||||
Spawn("dtbar -command power");
|
||||
}
|
||||
|
||||
Widget
|
||||
MakeStartupDisk(Widget parent)
|
||||
{
|
||||
Widget box = XtVaCreateManagedWidget("startupdisk",
|
||||
xmRowColumnWidgetClass, parent, XmNorientation, XmVERTICAL,
|
||||
XmNspacing, 8, NULL);
|
||||
Widget buttons;
|
||||
McdeSysInfo info;
|
||||
char row[256];
|
||||
int i, at = 0;
|
||||
|
||||
(void) Text(box, "startupLabel", "The volumes of this computer:");
|
||||
list = XmCreateScrolledList(box, "volumes", NULL, 0);
|
||||
XtVaSetValues(list, XmNvisibleItemCount, 8, XmNwidth, 460,
|
||||
XmNheight, 200, NULL);
|
||||
XtManageChild(list);
|
||||
XtAddCallback(list, XmNbrowseSelectionCallback, Chosen, NULL);
|
||||
detail = Text(box, "startupDetail", "");
|
||||
|
||||
ndisks = mcde_sys_disks(disks, 32);
|
||||
if (mcde_sys_info(&info) == MCDE_SYS_OK) {
|
||||
for (i = 0; i < ndisks; i++)
|
||||
if (strcmp(disks[i].name, info.disk) == 0 ||
|
||||
strcmp(disks[i].mountpoint, "/") == 0)
|
||||
current = i;
|
||||
}
|
||||
for (i = 0; i < ndisks; i++) {
|
||||
XmString s;
|
||||
|
||||
(void)snprintf(row, sizeof row, "%s%s", i == current ? "* " :
|
||||
" ", disks[i].label[0] != '\0' ? disks[i].label :
|
||||
disks[i].name);
|
||||
s = XmStringCreateLocalized(row);
|
||||
XmListAddItemUnselected(list, s, 0);
|
||||
XmStringFree(s);
|
||||
if (i == 0)
|
||||
at = 0;
|
||||
}
|
||||
if (ndisks > 0) {
|
||||
XmListSelectPos(list, current >= 0 ? current + 1 : 1, False);
|
||||
Show(current >= 0 ? current : 0);
|
||||
} else
|
||||
SetText(detail, ndisks < 0 ? mcde_sys_error() : "No volume was "
|
||||
"found.");
|
||||
|
||||
buttons = XtVaCreateManagedWidget("startupButtons",
|
||||
xmRowColumnWidgetClass, box, XmNorientation, XmHORIZONTAL,
|
||||
XmNspacing, 8, XmNmarginWidth, 0, NULL);
|
||||
(void) Button(buttons, "Restart...", Restart, NULL);
|
||||
(void) Text(box, "startupNote", "Choosing another startup volume "
|
||||
"writes the boot loader's configuration (root: grub on Linux, "
|
||||
"boot.cfg on NetBSD); that part is a follow-up. The volume in "
|
||||
"use is marked with *.");
|
||||
status = Text(box, "startupStatus", "");
|
||||
if (current >= 0) {
|
||||
(void)snprintf(row, sizeof row, "Started from: %s",
|
||||
disks[current].label[0] != '\0' ? disks[current].label :
|
||||
disks[current].name);
|
||||
SetText(status, row);
|
||||
}
|
||||
(void) at;
|
||||
return box;
|
||||
}
|
||||
@@ -85,6 +85,8 @@ Widget MakeInternet(Widget parent);
|
||||
Widget MakeDefaults(Widget parent);
|
||||
/* what this computer is (sysinfo.c): Hardware | Network | Software */
|
||||
Widget MakeSysinfo(Widget parent);
|
||||
/* the Startup Disk pane (startupdisk.c) */
|
||||
Widget MakeStartupDisk(Widget parent);
|
||||
int SetDefaultPrinterCommand(const char *name);
|
||||
int AddPrinterCommand(const char *name, const char *uri);
|
||||
int RemovePrinterCommand(const char *name);
|
||||
|
||||
Reference in new issue
Block a user