Skip to content

Commit

Permalink
Update libportal usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmardojai committed Mar 20, 2024
1 parent 86ab315 commit e007ac9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can clone and run from GNOME Builder.
- libadwaita (>= 1.5.0) `libadwaita`
- libsoup (>= 3.0) `libsoup`
- libsecret (>= 0.20) `libsecret`
- libportal (>= 0.6) `libportal`
- libportal (>= 0.7) `libportal`
- Meson `meson`
- Ninja `ninja`

Expand Down
6 changes: 3 additions & 3 deletions com.mardojai.ForgeSparksDevel.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
"config-opts": [
"-Ddocs=false",
"-Dvapi=false",
"-Dbackends=gtk4"
"-Dbackend-gtk4=enabled"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/flatpak/libportal/releases/download/0.6/libportal-0.6.tar.xz",
"sha256": "88a12c3ba71bc31acff7238c280de697d609cebc50830c3766776ec35abc6566"
"url": "https://github.com/flatpak/libportal/releases/download/0.7.1/libportal-0.7.1.tar.xz",
"sha256": "297b90b263fad22190a26b8c7e8ea938fe6b18fb936265e588927179920d3805"
}
]
},
Expand Down
36 changes: 3 additions & 33 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,9 @@ export function requestBackground(window, autostart=false, hidden=false) {
* @param {String} message
*/
export function setBackgroundStatus(message=_('Monitoring new notifications')) {
if (typeof portal.set_background_status === 'function') {
portal.set_background_status(message, null, (portal, result) => {
portal.set_background_status_finish(result);
});
} else {
/* Call the portal using DBus */
const connection = Gio.DBus.session;
const messageVariant = new GLib.Variant('(a{sv})', [{
'message': new GLib.Variant('s', message)
}]);

connection.call(
'org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop',
'org.freedesktop.portal.Background',
'SetStatus',
messageVariant,
null,
Gio.DBusCallFlags.NONE,
-1,
null,
(connection, res) => {
try {
connection.call_finish(res);
} catch (e) {
if (e instanceof Gio.DBusError)
Gio.DBusError.strip_remote_error(e);

console.error(e);
}
}
);
}
portal.set_background_status(message, null, (portal, result) => {
portal.set_background_status_finish(result);
});
}

/**
Expand Down

0 comments on commit e007ac9

Please sign in to comment.