source: capability panels as side-stack pages, with a probe for the path
This commit is contained in:
1 parent
79c33b25c5
commit
5cee00aaee
6 files changed
+209
-3
No files matched your search
@@ -128,6 +128,34 @@ class ProbeKind final : public SourceKind {
|
||||
f.on_change = [cb](std::function<void()> fn) { *cb = std::move(fn); };
|
||||
return f;
|
||||
}
|
||||
|
||||
std::vector<SourcePanel> make_panels(DataSource& source) const override {
|
||||
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_widget_set_margin_top(box, 12);
|
||||
gtk_widget_set_margin_bottom(box, 12);
|
||||
gtk_widget_set_margin_start(box, 12);
|
||||
gtk_widget_set_margin_end(box, 12);
|
||||
GtkWidget* label = gtk_label_new("Test panel");
|
||||
gtk_widget_set_halign(label, GTK_ALIGN_START);
|
||||
gtk_box_append(GTK_BOX(box), label);
|
||||
// The probe finds the button as the box's last child. It reaches the source only through
|
||||
// `post()`: the command runs inside the next `poll()`, on the producer thread.
|
||||
GtkWidget* poke = gtk_button_new_with_label("Poke");
|
||||
gtk_box_append(GTK_BOX(box), poke);
|
||||
DataSource* src = &source;
|
||||
g_signal_connect_data(
|
||||
poke, "clicked",
|
||||
G_CALLBACK(+[](GtkButton*, gpointer user) {
|
||||
DataSource* s = static_cast<DataSource*>(user);
|
||||
s->post([s] { static_cast<ProbeSource*>(s)->note_applied(); });
|
||||
}),
|
||||
src, nullptr, static_cast<GConnectFlags>(0));
|
||||
SourcePanel p;
|
||||
p.id = "poke";
|
||||
p.title = "Probe";
|
||||
p.widget = box;
|
||||
return {p};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in new issue
Block a user