fix: row titles mean their mnemonics instead of drawing the underscore
Fifteen display strings in the two preference forms were written as GTK mnemonics -- `_Directory`, `_Server`, `Multicast _group`, `_Theme` and the rest -- but the property that makes GTK read them was never set, so GTK drew the underscore literally: `_Directory` in the row, not a D with a line under it. Two switches are involved, FALSE by default in each case. `GtkLabel`/`GtkButton` take `use-underline`; the rows take `AdwPreferencesRow:use-underline`, "whether an embedded underline in the title indicates a mnemonic". The two buttons in the source form already set it (so their mnemonics worked and showed no underscore); the thirteen rows did not. All thirteen now do. The row classes that carry the property are not all related -- AdwEntryRow has its own, while AdwSpinRow, AdwComboRow and AdwSwitchRow get it through AdwActionRow -- so the probe reads it by name on a GObject (g_object_class_find_property, then g_object_get) rather than casting to one row type; a cast to a `GtkWidget*` where the type is only forward-declared does not compile at all. `_Cancel` and `_Connect` both claimed C in the same form, so Alt+C could only reach one of them: that marker was unreachable, which is worse than absent because it is in the source to be trusted. `_Connect` becomes `Conn_ect`, freeing C for Cancel. [prefs-probe] reads the count (4/4) on the real widgets; check_ui validates the property against the GIR for every object in every .ui file, inherited properties included.
This commit is contained in:
1 parent
2d9f327da7
commit
f00d161900
8 files changed
+78
-1
No files matched your search
@@ -642,6 +642,13 @@ gboolean pick_probe(gpointer user) {
|
||||
gtk_editable_set_text(GTK_EDITABLE(c.form_note), "made by the new-host probe");
|
||||
adw_spin_row_set_value(c.form_buffer, 32);
|
||||
adw_switch_row_set_active(c.form_relative, TRUE);
|
||||
// 8/8: the form's row titles are mnemonics (`_Server`, `_Port`, `Multicast _group`, ...). The two
|
||||
// buttons already asked for it; the rows did not, and drew their underscores.
|
||||
std::fprintf(stderr, "[sources] form mnemonics=%d/8\n",
|
||||
(row_underlines(G_OBJECT(c.form_server)) + row_underlines(G_OBJECT(c.form_port)) +
|
||||
row_underlines(G_OBJECT(c.form_group)) + row_underlines(G_OBJECT(c.form_iface)) +
|
||||
row_underlines(G_OBJECT(c.form_name)) + row_underlines(G_OBJECT(c.form_note)) +
|
||||
row_underlines(G_OBJECT(c.form_buffer)) + row_underlines(G_OBJECT(c.form_relative))));
|
||||
std::fprintf(stderr,
|
||||
"[sources] form: name='%s' note='%s' buffer=%.6g relative=%d "
|
||||
"connect_sensitive=%d\n",
|
||||
|
||||
@@ -32,12 +32,14 @@
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="dir_row">
|
||||
<property name="title" translatable="yes">_Directory</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="tooltip-text" translatable="yes">One directory in which every source gets a folder of its own, never one directory between two sources</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwSpinRow" id="keep_row">
|
||||
<property name="title" translatable="yes">Keep _events</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="subtitle" translatable="yes">Per source; 0 keeps every event, which is a decision about the disk</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
@@ -62,12 +64,14 @@
|
||||
<child>
|
||||
<object class="AdwSwitchRow" id="relative_row">
|
||||
<property name="title" translatable="yes">_Relative time</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="subtitle" translatable="yes">Take the plot's time from the sample rate and the packet counter rather than from the stream's own clock, so arrival and clock jitter cannot move a sample; absolute time is still kept for export. Read at start-up, because the buffers are planned before any source is known.</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwComboRow" id="theme_row">
|
||||
<property name="title" translatable="yes">_Theme</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="subtitle" translatable="yes">What the interface looks like; auto follows the system</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -84,6 +88,7 @@
|
||||
<child>
|
||||
<object class="AdwButtonRow" id="reset_row">
|
||||
<property name="title" translatable="yes">_Reset to defaults</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="start-icon-name">view-refresh-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="form_apply">
|
||||
<property name="label" translatable="yes">_Connect</property>
|
||||
<property name="label" translatable="yes">Conn_ect</property>
|
||||
<property name="use-underline">1</property>
|
||||
<property name="receives-default">1</property>
|
||||
<property name="css-classes">suggested-action</property>
|
||||
@@ -59,11 +59,13 @@
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="server_row">
|
||||
<property name="title" translatable="yes">_Server</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwSpinRow" id="port_row">
|
||||
<property name="title" translatable="yes">_Port</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="lower">1</property>
|
||||
@@ -77,11 +79,13 @@
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="group_row">
|
||||
<property name="title" translatable="yes">Multicast _group</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="iface_row">
|
||||
<property name="title" translatable="yes">_Interface</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -93,16 +97,19 @@
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="name_row">
|
||||
<property name="title" translatable="yes">_Name</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="note_row">
|
||||
<property name="title" translatable="yes">N_ote</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwSpinRow" id="buffer_row">
|
||||
<property name="title" translatable="yes">_Buffer MB</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="subtitle" translatable="yes">sample buffer per source, applied when this source is opened</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
@@ -117,6 +124,7 @@
|
||||
<child>
|
||||
<object class="AdwSwitchRow" id="form_relative_row">
|
||||
<property name="title" translatable="yes">_Relative time</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="subtitle" translatable="yes">plot time from the packet counter and the declared rate, instead of the stream's own time signal</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <gtk4/gtk_plot_area.hpp>
|
||||
|
||||
#include "acquisition.hpp"
|
||||
@@ -33,6 +34,8 @@
|
||||
#include "status_text.hpp"
|
||||
#include "waveform.hpp"
|
||||
|
||||
|
||||
|
||||
#include <adwaita.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
@@ -29,6 +29,23 @@
|
||||
|
||||
#include "settings.hpp"
|
||||
|
||||
/// Whether a row asks for `use-underline` -- the property (default FALSE) that makes a `_` in a row's title
|
||||
/// a mnemonic. Without it GTK draws the underscore as a literal character, which is what `_Directory` and the
|
||||
/// other row titles did.
|
||||
///
|
||||
/// Asked for by *name* on a plain `GObject`: the row classes that carry the property are not all related
|
||||
/// (`AdwEntryRow`'s `use-underline` is its own, `AdwSpinRow`/`AdwComboRow`/`AdwSwitchRow`'s come through
|
||||
/// `AdwActionRow`), so a common getter or a cast to one row type would miss half of them -- and passing a
|
||||
/// row as a `GtkWidget*` where the type is only forward-declared does not even compile. A class without the
|
||||
/// property answers false rather than crashing.
|
||||
inline bool row_underlines(GObject* row) {
|
||||
if (row == nullptr) return false;
|
||||
if (g_object_class_find_property(G_OBJECT_GET_CLASS(row), "use-underline") == nullptr) return false;
|
||||
gboolean on = FALSE;
|
||||
g_object_get(row, "use-underline", &on, nullptr);
|
||||
return on != FALSE;
|
||||
}
|
||||
|
||||
namespace udpscope {
|
||||
namespace ui_impl {
|
||||
|
||||
|
||||
@@ -1696,6 +1696,12 @@ gboolean prefs_probe(gpointer user) {
|
||||
// the `.ui` -- the one mistake neither the build nor `GtkBuilder` sees is a missing id.
|
||||
const char* shown =
|
||||
a.prefs.dir_row != nullptr ? gtk_editable_get_text(GTK_EDITABLE(a.prefs.dir_row)) : "-";
|
||||
// 4/4: every row's title carries a mnemonic (`_Directory`, `Keep _events`, ...), so a row that does not
|
||||
// ask for `use-underline` draws the underscore instead of underlining the letter.
|
||||
std::fprintf(stderr, "[prefs-probe] mnemonics=%d/4\n",
|
||||
(row_underlines(G_OBJECT(a.prefs.dir_row)) + row_underlines(G_OBJECT(a.prefs.keep_row)) +
|
||||
row_underlines(G_OBJECT(a.prefs.relative_row)) +
|
||||
row_underlines(G_OBJECT(a.prefs.theme_row))));
|
||||
std::fprintf(stderr, "[prefs-probe] opened=%d rows=%d dir=%s store=%s\n",
|
||||
a.prefs.dialog != nullptr ? 1 : 0, a.prefs.dir_row != nullptr ? 1 : 0,
|
||||
a.prefs.dir_row != nullptr ? shown : "-",
|
||||
|
||||
Reference in new issue
Block a user