From c33804137137453568ed626fdff8634548193941 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 12 Apr 2023 18:21:30 +0100 Subject: [PATCH] Add choice of destination --- src/ScreenshotWindow.vala | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ScreenshotWindow.vala b/src/ScreenshotWindow.vala index 672f5161..7e1725c5 100755 --- a/src/ScreenshotWindow.vala +++ b/src/ScreenshotWindow.vala @@ -1,4 +1,4 @@ -/* + /* * Copyright 2017–2020 elementary, Inc. (https://elementary.io) * 2014–2016 Fabio Zaramella * @@ -18,7 +18,7 @@ */ public class Screenshot.ScreenshotWindow : Hdy.ApplicationWindow { - public bool to_clipboard { get; construct; } + public bool to_clipboard { get; set construct; } public bool mouse_pointer { get; set; } public bool redact { get; set; } @@ -109,6 +109,22 @@ public class Screenshot.ScreenshotWindow : Hdy.ApplicationWindow { var delay_spin = new Gtk.SpinButton.with_range (0, 15, 1); + var destination_label = new Gtk.Label (_("Send to:")) { + halign = Gtk.Align.END, + valign = Gtk.Align.CENTER, + }; + + var dest_screenshots_button = new Gtk.RadioButton (null) { + tooltip_text = _("Save to Screenshots"), + image = new Gtk.Image.from_icon_name ("document-save", Gtk.IconSize.DND) + }; + + //TODO Better icon + var dest_clipboard_button = new Gtk.RadioButton.from_widget (dest_screenshots_button) { + tooltip_text = _("Save to Clipboard"), + image = new Gtk.Image.from_icon_name ("edit-paste", Gtk.IconSize.DND) + }; + var take_btn = new Gtk.Button.with_label (_("Take Screenshot")); take_btn.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); take_btn.can_default = true; @@ -136,6 +152,10 @@ public class Screenshot.ScreenshotWindow : Hdy.ApplicationWindow { option_grid.attach (delay_label, 0, 3); option_grid.attach (delay_spin, 1, 3); + option_grid.attach (destination_label, 0, 4); + option_grid.attach (dest_screenshots_button, 1, 4); + option_grid.attach (dest_clipboard_button, 2, 4); + var actions = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL) { layout_style = Gtk.ButtonBoxStyle.END, spacing = 6 @@ -208,6 +228,10 @@ public class Screenshot.ScreenshotWindow : Hdy.ApplicationWindow { destroy (); }); + dest_clipboard_button.toggled.connect (() => { + to_clipboard = dest_clipboard_button.active; + }); + var gtk_settings = Gtk.Settings.get_default (); gtk_settings.notify["gtk-application-prefer-dark-theme"].connect (() => { update_icons (gtk_settings.gtk_application_prefer_dark_theme); @@ -285,6 +309,11 @@ public class Screenshot.ScreenshotWindow : Hdy.ApplicationWindow { private void save_pixbuf (Gdk.Pixbuf screenshot) { if (to_clipboard) { Gtk.Clipboard.get_default (this.get_display ()).set_image (screenshot); + var notification = new Notification (_("Screenshot copied to clipboard")); + notification.set_icon (new ThemedIcon ("edit-paste")); + notification.set_priority (NotificationPriority.LOW); + + GLib.Application.get_default ().send_notification (null, notification); } else { try { save_file (screenshot);