diff --git a/src/ui.cpp b/src/ui.cpp index 6684c9e..fd566c4 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -2186,8 +2186,17 @@ void open_math_dialog(App& app, int edit) { gtk_box_append(GTK_BOX(form), buttons); gtk_box_append(GTK_BOX(body), form); // the form is the body's second child; the canvas is the file's - GtkWidget* actions = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); - GtkWidget* cancel = gtk_button_new_with_label("Cancel"); + // The action row is the file's; what is code is what the buttons *do*, and what the second one says: + // "Save" edits an existing channel and "Add" makes a new one, which the file cannot know. + GtkWidget* actions = GTK_WIDGET(gtk_builder_get_object(ui, "math_actions")); + GtkWidget* cancel = GTK_WIDGET(gtk_builder_get_object(ui, "math_cancel")); + GtkWidget* apply = GTK_WIDGET(gtk_builder_get_object(ui, "math_apply")); + if (actions == nullptr || cancel == nullptr || apply == nullptr) { + std::fprintf(stderr, "[math] editor: math-editor.ui is missing its action row\n"); + delete d; + return; + } + gtk_button_set_label(GTK_BUTTON(apply), edit >= 0 ? "Save" : "Add"); // Named so the headless probe can click the *button* rather than call its handler: the defect // this guards was in the connection, which a direct call cannot see. g_object_set_data(G_OBJECT(window), "udpscope-math-cancel", cancel); @@ -2196,13 +2205,7 @@ void open_math_dialog(App& app, int edit) { // later open then took the "already open" branch and presented it -- "I cannot edit a math // channel again". The same trap the other three windows in this file document. g_signal_connect_swapped(cancel, "clicked", G_CALLBACK(gtk_window_close), window); - GtkWidget* apply = gtk_button_new_with_label(edit >= 0 ? "Save" : "Add"); - gtk_widget_add_css_class(apply, "suggested-action"); g_signal_connect(apply, "clicked", G_CALLBACK(on_math_apply), d); - gtk_widget_set_halign(actions, GTK_ALIGN_END); - gtk_box_append(GTK_BOX(actions), cancel); - gtk_box_append(GTK_BOX(actions), apply); - gtk_box_append(GTK_BOX(outer), actions); app.math_dialog = window; d->apply = apply; diff --git a/src/ui/math-editor.ui b/src/ui/math-editor.ui index 32984f3..a74db9d 100644 --- a/src/ui/math-editor.ui +++ b/src/ui/math-editor.ui @@ -5,9 +5,10 @@ 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 canvas below them is *declared* here but *drawn* by code (`GtkDrawingArea`); the parameter form beside + it and the palette are code as well, because the form follows which node is selected and the palette is the + operation table itself — neither is data a file should hold. What is here is the frame: the window, the + identity row, the body with the canvas in it, and the two buttons that end the dialog. 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. @@ -61,5 +62,23 @@ + + + horizontal + 6 + end + + + Cancel + + + + + Add + suggested-action + + + +