Files
mcde/programs/dtbar/menuscale.c
T
lotherkandClaude Opus 5.5 776e0f3d47 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>
2026-11-10 11:23:50 +00:00

70 lines
1.7 KiB
C

/*
* 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);
}