Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 28, 2024
2 parents dad11d2 + bf276f7 commit e7c7745
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 9 deletions.
2 changes: 1 addition & 1 deletion data/pantheon.portal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[portal]
DBusName=org.freedesktop.impl.portal.desktop.pantheon
Interfaces=org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Background;org.freedesktop.impl.portal.Screenshot;
Interfaces=org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.AppChooser;org.freedesktop.impl.portal.Background;org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.Wallpaper
UseIn=pantheon
1 change: 1 addition & 0 deletions po/LINGUAS
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ aa
ab
gn
an
id_ID
1 change: 1 addition & 0 deletions po/extra/LINGUAS
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ aa
ab
gn
an
id_ID
73 changes: 73 additions & 0 deletions po/extra/id_ID.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the extra package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: extra\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 16:20+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: id_ID\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: data/portals.metainfo.xml.in:10
msgid "Portals"
msgstr ""

#: data/portals.metainfo.xml.in:11
msgid "Access system features in a secure way"
msgstr ""

#: data/portals.metainfo.xml.in:13
msgid ""
"Portals provide APIs to secure apps which enable them to access system "
"features while requiring informed consent."
msgstr ""

#: data/portals.metainfo.xml.in:22
msgid "elementary, Inc."
msgstr ""

#: data/portals.metainfo.xml.in:29 data/portals.metainfo.xml.in:41
#: data/portals.metainfo.xml.in:54 data/portals.metainfo.xml.in:64
msgid "New Features:"
msgstr ""

#: data/portals.metainfo.xml.in:31 data/portals.metainfo.xml.in:43
#: data/portals.metainfo.xml.in:57
msgid "Updated translations"
msgstr ""

#: data/portals.metainfo.xml.in:56
msgid "Support dialog parenting on wayland"
msgstr ""

#: data/portals.metainfo.xml.in:66
msgid "Add a destructive action option for access portals"
msgstr ""

#: data/portals.metainfo.xml.in:68 data/portals.metainfo.xml.in:79
msgid "Fixes:"
msgstr ""

#: data/portals.metainfo.xml.in:70
msgid "Fix a crash when opening apps in the AppChooser portal"
msgstr ""

#: data/portals.metainfo.xml.in:71
msgid "Fix window focus and position for Access portals with no parent window"
msgstr ""

#: data/portals.metainfo.xml.in:72
msgid "Set AppChooser portal as a modal dialog for proper animations"
msgstr ""

#: data/portals.metainfo.xml.in:81
msgid "Prevent delay after logging in"
msgstr ""
78 changes: 78 additions & 0 deletions po/id_ID.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the xdg-desktop-portal-pantheon package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: xdg-desktop-portal-pantheon\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 16:20+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: id_ID\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/Access/Dialog.vala:63
msgid "Deny Access"
msgstr ""

#: src/Access/Dialog.vala:64
msgid "Grant Access"
msgstr ""

#: src/AppChooser/Dialog.vala:51
msgid "Open file with…"
msgstr ""

#: src/AppChooser/Dialog.vala:53
#, c-format
msgid "Open “%s” with…"
msgstr ""

#: src/AppChooser/Dialog.vala:72
#, c-format
msgid "An application requested to open a %s."
msgstr ""

#: src/AppChooser/Dialog.vala:74
#, c-format
msgid "“%s” requested to open a %s."
msgstr ""

#: src/AppChooser/Dialog.vala:104
#, c-format
msgid "No installed apps can open %s"
msgstr ""

#: src/AppChooser/Dialog.vala:105
msgid "New apps can be installed from AppCenter"
msgstr ""

#: src/AppChooser/Dialog.vala:124
msgid "Cancel"
msgstr ""

#: src/AppChooser/Dialog.vala:126
msgid "Open"
msgstr ""

#: src/Background/NotificationRequest.vala:102
msgid "Allow"
msgstr ""

#: src/Background/NotificationRequest.vala:104
msgid "Forbid"
msgstr ""

#: src/Background/NotificationRequest.vala:113
msgid "Background activity"
msgstr ""

#: src/Background/NotificationRequest.vala:114
#, c-format
msgid "“%s” is running in the background without appropriate permission"
msgstr ""
8 changes: 4 additions & 4 deletions po/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: xdg-desktop-portal-pantheon\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 16:20+0000\n"
"PO-Revision-Date: 2023-07-23 07:07+0000\n"
"PO-Revision-Date: 2024-01-09 00:11+0000\n"
"Last-Translator: Ryo Nakano <[email protected]>\n"
"Language-Team: Japanese <https://l10n.elementary.io/projects/desktop/portals/"
"ja/>\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 4.17\n"
"X-Generator: Weblate 5.0.2\n"

#: src/Access/Dialog.vala:63
msgid "Deny Access"
Expand Down Expand Up @@ -73,9 +73,9 @@ msgstr "拒否"

#: src/Background/NotificationRequest.vala:113
msgid "Background activity"
msgstr "バックグラウンドでのアクティビティー"
msgstr "バックグラウンドでのアクティビティ"

