Skip to content

Commit b29e51d

Browse files
authored
mouse-click-effects@anaximeno: Add keybinding settings (#646)
1 parent 57a0982 commit b29e51d

File tree

9 files changed

+116
-13
lines changed

9 files changed

+116
-13
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* constants.js
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 2 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
* SPDX-License-Identifier: GPL-3.0-or-later
17+
*/
18+
'use strict';
19+
20+
const UUID = "mouse-click-effects@anaximeno";
21+
22+
const PAUSE_EFFECTS_KEY = `${UUID}-bind-pause-effects`;

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/extension.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@
1717
*/
1818
'use strict';
1919

20+
const Main = imports.ui.main;
2021
const Settings = imports.ui.settings;
2122
const Gettext = imports.gettext;
2223
const SignalManager = imports.misc.signalManager;
2324
const { Atspi, GLib, Gio } = imports.gi;
2425
const { ClickAnimationFactory } = require("./clickAnimations.js");
2526
const { Debouncer } = require("./helpers.js");
27+
const { UUID, PAUSE_EFFECTS_KEY } = require("./constants.js");
2628

2729

28-
const LOCALE_DIR = GLib.get_home_dir() + "/.local/share/locale";
29-
const UUID = "mouse-click-effects@anaximeno";
30-
31-
Gettext.bindtextdomain(UUID, LOCALE_DIR);
30+
Gettext.bindtextdomain(UUID, `${GLib.get_home_dir()}/.local/share/locale`);
3231

3332

3433
function _(text) {
3534
let localized = Gettext.dgettext(UUID, text);
3635
return localized != text ? localized : window._(text);
3736
}
3837

38+
3939
const ClickType = {
4040
LEFT: "left_click",
4141
MIDDLE: "middle_click",
@@ -57,16 +57,22 @@ class MouseClickEffects {
5757
this.signals.connect(global.screen, 'in-fullscreen-changed', this.on_fullscreen_changed, this);
5858

5959
this._click_animation = ClickAnimationFactory.createForMode(this.animation_mode);
60+
6061
this.display_click = (new Debouncer()).debounce(this._animate_click.bind(this), 2);
6162
this.colored_icon_store = {};
63+
this.enabled = false;
64+
6265
this.update_colored_icons();
66+
this.set_keybindings();
6367
}
6468

6569
_init_data_dir(uuid) {
6670
let data_dir = `${GLib.get_user_cache_dir()}/${uuid}`;
6771

68-
if (GLib.mkdir_with_parents(`${data_dir}/icons`, 0o777) < 0)
72+
if (GLib.mkdir_with_parents(`${data_dir}/icons`, 0o777) < 0) {
73+
global.logError(`Failed to create cache dir at ${data_dir}`);
6974
throw new Error(`Failed to create cache dir at ${data_dir}`);
75+
}
7076

7177
return data_dir;
7278
}
@@ -129,6 +135,11 @@ class MouseClickEffects {
129135
value: "animation_mode",
130136
cb: this.update_animation_mode,
131137
},
138+
{
139+
key: "pause-effects-binding",
140+
value: "pause_effects_binding",
141+
cb: this.set_keybindings,
142+
},
132143
{
133144
key: "deactivate-in-fullscreen",
134145
value: "deactivate_in_fullscreen",
@@ -150,9 +161,27 @@ class MouseClickEffects {
150161
}
151162

152163
disable() {
164+
this.set_active(false);
165+
this.unset_keybindings();
153166
this.destroy();
154167
}
155168

169+
unset_keybindings() {
170+
Main.keybindingManager.removeHotKey(PAUSE_EFFECTS_KEY);
171+
}
172+
173+
set_keybindings() {
174+
this.unset_keybindings();
175+
Main.keybindingManager.addHotKey(
176+
PAUSE_EFFECTS_KEY,
177+
this.pause_effects_binding,
178+
() => {
179+
global.log(UUID, `Click effects ${this.enabled ? "paused" : "resumed"}!`);
180+
this.set_active(!this.enabled);
181+
},
182+
);
183+
}
184+
156185
on_effects_enabled_updated(event) {
157186
thib.on_property_updated(event);
158187
}
@@ -203,6 +232,7 @@ class MouseClickEffects {
203232
}
204233

205234
set_active(enabled) {
235+
this.enabled = enabled;
206236
this.listener.deregister('mouse');
207237

208238
if (enabled) {

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/5.4/settings-schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
"default": false,
7373
"description": "Deactivate In Fullscreen"
7474
},
75+
"pause-effects-binding": {
76+
"type": "keybinding",
77+
"description": "Pause Effects Keybinding",
78+
"default": "",
79+
"tooltip": "Set keybinding to pause or continue the effects"
80+
},
7581

7682
"events-section": {
7783
"type": "section",

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"uuid": "mouse-click-effects@anaximeno",
33
"name": "Mouse Click Effects",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"description": "Display mouse click effects on Cinnamon.",
66
"url": "https://github.com/anaximeno/mouse-click-effects",
77
"website": "https://github.com/anaximeno/mouse-click-effects",

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/po/es.po

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
88
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
99
"extensions/issues\n"
10-
"POT-Creation-Date: 2024-05-30 05:46-0100\n"
10+
"POT-Creation-Date: 2024-05-30 19:05-0100\n"
1111
"PO-Revision-Date: 2024-05-30 11:01-0400\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
@@ -153,6 +153,14 @@ msgstr "Opacidad general"
153153
msgid "Deactivate In Fullscreen"
154154
msgstr "Desactivar en pantalla completa"
155155

156+
#. 5.4->settings-schema.json->pause-effects-binding->description
157+
msgid "Pause Effects Keybinding"
158+
msgstr ""
159+
160+
#. 5.4->settings-schema.json->pause-effects-binding->tooltip
161+
msgid "Set keybinding to pause or continue the effects"
162+
msgstr ""
163+
156164
#. 5.4->settings-schema.json->events-section->description
157165
msgid "Events"
158166
msgstr "Eventos"

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/po/eu.po

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
msgid ""
77
msgstr ""
88
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
9-
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-extensions/issues\n"
10-
"POT-Creation-Date: 2024-05-26 10:55-0100\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
10+
"extensions/issues\n"
11+
"POT-Creation-Date: 2024-05-30 19:05-0100\n"
1112
"PO-Revision-Date: 2024-05-30 9:50+1\n"
1213
"Last-Translator: Muxutruk <muxutruk2@users.noreply.github.com>\n"
1314
"Language-Team: Basque <muxutruk2@users.noreply.github.com>\n"
@@ -104,6 +105,10 @@ msgstr "Zirkulua"
104105
msgid "Gear"
105106
msgstr "Engranaje"
106107

108+
#. 5.4->settings-schema.json->icon-mode->options
109+
msgid "H-Star"
110+
msgstr ""
111+
107112
#. 5.4->settings-schema.json->size->units
108113
msgid "px"
109114
msgstr "pixel"
@@ -148,6 +153,14 @@ msgstr "Opakutasun orokorra"
148153
msgid "Deactivate In Fullscreen"
149154
msgstr "Desaktibatu pantaila osoan"
150155

156+
#. 5.4->settings-schema.json->pause-effects-binding->description
157+
msgid "Pause Effects Keybinding"
158+
msgstr ""
159+
160+
#. 5.4->settings-schema.json->pause-effects-binding->tooltip
161+
msgid "Set keybinding to pause or continue the effects"
162+
msgstr ""
163+
151164
#. 5.4->settings-schema.json->events-section->description
152165
msgid "Events"
153166
msgstr "Gertaerak"

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/po/mouse-click-effects@anaximeno.pot

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#, fuzzy
66
msgid ""
77
msgstr ""
8-
"Project-Id-Version: mouse-click-effects@anaximeno 0.2.0\n"
8+
"Project-Id-Version: mouse-click-effects@anaximeno 0.3.0\n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
1010
"extensions/issues\n"
11-
"POT-Creation-Date: 2024-05-30 05:46-0100\n"
11+
"POT-Creation-Date: 2024-05-30 19:05-0100\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -153,6 +153,14 @@ msgstr ""
153153
msgid "Deactivate In Fullscreen"
154154
msgstr ""
155155

156+
#. 5.4->settings-schema.json->pause-effects-binding->description
157+
msgid "Pause Effects Keybinding"
158+
msgstr ""
159+
160+
#. 5.4->settings-schema.json->pause-effects-binding->tooltip
161+
msgid "Set keybinding to pause or continue the effects"
162+
msgstr ""
163+
156164
#. 5.4->settings-schema.json->events-section->description
157165
msgid "Events"
158166
msgstr ""

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/po/pt.po

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
1010
"extensions/issues\n"
11-
"POT-Creation-Date: 2024-05-30 05:46-0100\n"
11+
"POT-Creation-Date: 2024-05-30 19:05-0100\n"
1212
"PO-Revision-Date: 2024-05-28 03:36-0100\n"
1313
"Last-Translator: \n"
1414
"Language-Team: \n"
@@ -154,6 +154,14 @@ msgstr "Opacidade Geral"
154154
msgid "Deactivate In Fullscreen"
155155
msgstr "Desativar em Tela Cheia"
156156

157+
#. 5.4->settings-schema.json->pause-effects-binding->description
158+
msgid "Pause Effects Keybinding"
159+
msgstr ""
160+
161+
#. 5.4->settings-schema.json->pause-effects-binding->tooltip
162+
msgid "Set keybinding to pause or continue the effects"
163+
msgstr ""
164+
157165
#. 5.4->settings-schema.json->events-section->description
158166
msgid "Events"
159167
msgstr "Eventos"

mouse-click-effects@anaximeno/files/mouse-click-effects@anaximeno/po/zh.po

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
1010
"extensions/issues\n"
11-
"POT-Creation-Date: 2024-05-30 05:46-0100\n"
11+
"POT-Creation-Date: 2024-05-30 19:05-0100\n"
1212
"PO-Revision-Date: 2024-05-28 11:48+0800\n"
1313
"Last-Translator: 张鹏 <scbeta@qq.com>\n"
1414
"Language-Team: \n"
@@ -154,6 +154,14 @@ msgstr "常规透明度"
154154
msgid "Deactivate In Fullscreen"
155155
msgstr "全屏时不激活"
156156

157+
#. 5.4->settings-schema.json->pause-effects-binding->description
158+
msgid "Pause Effects Keybinding"
159+
msgstr ""
160+
161+
#. 5.4->settings-schema.json->pause-effects-binding->tooltip
162+
msgid "Set keybinding to pause or continue the effects"
163+
msgstr ""
164+
157165
#. 5.4->settings-schema.json->events-section->description
158166
msgid "Events"
159167
msgstr "事件"

0 commit comments

Comments
 (0)