Skip to content

Commit 437fbb8

Browse files
committed
Send notification only when using shortcuts
1 parent 191e43c commit 437fbb8

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/ScreenshotManager.vala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ namespace Gala {
2121

2222
[DBus (name="org.gnome.Shell.Screenshot")]
2323
public class ScreenshotManager : Object {
24-
private const string NOTIFICATION_COMPONENT_NAME = "ScreenshotManager";
25-
2624
private WindowManager wm;
2725
private NotificationsManager notifications_manager;
2826
private Settings desktop_settings;
@@ -97,7 +95,6 @@ namespace Gala {
9795

9896
if (success) {
9997
play_shutter_sound ();
100-
send_notification (filename == "");
10198
}
10299
}
103100

@@ -129,7 +126,6 @@ namespace Gala {
129126

130127
if (success) {
131128
play_shutter_sound ();
132-
send_notification (filename == "");
133129
} else {
134130
throw new DBusError.FAILED ("Failed to save image");
135131
}
@@ -188,7 +184,6 @@ namespace Gala {
188184

189185
if (success) {
190186
play_shutter_sound ();
191-
send_notification (filename == "");
192187
}
193188
}
194189

@@ -389,18 +384,6 @@ namespace Gala {
389384
context.play_full (0, props, null);
390385
}
391386

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-
404387
private Cairo.ImageSurface take_screenshot (int x, int y, int width, int height, bool include_cursor) {
405388
Cairo.ImageSurface image;
406389
int image_width, image_height;

src/WindowManager.vala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,10 @@ namespace Gala {
23252325
bool success = false;
23262326
string filename_used = "";
23272327
yield screenshot_manager.screenshot_window (true, false, true, filename, out success, out filename_used);
2328+
2329+
if (success) {
2330+
send_screenshot_notification (clipboard);
2331+
}
23282332
} catch (Error e) {
23292333
// Ignore this error
23302334
}
@@ -2339,6 +2343,10 @@ namespace Gala {
23392343
int x, y, w, h;
23402344
yield screenshot_manager.select_area (out x, out y, out w, out h);
23412345
yield screenshot_manager.screenshot_area (x, y, w, h, true, filename, out success, out filename_used);
2346+
2347+
if (success) {
2348+
send_screenshot_notification (clipboard);
2349+
}
23422350
} catch (Error e) {
23432351
// Ignore this error
23442352
}
@@ -2350,9 +2358,25 @@ namespace Gala {
23502358
bool success = false;
23512359
string filename_used = "";
23522360
yield screenshot_manager.screenshot (false, true, filename, out success, out filename_used);
2361+
2362+
if (success) {
2363+
send_screenshot_notification (clipboard);
2364+
}
23532365
} catch (Error e) {
23542366
// Ignore this error
23552367
}
23562368
}
2369+
2370+
private void send_screenshot_notification (bool clipboard) {
2371+
notifications_manager.send (
2372+
new NotificationsManager.NotificationData (
2373+
"ScreenshotManager",
2374+
"Screenshot taken",
2375+
clipboard ? _("Screenshot is saved to clipboard") : _("Screenshot saved to screenshots folder"),
2376+
"image-x-generic",
2377+
new GLib.HashTable<string, Variant> (null, null)
2378+
)
2379+
);
2380+
}
23572381
}
23582382
}

0 commit comments

Comments
 (0)