mcde: dtbar status menus work: slider in the menu, icons as CDE icon files

- menuscale.c gives XmScale Motif's XmQTmenuSavvy trait (XmeTraitSet, as
  Label.c does for its classes): a menu takes the volume slider without
  "wrong child type".  Dragged against a private PulseAudio (null sink):
  40 % -> 100 %, two wheel steps -> 90 %.
- The icons are CDE icon files (icons/Mcde*.t.pm, appconfig/icons/C, in the
  PLIST), loaded with XmGetPixmap; the status menu bar has a fixed width (the
  form had squeezed the buttons to 10 pixels).
- McdeSys sets SIGCHLD to the default while it waits for a tool: dtbar
  ignored SIGCHLD, waitpid gave no status and every query failed (volume -1).
  dtbar starts programs with a double fork instead.
- Menu entries left-aligned; Mute shows its box when off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lotherkandClaude Opus 5.5 committed 2026-11-10 11:23:50 +00:00
1 parent a6be527b40
commit 6f669e37fe
16 files changed
+422 -221

No files matched your search

+8
View File
@@ -69,6 +69,14 @@ place of CDE; pkgsrc builds it on any platform from `pkgsrc/`.
the last two ask first), Lock Screen, Log Out with the user's name. Never
test the power items to the end on a development host: dtbar runs as the
user there, and the system may let the user shut it down.
Right of the menus, left of the clock (`status.c`): volume (a slider in
the menu -- `menuscale.c` gives XmScale Motif's XmQTmenuSavvy trait with
XmeTraitSet, so a menu takes it; Mute; the wheel over the speaker),
Bluetooth (on/off) and network (the cards, not bridges or containers), all
through McdeSys; icons are CDE icon files (`icons/Mcde*.t.pm`). The status
menu bar has a fixed width: the form sized it before the icons and the bar
squeezed them to 10 pixels. Test sound only against a private PulseAudio
(null sink, own socket): the slider changes the volume it reaches.
dtwm places and maximizes windows below the bar (`McdeExcludeBar` in
`programs/dtwm/WmMultiHead.c`); a full-screen window covers it.
- `programs/dtterm/Profiles.c` -- terminal profiles (font, colours, command)
+34 -3
View File
@@ -13,6 +13,7 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@@ -45,27 +46,52 @@ mcde_sys_fail(int status, const char *fmt, ...)
return status;
}
/* A program that ignores SIGCHLD (to have no zombies) gets no exit status
* from waitpid(2) -- POSIX: the children are reaped at once. While McdeSys
* waits for a tool, SIGCHLD is the default; the caller's way comes back. */
static void
ChildSignal(struct sigaction *saved, int restore)
{
struct sigaction dfl;
if (restore) {
(void) sigaction(SIGCHLD, saved, NULL);
return;
}
memset(&dfl, 0, sizeof dfl);
dfl.sa_handler = SIG_DFL;
sigemptyset(&dfl.sa_mask);
(void) sigaction(SIGCHLD, &dfl, saved);
}
int
mcde_sys_run(char *const argv[])
{
struct sigaction saved;
pid_t pid;
int st;
if (access(argv[0], X_OK) != 0)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "%s is not there.",
argv[0]);
ChildSignal(&saved, 0);
pid = fork();
if (pid < 0)
if (pid < 0) {
ChildSignal(&saved, 1);
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot start %s: %s.",
argv[0], strerror(errno));
}
if (pid == 0) {
execv(argv[0], argv);
_exit(127);
}
while (waitpid(pid, &st, 0) < 0)
if (errno != EINTR)
if (errno != EINTR) {
ChildSignal(&saved, 1);
return mcde_sys_fail(MCDE_SYS_EFAIL, "%s: %s.", argv[0],
strerror(errno));
}
ChildSignal(&saved, 1);
if (WIFEXITED(st) && WEXITSTATUS(st) == 0)
return MCDE_SYS_OK;
return mcde_sys_fail(MCDE_SYS_EFAIL, "%s did not succeed (status %d).",
@@ -84,6 +110,7 @@ mcde_sys_which(const char *const *paths)
int
mcde_sys_capture(char *const argv[], char *buf, size_t len)
{
struct sigaction saved;
int fd[2], st, nul;
size_t got = 0;
ssize_t r;
@@ -96,8 +123,10 @@ mcde_sys_capture(char *const argv[], char *buf, size_t len)
if (pipe(fd) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "No pipe: %s.",
strerror(errno));
ChildSignal(&saved, 0);
pid = fork();
if (pid < 0) {
ChildSignal(&saved, 1);
close(fd[0]);
close(fd[1]);
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot start %s: %s.",
@@ -131,10 +160,12 @@ mcde_sys_capture(char *const argv[], char *buf, size_t len)
}
buf[got] = '\0';
close(fd[0]);
st = -1;
while (waitpid(pid, &st, 0) < 0)
if (errno != EINTR)
break;
if (WIFEXITED(st) && WEXITSTATUS(st) == 0)
ChildSignal(&saved, 1);
if (st != -1 && WIFEXITED(st) && WEXITSTATUS(st) == 0)
return MCDE_SYS_OK;
return mcde_sys_fail(MCDE_SYS_EFAIL, "%s did not succeed (status %d).",
argv[0], WIFEXITED(st) ? WEXITSTATUS(st) : -1);
+8
View File
@@ -2122,6 +2122,14 @@ dt/appconfig/icons/C/IcMxbdy.t.bm
dt/appconfig/icons/C/IcMxbdy.t.pm
dt/appconfig/icons/C/IcMxbdy.t_m.bm
dt/appconfig/icons/C/MakronixDtlogo.pm
dt/appconfig/icons/C/McdeBluetoothOff.t.pm
dt/appconfig/icons/C/McdeBluetoothOn.t.pm
dt/appconfig/icons/C/McdeNetworkOff.t.pm
dt/appconfig/icons/C/McdeVolumeHigh.t.pm
dt/appconfig/icons/C/McdeVolumeLow.t.pm
dt/appconfig/icons/C/McdeVolumeMuted.t.pm
dt/appconfig/icons/C/McdeWifi.t.pm
dt/appconfig/icons/C/McdeWired.t.pm
dt/appconfig/icons/C/SDthtml.m.pm
dt/appconfig/icons/C/SDthtml.t.pm
dt/appconfig/icons/C/SDturlweb.l.pm
+9 -1
View File
@@ -6,11 +6,19 @@ MAINTAINERCLEANFILES = Makefile.in
# C with its own tests (make check).
bin_PROGRAMS = dtbar
dtbar_SOURCES = dtbar.c dtbar.h about.c forcequit.c status.c items.c items.h
dtbar_SOURCES = dtbar.c dtbar.h about.c forcequit.c status.c menuscale.c \
items.c items.h
dtbar_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) -I$(top_builddir)/include \
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
dtbar_LDADD = $(LIBMCDESYS) $(DTCLIENTLIBS) $(XTOOLLIB)
# the icons of the status menus, CDE's kind of icon file (status.c)
iconsdir = $(CDE_INSTALLATION_TOP)/appconfig/icons/C
dist_icons_DATA = icons/McdeVolumeHigh.t.pm icons/McdeVolumeLow.t.pm \
icons/McdeVolumeMuted.t.pm icons/McdeBluetoothOn.t.pm \
icons/McdeBluetoothOff.t.pm icons/McdeWifi.t.pm icons/McdeWired.t.pm \
icons/McdeNetworkOff.t.pm
check_PROGRAMS = test_items
test_items_SOURCES = test_items.c items.c items.h
TESTS = test_items
+27 -12
View File
@@ -24,6 +24,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/wait.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
@@ -118,28 +119,43 @@ IgnoreErrors(Display *d, XErrorEvent *e)
Widget barShell;
void
RunCommand(const char *command)
/* start ARGV in a session of its own, without waiting and without a
* zombie: the child forks the program and ends, the program becomes init's
* (SIGCHLD stays default: McdeSys waits for its tools) */
static void
Spawn(char *const argv[])
{
pid_t pid = fork();
if (pid == 0) {
setsid();
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
_exit(127);
if (fork() == 0) {
setsid();
execvp(argv[0], argv);
_exit(127);
}
_exit(0);
}
if (pid > 0)
while (waitpid(pid, NULL, 0) < 0 && errno == EINTR)
;
}
void
RunCommand(const char *command)
{
char *argv[] = { "/bin/sh", "-c", NULL, NULL };
argv[2] = (char *) command;
Spawn(argv);
}
static void
Run(const char *action)
{
pid_t pid = fork();
char *argv[] = { "dtaction", NULL, NULL };
if (pid == 0) {
setsid();
execlp("dtaction", "dtaction", action, (char *) NULL);
_exit(127);
}
argv[1] = (char *) action;
Spawn(argv);
}
static void
@@ -740,7 +756,6 @@ main(int argc, char **argv)
XEvent ev;
int width;
signal(SIGCHLD, SIG_IGN); /* no zombies of dtaction */
XtSetLanguageProc(NULL, NULL, NULL);
shell = XtVaAppInitialize(&app, "Dtbar", NULL, 0, &argc, argv,
(String *) fallback, XmNoverrideRedirect, True, NULL);
+2
View File
@@ -24,6 +24,8 @@ extern void Centre(Widget dialog);
/* volume, Bluetooth and network, left of the clock (status.c) */
extern Widget MakeStatus(Widget parent);
extern void StartStatus(XtAppContext app);
/* a slider that a Motif menu takes as an entry (menuscale.c) */
extern Widget MenuScale(Widget menu, const char *name, Arg *args, Cardinal n);
/* run a shell command line, in a session of its own, without waiting */
extern void RunCommand(const char *command);
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeBluetoothOff (programs/dtbar/status.c) */
static char *McdeBluetoothOff[] = {
"16 16 2 1",
" c None s background",
". c #8c8c8c",
" . ",
" .. ",
" . . ",
" . . . ",
" . . . ",
" . . . ",
" ... ",
" . ",
" ... ",
" . . . ",
" . . . ",
" . . . ",
" . . ",
" .. ",
" . ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeBluetoothOn (programs/dtbar/status.c) */
static char *McdeBluetoothOn[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" . ",
" .. ",
" . . ",
" . . . ",
" . . . ",
" . . . ",
" ... ",
" . ",
" ... ",
" . . . ",
" . . . ",
" . . . ",
" . . ",
" .. ",
" . ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeNetworkOff (programs/dtbar/status.c) */
static char *McdeNetworkOff[] = {
"16 16 2 1",
" c None s background",
". c #8c8c8c",
" ",
" ",
" ...... ",
" .. .. ",
" . . ",
" . ...... . ",
" .. .. ",
" . . ",
" ...... ",
" . . ",
" ",
" .. ",
" .... ",
" .. ",
" ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeVolumeHigh (programs/dtbar/status.c) */
static char *McdeVolumeHigh[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" ",
" . . ",
" .. . . ",
" ... . . ",
" .... . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
" .... . . ",
" ... . . ",
" .. . . ",
" . . ",
" ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeVolumeLow (programs/dtbar/status.c) */
static char *McdeVolumeLow[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" ",
" . ",
" .. ",
" ... ",
" .... ",
"...... . ",
"...... . ",
"...... . ",
"...... . ",
"...... . ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeVolumeMuted (programs/dtbar/status.c) */
static char *McdeVolumeMuted[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" ",
" . ",
" .. ",
" ... ",
" .... ",
"...... . . ",
"...... . . ",
"...... . ",
"...... . . ",
"...... . . ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeWifi (programs/dtbar/status.c) */
static char *McdeWifi[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" ",
" ",
" ...... ",
" .. .. ",
" . . ",
" . ...... . ",
" .. .. ",
" . . ",
" ...... ",
" . . ",
" ",
" .. ",
" .... ",
" .. ",
" ",
" "};
@@ -0,0 +1,22 @@
/* XPM */
/* MCDE: dtbar, McdeWired (programs/dtbar/status.c) */
static char *McdeWired[] = {
"16 16 2 1",
" c None s background",
". c #000000",
" ",
" ...... ",
" . . ",
" . . ",
" ...... ",
" . ",
" . ",
" ............ ",
" . . ",
" . . ",
"...... ......",
". . . .",
". . . .",
"...... ......",
" ",
" "};
+69
View File
@@ -0,0 +1,69 @@
/*
* menuscale.c -- dtbar: a slider in a Motif menu
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*
* A Motif menu takes as entry a widget whose class carries the trait
* XmQTmenuSavvy, and warns "Attempt to add wrong child type to a menu"
* otherwise (lib/Xm/RowColumn.c, InsertChild; motif-2.3.8). Labels and
* buttons carry it (Label.c, LabelG.c); XmScale does not. Here XmScale gets
* it the way Motif gives it to its own classes, XmeTraitSet(3): no mnemonic,
* no accelerator, and valueChanged as the callback a menu's entryCallback
* stands in for (RCMenu.c asks getActivateCBName for it). Nothing in Motif
* changes; the trait is on the class within this program.
*
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
*/
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/MenuT.h>
#include <Xm/Scale.h>
#include <Xm/TraitP.h>
#include "dtbar.h"
static void
Disable(Widget w, XmActivateState state)
{
(void) w;
(void) state; /* a scale has no activate callback to defer */
}
static char *
Accelerator(Widget w)
{
(void) w;
return NULL;
}
static KeySym
Mnemonic(Widget w)
{
(void) w;
return NoSymbol;
}
static char *
ActivateName(void)
{
return XmNvalueChangedCallback;
}
static XmMenuSavvyTraitRec scaleSavvy = {
0, Disable, Accelerator, Mnemonic, ActivateName
};
Widget
MenuScale(Widget menu, const char *name, Arg *args, Cardinal n)
{
static Boolean done;
if (!done) {
XtInitializeWidgetClass(xmScaleWidgetClass);
(void) XmeTraitSet((XtPointer) xmScaleWidgetClass, XmQTmenuSavvy,
(XtPointer) &scaleSavvy);
done = True;
}
return XtCreateManagedWidget(name, xmScaleWidgetClass, menu, args, n);
}
+89 -205
View File
@@ -22,8 +22,8 @@
#include <string.h>
#include <X11/Intrinsic.h>
#include <X11/xpm.h>
#include <Xm/Xm.h>
#include <Xm/CascadeB.h>
#include <Xm/CascadeBG.h>
#include <Xm/LabelG.h>
#include <Xm/PushBG.h>
@@ -36,205 +36,39 @@
#include "dtbar.h"
/* ---- the icons: 16x16, black on the bar, grey when off ---------------- */
static const char *speakerHigh[] = {
"16 16 2 1", " c None", ". c #000000",
" ",
" . . ",
" .. . . ",
" ... . . ",
" .... . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
"...... . . . ",
" .... . . ",
" ... . . ",
" .. . . ",
" . . ",
" ",
" "};
static const char *speakerLow[] = {
"16 16 2 1", " c None", ". c #000000",
" ",
" . ",
" .. ",
" ... ",
" .... ",
"...... . ",
"...... . ",
"...... . ",
"...... . ",
"...... . ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
static const char *speakerMuted[] = {
"16 16 2 1", " c None", ". c #000000",
" ",
" . ",
" .. ",
" ... ",
" .... ",
"...... . . ",
"...... . . ",
"...... . ",
"...... . . ",
"...... . . ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
static const char *bluetoothOn[] = {
"16 16 2 1", " c None", ". c #000000",
" . ",
" .. ",
" . . ",
" . . . ",
" . . . ",
" . . . ",
" ... ",
" . ",
" ... ",
" . . . ",
" . . . ",
" . . . ",
" . . ",
" .. ",
" . ",
" "};
static const char *bluetoothOff[] = {
"16 16 2 1", " c None", ". c #8c8c8c",
" . ",
" .. ",
" . . ",
" . . . ",
" . . . ",
" . . . ",
" ... ",
" . ",
" ... ",
" . . . ",
" . . . ",
" . . . ",
" . . ",
" .. ",
" . ",
" "};
static const char *wifiOn[] = {
"16 16 2 1", " c None", ". c #000000",
" ",
" ",
" ...... ",
" .. .. ",
" . . ",
" . ...... . ",
" .. .. ",
" . . ",
" ...... ",
" . . ",
" ",
" .. ",
" .... ",
" .. ",
" ",
" "};
static const char *wiredOn[] = {
"16 16 2 1", " c None", ". c #000000",
" ",
" ...... ",
" . . ",
" . . ",
" ...... ",
" . ",
" . ",
" ............ ",
" . . ",
" . . ",
"...... ......",
". . . .",
". . . .",
"...... ......",
" ",
" "};
static const char *netOff[] = {
"16 16 2 1", " c None", ". c #8c8c8c",
" ",
" ",
" ...... ",
" .. .. ",
" . . ",
" . ...... . ",
" .. .. ",
" . . ",
" ...... ",
" . . ",
" ",
" .. ",
" .... ",
" .. ",
" ",
" "};
/* ---- the icons: 16x16 icon files of CDE's kind (icons/Mcde*.t.pm, in
* appconfig/icons/C), loaded by XmGetPixmap: Motif then knows their size --
* a pixmap made here was sized 10 pixels wide by the menu bar under dtwm */
static Pixmap
Icon(Widget w, const char **xpm)
Icon(Widget w, const char *name)
{
Pixmap pm = None, mask = None;
XpmAttributes attr;
Pixel bg;
char path[512];
Pixel fg, bg;
Pixmap pm;
/* "None" becomes the bar's own background, not a hole */
XtVaGetValues(w, XmNbackground, &bg, NULL);
memset(&attr, 0, sizeof attr);
{
static XpmColorSymbol none;
none.name = NULL;
none.value = "None";
none.pixel = bg;
attr.colorsymbols = &none;
attr.numsymbols = 1;
attr.valuemask = XpmColorSymbols;
}
/* W is a gadget: no screen of its own (XtScreen would crash) */
if (XpmCreatePixmapFromData(XtDisplayOfObject(w),
RootWindowOfScreen(XtScreenOfObject(w)), (char **) xpm, &pm, &mask,
&attr) != XpmSuccess) {
fprintf(stderr, "dtbar: an icon cannot be made\n");
return XmUNSPECIFIED_PIXMAP;
}
if (getenv("MCDE_GLOBAL_MENU_DEBUG"))
fprintf(stderr, "dtbar: icon 0x%lx for %s\n", (unsigned long) pm,
XtName(w));
if (mask != None)
XFreePixmap(XtDisplayOfObject(w), mask);
/* "None" in the file becomes the bar's background (XmGetPixmap); W is
* a gadget, with no screen of its own (XtScreen would crash) */
XtVaGetValues(XtIsWidget(w) ? w : XtParent(w), XmNforeground, &fg,
XmNbackground, &bg, NULL);
snprintf(path, sizeof path, "%s/appconfig/icons/C/%s.t.pm",
CDE_INSTALLATION_TOP, name);
pm = XmGetPixmap(XtScreenOfObject(w), path, fg, bg);
if (pm == XmUNSPECIFIED_PIXMAP)
fprintf(stderr, "dtbar: no icon %s\n", path);
return pm;
}
static void
SetIcon(Widget cascade, Pixmap *cache, const char **xpm, const char **shown)
SetIcon(Widget cascade, Pixmap *cache, const char *name, const char **shown)
{
if (*shown == (const char *) xpm)
if (*shown != NULL && strcmp(*shown, name) == 0)
return;
if (*cache == None)
*cache = Icon(cascade, xpm);
*cache = Icon(cascade, name);
XtVaSetValues(cascade, XmNlabelType, XmPIXMAP, XmNlabelPixmap, *cache,
NULL);
*shown = (const char *) xpm;
*shown = name;
}
/* ---- the widgets -------------------------------------------------------- */
@@ -263,7 +97,7 @@ Item(Widget menu, WidgetClass class, const char *text)
{
XmString s = XmStringCreateLocalized((char *) text);
Widget w = XtVaCreateManagedWidget("item", class, menu,
XmNlabelString, s, NULL);
XmNlabelString, s, XmNalignment, XmALIGNMENT_BEGINNING, NULL);
XmStringFree(s);
return w;
@@ -275,11 +109,11 @@ static void
VolumeIcon(void)
{
if (volume < 0 || muted || volume == 0)
SetIcon(volCascade, &pmMuted, speakerMuted, &volShown);
SetIcon(volCascade, &pmMuted, "McdeVolumeMuted", &volShown);
else if (volume < 50)
SetIcon(volCascade, &pmLow, speakerLow, &volShown);
SetIcon(volCascade, &pmLow, "McdeVolumeLow", &volShown);
else
SetIcon(volCascade, &pmHigh, speakerHigh, &volShown);
SetIcon(volCascade, &pmHigh, "McdeVolumeHigh", &volShown);
}
static void
@@ -383,9 +217,9 @@ ReadBluetooth(void)
XtSetSensitive(btPower, True);
}
if (bt.present && bt.on)
SetIcon(btCascade, &pmBtOn, bluetoothOn, &btShown);
SetIcon(btCascade, &pmBtOn, "McdeBluetoothOn", &btShown);
else
SetIcon(btCascade, &pmBtOff, bluetoothOff, &btShown);
SetIcon(btCascade, &pmBtOff, "McdeBluetoothOff", &btShown);
}
static void
@@ -445,11 +279,11 @@ ReadNetwork(void)
for (; slot < NET_SLOTS; slot++)
XtUnmanageChild(netLabels[slot]);
if (wiredUp)
SetIcon(netCascade, &pmWired, wiredOn, &netShown);
SetIcon(netCascade, &pmWired, "McdeWired", &netShown);
else if (wifiUp)
SetIcon(netCascade, &pmWifi, wifiOn, &netShown);
SetIcon(netCascade, &pmWifi, "McdeWifi", &netShown);
else
SetIcon(netCascade, &pmNetOff, netOff, &netShown);
SetIcon(netCascade, &pmNetOff, "McdeNetworkOff", &netShown);
}
/* ---- the menus ---------------------------------------------------------- */
@@ -466,14 +300,20 @@ Opening(Widget w, XtPointer data, XtPointer call)
}
}
/* the cascade gets its first icon when it is made: Motif sizes a label in
* Initialize, and a pixmap set later left the button 10 pixels wide */
static Widget
Menu(Widget bar, const char *name, Widget *pulldown, int which)
Menu(Widget bar, const char *name, Widget *pulldown, int which,
Pixmap *cache, const char *icon, const char **shown)
{
Widget c;
*pulldown = XmCreatePulldownMenu(bar, (char *) name, NULL, 0);
c = XtVaCreateManagedWidget(name, xmCascadeButtonGadgetClass, bar,
XmNsubMenuId, *pulldown, XmNlabelType, XmPIXMAP, NULL);
*cache = Icon(bar, icon);
*shown = icon;
c = XtVaCreateManagedWidget(name, xmCascadeButtonWidgetClass, bar,
XmNsubMenuId, *pulldown, XmNlabelType, XmPIXMAP,
XmNlabelPixmap, *cache, NULL);
XtAddCallback(c, XmNcascadingCallback, Opening,
(XtPointer) (size_t) which);
return c;
@@ -498,21 +338,33 @@ MakeStatus(Widget parent)
XtVaSetValues(bar, XmNshadowThickness, 0, XmNmarginHeight, 0, NULL);
volCascade = Menu(bar, "volume", &m, 0);
volCascade = Menu(bar, "volume", &m, 0, &pmMuted, "McdeVolumeMuted",
&volShown);
volLabel = Item(m, xmLabelGadgetClass, "Volume");
volScale = XtVaCreateManagedWidget("scale", xmScaleWidgetClass, m,
XmNorientation, XmHORIZONTAL, XmNminimum, 0, XmNmaximum, 100,
XmNshowValue, False, XmNscaleWidth, 180, NULL);
{
Arg a[6];
Cardinal n = 0;
/* a slider Motif takes as a menu entry (menuscale.c) */
XtSetArg(a[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(a[n], XmNminimum, 0); n++;
XtSetArg(a[n], XmNmaximum, 100); n++;
XtSetArg(a[n], XmNshowValue, False); n++;
XtSetArg(a[n], XmNscaleWidth, 180); n++;
volScale = MenuScale(m, "scale", a, n);
}
XtAddCallback(volScale, XmNvalueChangedCallback, VolumeChanged, NULL);
XtAddCallback(volScale, XmNdragCallback, VolumeChanged, NULL);
volMute = Item(m, xmToggleButtonGadgetClass, "Mute");
XtVaSetValues(volMute, XmNvisibleWhenOff, True, NULL);
XtAddCallback(volMute, XmNvalueChangedCallback, MuteChanged, NULL);
XtVaCreateManagedWidget("sep", xmSeparatorGadgetClass, m, NULL);
XtSetSensitive(Item(m, xmPushButtonGadgetClass, "Sound Settings..."),
False);
XtAddEventHandler(bar, ButtonPressMask, False, Wheel, NULL);
btCascade = Menu(bar, "bluetooth", &m, 1);
btCascade = Menu(bar, "bluetooth", &m, 1, &pmBtOff, "McdeBluetoothOff",
&btShown);
btLabel = Item(m, xmLabelGadgetClass, "Bluetooth");
btPower = Item(m, xmPushButtonGadgetClass, "Turn Bluetooth Off");
XtAddCallback(btPower, XmNactivateCallback, BluetoothPower, NULL);
@@ -520,13 +372,18 @@ MakeStatus(Widget parent)
XtSetSensitive(Item(m, xmPushButtonGadgetClass,
"Bluetooth Settings..."), False);
netCascade = Menu(bar, "network", &m, 2);
netCascade = Menu(bar, "network", &m, 2, &pmNetOff, "McdeNetworkOff",
&netShown);
for (i = 0; i < NET_SLOTS; i++)
netLabels[i] = Item(m, xmLabelGadgetClass, "");
XtVaCreateManagedWidget("sep", xmSeparatorGadgetClass, m, NULL);
w = Item(m, xmPushButtonGadgetClass, "Network Settings...");
XtSetSensitive(w, False);
/* three icons wide, fixed: the form gave the menu bar the width it had
* before the icons were measured, and the bar squeezed its buttons to
* 10 pixels (measured, MCDE_GLOBAL_MENU_DEBUG) */
XtVaSetValues(bar, XmNwidth, 3 * 30 + 12, XmNresizeWidth, False, NULL);
XtManageChild(bar);
return bar;
}
@@ -535,4 +392,31 @@ void
StartStatus(XtAppContext app)
{
Poll((XtPointer) app, NULL);
if (getenv("MCDE_GLOBAL_MENU_DEBUG")) {
fprintf(stderr, "dtbar: volume %d muted %d (%s)\n", volume, muted,
volume < 0 ? mcde_sys_error() : "ok");
{
Dimension h = 0;
XtVaGetValues(XtParent(volCascade), XmNheight, &h, NULL);
fprintf(stderr, "dtbar: status bar height %u\n", h);
}
Widget c[3];
int i;
c[0] = volCascade;
c[1] = btCascade;
c[2] = netCascade;
for (i = 0; i < 3; i++) {
Dimension w = 0, h = 0;
Pixmap pm = None;
unsigned char type = 0;
XtVaGetValues(c[i], XmNwidth, &w, XmNheight, &h,
XmNlabelPixmap, &pm, XmNlabelType, &type, NULL);
fprintf(stderr, "dtbar: %s %ux%u pixmap 0x%lx type %d "
"managed %d\n", XtName(c[i]), w, h,
(unsigned long) pm, type, XtIsManaged(c[i]));
}
}
}