Skip to content

Commit 48dc291

Browse files
committed
screenshot: Allow disabling the flash.
Adds a Preference to disable the 'flash' effect when taking a screenshot. Remove some unused code. ref: https://github.com/orgs/linuxmint/discussions/219
1 parent b798ba9 commit 48dc291

6 files changed

Lines changed: 14 additions & 29 deletions

File tree

data/org.cinnamon.gschema.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,12 @@
10461046
<description>When enabled, a copy of every screenshot that is saved to a file is also placed on the clipboard.</description>
10471047
</key>
10481048

1049+
<key name="use-flash" type="b">
1050+
<default>true</default>
1051+
<summary>Use a flash</summary>
1052+
<description>When enabled, a brief flash is shown over the captured area after taking a screenshot.</description>
1053+
</key>
1054+
10491055
</schema>
10501056

10511057
</schemalist>

files/usr/share/cinnamon/cinnamon-screenshot/backends/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ def screenshot_window_by_id(self, window_id, include_pointer, include_shadow, on
1414
def screenshot_area(self, x, y, w, h, include_pointer, on_done, copy_to_clipboard=False):
1515
on_done(None)
1616

17-
def flash_area(self, x, y, w, h):
18-
pass
19-
2017
def select_area(self, on_done):
2118
on_done(None)
2219

files/usr/share/cinnamon/cinnamon-screenshot/backends/cinnamon.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ def screenshot_area(self, x, y, w, h, include_pointer, on_done, copy_to_clipboar
9191
GLib.Variant('(iiiibsb)', (x, y, w, h, include_pointer, path, copy_to_clipboard)),
9292
lambda result: self._deliver_image(path, result, on_done))
9393

94-
def flash_area(self, x, y, w, h):
95-
self._proxy.call('FlashArea', GLib.Variant('(iiii)', (x, y, w, h)),
96-
Gio.DBusCallFlags.NONE, -1, None, None)
97-
9894
def select_area(self, on_done):
9995
self._call('SelectArea', None,
10096
lambda result: on_done(tuple(result) if result else None))

files/usr/share/cinnamon/cinnamon-screenshot/prefs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
LAUNCH_FILE_MANAGER_KEY = 'launch-file-manager-after-save'
1515
AUTOSAVE_TO_FILE_KEY = 'autosave-to-file'
1616
AUTOSAVE_TO_CLIPBOARD_KEY = 'autosave-to-clipboard'
17+
USE_FLASH_KEY = 'use-flash'
1718

1819
settings = Gio.Settings.new(SCHEMA_ID)
1920
if not settings.get_string(SAVE_DIRECTORY_KEY):
@@ -126,6 +127,10 @@ def __init__(self, parent):
126127
_('Copy to clipboard when saving'),
127128
SCHEMA_ID, AUTOSAVE_TO_CLIPBOARD_KEY,
128129
))
130+
section_behavior.add_row(GSettingsSwitch(
131+
_('Use a flash'),
132+
SCHEMA_ID, USE_FLASH_KEY,
133+
))
129134

130135
self.window.show_all()
131136

files/usr/share/cinnamon/cinnamon-screenshot/screenshot_backend.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ def screenshot_window_by_id(self, window_id, include_pointer, include_shadow, on
4141
def screenshot_area(self, x, y, w, h, include_pointer, on_done, copy_to_clipboard=False):
4242
self._active().screenshot_area(x, y, w, h, include_pointer, on_done, copy_to_clipboard=copy_to_clipboard)
4343

44-
def flash_area(self, x, y, w, h):
45-
self._active().flash_area(x, y, w, h)
46-
4744
def select_area(self, on_done):
4845
self._active().select_area(on_done)
4946

js/ui/screenshot.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ const ScreenshotIface =
130130
<arg type="b" direction="out" name="success"/> \
131131
<arg type="s" direction="out" name="filename_used"/> \
132132
</method> \
133-
<method name="FlashArea"> \
134-
<arg type="i" direction="in" name="x"/> \
135-
<arg type="i" direction="in" name="y"/> \
136-
<arg type="i" direction="in" name="width"/> \
137-
<arg type="i" direction="in" name="height"/> \
138-
</method> \
139133
<method name="SelectArea"> \
140134
<arg type="i" direction="out" name="x"/> \
141135
<arg type="i" direction="out" name="y"/> \
@@ -164,10 +158,12 @@ var ScreenshotService = class ScreenshotService {
164158
this._dbusImpl.export(Gio.DBus.session, '/org/cinnamon/Screenshot');
165159

166160
Gio.DBus.session.own_name('org.cinnamon.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
161+
162+
this._settings = new Gio.Settings({ schema_id: 'org.cinnamon.screenshot' });
167163
}
168164

169165
_onScreenshotComplete (obj, success, area, filename, invocation=null) {
170-
if (success) {
166+
if (success && this._settings.get_boolean('use-flash')) {
171167
let flashspot = new Flashspot.Flashspot(area);
172168
flashspot.fire();
173169
}
@@ -291,18 +287,6 @@ var ScreenshotService = class ScreenshotService {
291287
}
292288
}
293289

294-
FlashAreaAsync(params, invocation) {
295-
let [x, y, width, height] = params;
296-
297-
let flashspot = new Flashspot.Flashspot({
298-
x: x * global.ui_scale,
299-
y: y * global.ui_scale,
300-
width: width * global.ui_scale,
301-
height: height * global.ui_scale
302-
});
303-
flashspot.fire();
304-
invocation.return_value(null);
305-
}
306290
}
307291

308292
class SelectArea {

0 commit comments

Comments
 (0)