Skip to content

Commit cb3a06d

Browse files
committed
desklets: Allow desklets to be locked in place.
All at once, not individually. Fixes #3767 Fixes #9622
1 parent b60a8f9 commit cb3a06d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

data/org.cinnamon.gschema.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@
9494
<summary>The interval between each possible grid position when desklets "snap"</summary>
9595
<description>If desklet-snap is enabled, the possible positions of desklets will be all integer multiples of the value of "desklet-snap-size"</description>
9696
</key>
97-
97+
<key name="lock-desklets" type="b">
98+
<default>false</default>
99+
<summary> Locks the current position of all desklets and prevents dragging</summary>
100+
</key>
98101
<key name="panels-enabled" type="as">
99102
<default>['1:0:bottom']</default>
100103
<summary>List of panels used</summary>

files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def load(self, window):
6969
settings.add_row(GSettingsSwitch(_("Snap desklets to grid"), "org.cinnamon", "desklet-snap"))
7070
settings.add_reveal_row(GSettingsSpinButton(_("Width of desklet snap grid"), "org.cinnamon", "desklet-snap-interval", "", 0, 100, 1, 5), "org.cinnamon", "desklet-snap")
7171

72+
settings = page.add_section("")
73+
settings.add_row(GSettingsSwitch(_("Lock desklets in their current position"), "org.cinnamon", "lock-desklets"))
74+
7275
class ManageDeskletsPage(ManageSpicesPage):
7376
directories = [("%s/.local/share/cinnamon/desklets") % GLib.get_home_dir(), "/usr/share/cinnamon/desklets"]
7477
collection_type = "desklet"

js/ui/deskletManager.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const DESKLET_SNAP_KEY = 'desklet-snap';
3838
const DESKLET_SNAP_INTERVAL_KEY = 'desklet-snap-interval';
3939
const KEYBINDING_SCHEMA = 'org.cinnamon.desktop.keybindings';
4040
const SHOW_DESKLETS_KEY = 'show-desklets';
41+
const LOCK_DESKLETS_KEY = "lock-desklets";
4142

4243
function initEnabledDesklets() {
4344
for (let i = 0; i < definitions.length; i++) {
@@ -445,6 +446,8 @@ DeskletContainer.prototype = {
445446
this.lower();
446447
}
447448
});
449+
450+
global.settings.connect('changed::' + LOCK_DESKLETS_KEY, () => this.onDeskletsLockedChanged());
448451
},
449452

450453
applyKeyBindings: function() {
@@ -463,6 +466,7 @@ DeskletContainer.prototype = {
463466
*/
464467
addDesklet: function(actor){
465468
this.actor.add_actor(actor);
469+
actor._delegate._draggable.inhibit = global.settings.get_boolean(LOCK_DESKLETS_KEY);
466470
},
467471

468472
/**
@@ -477,6 +481,12 @@ DeskletContainer.prototype = {
477481
return this.actor.contains(actor);
478482
},
479483

484+
onDeskletsLockedChanged: function(settings, key) {
485+
this.actor.get_children().forEach((deskletActor) => {
486+
deskletActor._delegate._draggable.inhibit = global.settings.get_boolean(LOCK_DESKLETS_KEY);
487+
});
488+
},
489+
480490
handleDragOver: function(source, actor, x, y, time) {
481491
deskletsDragging = true;
482492

0 commit comments

Comments
 (0)