Skip to content

Commit 92a01f3

Browse files
committed
Send notification on screenshot
1 parent 7576880 commit 92a01f3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/ScreenshotManager.vala

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ namespace Gala {
2121

2222
[DBus (name="org.gnome.Shell.Screenshot")]
2323
public class ScreenshotManager : Object {
24+
private const string NOTIFICATION_COMPONENT_NAME = "ScreenshotManager";
25+
2426
private WindowManager wm;
27+
private NotificationsManager notifications_manager;
2528
private Settings desktop_settings;
2629

2730
private string prev_font_regular;
@@ -30,8 +33,9 @@ namespace Gala {
3033
private uint conceal_timeout;
3134

3235
[DBus (visible = false)]
33-
public ScreenshotManager (WindowManager _wm) {
36+
public ScreenshotManager (WindowManager _wm, NotificationsManager _notifications_manager) {
3437
wm = _wm;
38+
notifications_manager = _notifications_manager;
3539
}
3640

3741
construct {
@@ -93,6 +97,7 @@ namespace Gala {
9397

9498
if (success) {
9599
play_shutter_sound ();
100+
send_notification (filename == "");
96101
}
97102
}
98103

@@ -124,6 +129,7 @@ namespace Gala {
124129

125130
if (success) {
126131
play_shutter_sound ();
132+
send_notification (filename == "");
127133
} else {
128134
throw new DBusError.FAILED ("Failed to save image");
129135
}
@@ -182,6 +188,7 @@ namespace Gala {
182188

183189
if (success) {
184190
play_shutter_sound ();
191+
send_notification (filename == "");
185192
}
186193
}
187194

@@ -382,6 +389,18 @@ namespace Gala {
382389
context.play_full (0, props, null);
383390
}
384391

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

src/WindowManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace Gala {
194194
unowned Meta.Display display = get_display ();
195195

196196
notifications_manager = new NotificationsManager ();
197-
screenshot_manager = new ScreenshotManager (this);
197+
screenshot_manager = new ScreenshotManager (this, notifications_manager);
198198
dbus_accelerator = new DBusAccelerator (display, notifications_manager);
199199
DBus.init (this, dbus_accelerator, screenshot_manager);
200200

0 commit comments

Comments
 (0)