#: src/Background/NotificationRequest.vala:114
#, c-format
msgid "“%s” is running in the background without appropriate permission"
msgstr "“%s” は適切な許可なしにバックグラウンドで動作しています"
msgstr "“%s” は適切な許可なくバックグラウンドで動作しています"
11 changes: 7 additions & 4 deletions po/uz.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ msgstr ""
"Project-Id-Version: xdg-desktop-portal-pantheon\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 16:20+0000\n"
"PO-Revision-Date: 2021-10-20 14:02-0700\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"PO-Revision-Date: 2024-02-22 04:12+0000\n"
"Last-Translator: Shukrullo Turgunov <[email protected]>\n"
"Language-Team: Uzbek <https://l10n.elementary.io/projects/desktop/portals/uz/"
">\n"
"Language: uz\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.0.2\n"

#: src/Access/Dialog.vala:63
msgid "Deny Access"
Expand Down Expand Up @@ -54,7 +57,7 @@ msgstr ""

#: src/AppChooser/Dialog.vala:124
msgid "Cancel"
msgstr ""
msgstr "Bekor qilish"

#: src/AppChooser/Dialog.vala:126
msgid "Open"
Expand Down
126 changes: 126 additions & 0 deletions src/Wallpaper/Portal.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* SPDX-FileCopyrigthText: 2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: LGPL-2.1-or-later
*/

[DBus (name = "org.freedesktop.impl.portal.Wallpaper")]
public class Wallpaper.Portal : Object {
private DBusConnection connection;

public Portal (DBusConnection connection) {
this.connection = connection;
}

[DBus (name = "SetWallpaperURI")]
public async uint set_wallpaper_uri (
ObjectPath handle,
string app_id,
string parent_window,
string uri,
HashTable<string, Variant> options
) throws DBusError, IOError {
unowned string set_on = "both"; // Possible values are background, lockscreen or both.
unowned bool show_preview = false; // FIXME: implement preview dialog

unowned var _set_on = options.get ("set-on");
if (_set_on.is_of_type (GLib.VariantType.STRING)) {
set_on = _set_on.get_string ();
}

unowned var _show_preview = options.get ("show-preview");
if (_show_preview.is_of_type (GLib.VariantType.BOOLEAN)) {
show_preview = _show_preview.get_boolean ();
}

// Currently only support Both
if (set_on == "background" || set_on == "lockscreen") {
return 1;
}

var file = File.new_for_uri (uri);
if (!get_is_file_in_bg_dir (file)) {
file = copy_for_library (file);
}

if (file != null) {
var settings = new Settings ("org.gnome.desktop.background");
settings.set_string ("picture-uri", file.get_uri ());
}

return 0;
}

private static bool get_is_file_in_bg_dir (File file) {
string path = file.get_path ();

foreach (unowned string directory in get_bg_directories ()) {
if (path.has_prefix (directory)) {
return true;
}
}

return false;
}

private static File? copy_for_library (File source) {
File? dest = null;

try {
var timestamp = new DateTime.now_local ().format ("%Y-%m-%d-%H-%M-%S");
var filename = "%s-%s".printf (timestamp, source.get_basename ());
dest = ensure_local_bg_exists ().get_child (filename);
source.copy (dest, FileCopyFlags.OVERWRITE | FileCopyFlags.ALL_METADATA);
} catch (Error e) {
warning (e.message);
}

return dest;
}

private static string[] get_bg_directories () {
string[] background_directories = {};

// Add user background directory first
background_directories += get_local_bg_directory ();

foreach (var bg_dir in get_system_bg_directories ()) {
background_directories += bg_dir;
}

if (background_directories.length == 0) {
warning ("No background directories found");
}

return background_directories;
}

private static File ensure_local_bg_exists () {
var folder = File.new_for_path (get_local_bg_directory ());
if (!folder.query_exists ()) {
try {
folder.make_directory_with_parents ();
} catch (Error e) {
warning (e.message);
}
}

return folder;
}

private static string get_local_bg_directory () {
return Path.build_filename (Environment.get_user_data_dir (), "backgrounds") + "/";
}

private static string[] get_system_bg_directories () {
string[] directories = {};
foreach (unowned string data_dir in Environment.get_system_data_dirs ()) {
var system_background_dir = Path.build_filename (data_dir, "backgrounds") + "/";
if (FileUtils.test (system_background_dir, FileTest.EXISTS)) {
debug ("Found system background directory: %s", system_background_dir);
directories += system_background_dir;
}
}

return directories;
}
}
3 changes: 3 additions & 0 deletions src/XdgDesktopPortalPantheon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ private void on_bus_acquired (DBusConnection connection, string name) {

connection.register_object ("/org/freedesktop/portal/desktop", new Screenshot.Portal (connection));
debug ("Screenshot Portal registered!");

connection.register_object ("/org/freedesktop/portal/desktop", new Wallpaper.Portal (connection));
debug ("Wallpaper Portal registered!");
} catch (Error e) {
critical ("Unable to register the object: %s", e.message);
}
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ executable(
'Screenshot/ApprovalDialog.vala',
'Screenshot/Portal.vala',
'Screenshot/SetupDialog.vala',
'Wallpaper/Portal.vala',
configure_file(input: 'Config.vala.in', output: '@BASENAME@', configuration: conf_data),
'ExternalWindow.vala',
'XdgDesktopPortalPantheon.vala',
Expand Down

0 comments on commit e7c7745

Please sign in to comment.