feat: the cursors panel is a UI file
src/ui/cursors-panel.ui holds the panel's shape -- the header with the mode dropdown and the reset button, and the grid the two cursor times are read in. What is not in it is the grid's contents, which follow the cursor mode and the rows and are rebuilt whenever either changes. Panels need a builder that outlives them, unlike the dialogs, which are rebuilt on every opening: a widget belongs to the builder that built it, so App::ui_builders holds each panel's for the life of the window. ui_load() is that, in ui_widgets.cpp. make test-ui also checks that udpscope-ui.gresource.xml lists every .ui file now. That was the third trap of this refactor -- a file on disk but not in the resource is a Gtk-ERROR at load, which aborts -- and it is a compile-time mistake that nothing else in the build could see. Verified by unlisting the new file and watching the check fail, then restoring it. [cursors-probe] reads as it did: all four modes, pane=1, the timings and the drag cases.
This commit is contained in:
1 parent
7a982da6c4
commit
ed82abd405
8 files changed
+118
-25
No files matched your search
@@ -12,6 +12,22 @@
|
||||
namespace udpscope {
|
||||
namespace ui_impl {
|
||||
|
||||
/// Loads one UI file and keeps its builder for the life of the window.
|
||||
///
|
||||
/// A widget belongs to the builder that built it -- drop the builder and the widgets it made go with
|
||||
/// it -- so the panels' builders are kept in `App` beside the widgets they built. Unlike the dialogs
|
||||
/// (`prefs_open()`, `show_help()`), a panel is built once and lives as long as the window, so these are
|
||||
/// appended and never replaced.
|
||||
///
|
||||
/// A resource that is not in the GResource aborts here rather than returning null: `GtkBuilder` reports
|
||||
/// a missing resource with a `Gtk-ERROR`, which is fatal. `make test-ui` checks that the xml lists every
|
||||
/// `.ui` file, which is the only way to make that a build-time failure instead.
|
||||
GtkBuilder* ui_load(App& app, const char* resource) {
|
||||
GtkBuilder* builder = gtk_builder_new_from_resource(resource);
|
||||
app.ui_builders.push_back(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// Installs the one style rule the app needs: a signal row that is as short as its
|
||||
/// contents.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user