Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8de3874
commit e74f337
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Gtk 4.0; | ||
using Adw 1; | ||
|
||
Adw.StatusPage { | ||
title: _("Wallpaper"); | ||
description: _("Request to set the user desktop background image"); | ||
margin-top: 48; | ||
|
||
Box { | ||
orientation: vertical; | ||
halign: center; | ||
|
||
Button button { | ||
label: _("Set Wallpaper"); | ||
margin-bottom: 42; | ||
halign: center; | ||
styles ["suggested-action", "pill"] | ||
} | ||
|
||
LinkButton { | ||
label: "API Reference"; | ||
uri: "https://libportal.org/method.Portal.set_wallpaper.html"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Gio from "gi://Gio"; | ||
import Xdp from "gi://Xdp"; | ||
import XdpGtk from "gi://XdpGtk4"; | ||
|
||
const portal = new Xdp.Portal(); | ||
const parent = XdpGtk.parent_new_gtk(workbench.window); | ||
const button = workbench.builder.get_object("button"); | ||
|
||
const file = Gio.File.new_for_path(pkg.pkgdatadir).resolve_relative_path( | ||
"Library/demos/Wallpaper/wallpaper.png", | ||
); | ||
|
||
Gio._promisify(Xdp.Portal.prototype, "set_wallpaper", "set_wallpaper_finish"); | ||
|
||
async function onClicked() { | ||
const success = await portal.set_wallpaper( | ||
parent, | ||
file.get_uri(), | ||
Xdp.WallpaperFlags.PREVIEW | | ||
Xdp.WallpaperFlags.BACKGROUND | | ||
Xdp.WallpaperFlags.LOCKSCREEN, | ||
null, | ||
); | ||
|
||
if (success) { | ||
console.log("Wallpaper set successfully"); | ||
} else { | ||
console.log("Could not set wallpaper"); | ||
} | ||
} | ||
|
||
button.connect("clicked", () => { | ||
onClicked().catch(logError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "Wallpaper", | ||
"category": "platform", | ||
"description": "Request to set the user desktop background image", | ||
"panels": ["code", "preview"], | ||
"autorun": true | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters