diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-04-10 15:07:27 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-04-10 15:07:27 +0200 |
commit | 2f7fd6adc286008a8c1f3b6cb7b63f3540d0e2e0 (patch) | |
tree | eac0bbdb792ced73207004b9c71c699dfc302ce7 /src/DesktopIntegration.vala | |
parent | 10fbc2942e6833ed36bd4ea663a33f52f3a35d03 (diff) | |
parent | bb9797c14470641b082ebf635e2ae3cfd5f27a3b (diff) |
Update upstream source from tag 'upstream/0.30.18'
Update to upstream version '0.30.18'
with Debian dir d1ea682c56714cd4c2a932161997cb833722fcb9
Diffstat (limited to 'src/DesktopIntegration.vala')
-rw-r--r-- | src/DesktopIntegration.vala | 72 |
1 files changed, 27 insertions, 45 deletions
diff --git a/src/DesktopIntegration.vala b/src/DesktopIntegration.vala index 024bc8b..68d1ec6 100644 --- a/src/DesktopIntegration.vala +++ b/src/DesktopIntegration.vala @@ -21,12 +21,6 @@ private bool set_screensaver = false; public void init() { if (init_count++ != 0) return; - try{ - Portal.get_instance(); - send_to_installed = true; - } catch (Error error) { - send_to_installed = false; - } } public void terminate() { @@ -93,45 +87,31 @@ public string? get_app_open_command(AppInfo app_info) { } public bool is_send_to_installed() { - // FIXME: Check if portal is available - return send_to_installed; + return true; } public async void files_send_to(File[] files) { if (files.length == 0) return; - + var parent = Xdp.parent_new_gtk(AppWindow.get_instance()); + var file_names = new StringBuilder(); - var files_builder = new VariantBuilder (new VariantType ("ah")); - var file_descriptors = new UnixFDList (); + var file_paths = new string[files.length]; for (int i=0; i<files.length; i++){ - var fd = Posix.open (files[i].get_path (), Posix.O_RDONLY | Posix.O_CLOEXEC); - if (fd == -1) { - warning ("Send to: cannot open file: '%s'", files[i].get_path ()); - continue; - } - try { - files_builder.add ("h", file_descriptors.append (fd)); - } catch (Error e) { - warning ("Send to: cannot append file %s to file descriptor list: %s", - files[i].get_path(), e.message); - } file_names.append(files[i].get_basename()); if(i<files.length-1){ file_names.append(", "); } + file_paths[i] = files[i].get_path(); } - var options = new HashTable<string, Variant> (str_hash, str_equal); - options.insert ("subject", _("Send files per Mail: ") + file_names.str); - options.insert ("attachment_fds", files_builder.end()); - options.insert ("addresses", new Variant ("as", null)); AppWindow.get_instance().set_busy_cursor(); try{ - var response = yield Portal.get_instance().compose_email (options, file_descriptors); - if (response == null){ - throw new DBusError.FAILED("Did not get response"); - } + var portal = new Xdp.Portal(); + + // Use empty list for addresses instead of null to word around bug in xdg-desktop-portal-gtk + yield portal.compose_email(parent, {null}, null, null, + _("Send files per Mail: ") + file_names.str, null, file_paths, Xdp.EmailFlags.NONE, null); } catch (Error e){ AppWindow.error_message(_("Unable to send file %s, %s").printf( file_names.str, e.message)); @@ -193,14 +173,15 @@ public void set_background(Photo photo, bool desktop, bool screensaver) { return; } - - if (desktop) { - Config.Facade.get_instance().set_desktop_background(save_as.get_path()); - } - if (screensaver) { - Config.Facade.get_instance().set_screensaver(save_as.get_path()); - } - + + var parent = Xdp.parent_new_gtk(AppWindow.get_instance()); + var portal = new Xdp.Portal(); + Xdp.WallpaperFlags flags = Xdp.WallpaperFlags.PREVIEW; + if (desktop) flags |= Xdp.WallpaperFlags.BACKGROUND; + if (screensaver) flags |= Xdp.WallpaperFlags.LOCKSCREEN; + + portal.set_wallpaper.begin(parent, save_as.get_uri(), flags, null); + GLib.FileUtils.chmod(save_as.get_parse_name(), 0644); } @@ -226,7 +207,7 @@ private class BackgroundSlideshowXMLBuilder { public void open() throws Error { outs = new DataOutputStream(tmp_file.replace(null, false, FileCreateFlags.NONE, null)); - outs.put_string("<background>\n"); + outs.put_string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<background>\n"); } private void write_transition(File from, File to) throws Error { @@ -331,12 +312,13 @@ private void on_desktop_slideshow_exported(Exporter exporter, bool is_cancelled) return; } - if (set_desktop_background) { - Config.Facade.get_instance().set_desktop_background(xml_file.get_path()); - } - if (set_screensaver) { - Config.Facade.get_instance().set_screensaver(xml_file.get_path()); - } + var parent = Xdp.parent_new_gtk(AppWindow.get_instance()); + var portal = new Xdp.Portal(); + Xdp.WallpaperFlags flags = Xdp.WallpaperFlags.PREVIEW; + if (set_desktop_background) flags |= Xdp.WallpaperFlags.BACKGROUND; + if (set_screensaver) flags |= Xdp.WallpaperFlags.LOCKSCREEN; + + portal.set_wallpaper.begin(parent, xml_file.get_uri(), flags, null); } } |