The launch path calls McdeSoundEvent (Columns.c:441) without the header; GCC 14 and later make an implicit function declaration an error in C99+. FileMgr.c and the other callers already include it. Seen as a warning in build/logs/mcde-host-install-2026-11-13b.log; part of the C23 cleanup (tasksd t0170). Co-authored-by: Iceman Contributor Free <noreply@opencode.ai>
596 lines
17 KiB
C
596 lines
17 KiB
C
/*
|
|
* Columns.c -- MCDE: the column view of the file manager window
|
|
*
|
|
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
|
*
|
|
* A fourth view beside CDE's icons, small icons and list (Navigation.c): one
|
|
* column for each folder from the place it lies in (Home, or the Computer)
|
|
* down to the folder shown, and on the right what is chosen -- its icon,
|
|
* name, kind, size and date. A folder chosen in a column opens the next
|
|
* column and becomes the window's folder through dtfile's own
|
|
* ChangeDirectoryToParent (_McdeNavGoTo), so title, history and the other
|
|
* views follow; a file is opened with a double click by the first action
|
|
* of its data type, as dtfile runs a default action (Command.c,
|
|
* DtActionInvoke).
|
|
*
|
|
* The columns replace the work area while the view is on: they are a
|
|
* sibling of CDE's work frame with the same attachments. As many columns
|
|
* as fit are shown, the deepest ones.
|
|
*
|
|
* C99, POSIX and Motif (ext/src/mcde/AGENTS.md).
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
#include <dirent.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <strings.h>
|
|
#include <time.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <Xm/Xm.h>
|
|
#include <Xm/Form.h>
|
|
#include <Xm/Frame.h>
|
|
#include <Xm/Label.h>
|
|
#include <Xm/List.h>
|
|
#include <Xm/RowColumn.h>
|
|
|
|
#include <Dt/Action.h>
|
|
#include <Dt/Dts.h>
|
|
|
|
#include <Mcde/Sound.h> /* McdeSoundEvent, used on a launch */
|
|
|
|
#include "Encaps.h"
|
|
#include "SharedProcs.h"
|
|
#include "FileMgr.h"
|
|
#include "Navigation.h"
|
|
#include "Peek.h"
|
|
|
|
#define COLUMN_WIDTH 180
|
|
#define PREVIEW_WIDTH 210
|
|
#define MAX_COLUMNS 32
|
|
|
|
typedef struct {
|
|
char *dir; /* the folder the column shows */
|
|
char **names; /* its entries, sorted */
|
|
int n;
|
|
Widget list; /* the scrolled list */
|
|
} Column;
|
|
|
|
/* the columns of one window; kept here, not in FileMgrRec, whose fields are
|
|
* CDE's, beside one widget (rec->mcde_columns) */
|
|
#define MAX_WINDOWS 32
|
|
static struct {
|
|
FileMgrRec *rec;
|
|
Column col[MAX_COLUMNS];
|
|
int ncol;
|
|
Widget preview, picon, pname, pinfo;
|
|
} wins[MAX_WINDOWS];
|
|
|
|
static int
|
|
WinOf(FileMgrRec *rec, Boolean make)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < MAX_WINDOWS; i++)
|
|
if (wins[i].rec == rec)
|
|
return i;
|
|
if (!make)
|
|
return -1;
|
|
for (i = 0; i < MAX_WINDOWS; i++)
|
|
if (wins[i].rec == NULL) {
|
|
memset(&wins[i], 0, sizeof wins[i]);
|
|
wins[i].rec = rec;
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
static int
|
|
NameCompare(const void *a, const void *b)
|
|
{
|
|
return strcasecmp(*(char *const *)a, *(char *const *)b);
|
|
}
|
|
|
|
static Boolean
|
|
IsDir(const char *path)
|
|
{
|
|
struct stat st;
|
|
|
|
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
|
|
}
|
|
|
|
static char *
|
|
Join(const char *dir, const char *name)
|
|
{
|
|
size_t n = strlen(dir) + strlen(name) + 2;
|
|
char *p = XtMalloc((Cardinal)n);
|
|
|
|
(void)snprintf(p, n, "%s%s%s", dir,
|
|
strcmp(dir, "/") == 0 ? "" : "/", name);
|
|
return p;
|
|
}
|
|
|
|
static void
|
|
SetLabel(Widget w, const char *text)
|
|
{
|
|
XmString s = XmStringCreateLocalized((char *)text);
|
|
|
|
XtVaSetValues(w, XmNlabelString, s, NULL);
|
|
XmStringFree(s);
|
|
}
|
|
|
|
/* ---- the preview -------------------------------------------------------- */
|
|
|
|
static void
|
|
Preview(int k, const char *path)
|
|
{
|
|
Widget form = wins[k].preview;
|
|
char info[512], when[64], kind[160], *type = NULL, *label = NULL;
|
|
char *mime = NULL, *icon = NULL;
|
|
const char *name = strrchr(path, '/');
|
|
struct stat st;
|
|
Pixmap pm = XmUNSPECIFIED_PIXMAP;
|
|
|
|
name = name != NULL && name[1] != '\0' ? name + 1 : path;
|
|
if (stat(path, &st) != 0) {
|
|
SetLabel(wins[k].pname, name);
|
|
SetLabel(wins[k].pinfo, "");
|
|
return;
|
|
}
|
|
type = DtDtsFileToDataType((char *)path);
|
|
if (type != NULL) {
|
|
label = DtDtsDataTypeToAttributeValue(type, "TYPE_LABEL", NULL);
|
|
mime = DtDtsDataTypeToAttributeValue(type, "MIME_TYPE", NULL);
|
|
icon = DtDtsDataTypeToAttributeValue(type, DtDTS_DA_ICON, NULL);
|
|
}
|
|
/* the kind, short: the type's label ("TEXTFILE", "TRASH_FOLDER") read
|
|
* as words, and its MIME type; the DESCRIPTION is a paragraph */
|
|
{
|
|
const char *l = label != NULL ? label : (type != NULL ? type :
|
|
(S_ISDIR(st.st_mode) ? "FOLDER" : "FILE"));
|
|
size_t i, n = 0;
|
|
|
|
for (i = 0; l[i] != '\0' && n + 1 < sizeof kind; i++)
|
|
kind[n++] = l[i] == '_' ? ' ' : (char)(i == 0 ?
|
|
toupper((unsigned char)l[i]) :
|
|
tolower((unsigned char)l[i]));
|
|
kind[n] = '\0';
|
|
if (mime != NULL && mime[0] != '\0')
|
|
(void)snprintf(kind + n, sizeof kind - n, " (%s)", mime);
|
|
}
|
|
/* the large icon of the type, as CDE names them (NAME.l.pm) */
|
|
if (icon != NULL) {
|
|
static const char *const sizes[] = { ".l.pm", ".m.pm", ".l.bm" };
|
|
char buf[256];
|
|
size_t i;
|
|
Pixel fg, bg;
|
|
|
|
XtVaGetValues(form, XmNforeground, &fg, XmNbackground, &bg, NULL);
|
|
/* by Motif's icon search path first, then in CDE's own
|
|
* directory (a session without XMICONSEARCHPATH) */
|
|
for (i = 0; i < sizeof sizes / sizeof sizes[0] &&
|
|
pm == XmUNSPECIFIED_PIXMAP; i++) {
|
|
(void)snprintf(buf, sizeof buf, "%s%s", icon, sizes[i]);
|
|
pm = XmGetPixmap(XtScreen(form), buf, fg, bg);
|
|
if (pm == XmUNSPECIFIED_PIXMAP) {
|
|
(void)snprintf(buf, sizeof buf,
|
|
"%s/appconfig/icons/C/%s%s",
|
|
CDE_INSTALLATION_TOP, icon, sizes[i]);
|
|
pm = XmGetPixmap(XtScreen(form), buf, fg, bg);
|
|
}
|
|
}
|
|
}
|
|
/* the icon label is made anew: Motif takes a label's pixmap reliably
|
|
* only when the label is created (measured in dtsystemsettings) */
|
|
if (wins[k].picon != NULL)
|
|
XtDestroyWidget(wins[k].picon);
|
|
wins[k].picon = XtVaCreateManagedWidget("mcdePreviewIcon",
|
|
xmLabelWidgetClass, form,
|
|
XmNlabelType, pm != XmUNSPECIFIED_PIXMAP ? XmPIXMAP : XmSTRING,
|
|
XmNlabelPixmap, pm, XmNtopAttachment, XmATTACH_FORM,
|
|
XmNtopOffset, 16, XmNleftAttachment, XmATTACH_FORM,
|
|
XmNrightAttachment, XmATTACH_FORM, NULL);
|
|
if (pm == XmUNSPECIFIED_PIXMAP)
|
|
SetLabel(wins[k].picon, "");
|
|
XtVaSetValues(wins[k].pname, XmNtopAttachment, XmATTACH_WIDGET,
|
|
XmNtopWidget, wins[k].picon, XmNtopOffset, 12, NULL);
|
|
SetLabel(wins[k].pname, name);
|
|
(void)strftime(when, sizeof when, "%e %b %Y, %H:%M",
|
|
localtime(&st.st_mtime));
|
|
if (S_ISDIR(st.st_mode))
|
|
(void)snprintf(info, sizeof info, "Kind: %s\nModified: %s",
|
|
kind, when);
|
|
else
|
|
(void)snprintf(info, sizeof info,
|
|
"Kind: %s\nSize: %.1f KB (%lld bytes)\nModified: %s",
|
|
kind, (double)st.st_size / 1024.0, (long long)st.st_size,
|
|
when);
|
|
SetLabel(wins[k].pinfo, info);
|
|
if (label != NULL)
|
|
DtDtsFreeAttributeValue(label);
|
|
if (mime != NULL)
|
|
DtDtsFreeAttributeValue(mime);
|
|
if (icon != NULL)
|
|
DtDtsFreeAttributeValue(icon);
|
|
if (type != NULL)
|
|
DtDtsFreeDataType(type);
|
|
}
|
|
|
|
/* ---- the columns -------------------------------------------------------- */
|
|
|
|
static void ColumnChosen(Widget w, XtPointer client, XtPointer call);
|
|
static void ColumnOpen(Widget w, XtPointer client, XtPointer call);
|
|
|
|
static void
|
|
FreeColumn(Column *c)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < c->n; i++)
|
|
XtFree(c->names[i]);
|
|
XtFree((char *)c->names);
|
|
XtFree(c->dir);
|
|
if (c->list != NULL)
|
|
XtDestroyWidget(XtParent(c->list));
|
|
memset(c, 0, sizeof *c);
|
|
}
|
|
|
|
/* how many columns fit beside the preview */
|
|
static int
|
|
Fitting(FileMgrRec *rec)
|
|
{
|
|
Dimension w = 0;
|
|
int n;
|
|
|
|
XtVaGetValues(rec->mcde_columns, XmNwidth, &w, NULL);
|
|
n = ((int)w - PREVIEW_WIDTH) / COLUMN_WIDTH;
|
|
return n < 1 ? 1 : n;
|
|
}
|
|
|
|
/* attach the shown columns left to right, the deepest ones that fit */
|
|
static void
|
|
Layout(int k)
|
|
{
|
|
FileMgrRec *rec = wins[k].rec;
|
|
int fit = Fitting(rec), first = wins[k].ncol - fit, i;
|
|
Widget left = NULL;
|
|
|
|
if (first < 0)
|
|
first = 0;
|
|
for (i = 0; i < wins[k].ncol; i++) {
|
|
Widget sw = XtParent(wins[k].col[i].list);
|
|
|
|
if (i < first) {
|
|
XtUnmanageChild(sw);
|
|
continue;
|
|
}
|
|
XtVaSetValues(sw, XmNleftAttachment,
|
|
left != NULL ? XmATTACH_WIDGET : XmATTACH_FORM,
|
|
XmNleftWidget, left, NULL);
|
|
XtManageChild(sw);
|
|
left = sw;
|
|
}
|
|
}
|
|
|
|
static void
|
|
AddColumn(int k, const char *dir)
|
|
{
|
|
FileMgrRec *rec = wins[k].rec;
|
|
Column *c;
|
|
DIR *d;
|
|
struct dirent *de;
|
|
Arg args[10];
|
|
int n = 0, cap = 0, i;
|
|
|
|
if (wins[k].ncol >= MAX_COLUMNS)
|
|
return;
|
|
c = &wins[k].col[wins[k].ncol];
|
|
memset(c, 0, sizeof *c);
|
|
c->dir = XtNewString(dir);
|
|
if ((d = opendir(dir)) != NULL) {
|
|
while ((de = readdir(d)) != NULL) {
|
|
if (de->d_name[0] == '.')
|
|
continue; /* hidden, as dtfile hides them */
|
|
if (c->n == cap) {
|
|
cap = cap ? 2 * cap : 64;
|
|
c->names = (char **)XtRealloc((char *)c->names,
|
|
(Cardinal)(cap * sizeof(char *)));
|
|
}
|
|
c->names[c->n++] = XtNewString(de->d_name);
|
|
}
|
|
closedir(d);
|
|
}
|
|
if (c->n > 0)
|
|
qsort(c->names, (size_t)c->n, sizeof(char *), NameCompare);
|
|
|
|
XtSetArg(args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
|
|
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
|
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
|
XtSetArg(args[n], XmNwidth, COLUMN_WIDTH); n++;
|
|
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); n++;
|
|
XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); n++;
|
|
c->list = XmCreateScrolledList(rec->mcde_columns, "mcdeColumn",
|
|
args, n);
|
|
XtVaSetValues(XtParent(c->list), XmNwidth, COLUMN_WIDTH, NULL);
|
|
for (i = 0; i < c->n; i++) {
|
|
char *path = Join(dir, c->names[i]), label[600];
|
|
XmString s;
|
|
|
|
/* a folder says so: it leads on */
|
|
(void)snprintf(label, sizeof label, "%s%s", c->names[i],
|
|
IsDir(path) ? " >" : "");
|
|
XtFree(path);
|
|
s = XmStringCreateLocalized(label);
|
|
XmListAddItemUnselected(c->list, s, 0);
|
|
XmStringFree(s);
|
|
}
|
|
XtAddCallback(c->list, XmNbrowseSelectionCallback, ColumnChosen,
|
|
(XtPointer)rec);
|
|
XtAddCallback(c->list, XmNdefaultActionCallback, ColumnOpen,
|
|
(XtPointer)rec);
|
|
/* MCDE: Space and Escape mean the same here as in the work area, which
|
|
* the list has taken the focus from (Peek.c) */
|
|
{
|
|
char trans[256];
|
|
|
|
(void)snprintf(trans, sizeof trans,
|
|
"<Key>space:McdeKey(%p,peek)\n"
|
|
"<Key>osfCancel:McdeKey(%p,peekesc)", (void *)rec,
|
|
(void *)rec);
|
|
XtOverrideTranslations(c->list,
|
|
XtParseTranslationTable(trans));
|
|
}
|
|
XtManageChild(c->list);
|
|
wins[k].ncol++;
|
|
}
|
|
|
|
static int Chosen(int k, Widget list, int *entry);
|
|
|
|
/* MCDE: the entry the column view has chosen, the deepest one; the space
|
|
* key of the window previews it (Peek.c). The caller frees the string. */
|
|
char *
|
|
_McdeColumnsChosen(FileMgrRec *rec)
|
|
{
|
|
int k = WinOf(rec, False), ci, entry;
|
|
|
|
if (k < 0 || !rec->mcde_columns_on)
|
|
return NULL;
|
|
for (ci = wins[k].ncol - 1; ci >= 0; ci--) {
|
|
if (Chosen(k, wins[k].col[ci].list, &entry) == ci)
|
|
return Join(wins[k].col[ci].dir,
|
|
wins[k].col[ci].names[entry]);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/* the column of LIST, and the entry chosen in it; -1 if none */
|
|
static int
|
|
Chosen(int k, Widget list, int *entry)
|
|
{
|
|
int i, *pos = NULL, n = 0;
|
|
|
|
for (i = 0; i < wins[k].ncol; i++)
|
|
if (wins[k].col[i].list == list)
|
|
break;
|
|
if (i == wins[k].ncol)
|
|
return -1;
|
|
*entry = -1;
|
|
if (XmListGetSelectedPos(list, &pos, &n) && n > 0)
|
|
*entry = pos[0] - 1;
|
|
XtFree((char *)pos);
|
|
return *entry >= 0 && *entry < wins[k].col[i].n ? i : -1;
|
|
}
|
|
|
|
static void
|
|
ColumnChosen(Widget w, XtPointer client, XtPointer call)
|
|
{
|
|
FileMgrRec *rec = (FileMgrRec *)client;
|
|
int k = WinOf(rec, False), ci, entry;
|
|
char *path;
|
|
|
|
(void)call;
|
|
if (k < 0 || (ci = Chosen(k, w, &entry)) < 0)
|
|
return;
|
|
path = Join(wins[k].col[ci].dir, wins[k].col[ci].names[entry]);
|
|
/* what lay behind this column goes */
|
|
while (wins[k].ncol > ci + 1)
|
|
FreeColumn(&wins[k].col[--wins[k].ncol]);
|
|
Preview(k, path);
|
|
/* MCDE: the preview window, if it is up, follows the column */
|
|
_McdePeekPath(rec, path);
|
|
if (IsDir(path)) {
|
|
AddColumn(k, path);
|
|
Layout(k);
|
|
/* the window's folder follows; _McdeNavVisit finds the
|
|
* columns already there (_McdeColumnsFollow) */
|
|
_McdeNavGoTo(rec, path);
|
|
} else
|
|
Layout(k);
|
|
XtFree(path);
|
|
}
|
|
|
|
/* a double click: a folder is already open; a file runs the first action
|
|
* of its type, as a double click on its icon does */
|
|
static void
|
|
ColumnOpen(Widget w, XtPointer client, XtPointer call)
|
|
{
|
|
FileMgrRec *rec = (FileMgrRec *)client;
|
|
int k = WinOf(rec, False), ci, entry;
|
|
char *path, *type, *actions, *first, *end;
|
|
DtActionArg arg;
|
|
|
|
(void)call;
|
|
if (k < 0 || (ci = Chosen(k, w, &entry)) < 0)
|
|
return;
|
|
path = Join(wins[k].col[ci].dir, wins[k].col[ci].names[entry]);
|
|
if (IsDir(path) || (type = DtDtsFileToDataType(path)) == NULL) {
|
|
XtFree(path);
|
|
return;
|
|
}
|
|
actions = DtDtsDataTypeToAttributeValue(type, DtDTS_DA_ACTION_LIST,
|
|
NULL);
|
|
first = actions != NULL ? XtNewString(actions) : XtNewString("Open");
|
|
if ((end = strchr(first, ',')) != NULL)
|
|
*end = '\0';
|
|
memset(&arg, 0, sizeof arg);
|
|
arg.argClass = DtACTION_FILE;
|
|
arg.u.file.name = path;
|
|
(void)McdeSoundEvent(XtDisplay(w), "Launch");
|
|
(void)DtActionInvoke(w, first, &arg, 1, NULL, NULL,
|
|
wins[k].col[ci].dir, True, NULL, NULL);
|
|
XtFree(first);
|
|
if (actions != NULL)
|
|
DtDtsFreeAttributeValue(actions);
|
|
DtDtsFreeDataType(type);
|
|
XtFree(path);
|
|
}
|
|
|
|
/* the columns from the place DIR lies in down to DIR */
|
|
static void
|
|
Build(int k, const char *dir)
|
|
{
|
|
const char *home = getenv("HOME");
|
|
char *root, *p, *path;
|
|
size_t rl;
|
|
|
|
while (wins[k].ncol > 0)
|
|
FreeColumn(&wins[k].col[--wins[k].ncol]);
|
|
if (home != NULL && home[0] == '/' &&
|
|
strncmp(dir, home, strlen(home)) == 0 &&
|
|
(dir[strlen(home)] == '/' || dir[strlen(home)] == '\0'))
|
|
root = XtNewString(home);
|
|
else
|
|
root = XtNewString("/");
|
|
AddColumn(k, root);
|
|
rl = strlen(root);
|
|
path = XtNewString(dir);
|
|
/* every folder below the root, each one more column, its entry
|
|
* selected in the column before */
|
|
for (p = path + rl; p != NULL && *p != '\0'; ) {
|
|
char *slash, save, *name;
|
|
int i;
|
|
|
|
while (*p == '/')
|
|
p++;
|
|
if (*p == '\0')
|
|
break;
|
|
slash = strchr(p, '/');
|
|
save = slash != NULL ? *slash : '\0';
|
|
if (slash != NULL)
|
|
*slash = '\0';
|
|
name = strrchr(path, '/') + 1;
|
|
{
|
|
Column *c = &wins[k].col[wins[k].ncol - 1];
|
|
|
|
for (i = 0; i < c->n; i++)
|
|
if (strcmp(c->names[i], name) == 0) {
|
|
XmListSelectPos(c->list, i + 1, False);
|
|
XmListSetPos(c->list,
|
|
i > 5 ? i - 5 : 1);
|
|
break;
|
|
}
|
|
}
|
|
AddColumn(k, path);
|
|
if (slash != NULL)
|
|
*slash = save;
|
|
p = slash;
|
|
}
|
|
XtFree(path);
|
|
XtFree(root);
|
|
Layout(k);
|
|
Preview(k, dir);
|
|
}
|
|
|
|
/* ---- the view ----------------------------------------------------------- */
|
|
|
|
void
|
|
_McdeColumnsCreate(FileMgrRec *rec, Widget parent, Widget work)
|
|
{
|
|
Widget form, frame, preview;
|
|
int k = WinOf(rec, True);
|
|
Arg args[8];
|
|
int n = 0;
|
|
|
|
XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
|
|
XtSetArg(args[n], XmNtopWidget, work); n++;
|
|
XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
|
|
XtSetArg(args[n], XmNleftWidget, work); n++;
|
|
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
|
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
|
form = XmCreateForm(parent, "mcdeColumns", args, n);
|
|
rec->mcde_columns = form;
|
|
if (k < 0)
|
|
return;
|
|
|
|
frame = XtVaCreateManagedWidget("mcdePreviewFrame", xmFrameWidgetClass,
|
|
form, XmNshadowType, XmSHADOW_IN, XmNwidth, PREVIEW_WIDTH,
|
|
XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
|
|
XmNrightAttachment, XmATTACH_FORM, NULL);
|
|
preview = XtVaCreateManagedWidget("mcdePreview", xmFormWidgetClass,
|
|
frame, NULL);
|
|
wins[k].preview = preview;
|
|
wins[k].picon = NULL;
|
|
wins[k].pname = XtVaCreateManagedWidget("mcdePreviewName",
|
|
xmLabelWidgetClass, preview, XmNtopAttachment, XmATTACH_FORM,
|
|
XmNtopOffset, 90, XmNleftAttachment, XmATTACH_FORM,
|
|
XmNrightAttachment, XmATTACH_FORM, NULL);
|
|
wins[k].pinfo = XtVaCreateManagedWidget("mcdePreviewInfo",
|
|
xmLabelWidgetClass, preview, XmNtopAttachment, XmATTACH_WIDGET,
|
|
XmNtopWidget, wins[k].pname, XmNtopOffset, 12,
|
|
XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 8,
|
|
XmNalignment, XmALIGNMENT_BEGINNING, NULL);
|
|
SetLabel(wins[k].pname, "");
|
|
SetLabel(wins[k].pinfo, "");
|
|
/* the columns end at the preview */
|
|
XtVaSetValues(form, XmNwidth, 3 * COLUMN_WIDTH + PREVIEW_WIDTH, NULL);
|
|
}
|
|
|
|
/* the view on (the columns for DIR in place of WORK) or off */
|
|
void
|
|
_McdeColumnsShow(FileMgrRec *rec, Widget work, const char *dir, Boolean on)
|
|
{
|
|
int k = WinOf(rec, False);
|
|
|
|
if (k < 0 || rec->mcde_columns == NULL)
|
|
return;
|
|
/* the form around keeps its size while one part replaces the other:
|
|
* unmanaging the first made it ask the window for less (measured) */
|
|
XtVaSetValues(XtParent(work), XmNresizePolicy, XmRESIZE_NONE, NULL);
|
|
if (!on) {
|
|
XtManageChild(work);
|
|
XtUnmanageChild(rec->mcde_columns);
|
|
return;
|
|
}
|
|
/* the size of the work area: the form would ask the window for its
|
|
* own, smaller one, and the window shrank (measured) */
|
|
{
|
|
Dimension w = 0, h = 0;
|
|
|
|
XtVaGetValues(work, XmNwidth, &w, XmNheight, &h, NULL);
|
|
XtVaSetValues(rec->mcde_columns, XmNwidth, w, XmNheight, h,
|
|
XmNresizePolicy, XmRESIZE_NONE, NULL);
|
|
}
|
|
XtManageChild(rec->mcde_columns);
|
|
XtUnmanageChild(work);
|
|
Build(k, dir);
|
|
}
|
|
|
|
/* the window went to DIR (ShowNewDirectory): the columns follow, unless
|
|
* they lead there already */
|
|
void
|
|
_McdeColumnsFollow(FileMgrRec *rec, const char *dir)
|
|
{
|
|
int k = WinOf(rec, False);
|
|
|
|
if (k < 0 || rec->mcde_columns == NULL ||
|
|
!XtIsManaged(rec->mcde_columns))
|
|
return;
|
|
if (wins[k].ncol > 0 &&
|
|
strcmp(wins[k].col[wins[k].ncol - 1].dir, dir) == 0)
|
|
return;
|
|
Build(k, dir);
|
|
}
|