ui: the math editor's window, identity row and canvas are a .ui file

The second half of this plan row, and the half of that dialog which is template.
src/ui/math-editor.ui holds the window (its size and modality), the box around it,
the identity row -- the name and the unit -- and the body with the canvas in it.

What stays in code is the drawing: the canvas is a GtkDrawingArea the file *declares*
and the code draws, with the gestures that make it a graph editor, and the parameter
form follows which node is selected. The palette and the buttons go next.

The builder is held on `App` and cleared on the *next* opening rather than with the
window: the window belongs to the builder's object list, so freeing the builder under a
live window frees the window with it. That is the source form's pattern, and the probe's
close-then-reopen path is what exercises it -- `reopened: dialog=ok, nodes=2`.

The identity row is read back too, since a `.ui` can hold the widget but not the value:
`dialog build: ... name='math3' unit='' ...`, the entries having been filled from the
channel being edited. check_ui is at 12 ok, 0 failed.
This commit is contained in:
Martino Ferrari committed 2026-10-12 15:57:43 +02:00
1 parent 90a17eb186
commit 1a02946656
7 files changed
+123 -36

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- SPDX-License-Identifier: MIT -->
<!-- SPDX-FileCopyrightText: 2026 Martino Ferrari -->
<!--
The math channel editor's window and its identity row: the name the channel is called, and the unit its
readouts carry.
The canvas below them is *declared* here but *drawn* by code (`GtkDrawingArea`), and the palette, the
parameter form and the buttons around it are code as well, because the form follows the selection: that is
the half of this dialog which is not template. The row here is the half that is.
The window's title is not here: it says which mode the editor is in ("Edit math channel" against "New math
channel"), which the code that opens it knows and a file cannot.
The name takes the slack and the unit does not: the name is also how another graph refers to this channel
as a source, so it is the one that should grow as the window does.
-->
<interface>
<object class="GtkWindow" id="math_window">
<property name="default-width">720</property>
<property name="default-height">420</property>
<property name="modal">1</property>
<child>
<object class="GtkBox" id="math_outer">
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<child>
<object class="GtkBox" id="math_head">
<property name="orientation">horizontal</property>
<property name="spacing">8</property>
<child>
<object class="GtkEntry" id="math_name">
<property name="placeholder-text" translatable="yes">name</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkEntry" id="math_unit">
<property name="placeholder-text" translatable="yes">unit (optional)</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="math_body">
<property name="orientation">horizontal</property>
<property name="spacing">10</property>
<child>
<object class="GtkDrawingArea" id="math_canvas">
<property name="width-request">420</property>
<property name="height-request">300</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</interface>
+1
View File
@@ -18,6 +18,7 @@
<file preprocess="xml-stripblanks">cursors-panel.ui</file>
<file preprocess="xml-stripblanks">measures-panel.ui</file>
<file preprocess="xml-stripblanks">math-panel.ui</file>
<file preprocess="xml-stripblanks">math-editor.ui</file>
<file preprocess="xml-stripblanks">trigger-panel.ui</file>
<file preprocess="xml-stripblanks">signals-panel.ui</file>
</gresource>