Feature/source plugins #1

Merged
martino merged 130 commits from feature/source-plugins into main 2026-11-04 07:35:21 +01:00
Showing only changes of commit 79c33b25c5 - Show all commits
+15 -1
View File
@@ -470,7 +470,7 @@ void form_rebuild(Chooser& c, SourceKind& kind, const SourceConfig& initial) {
c.form_cfg.description.empty() ? nullptr : c.form_cfg.description.c_str()); c.form_cfg.description.empty() ? nullptr : c.form_cfg.description.c_str());
c.form_cfg.write(initial); c.form_cfg.write(initial);
c.form_cfg.on_change([&c] { c.form_cfg.on_change([&c] {
if (c.form_connect != nullptr) { if (c.form_connect != nullptr && c.form_cfg.valid) {
gtk_widget_set_sensitive(c.form_connect, c.form_cfg.valid() ? TRUE : FALSE); gtk_widget_set_sensitive(c.form_connect, c.form_cfg.valid() ? TRUE : FALSE);
} }
}); });
@@ -570,6 +570,18 @@ void open_form(Chooser& c, int edit_index = -1) {
edit_index >= 0 && static_cast<std::size_t>(edit_index) < c.known.size() edit_index >= 0 && static_cast<std::size_t>(edit_index) < c.known.size()
? &c.known[static_cast<std::size_t>(edit_index)] ? &c.known[static_cast<std::size_t>(edit_index)]
: nullptr; : nullptr;
// An edit of a session whose kind is not registered is refused: the form would rebuild as the first
// kind, and Save would rewrite the file as that kind and delete the original.
if (src != nullptr && !src->kind.empty()) {
bool known_kind = false;
for (SourceKind* k : kinds()) known_kind = known_kind || k->id() == src->kind;
if (!known_kind) {
std::fprintf(stderr, "[sources] cannot edit %s: source kind '%s' is not registered\n",
src->config.c_str(), src->kind.c_str());
std::fflush(stderr);
return;
}
}
c.edit_host = src != nullptr ? src->host : std::string(); c.edit_host = src != nullptr ? src->host : std::string();
c.edit_port = src != nullptr ? src->port : 0; c.edit_port = src != nullptr ? src->port : 0;
c.edit_config = src != nullptr ? src->config : std::string(); c.edit_config = src != nullptr ? src->config : std::string();
@@ -668,6 +680,8 @@ void open_form(Chooser& c, int edit_index = -1) {
ch.form_cfg_rows.clear(); ch.form_cfg_rows.clear();
ch.form_kind_row = nullptr; ch.form_kind_row = nullptr;
ch.form_source_group = nullptr; ch.form_source_group = nullptr;
ch.form_connect = nullptr;
ch.form_kinds.clear();
}), }),
&c); &c);