I think you should use either Gio::ActionMap::add_action_bool() or add_action_with_parameter()
instead of add_action(). add_action() creates an action without a parameter.
There are examples of add_action_bool() in
add_action_with_parameter(
"open",
Glib::VARIANT_TYPE_STRING, // or Glib::VariantType("s")
[this](const Glib::VariantBase & parameter)
{
// By cast:
// Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(parameter).get()
// By type condition:
// if (parameter.is_of_type(Glib::VARIANT_TYPE_STRING)) ..
}
);
In target widget:
signal_activate_link().connect(
[this](const Glib::ustring & URI) -> bool
{
// Open link URI
activate_action(
"win.open",
Glib::Variant<Glib::ustring>::create(
URI
)
);
return true;
},
false // after
);
It’s raw fragment that works, maybe I’ll update it as looks super strange.
GLib-CRITICAL **: 03:29:56.913: g_variant_type_is_subtype_of: assertion 'g_variant_type_check (type)' failed
GLib-CRITICAL **: 03:29:56.913: g_variant_get_type_string: assertion 'value != NULL' failed
GLib-ERROR **: 03:29:56.913: g_variant_new: expected GVariant of type '(bgav)' but received value has type '(null)'
Trace/breakpoint trap
Is it my mistake or bug?
Compiler say Glib::VARIANT_TYPE_ARRAY defined, the problem on application launch only