Workbench
Workbench copied to clipboard
Allow using actions in the external preview
When using Vala, the code and preview runs in a separate process.
So far, we were unable to use actions there so we had to disable/downgrade demos for Vala. See
- https://github.com/sonnyp/Workbench/pull/101/commits/2df37308f602f93ae2d2a7a73da369922a45a362
- https://github.com/sonnyp/Workbench/pull/101/commits/145f37cd6e1277019692de0358886d5976259da4
This ticket is about enabling the usage of actions in library entries when using Vala.
See the previous description below and comments for an analysis of the issue.
Since then, the architecture changed a little bit and the external process isn't a GApplication anymore. Instead Workench and the external process communicate via a direct dbus connection instead of via the session bus.
See https://github.com/sonnyp/Workbench/pull/184/files#diff-24cdf4b8c7c2fbd1c6b43e8b7bcc877d14cae496dd01e82eb212b6d5b4c68d59
Please note that Flatpak apps cannot have multiple dbus targets. https://github.com/flatpak/flatpak/issues/1902
Todo
- [ ] Permit usage of
GActionsin Vala examples - [ ] Upgrade Vala examples to use
GActionslike the js ones- [ ] Toasts
- [ ] Notifications
Some ideas:
- Proxy/relay all dbus stuff somehow through the Workbench process
- custom WorkbenchApplication object, that delegates stuff over dbus to the workbench ui. Also stuff like application.quit() could be handled safely then. (by @lw64 )
- Start the vala/previewer process outside the sandbox (probably no)
- Do not use actions at all in Workbench demos (probably no)
Doing some investigation.
Both applications are registered

but when running the Vala desktop notification demo:
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1
public void main () {
var application = workbench.application as GLib.Application;
// this is required now for some reason?
application.register(null);
var notification = new Notification ("Lunch is ready");
notification.set_body (
"Today we have pancakes and salad, and fruit and cake for dessert"
);
notification.set_default_action ("app.notification-reply");
notification.add_button ("Accept", "app.notification-accept");
notification.add_button ("Decline", "app.notification-decline");
var icon = new ThemedIcon ("object-rotate-right-symbolic");
notification.set_icon (icon);
var simple_button = workbench.builder.get_object ("button_simple") as Gtk.Button;
simple_button.clicked.connect (() => {
application.send_notification ("lunch-is-ready", notification);
});
var action_reply = new SimpleAction ("notification-reply", null);
action_reply.activate.connect (() => {
stdout.printf ("Reply");
});
application.add_action (action_reply);
var action_accept = new SimpleAction ("notification-accept", null);
action_accept.activate.connect (() => {
stdout.printf ("Accept");
});
application.add_action (action_accept);
var action_decline = new SimpleAction ("notification-decline", null);
action_decline.activate.connect (() => {
stdout.printf ("Decline");
});
application.add_action (action_decline);
}
the notification shows but clicking on an action Accept or Decline appears to communicate with /re/sonny/Workbench instead of /re/sonny/Workbench/vala_previewer.

Actions are registered properly on /re/sonny/Workbench/vala_preview
