Skip to content

Commit f370c9c

Browse files
committed
ScreenshotManager: add notification on success
1 parent 7a84ee1 commit f370c9c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/ScreenshotManager.vala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
[DBus (name="org.gnome.Shell.Screenshot")]
1919
public class Gala.ScreenshotManager : GLib.Object {
20+
private const string NOTIFICATION_COMPONENT_NAME = "ScreenshotManager";
2021
private const string EXTENSION = ".png";
2122
private const int UNCONCEAL_TEXT_TIMEOUT = 2000;
2223

2324
private WindowManager wm;
25+
private NotificationsManager notifications_manager;
2426
private Settings desktop_settings;
2527

2628
private string prev_font_regular;
@@ -29,8 +31,9 @@ public class Gala.ScreenshotManager : GLib.Object {
2931
private uint conceal_timeout;
3032

3133
[DBus (visible = false)]
32-
public ScreenshotManager (WindowManager _wm) {
34+
public ScreenshotManager (WindowManager _wm, NotificationsManager _notifications_manager) {
3335
wm = _wm;
36+
notifications_manager = _notifications_manager;
3437
}
3538

3639
construct {
@@ -92,6 +95,7 @@ public class Gala.ScreenshotManager : GLib.Object {
9295

9396
if (success) {
9497
play_shutter_sound ();
98+
send_notification (filename == "");
9599
}
96100
}
97101

@@ -123,6 +127,7 @@ public class Gala.ScreenshotManager : GLib.Object {
123127

124128
if (success) {
125129
play_shutter_sound ();
130+
send_notification (filename == "");
126131
} else {
127132
throw new DBusError.FAILED ("Failed to save image");
128133
}
@@ -181,6 +186,7 @@ public class Gala.ScreenshotManager : GLib.Object {
181186

182187
if (success) {
183188
play_shutter_sound ();
189+
send_notification (filename == "");
184190
}
185191
}
186192

@@ -381,6 +387,18 @@ public class Gala.ScreenshotManager : GLib.Object {
381387
context.play_full (0, props, null);
382388
}
383389

390+
private void send_notification (bool clipboard) {
391+
notifications_manager.send (
392+
new NotificationsManager.NotificationData (
393+
NOTIFICATION_COMPONENT_NAME,
394+
"Screenshot taken",
395+
clipboard ? _("Screenshot is saved to clipboard") : _("Screenshot saved to screenshots folder"),
396+
"image-x-generic",
397+
new GLib.HashTable<string, Variant> (null, null)
398+
)
399+
);
400+
}
401+
384402
private Cairo.ImageSurface take_screenshot (int x, int y, int width, int height, bool include_cursor) {
385403
Cairo.ImageSurface image;
386404
int image_width, image_height;

src/WindowManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace Gala {
197197

198198
notifications_manager = new NotificationsManager ();
199199
dbus_accelerator = new DBusAccelerator (display, notifications_manager);
200-
screenshot_manager = new ScreenshotManager (this);
200+
screenshot_manager = new ScreenshotManager (this, notifications_manager);
201201
dbus_manager = new DBusManager (this, dbus_accelerator, screenshot_manager);
202202

203203
WindowListener.init (display);

0 commit comments

Comments
 (0)