- Top-level Makefile builds both halves (designer + widgets CMake); .gitignore no longer ignores a hand-written top-level Makefile. - ./ide launcher: starts designer + XFrame palette + layout as separate top-level windows on one display (--build, --no-xframe). - widgets/ path fixes for the move: palette icon search candidates and ipc.h default now point at widgets/icons; test-driver, palette/ layout test, composite scripts derive paths from __file__; docgen scripts re-pointed at widgets/components + docs via REPO_ROOT; gen_registry tolerates a missing widgets README. - Seam: widgets/tools/layout_to_fdesigner.py converts a layout file (Name x y w h) to a .fdj project the designer opens: 136/194 XFrame widgets map to a real GTK counterpart (35 marked approximate), 58 (dialogs/choosers/menus/...) have none and are reported, never forced. widgets/tests/test_layout_to_fdesigner.py proves it end to end: convert -> real project_io load -> real generator (277 files) -> CMake build of the generated project -> app binary. Seam test: ALL PASS.
64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
// common/ipc.h — how the palette and layout windows share state.
|
|
// Palette -> layout: the palette writes the selected widget name to the
|
|
// selection file on every selection; the layout polls the file's mtime.
|
|
// Layout -> tests: the layout writes its full placed-widget state to the
|
|
// state file after every mutation, so the driver can verify bounds
|
|
// without guessing from pixels.
|
|
#pragma once
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
#include <sys/stat.h>
|
|
|
|
namespace cw {
|
|
|
|
inline std::string selection_path() {
|
|
const char* e = getenv("CWIDGETS_SELECTION");
|
|
if (e && *e) return e;
|
|
return "/tmp/cwidgets-selection.txt";
|
|
}
|
|
|
|
inline std::string layout_state_path() {
|
|
const char* e = getenv("CWIDGETS_LAYOUT_STATE");
|
|
if (e && *e) return e;
|
|
return "/tmp/cwidgets-layout-state.txt";
|
|
}
|
|
|
|
inline std::string icons_dir() {
|
|
const char* e = getenv("CWIDGETS_ICONS");
|
|
if (e && *e) return e;
|
|
return "/opt/cwidgets/widgets/icons";
|
|
}
|
|
|
|
inline bool write_selection(const std::string& name, int index) {
|
|
FILE* f = fopen(selection_path().c_str(), "w");
|
|
if (!f) return false;
|
|
fprintf(f, "%s\n%d\n", name.c_str(), index);
|
|
fclose(f);
|
|
return true;
|
|
}
|
|
|
|
inline bool read_selection(std::string& name, int& index) {
|
|
FILE* f = fopen(selection_path().c_str(), "r");
|
|
if (!f) return false;
|
|
char buf[256];
|
|
bool ok = false;
|
|
if (fgets(buf, sizeof(buf), f)) {
|
|
buf[strcspn(buf, "\r\n")] = 0;
|
|
name = buf;
|
|
ok = true;
|
|
}
|
|
index = -1;
|
|
if (fscanf(f, "%d", &index) != 1) index = -1;
|
|
fclose(f);
|
|
return ok;
|
|
}
|
|
|
|
inline long file_mtime(const std::string& path) {
|
|
struct stat st;
|
|
if (stat(path.c_str(), &st) != 0) return -1;
|
|
return (long)st.st_mtime * 1000000000L + (long)st.st_mtim.tv_nsec;
|
|
}
|
|
|
|
} // namespace cw
|