diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-04-10 15:07:19 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-04-10 15:07:19 +0200 |
commit | bb9797c14470641b082ebf635e2ae3cfd5f27a3b (patch) | |
tree | 9c3fbc5053ab21c1bda82b4d0f561711d8d4ee00 /src | |
parent | bb0e1e40d2de6b093b564f4f2cd0c44aa32380b8 (diff) |
New upstream version 0.30.18upstream/0.30.18
Diffstat (limited to 'src')
-rw-r--r-- | src/DesktopIntegration.vala | 72 | ||||
-rw-r--r-- | src/Portal.vala | 71 | ||||
-rw-r--r-- | src/editing_tools/EditingTools.vala | 2 | ||||
-rw-r--r-- | src/meson.build | 3 |
4 files changed, 29 insertions, 119 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); } } diff --git a/src/Portal.vala b/src/Portal.vala deleted file mode 100644 index c2e8e1e..0000000 --- a/src/Portal.vala +++ /dev/null @@ -1,71 +0,0 @@ -[DBus (name="org.freedesktop.portal.Email")] -private interface PortalEmail : DBusProxy { - [DBus (name = "version")] - public abstract uint version { get; } -} - -public class Portal : GLib.Object { - private static Portal portal; - public static Portal get_instance () { - if (portal == null){ - portal = new Portal (); - } - return portal; - } - - private const string BUS_NAME = "org.freedesktop.portal.Desktop"; - private const string OBJECT_PATH = "/org/freedesktop/portal/desktop"; - - private GLib.DBusConnection bus; - - public async Variant compose_email (HashTable<string, Variant> options, - UnixFDList attachments) throws Error{ - if (bus == null){ - bus = yield Bus.get(BusType.SESSION); - } - - options.insert ("handle_token", Portal.generate_handle()); - - var options_builder = new VariantBuilder (VariantType.VARDICT); - options.foreach ((key, val) => { - options_builder.add ("{sv}", key, val); - }); - - PortalEmail? email = yield bus.get_proxy(BUS_NAME, OBJECT_PATH); - - var response = email.call_with_unix_fd_list_sync ( - "ComposeEmail", - new Variant ("(sa{sv})", yield Portal.get_parent_window(), options_builder), - DBusCallFlags.NONE, - -1, - attachments - ); - return response; - } - - private static string generate_handle () { - return "%s_%i".printf ( - GLib.Application.get_default ().application_id.replace (".", "_").replace("-", "_"), - Random.int_range (0, int32.MAX) - ); - } - - private static async string get_parent_window () { - var window = AppWindow.get_instance().get_window (); - - if (window is Gdk.Wayland.Window) { - var handle = "wayland:"; - ((Gdk.Wayland.Window) window).export_handle ((w, h) => { - handle += h; - get_parent_window.callback (); - }); - yield; - return handle; - } else if (window is Gdk.X11.Window) { - return "x11:%x".printf ((uint) ((Gdk.X11.Window) window).get_xid ()); - } else { - warning ("Could not get parent window"); - return ""; - } - } -} diff --git a/src/editing_tools/EditingTools.vala b/src/editing_tools/EditingTools.vala index 02e366a..82fef0f 100644 --- a/src/editing_tools/EditingTools.vala +++ b/src/editing_tools/EditingTools.vala @@ -2251,7 +2251,7 @@ public class AdjustTool : EditingTool { slider_organizer.attach(saturation_label, 0, 2, 1, 1); slider_organizer.attach(saturation_slider, 1, 2, 1, 1); saturation_slider.set_size_request(SLIDER_WIDTH, -1); - saturation_slider.set_draw_value(false); + saturation_slider.set_value_pos(Gtk.PositionType.RIGHT); saturation_slider.set_margin_end(0); Gtk.Label tint_label = new Gtk.Label.with_mnemonic(_("Tint:")); diff --git a/src/meson.build b/src/meson.build index cc99f56..a532eec 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,7 +29,7 @@ face_sources = (['faces/FacesBranch.vala', shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2, gstreamer_pbu, gio_unix, gudev, gexiv2, gmodule, - libraw, libexif, sw_plugin, gdk, version] + libraw, libexif, sw_plugin, portal, version] if unity_available shotwell_deps += [unity] endif @@ -194,7 +194,6 @@ executable('shotwell', 'MediaPage.vala', 'MediaDataRepresentation.vala', 'DesktopIntegration.vala', - 'Portal.vala', 'MediaInterfaces.vala', 'MediaMetadata.vala', 'VideoMetadata.vala', |