Merge pull request #13 from D-Modem/claude/project-thread-0xgx4j

Settings: the connection path at the top, as PCOMM draws its link
This commit is contained in:
Neo authored and GitHub committed 2026-11-20 02:45:44 -08:00
commit 83cdbd2665
17 files changed
+1042 -5

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ set(DMODEMCTL_SOURCES
src/session.c
src/model.c
src/diag.c
src/path.c
src/vt.c
src/vt_charsets.c
src/vt_data.c
+69
View File
@@ -321,6 +321,75 @@ DMC_API const char *dmc_diag_raw(const dmc_diag *d, int key);
/* there was a call to report (key 1 not "no previous call") */
DMC_API int dmc_diag_has_call(const dmc_diag *d);
/*
* The connection path
*
* The picture at the top of the Settings page of how a call is made, as
* PCOMM's "Connection Overview" draws its link: four steps, left to right,
* each with its role above its icon and what it is below, one line
* joining them. Idle, each step is as the line settings set it up (ready,
* or something still to set); starting, calling and online, as it is now.
* The words are here so that every app says the same; each draws them.
*/
typedef struct dmc_path dmc_path;
/* the line settings' kinds of line */
enum {
DMC_LINE_SIP = 0, /* dmodemd on a SIP account (or none) */
DMC_LINE_USB, /* dmodemd on a USB modem's phone line */
DMC_LINE_CODEC, /* dmodemd on a softmodem codec (ALSA) */
DMC_LINE_DEVICE, /* a modem that already runs, at a device */
DMC_LINE_TCP, /* dmodemd that already runs, over TCP */
DMC_LINE_COM /* a modem on a COM port */
};
/* a step's state: ready (set up, idle), something to set first, not in
use, starting or connecting, in the call */
enum {
DMC_STEP_READY = 0, DMC_STEP_SETUP, DMC_STEP_OFF, DMC_STEP_WORKING,
DMC_STEP_ACTIVE
};
/* what a step is, for its icon */
enum {
DMC_KIND_TERMINAL = 0, DMC_KIND_SOFTMODEM, DMC_KIND_MODEM,
DMC_KIND_SIP, DMC_KIND_USB, DMC_KIND_CODEC, DMC_KIND_SERIAL,
DMC_KIND_NETWORK, DMC_KIND_PHONE_NETWORK, DMC_KIND_SIP_ADDRESS,
DMC_KIND_PHONE_LINE
};
DMC_API dmc_path *dmc_path_new(void);
DMC_API void dmc_path_free(dmc_path *p);
/* the line settings: the kind of line (DMC_LINE_*), where it is (--usb's
device, the codec, the device's path, the TCP address, the COM port;
NULL or "" for none), and the SIP account: none (anonymous), its user
and server, taking calls (registering) */
DMC_API void dmc_path_set_line(dmc_path *p, int line, const char *where,
int sip_anonymous, const char *sip_user,
const char *sip_server, int listen);
/* now: dmodemd (or the device) started, the session's state
(dmc_state(), DMC_CLOSED for none), the CONNECT line online */
DMC_API void dmc_path_set_live(dmc_path *p, int running, int state,
const char *connect);
/* the steps: how many, each one's kind, state (DMC_STEP_*), role ("Modem",
the label above it), title ("D-Modem") and what it is ("Registers as
alice@example.com") */
DMC_API int dmc_path_steps(const dmc_path *p);
DMC_API int dmc_path_kind(const dmc_path *p, int i);
DMC_API int dmc_path_state(const dmc_path *p, int i);
DMC_API const char *dmc_path_role(const dmc_path *p, int i);
DMC_API const char *dmc_path_title(const dmc_path *p, int i);
DMC_API const char *dmc_path_detail(const dmc_path *p, int i);
/* the line from step i to the next: the lesser of the two's states
(off, then to set, working, ready, active) */
DMC_API int dmc_path_link(const dmc_path *p, int i);
/* the whole in a line: what needs setting, or what it's doing, or that
it's ready */
DMC_API const char *dmc_path_headline(const dmc_path *p);
/* some step is still to set */
DMC_API int dmc_path_needs_setup(const dmc_path *p);
/*
* The terminal screen
*
+266
View File
@@ -0,0 +1,266 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (C) 2026 D-Modem Authors
*
* path.c - the connection path: the picture at the top of the Settings
* page of how a call is made, step by step (the D-Modem app's
* ConnectionPath, for the desktop's lines)
*
* dmodemd's own line: Terminal -> D-Modem -> SIP, USB modem or codec
* -> the phone network, SIP addresses, a phone line
* a modem that runs: Terminal -> its device, TCP or COM port -> the
* modem -> its phone line
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dmodemctl.h"
#define STEPS 4
typedef struct Step {
int kind, state;
const char *role;
char title[32], detail[400];
} Step;
struct dmc_path {
/* the settings */
int line, anonymous, listen;
char where[256], user[128], server[256];
/* now */
int running, state;
char connect[128];
/* what they make */
Step step[STEPS];
char headline[512];
};
static void copy(char *d, size_t n, const char *s)
{
snprintf(d, n, "%s", s ? s : "");
}
static void step(Step *s, int kind, const char *title, int state,
const char *detail)
{
s->kind = kind;
s->state = state;
copy(s->title, sizeof(s->title), title);
copy(s->detail, sizeof(s->detail), detail);
}
static int rank(int state)
{
switch (state) {
case DMC_STEP_OFF: return 0;
case DMC_STEP_SETUP: return 1;
case DMC_STEP_WORKING: return 2;
case DMC_STEP_READY: return 3;
default: return 4;
}
}
/* the steps and the headline, from the settings and now */
static void make(dmc_path *p)
{
static const char *const roles[] = { "Program", "Modem", "Line", "Reaches" };
static const char *const external[] = { "Program", "Port", "Modem", "Line" };
Step *s = p->step;
char b[400];
int own = p->line == DMC_LINE_SIP || p->line == DMC_LINE_USB ||
p->line == DMC_LINE_CODEC;
step(&s[0], DMC_KIND_TERMINAL, "Terminal", DMC_STEP_READY,
"AT commands and calls");
if (own) {
int st = p->running && p->state == DMC_CLOSED ? DMC_STEP_WORKING :
DMC_STEP_READY;
step(&s[1], DMC_KIND_SOFTMODEM, "D-Modem", st,
st == DMC_STEP_WORKING ? "Starting" :
p->running ? "Running" : "dmodemd, the V.92 softmodem");
}
switch (p->line) {
case DMC_LINE_USB:
snprintf(b, sizeof(b), "%s", *p->where && strcmp(p->where, "auto") ?
p->where : "The first one found");
step(&s[2], DMC_KIND_USB, "USB modem", DMC_STEP_READY, b);
step(&s[3], DMC_KIND_PHONE_LINE, "Phone line", DMC_STEP_READY,
"The USB modem's");
break;
case DMC_LINE_CODEC:
step(&s[2], DMC_KIND_CODEC, "Codec", *p->where ? DMC_STEP_READY :
DMC_STEP_SETUP, *p->where ? p->where : "No ALSA device set");
step(&s[3], DMC_KIND_PHONE_LINE, "Phone line", DMC_STEP_READY,
"The codec's");
break;
case DMC_LINE_DEVICE:
case DMC_LINE_TCP:
case DMC_LINE_COM: {
int set = *p->where != '\0';
int st = !set ? DMC_STEP_SETUP :
p->running && p->state == DMC_CLOSED ? DMC_STEP_WORKING :
DMC_STEP_READY;
const char *title = p->line == DMC_LINE_TCP ? "TCP" :
p->line == DMC_LINE_COM ? "COM port" : "Device";
step(&s[1], p->line == DMC_LINE_TCP ? DMC_KIND_NETWORK :
DMC_KIND_SERIAL, title, st,
set ? p->where : "Not set yet");
step(&s[2], p->line == DMC_LINE_TCP ? DMC_KIND_SOFTMODEM :
DMC_KIND_MODEM, p->line == DMC_LINE_TCP ? "D-Modem" : "Modem",
DMC_STEP_READY,
p->running && p->state != DMC_CLOSED ? "Running" :
"Already running");
step(&s[3], DMC_KIND_PHONE_LINE, "Phone line", DMC_STEP_READY,
"The modem's own");
break;
}
default:
if (p->anonymous) {
snprintf(b, sizeof(b), "Anonymous: nothing registered%s",
p->listen ? ", takes direct calls" : "");
step(&s[2], DMC_KIND_SIP, "SIP", DMC_STEP_READY, b);
step(&s[3], DMC_KIND_SIP_ADDRESS, "SIP addresses",
DMC_STEP_READY, "Dialled directly (sip:user@host)");
} else if (!*p->user || !*p->server) {
step(&s[2], DMC_KIND_SIP, "SIP", DMC_STEP_SETUP,
"No account set up");
step(&s[3], DMC_KIND_PHONE_NETWORK, "Phone network",
DMC_STEP_SETUP, "Through a SIP provider");
} else {
snprintf(b, sizeof(b), "%s %s@%s",
p->listen ? "Registers as" : "Account",
p->user, p->server);
step(&s[2], DMC_KIND_SIP, "SIP", DMC_STEP_READY, b);
snprintf(b, sizeof(b), "Through %s", p->server);
step(&s[3], DMC_KIND_PHONE_NETWORK, "Phone network",
DMC_STEP_READY, b);
}
break;
}
/* a call: each step in use lights; idle, as set up */
int now = -1;
switch (p->state) {
case DMC_ONLINE:
case DMC_ONLINE_COMMAND:
case DMC_VOICE:
case DMC_VOICEMAIL:
now = DMC_STEP_ACTIVE;
break;
case DMC_DIALING:
case DMC_ANSWERING:
case DMC_RINGING:
case DMC_HANGING_UP:
now = DMC_STEP_WORKING;
break;
}
int setup = 0;
for (int i = 0; i < STEPS; i++) {
s[i].role = own ? roles[i] : external[i];
if (now >= 0 && s[i].state != DMC_STEP_OFF &&
s[i].state != DMC_STEP_SETUP)
s[i].state = now;
if (s[i].state == DMC_STEP_SETUP && !setup) {
setup = 1;
char d[400];
copy(d, sizeof(d), s[i].detail);
if (d[0] >= 'A' && d[0] <= 'Z')
d[0] = (char)(d[0] - 'A' + 'a');
snprintf(p->headline, sizeof(p->headline),
"Not ready: %s (%s)", s[i].title, d);
}
}
if (now == DMC_STEP_ACTIVE && (p->state == DMC_VOICE ||
p->state == DMC_VOICEMAIL))
copy(p->headline, sizeof(p->headline), "In a voice call");
else if (now == DMC_STEP_ACTIVE)
snprintf(p->headline, sizeof(p->headline), "Online%s%s",
*p->connect ? ": " : "", p->connect);
else if (p->state == DMC_RINGING)
copy(p->headline, sizeof(p->headline), "Ringing");
else if (p->state == DMC_HANGING_UP)
copy(p->headline, sizeof(p->headline), "Hanging up");
else if (now == DMC_STEP_WORKING)
copy(p->headline, sizeof(p->headline), "Connecting");
else if (!setup && p->running && p->state == DMC_CLOSED)
copy(p->headline, sizeof(p->headline), "Starting the modem");
else if (!setup && p->running)
copy(p->headline, sizeof(p->headline), "Ready: the modem is running");
else if (!setup)
copy(p->headline, sizeof(p->headline),
"Ready: start the modem to dial");
}
dmc_path *dmc_path_new(void)
{
dmc_path *p = calloc(1, sizeof(*p));
if (p)
make(p);
return p;
}
void dmc_path_free(dmc_path *p)
{
free(p);
}
void dmc_path_set_line(dmc_path *p, int line, const char *where,
int sip_anonymous, const char *sip_user,
const char *sip_server, int listen)
{
p->line = line;
copy(p->where, sizeof(p->where), where);
p->anonymous = sip_anonymous != 0;
copy(p->user, sizeof(p->user), sip_user);
copy(p->server, sizeof(p->server), sip_server);
p->listen = listen != 0;
make(p);
}
void dmc_path_set_live(dmc_path *p, int running, int state,
const char *connect)
{
p->running = running != 0;
p->state = state;
copy(p->connect, sizeof(p->connect), connect);
make(p);
}
int dmc_path_steps(const dmc_path *p)
{
(void)p;
return STEPS;
}
static const Step *at(const dmc_path *p, int i)
{
static const Step none = { 0, DMC_STEP_OFF, "", "", "" };
return i >= 0 && i < STEPS ? &p->step[i] : &none;
}
int dmc_path_kind(const dmc_path *p, int i) { return at(p, i)->kind; }
int dmc_path_state(const dmc_path *p, int i) { return at(p, i)->state; }
const char *dmc_path_role(const dmc_path *p, int i) { return at(p, i)->role; }
const char *dmc_path_title(const dmc_path *p, int i) { return at(p, i)->title; }
const char *dmc_path_detail(const dmc_path *p, int i) { return at(p, i)->detail; }
int dmc_path_link(const dmc_path *p, int i)
{
int a = at(p, i)->state, b = at(p, i + 1)->state;
return rank(a) <= rank(b) ? a : b;
}
const char *dmc_path_headline(const dmc_path *p)
{
return p->headline;
}
int dmc_path_needs_setup(const dmc_path *p)
{
for (int i = 0; i < STEPS; i++)
if (p->step[i].state == DMC_STEP_SETUP)
return 1;
return 0;
}
+52
View File
@@ -1206,6 +1206,57 @@ static void test_net(void)
dmc_net_free(n);
}
/* the connection path: each line's steps, idle as set up, in a call as
it is */
static void test_path(void)
{
dmc_path *p = dmc_path_new();
dmc_path_set_line(p, DMC_LINE_SIP, "", 0, "alice", "sip.example.com", 1);
CHECK(dmc_path_steps(p) == 4);
CHECK(dmc_path_kind(p, 0) == DMC_KIND_TERMINAL);
CHECK(dmc_path_kind(p, 1) == DMC_KIND_SOFTMODEM);
CHECK(dmc_path_kind(p, 3) == DMC_KIND_PHONE_NETWORK);
CHECK_STR(dmc_path_role(p, 2), "Line");
CHECK_STR(dmc_path_detail(p, 2), "Registers as alice@sip.example.com");
CHECK(!dmc_path_needs_setup(p));
CHECK_STR(dmc_path_headline(p), "Ready: start the modem to dial");
/* no account yet */
dmc_path_set_line(p, DMC_LINE_SIP, "", 0, "", "", 0);
CHECK(dmc_path_state(p, 2) == DMC_STEP_SETUP);
CHECK(dmc_path_link(p, 1) == DMC_STEP_SETUP);
CHECK(dmc_path_link(p, 0) == DMC_STEP_READY);
CHECK_STR(dmc_path_headline(p), "Not ready: SIP (no account set up)");
/* anonymous */
dmc_path_set_line(p, DMC_LINE_SIP, "", 1, "", "", 0);
CHECK(dmc_path_kind(p, 3) == DMC_KIND_SIP_ADDRESS);
CHECK(!dmc_path_needs_setup(p));
/* a modem that already runs: reached by its port */
dmc_path_set_line(p, DMC_LINE_COM, "COM2", 0, "", "", 0);
CHECK(dmc_path_kind(p, 1) == DMC_KIND_SERIAL);
CHECK_STR(dmc_path_role(p, 1), "Port");
CHECK_STR(dmc_path_detail(p, 1), "COM2");
dmc_path_set_line(p, DMC_LINE_DEVICE, "", 0, "", "", 0);
CHECK(dmc_path_state(p, 1) == DMC_STEP_SETUP);
/* starting, dialling, online */
dmc_path_set_line(p, DMC_LINE_USB, "auto", 0, "", "", 0);
dmc_path_set_live(p, 1, DMC_CLOSED, "");
CHECK(dmc_path_state(p, 1) == DMC_STEP_WORKING);
CHECK(dmc_path_state(p, 2) == DMC_STEP_READY);
CHECK_STR(dmc_path_headline(p), "Starting the modem");
dmc_path_set_live(p, 1, DMC_DIALING, "");
CHECK(dmc_path_link(p, 2) == DMC_STEP_WORKING);
dmc_path_set_live(p, 1, DMC_ONLINE, "CONNECT 48000/26400");
for (int i = 0; i < 4; i++)
CHECK(dmc_path_state(p, i) == DMC_STEP_ACTIVE);
CHECK_STR(dmc_path_headline(p), "Online: CONNECT 48000/26400");
CHECK(dmc_path_state(p, 9) == DMC_STEP_OFF);
dmc_path_free(p);
}
int main(int argc, char **argv)
{
const char *dir = argc > 1 ? argv[1] : ".";
@@ -1226,6 +1277,7 @@ int main(int argc, char **argv)
test_wav();
test_formats();
test_net();
test_path();
printf("%d checks, %d failed\n", checks, failures);
return failures ? 1 : 0;
}
+27 -1
View File
@@ -14,6 +14,7 @@ UBSan).
| --- | --- |
| `dmc_session` | The AT conversation: a queue of commands and their responses, the state of the call from the result codes (RING, CONNECT, NO CARRIER), caller ID, the escape (`+++` with its guard times) and the hang-up, and the byte stream for the terminal |
| `dmc_model` | The settings of the modem from AT!M, with the check of each setting and the command that sets it |
| `dmc_path` | The connection path at the top of the Settings page: the terminal, the modem, the line and what the line reaches. For each step, its role, name, state and setting, from the line settings and the state of the session |
| `dmc_diag` | The statistics of the last call from AT#UD, as labelled rows (with the V.58 code tables decoded) |
| `dmc_vt` | The terminal emulator of the D-Modem app (`shared/.../terminal` of D-Modem/app), ported to C: each type of terminal that it emulates (see below). Each app draws it from its cells |
| `dmc_net` | Telnet (option negotiation, terminal type, window size) and rlogin (the handshake, and the window size on the urgent request of the server), for the Remote page |
@@ -44,7 +45,7 @@ Each app has the same seven pages, with the same words:
| Phone | The state of a voice call, Call and Answer, the keypad (DTMF), Mute and Listen. The answering machine (on or off, rings, the greeting) and its messages |
| Terminal | The AT console. The buttons **Full-screen setup** (AT!CF) and **Command-line setup** (AT!CT). The type of terminal |
| Remote | SSH, Telnet or rlogin. The server, its port (empty: the port of the protocol) and the user. The login method of SSH (keys and the agent, the agent only, a key file, the import of a PuTTY key). Connect. A separate terminal, with its type. The terminal sends its size to the server when the size changes |
| Settings | Groups of settings as native controls, with the changed settings marked. Defaults (ATZ), the init string and Keep |
| Settings | The connection path. Groups of settings as native controls, with the changed settings marked. Defaults (ATZ), the init string and Keep |
| Call Stats | The rows of AT#UD and the report of ATI11, refreshed after each call |
| Log | The text that dmodemd printed, and the command line that started it |
@@ -52,6 +53,31 @@ The terminal sends Backspace as BS (0x08), the S5 of the modem, because the
modem does not accept DEL. The colours are the colours of the brand:
background `#0a0f1c`, text `#e8f0ff`.
## The connection path
The top of the Settings page shows how a call is made, as the "Connection
Overview" of PCOMM draws its link: four steps joined by one line. Each step
has its role above its icon and its setting below.
| Line | Program | Modem (or Port) | Line (or Modem) | Reaches (or Line) |
| --- | --- | --- | --- | --- |
| SIP account | Terminal | D-Modem | SIP: the account, registered when the modem takes calls | The phone network, through the server |
| SIP, anonymous | Terminal | D-Modem | SIP: nothing registered | SIP addresses, dialled directly |
| USB modem | Terminal | D-Modem | The USB modem | Its phone line |
| Codec (Linux) | Terminal | D-Modem | The ALSA device | Its phone line |
| A modem that already runs | Terminal | Its device, TCP address or COM port | The modem | Its phone line |
When idle, each step shows the line settings. A step that is ready is in the
accent colour. A step that you must still set (no SIP account, no device) is
red and its line is dashed, and the text below says what to set. When the
modem starts, dials and is online, the steps light green as the call goes,
and the text below shows the CONNECT line. `dmc_path` of libdmodemctl has the
words, so the three apps show the same text. Each app draws them:
`pathview.c`, `pathview.cpp` (GDI, with the Wingdings of Windows 95) and
`PathView.swift`. The D-Modem app has the same picture at the top of its
Settings, with its own lines (Wi-Fi and Bluetooth to another phone, the
mobile calls of the phone, external modems).
## The terminals
The two terminals (the console of the modem and the terminal of the Remote
Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

+1
View File
@@ -7,6 +7,7 @@ add_executable(dmodem-gui
src/config.c
src/usbmodem.c
src/settings.c
src/pathview.c
src/stats.c
src/voice.c
src/remote.c
+5
View File
@@ -195,6 +195,11 @@ GtkWidget *remote_page_new(App *a);
/* its connection ended (the app is quitting) */
void remote_stop(App *a);
/* pathview.c: the connection path at the top of the Settings page, as
the line settings and the modem are now */
GtkWidget *pathview_new(App *a);
void pathview_update(App *a);
/* stats.c */
GtkWidget *stats_page_new(App *a);
void stats_refresh(App *a);
+225
View File
@@ -0,0 +1,225 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (C) 2026 D-Modem Authors
*
* pathview.c - the connection path at the top of the Settings page, as
* PCOMM's "Connection Overview" draws its link: each step's
* role above its icon, what it is below, one line joining
* them (libdmodemctl's dmc_path). Idle, how the line
* settings set it up; starting, calling and online, as it is.
*/
#include "app.h"
#define STEPS 4
typedef struct PathView {
dmc_path *path;
GtkWidget *role[STEPS], *line[STEPS], *icon[STEPS], *title[STEPS],
*detail[STEPS], *headline;
int state[STEPS], left[STEPS], right[STEPS];
} PathView;
static PathView pv;
static const char *icon_name(int kind)
{
switch (kind) {
case DMC_KIND_TERMINAL: return "utilities-terminal-symbolic";
case DMC_KIND_SOFTMODEM:
case DMC_KIND_MODEM: return "modem-symbolic";
case DMC_KIND_SIP: return "call-start-symbolic";
case DMC_KIND_USB: return "media-removable-symbolic";
case DMC_KIND_CODEC: return "audio-card-symbolic";
case DMC_KIND_SERIAL: return "network-wired-symbolic";
case DMC_KIND_NETWORK: return "network-workgroup-symbolic";
case DMC_KIND_SIP_ADDRESS: return "send-to-symbolic";
default: return "phone-symbolic";
}
}
/* a state's colour: ready the accent, to set red, working and active
green (libadwaita's), off the text's, faint */
static void state_rgba(GtkWidget *w, int state, GdkRGBA *c)
{
switch (state) {
case DMC_STEP_SETUP: gdk_rgba_parse(c, "#e01b24"); break;
case DMC_STEP_WORKING:
case DMC_STEP_ACTIVE: gdk_rgba_parse(c, "#26a269"); break;
case DMC_STEP_OFF:
gtk_widget_get_color(w, c);
c->alpha = 0.3f;
break;
default: gdk_rgba_parse(c, "#3584e4"); break;
}
}
static const char *state_class(int state)
{
switch (state) {
case DMC_STEP_SETUP: return "error";
case DMC_STEP_WORKING:
case DMC_STEP_ACTIVE: return "success";
case DMC_STEP_OFF: return "dim-label";
default: return "accent";
}
}
/* step i's icon row: the line through its middle, half to the step before
and half to the next (dashed where one is still to set, or off), and
the ring the icon sits in */
static void draw_step(GtkDrawingArea *da, cairo_t *cr, int w, int h,
gpointer data)
{
int i = GPOINTER_TO_INT(data);
double y = h / 2.0, r = 22;
static const double dash[] = { 6, 4 };
GdkRGBA c;
cairo_set_line_width(cr, 2);
for (int side = 0; side < 2; side++) {
int st = side ? pv.right[i] : pv.left[i];
if (st < 0)
continue;
state_rgba(GTK_WIDGET(da), st, &c);
gdk_cairo_set_source_rgba(cr, &c);
cairo_set_dash(cr, dash, st == DMC_STEP_SETUP ||
st == DMC_STEP_OFF ? 2 : 0, 0);
cairo_move_to(cr, side ? w / 2.0 + r : 0, y);
cairo_line_to(cr, side ? w : w / 2.0 - r, y);
cairo_stroke(cr);
}
cairo_set_dash(cr, NULL, 0, 0);
state_rgba(GTK_WIDGET(da), pv.state[i], &c);
cairo_arc(cr, w / 2.0, y, r, 0, 2 * G_PI);
if (pv.state[i] == DMC_STEP_ACTIVE) {
GdkRGBA f = c;
f.alpha = 0.2f;
gdk_cairo_set_source_rgba(cr, &f);
cairo_fill_preserve(cr);
}
gdk_cairo_set_source_rgba(cr, &c);
cairo_stroke(cr);
}
static void set_class(GtkWidget *w, const char *cls)
{
static const char *const all[] = { "error", "success", "dim-label",
"accent" };
for (guint k = 0; k < G_N_ELEMENTS(all); k++)
gtk_widget_remove_css_class(w, all[k]);
gtk_widget_add_css_class(w, cls);
}
void pathview_update(App *a)
{
if (!pv.path)
return;
const Config *c = &a->cfg;
int line = DMC_LINE_SIP;
const char *where = "";
if (!g_strcmp0(c->line, "usb")) {
line = DMC_LINE_USB;
where = c->usb;
} else if (!g_strcmp0(c->line, "alsa")) {
line = DMC_LINE_CODEC;
where = c->alsa;
} else if (!g_strcmp0(c->line, "device")) {
line = DMC_LINE_DEVICE;
where = c->device;
}
dmc_path_set_line(pv.path, line, where, c->sip_anonymous, c->sip_user,
c->sip_server, c->listen);
int st = a->s ? dmc_state(a->s) : DMC_CLOSED;
dmc_path_set_live(pv.path, modem_running(a), st,
st == DMC_ONLINE || st == DMC_ONLINE_COMMAND ?
dmc_connect_text(a->s) : "");
int n = dmc_path_steps(pv.path);
GString *spoken = g_string_new(dmc_path_headline(pv.path));
for (int i = 0; i < STEPS && i < n; i++) {
pv.state[i] = dmc_path_state(pv.path, i);
pv.left[i] = i > 0 ? dmc_path_link(pv.path, i - 1) : -1;
pv.right[i] = i < n - 1 ? dmc_path_link(pv.path, i) : -1;
gtk_label_set_text(GTK_LABEL(pv.role[i]), dmc_path_role(pv.path, i));
gtk_label_set_text(GTK_LABEL(pv.title[i]), dmc_path_title(pv.path, i));
gtk_label_set_text(GTK_LABEL(pv.detail[i]), dmc_path_detail(pv.path, i));
gtk_image_set_from_icon_name(GTK_IMAGE(pv.icon[i]),
icon_name(dmc_path_kind(pv.path, i)));
set_class(pv.icon[i], state_class(pv.state[i]));
if (pv.state[i] == DMC_STEP_SETUP)
gtk_widget_add_css_class(pv.detail[i], "error");
else
gtk_widget_remove_css_class(pv.detail[i], "error");
gtk_widget_queue_draw(pv.line[i]);
g_string_append_printf(spoken, ". %s: %s, %s",
dmc_path_role(pv.path, i),
dmc_path_title(pv.path, i),
dmc_path_detail(pv.path, i));
}
gtk_label_set_text(GTK_LABEL(pv.headline), dmc_path_headline(pv.path));
set_class(pv.headline, dmc_path_needs_setup(pv.path) ? "error" :
"dim-label");
gtk_accessible_update_property(GTK_ACCESSIBLE(gtk_widget_get_parent(pv.headline)),
GTK_ACCESSIBLE_PROPERTY_LABEL, spoken->str, -1);
g_string_free(spoken, TRUE);
}
static GtkWidget *label(const char *cls, gboolean wrap)
{
GtkWidget *l = gtk_label_new("");
gtk_label_set_justify(GTK_LABEL(l), GTK_JUSTIFY_CENTER);
if (wrap) {
gtk_label_set_wrap(GTK_LABEL(l), TRUE);
gtk_label_set_wrap_mode(GTK_LABEL(l), PANGO_WRAP_WORD_CHAR);
gtk_label_set_max_width_chars(GTK_LABEL(l), 18);
gtk_label_set_lines(GTK_LABEL(l), 3);
gtk_label_set_ellipsize(GTK_LABEL(l), PANGO_ELLIPSIZE_END);
}
if (cls)
gtk_widget_add_css_class(l, cls);
return l;
}
GtkWidget *pathview_new(App *a)
{
pv.path = dmc_path_new();
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_add_css_class(box, "card");
gtk_widget_set_margin_bottom(box, 6);
GtkWidget *row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(row), TRUE);
gtk_widget_set_margin_top(row, 12);
for (int i = 0; i < STEPS; i++) {
GtkWidget *col = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
pv.role[i] = label("caption", FALSE);
gtk_widget_add_css_class(pv.role[i], "dim-label");
gtk_box_append(GTK_BOX(col), pv.role[i]);
GtkWidget *ov = gtk_overlay_new();
pv.line[i] = gtk_drawing_area_new();
gtk_drawing_area_set_content_height(GTK_DRAWING_AREA(pv.line[i]), 48);
gtk_widget_set_hexpand(pv.line[i], TRUE);
gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(pv.line[i]),
draw_step, GINT_TO_POINTER(i), NULL);
gtk_overlay_set_child(GTK_OVERLAY(ov), pv.line[i]);
pv.icon[i] = gtk_image_new();
gtk_image_set_pixel_size(GTK_IMAGE(pv.icon[i]), 20);
gtk_widget_set_halign(pv.icon[i], GTK_ALIGN_CENTER);
gtk_widget_set_valign(pv.icon[i], GTK_ALIGN_CENTER);
gtk_overlay_add_overlay(GTK_OVERLAY(ov), pv.icon[i]);
gtk_box_append(GTK_BOX(col), ov);
pv.title[i] = label("heading", FALSE);
gtk_box_append(GTK_BOX(col), pv.title[i]);
pv.detail[i] = label("caption", TRUE);
gtk_widget_set_margin_start(pv.detail[i], 4);
gtk_widget_set_margin_end(pv.detail[i], 4);
gtk_box_append(GTK_BOX(col), pv.detail[i]);
gtk_box_append(GTK_BOX(row), col);
}
gtk_box_append(GTK_BOX(box), row);
pv.headline = label(NULL, TRUE);
gtk_label_set_max_width_chars(GTK_LABEL(pv.headline), 60);
gtk_widget_set_margin_bottom(pv.headline, 12);
gtk_widget_set_margin_start(pv.headline, 12);
gtk_widget_set_margin_end(pv.headline, 12);
gtk_box_append(GTK_BOX(box), pv.headline);
pathview_update(a);
return box;
}
+6
View File
@@ -314,6 +314,12 @@ GtkWidget *settings_page_new(App *a)
a->setting_rows = g_ptr_array_new();
a->settings_page = ADW_PREFERENCES_PAGE(adw_preferences_page_new());
/* how a call is made, step by step: as set up when idle, as it is in
a call */
GtkWidget *path = adw_preferences_group_new();
adw_preferences_group_add(ADW_PREFERENCES_GROUP(path), pathview_new(a));
adw_preferences_page_add(a->settings_page, ADW_PREFERENCES_GROUP(path));
GtkWidget *top = adw_preferences_group_new();
adw_preferences_group_set_title(ADW_PREFERENCES_GROUP(top), "The modem's settings");
adw_preferences_group_set_description(ADW_PREFERENCES_GROUP(top),
+1
View File
@@ -84,6 +84,7 @@ void window_state(App *a)
gtk_widget_set_sensitive(a->copy_btn, a->fd >= 0);
gtk_widget_set_sensitive(a->term_buttons, st == DMC_IDLE);
settings_sensitive(a, st == DMC_IDLE);
pathview_update(a);
voice_state(a);
}
+4
View File
@@ -164,6 +164,10 @@ struct SettingsPage: View {
var body: some View {
Form {
// (how a call is made, step by step: as set up when idle, as it is in a call)
Section {
PathView()
}
Section {
LabeledContent("Init string") {
HStack {
+148
View File
@@ -0,0 +1,148 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 D-Modem Authors
//
// PathView.swift - the connection path at the top of the Settings page, as
// PCOMM's "Connection Overview" draws its link: each step's role above its
// icon, what it is below, one line joining them (libdmodemctl's dmc_path).
// Idle, how the line settings set it up; starting, calling and online, as
// it is now.
import SwiftUI
/// a step of the path, as dmc_path gives it
private struct PathStep: Identifiable {
let id: Int
let kind: Int32
let state: Int32
let role, title, detail: String
}
struct PathView: View {
@EnvironmentObject var modem: Modem
var body: some View {
let (steps, links, headline, setup) = Self.make(modem)
VStack(spacing: 8) {
HStack(alignment: .top, spacing: 0) {
ForEach(steps) { s in
StepView(
step: s,
left: s.id > 0 ? links[s.id - 1] : nil,
right: s.id < steps.count - 1 ? links[s.id] : nil
)
.frame(maxWidth: .infinity)
}
}
Text(headline)
.font(.callout)
.foregroundStyle(setup ? Color.red : Color.secondary)
.multilineTextAlignment(.center)
}
.padding(.vertical, 6)
.accessibilityElement(children: .ignore)
.accessibilityLabel(headline + ". " + steps.map { "\($0.role): \($0.title), \($0.detail)" }.joined(separator: ". "))
}
/// the steps, the links between them, the headline, and whether a step is still to set
private static func make(_ modem: Modem) -> ([PathStep], [Int32], String, Bool) {
let p = dmc_path_new()
defer { dmc_path_free(p) }
let c = modem.config
let line: Int32
let whereTo: String
switch c.line {
case .usb: line = Int32(DMC_LINE_USB); whereTo = c.usb
case .device: line = Int32(DMC_LINE_DEVICE); whereTo = c.device
case .sip: line = Int32(DMC_LINE_SIP); whereTo = ""
}
dmc_path_set_line(p, line, whereTo, c.sipAnonymous ? 1 : 0, c.sipUser, c.sipServer, c.listen ? 1 : 0)
let st = Int32(modem.state)
let online = st == Int32(DMC_ONLINE) || st == Int32(DMC_ONLINE_COMMAND)
dmc_path_set_live(p, modem.running ? 1 : 0, st, online ? modem.detail : "")
let n = Int(dmc_path_steps(p))
var steps: [PathStep] = []
var links: [Int32] = []
for i in 0..<n {
let k = Int32(i)
steps.append(PathStep(
id: i, kind: dmc_path_kind(p, k), state: dmc_path_state(p, k),
role: cstr(dmc_path_role(p, k)), title: cstr(dmc_path_title(p, k)),
detail: cstr(dmc_path_detail(p, k))
))
if i < n - 1 { links.append(dmc_path_link(p, k)) }
}
return (steps, links, cstr(dmc_path_headline(p)), dmc_path_needs_setup(p) != 0)
}
}
/// a step: its role, its icon on the line (its links to either side), its name and what it is
private struct StepView: View {
let step: PathStep
let left: Int32?
let right: Int32?
var body: some View {
VStack(spacing: 4) {
Text(step.role).font(.caption).foregroundStyle(.secondary).lineLimit(1)
ZStack {
// (the line through the icons' middles: half to the step before, half to the next)
GeometryReader { g in
let y = g.size.height / 2
if let left {
Path { p in p.move(to: CGPoint(x: 0, y: y)); p.addLine(to: CGPoint(x: g.size.width / 2, y: y)) }
.stroke(Self.color(left), style: Self.stroke(left))
}
if let right {
Path { p in p.move(to: CGPoint(x: g.size.width / 2, y: y)); p.addLine(to: CGPoint(x: g.size.width, y: y)) }
.stroke(Self.color(right), style: Self.stroke(right))
}
}
Circle()
.fill(step.state == Int32(DMC_STEP_ACTIVE) ? Self.color(step.state).opacity(0.2) : Color(nsColor: .controlBackgroundColor))
.overlay(Circle().stroke(Self.color(step.state), lineWidth: 2))
.frame(width: 40, height: 40)
Image(systemName: Self.symbol(step.kind))
.font(.system(size: 16, weight: .medium))
.foregroundStyle(Self.color(step.state))
}
.frame(height: 44)
Text(step.title).font(.headline).multilineTextAlignment(.center).lineLimit(1)
Text(step.detail)
.font(.caption)
.multilineTextAlignment(.center)
.lineLimit(3)
.foregroundStyle(step.state == Int32(DMC_STEP_SETUP) ? Color.red : Color.secondary)
}
.padding(.horizontal, 4)
}
/// a state's colour: ready the accent, to set red, dialling and online green, off faint
static func color(_ s: Int32) -> Color {
switch s {
case Int32(DMC_STEP_SETUP): return .red
case Int32(DMC_STEP_WORKING), Int32(DMC_STEP_ACTIVE): return .green
case Int32(DMC_STEP_OFF): return Color(nsColor: .tertiaryLabelColor)
default: return .accentColor
}
}
/// a link's line: dashed where a step is still to set, or off
static func stroke(_ s: Int32) -> StrokeStyle {
let dashed = s == Int32(DMC_STEP_SETUP) || s == Int32(DMC_STEP_OFF)
return StrokeStyle(lineWidth: 2, dash: dashed ? [6, 4] : [])
}
/// a step's SF Symbol
static func symbol(_ k: Int32) -> String {
switch k {
case Int32(DMC_KIND_TERMINAL): return "terminal"
case Int32(DMC_KIND_SOFTMODEM), Int32(DMC_KIND_MODEM): return "server.rack"
case Int32(DMC_KIND_SIP): return "phone.arrow.up.right"
case Int32(DMC_KIND_USB), Int32(DMC_KIND_SERIAL): return "cable.connector"
case Int32(DMC_KIND_CODEC): return "waveform"
case Int32(DMC_KIND_NETWORK): return "network"
case Int32(DMC_KIND_SIP_ADDRESS): return "at"
default: return "phone"
}
}
}
+1
View File
@@ -8,6 +8,7 @@ add_executable(dmodem WIN32
src/pages.cpp
src/term.cpp
src/settings.cpp
src/pathview.cpp
src/config.cpp
src/voice.cpp
src/audio.cpp
+5
View File
@@ -186,6 +186,11 @@ void remote_stop();
/* settings.cpp: the Settings page */
HWND settings_page_new(HWND parent);
/* pathview.cpp: the connection path at the top of the Settings page, as
the line settings and the modem are now; its height */
HWND pathview_new(HWND parent);
void pathview_update();
int pathview_height();
void settings_page_layout(HWND page, int w, int h);
void settings_load();
void settings_clear();
+219
View File
@@ -0,0 +1,219 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (C) 2026 D-Modem Authors
*
* pathview.cpp - the connection path at the top of the Settings page, as
* PCOMM's "Connection Overview" draws its link: each step's
* role above its icon, what it is below, one line joining
* them (libdmodemctl's dmc_path), in plain GDI for Windows
* 95 and later. Idle, how the line settings set it up;
* starting, calling and online, as it is now.
*/
#include <string.h>
#include "app.h"
static dmc_path *path;
static HWND view;
static HFONT glyph_font;
/* a state's colour: ready the highlight's, to set red, working and
active green, off grey */
static COLORREF state_color(int st)
{
switch (st) {
case DMC_STEP_SETUP: return RGB(192, 0, 0);
case DMC_STEP_WORKING:
case DMC_STEP_ACTIVE: return RGB(0, 128, 0);
case DMC_STEP_OFF: return GetSysColor(COLOR_GRAYTEXT);
default: return GetSysColor(COLOR_HIGHLIGHT);
}
}
/* a step's mark in its ring: a Wingdings picture (as Windows 95 has
them), or the port's name */
static const char *mark(int kind, bool *wingdings)
{
*wingdings = true;
switch (kind) {
case DMC_KIND_TERMINAL: return ":"; /* a computer */
case DMC_KIND_SOFTMODEM:
case DMC_KIND_MODEM: return ";"; /* a box */
case DMC_KIND_SIP: return ")"; /* a telephone, ringed */
case DMC_KIND_SIP_ADDRESS: return "*"; /* an envelope */
case DMC_KIND_PHONE_NETWORK:
case DMC_KIND_PHONE_LINE: return "("; /* a telephone */
}
*wingdings = false;
switch (kind) {
case DMC_KIND_USB: return "USB";
case DMC_KIND_CODEC: return "ALSA";
case DMC_KIND_NETWORK: return "TCP";
default: return "COM";
}
}
static void line(HDC dc, int st, int x0, int x1, int y)
{
bool dashed = st == DMC_STEP_SETUP || st == DMC_STEP_OFF;
/* (Windows 9x dashes only one pixel wide pens) */
HPEN pen = CreatePen(dashed ? PS_DASH : PS_SOLID, dashed ? 1 : 2,
state_color(st));
HGDIOBJ old = SelectObject(dc, pen);
MoveToEx(dc, x0, y, NULL);
LineTo(dc, x1, y);
SelectObject(dc, old);
DeleteObject(pen);
}
static void text(HDC dc, HFONT f, COLORREF c, const char *utf8, RECT *r,
UINT how)
{
char a[512];
to_ansi(utf8, a, sizeof(a));
SelectObject(dc, f);
SetTextColor(dc, c);
DrawText(dc, a, -1, r, how | DT_NOPREFIX);
}
static void paint(HWND w)
{
PAINTSTRUCT ps;
HDC dc = BeginPaint(w, &ps);
RECT rc;
GetClientRect(w, &rc);
FillRect(dc, &rc, (HBRUSH)(COLOR_BTNFACE + 1));
SetBkMode(dc, TRANSPARENT);
HGDIOBJ oldf = SelectObject(dc, app.font);
TEXTMETRIC tm;
GetTextMetrics(dc, &tm);
int th = tm.tmHeight;
int n = dmc_path_steps(path), cw = (rc.right - 8) / n;
int r = 18, top = 4, cy = top + th + 4 + r;
COLORREF grey = GetSysColor(COLOR_GRAYTEXT),
ink = GetSysColor(COLOR_BTNTEXT);
for (int i = 0; i < n; i++) {
int x = 4 + cw * i, cx = x + cw / 2;
int st = dmc_path_state(path, i);
if (i > 0)
line(dc, dmc_path_link(path, i - 1), x, cx - r, cy);
if (i < n - 1)
line(dc, dmc_path_link(path, i), cx + r, x + cw, cy);
RECT t = { x, top, x + cw, top + th };
text(dc, app.font, grey, dmc_path_role(path, i), &t,
DT_CENTER | DT_SINGLELINE);
/* the ring, filled in a call */
HPEN pen = CreatePen(PS_SOLID, 2, state_color(st));
HBRUSH br = st == DMC_STEP_ACTIVE ?
CreateSolidBrush(RGB(214, 238, 214)) :
CreateSolidBrush(GetSysColor(COLOR_WINDOW));
HGDIOBJ op = SelectObject(dc, pen), ob = SelectObject(dc, br);
Ellipse(dc, cx - r, cy - r, cx + r + 1, cy + r + 1);
SelectObject(dc, op);
SelectObject(dc, ob);
DeleteObject(pen);
DeleteObject(br);
bool wd;
const char *m = mark(dmc_path_kind(path, i), &wd);
RECT g = { cx - r, cy - r, cx + r, cy + r };
SelectObject(dc, wd ? glyph_font : app.font);
SetTextColor(dc, state_color(st));
DrawText(dc, m, -1, &g, DT_CENTER | DT_VCENTER | DT_SINGLELINE |
DT_NOPREFIX);
RECT tt = { x, cy + r + 4, x + cw, cy + r + 4 + th };
text(dc, app.bold_font, ink, dmc_path_title(path, i), &tt,
DT_CENTER | DT_SINGLELINE);
RECT d = { x + 2, tt.bottom + 2, x + cw - 2, tt.bottom + 2 + 2 * th };
text(dc, app.font, st == DMC_STEP_SETUP ? state_color(st) : grey,
dmc_path_detail(path, i), &d,
DT_CENTER | DT_WORDBREAK | DT_END_ELLIPSIS);
}
RECT h = { 4, rc.bottom - th - 4, rc.right - 4, rc.bottom - 4 };
text(dc, app.font, dmc_path_needs_setup(path) ?
state_color(DMC_STEP_SETUP) : grey, dmc_path_headline(path), &h,
DT_CENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
SelectObject(dc, oldf);
EndPaint(w, &ps);
}
static LRESULT CALLBACK path_proc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg) {
case WM_PAINT:
paint(w);
return 0;
case WM_ERASEBKGND:
return 1;
case WM_SIZE:
InvalidateRect(w, NULL, FALSE);
return 0;
}
return DefWindowProc(w, msg, wp, lp);
}
HWND pathview_new(HWND parent)
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = path_proc;
wc.hInstance = app.inst;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = "DModemPath";
RegisterClass(&wc);
if (!glyph_font) {
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -20;
lf.lfCharSet = SYMBOL_CHARSET;
strcpy(lf.lfFaceName, "Wingdings");
glyph_font = CreateFontIndirect(&lf);
}
path = dmc_path_new();
view = CreateWindowEx(0, "DModemPath", "", WS_CHILD | WS_VISIBLE,
0, 0, 10, 10, parent, NULL, app.inst, NULL);
pathview_update();
return view;
}
int pathview_height()
{
HDC dc = GetDC(view);
HGDIOBJ old = SelectObject(dc, app.font);
TEXTMETRIC tm;
GetTextMetrics(dc, &tm);
SelectObject(dc, old);
ReleaseDC(view, dc);
/* the role, the ring, the title, two lines of what it is, the
headline */
return 4 + tm.tmHeight + 4 + 36 + 4 + tm.tmHeight + 2 +
2 * tm.tmHeight + 6 + tm.tmHeight + 4;
}
void pathview_update()
{
if (!path)
return;
const Config *c = &app.cfg;
int kind = DMC_LINE_SIP;
const char *where = "";
if (c->line == LINE_TCP) {
kind = DMC_LINE_TCP;
where = c->tcp;
} else if (c->line == LINE_COM) {
kind = DMC_LINE_COM;
where = c->com;
} else if (c->usb[0]) {
kind = DMC_LINE_USB;
where = c->usb;
}
dmc_path_set_line(path, kind, where, c->sip_anonymous, c->sip_user,
c->sip_server, c->listen);
int st = app.s ? dmc_state(app.s) : DMC_CLOSED;
dmc_path_set_live(path, link_running(), st,
st == DMC_ONLINE || st == DMC_ONLINE_COMMAND ?
dmc_connect_text(app.s) : "");
char a[512];
to_ansi(dmc_path_headline(path), a, sizeof(a));
SetWindowText(view, a); /* (for a screen reader) */
InvalidateRect(view, NULL, FALSE);
}
+12 -4
View File
@@ -161,6 +161,7 @@ void settings_state()
{
if (!page)
return;
pathview_update();
bool idle = dmc_state(app.s) == DMC_IDLE && model;
EnableWindow(GetDlgItem(page, IDC_CHANGE), idle);
EnableWindow(GetDlgItem(page, IDC_DEFAULTS), idle);
@@ -374,6 +375,9 @@ static LRESULT CALLBACK list_proc(HWND w, UINT m, WPARAM wp, LPARAM lp)
HWND settings_page_new(HWND parent)
{
page = page_new(parent, settings_command);
/* how a call is made, step by step: as set up when idle, as it is
in a call */
pathview_new(page);
make_child("LISTBOX", "", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY |
LBS_NOINTEGRALHEIGHT, page, IDC_GROUPS, WS_EX_CLIENTEDGE);
HWND lv = make_child(WC_LISTVIEW, "", WS_TABSTOP | LVS_REPORT |
@@ -410,11 +414,15 @@ HWND settings_page_new(HWND parent)
void settings_page_layout(HWND p, int w, int h)
{
int m = 8, bh = 24, gw = 130, bw = 90;
int listh = h - 4 * m - 2 * bh - 36;
MoveWindow(GetDlgItem(p, IDC_GROUPS), m, m, gw, listh, TRUE);
MoveWindow(GetDlgItem(p, IDC_SETTINGS), 2 * m + gw, m, w - 3 * m - gw,
int ph = pathview_height();
MoveWindow(FindWindowEx(p, NULL, "DModemPath", NULL), m, m,
w - 2 * m, ph, TRUE);
int top = m + ph + m;
int listh = h - top - 3 * m - 2 * bh - 36;
MoveWindow(GetDlgItem(p, IDC_GROUPS), m, top, gw, listh, TRUE);
MoveWindow(GetDlgItem(p, IDC_SETTINGS), 2 * m + gw, top, w - 3 * m - gw,
listh, TRUE);
int y = m + listh + m;
int y = top + listh + m;
MoveWindow(GetDlgItem(p, IDC_SETTING_HELP), m, y, w - 2 * m, 32, TRUE);
y += 36;
MoveWindow(GetDlgItem(p, IDC_CHANGE), m, y, bw, bh, TRUE);