Skip to content
25 changes: 23 additions & 2 deletions src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class Gala.ScreenshotManager : Object {
var show_in_files_action = new GLib.SimpleAction ("show-in-files", GLib.VariantType.STRING);
show_in_files_action.activate.connect (show_in_files);
notifications_manager.add_action (show_in_files_action);

var open_in_photos_action = new GLib.SimpleAction ("open-in-photos", GLib.VariantType.STRING);
open_in_photos_action.activate.connect (open_in_photos);
notifications_manager.add_action (open_in_photos_action);
}

[CCode (instance_pos = -1)]
Expand Down Expand Up @@ -133,8 +137,12 @@ public class Gala.ScreenshotManager : Object {

string[] actions = {};
if (!clipboard) {
/// TRANSLATORS: 'Files' is the name of file manager used by elementary OS
actions = { GLib.Action.print_detailed_name ("show-in-files", new Variant ("s", filename_used)), _("Show in Files") };
actions = {
/// TRANSLATORS: 'Files' is the name of file manager used by elementary OS
GLib.Action.print_detailed_name ("show-in-files", new Variant ("s", filename_used)), _("Show in Files"),
/// TRANSLATORS: 'Photos' is the name of image viewer used by elementary OS
GLib.Action.print_detailed_name ("open-in-photos", new Variant ("s", filename_used)), _("Open in Photos")
};
}

notifications_manager.send.begin (
Expand All @@ -160,6 +168,19 @@ public class Gala.ScreenshotManager : Object {
}
}

private void open_in_photos (GLib.Variant? variant) requires (variant != null && variant.is_of_type (GLib.VariantType.STRING)) {
var files_list = new GLib.List<GLib.File> ();
files_list.append (GLib.File.new_for_path (variant.get_string ()));

var photos_appinfo = AppInfo.get_default_for_type ("image/png", true);

try {
photos_appinfo.launch (files_list, null);
} catch (Error e) {
warning (e.message);
}
}

public void flash_area (int x, int y, int width, int height) throws DBusError, IOError {
debug ("Flashing area");

Expand Down