Skip to content

Commit

Permalink
mouse-click-effects@anaximeno: Version 1.0.2 (#754)
Browse files Browse the repository at this point in the history
* Suppress unnecessary logs in production and fix typo in settings
  • Loading branch information
anaximeno authored Sep 22, 2024
1 parent abd85b0 commit 47133e9
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
'use strict';

const DEBUG = false;

const UUID = "mouse-click-effects@anaximeno";

const PAUSE_EFFECTS_KEY = `${UUID}-bind-pause-effects`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Gettext = imports.gettext;
const ByteArray = imports.byteArray;
const { Atspi, GLib, Gio } = imports.gi;
const { ClickAnimationFactory, ClickAnimationModes } = require("./clickAnimations.js");
const { Debouncer } = require("./helpers.js");
const { Debouncer, logInfo, logError } = require("./helpers.js");
const { UUID, PAUSE_EFFECTS_KEY, CLICK_DEBOUNCE_MS, POINTER_WATCH_MS, IDLE_TIME } = require("./constants.js");
const { IdleMonitor } = require("./idleMonitor.js");
const { MouseMovementTracker } = require("./mouseMovementTracker.js");
Expand Down Expand Up @@ -76,7 +76,7 @@ class MouseClickEffects {
let data_dir = `${GLib.get_user_cache_dir()}/${uuid}`;

if (GLib.mkdir_with_parents(`${data_dir}/icons`, 0o777) < 0) {
global.logError(`Failed to create cache dir at ${data_dir}`);
logError(`Failed to create cache dir at ${data_dir}`);
throw new Error(`Failed to create cache dir at ${data_dir}`);
}

Expand Down Expand Up @@ -255,14 +255,14 @@ class MouseClickEffects {
this._enable_on_drag_end = true;
this.set_active(false);
}
}).bind(this)
}).bind(this);

dragDrop = ((event) => {
if (this._enable_on_drag_end) {
this._enable_on_drag_end = false;
this.set_active(true);
}
}).bind(this)
}).bind(this);

enable() {
this.update_colored_icons();
Expand Down Expand Up @@ -372,9 +372,9 @@ class MouseClickEffects {
// this.idleMonitor.start();
// }

global.log(UUID, "activated");
logInfo("activated");
} else {
global.log(UUID, "deactivated");
logInfo("deactivated");
}
}

Expand All @@ -397,17 +397,18 @@ class MouseClickEffects {

let [r_success, tag] = dest.replace_contents(contents, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null);

if (r_success) global.log(UUID, `created colored icon cache for ${name}`);
if (r_success) logInfo(`created colored icon cache for ${name}`);

return r_success;
}

display_click = (new Debouncer()).debounce((...args) => {
if (this.deactivate_in_fullscreen && global.display.focus_window && global.display.focus_window.is_fullscreen()) {
// global.log(UUID, "Click effects not displayed due to being disabled for fullscreen focused windows");
logInfo("Click effects not displayed due to being disabled for fullscreen focused windows");
return;
}
this.animate_click(...args);
}, CLICK_DEBOUNCE_MS)
}, CLICK_DEBOUNCE_MS);

animate_click(click_type, color) {
this.update_animation_mode();
Expand All @@ -432,7 +433,7 @@ class MouseClickEffects {
timeout: this.animation_time,
});
} else {
global.logError(`${UUID}: Couldn't get Click Icon (mode = ${this.icon_mode}, type = ${click_type}, color = ${color})`)
logError(`Couldn't get Click Icon (mode = ${this.icon_mode}, type = ${click_type}, color = ${color})`)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

const Util = imports.misc.util;

const { UUID, DEBUG } = require('./constants.js');


var Debouncer = class Debouncer {
_sourceId;

Expand All @@ -43,3 +46,12 @@ var Debouncer = class Debouncer {
}).bind(this);
}
}


function logInfo(...args) {
if (DEBUG) global.log(`${UUID}: ${args.join(' ')}`);
}

function logError(...args) {
global.logError(`${UUID}: ${args.join(' ')}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ const Main = imports.ui.main;

const PointerWatcher = require("./pointerWatcher.js").getPointerWatcher();
const { POINTER_WATCH_MS, UUID, MOUSE_PARADE_DELAY_MS } = require("./constants.js");
const { Debouncer } = require("./helpers.js");
const { Debouncer, logInfo } = require("./helpers.js");


var MouseMovementTracker = class MouseMovementTracker {
constructor(icon, size, opacity, persist_on_stopped) {
this.size = size;
this.opacity = opacity;
this.icon = icon;
this.persist_on_stopped = persist_on_stopped;
this.icon_actor = null;
this.listener = null;
this.persist_on_stopped = persist_on_stopped;
this.handle_parade = (new Debouncer()).debounce(
this.on_parade.bind(this),
MOUSE_PARADE_DELAY_MS,
);
}

start() {
Expand All @@ -34,7 +30,7 @@ var MouseMovementTracker = class MouseMovementTracker {
this.move_to(x, y);
Main.uiGroup.add_child(this.icon_actor);
this.listener = PointerWatcher.addWatch(POINTER_WATCH_MS, this.move_to.bind(this));
global.log(UUID, "mouse movement tracker started");
logInfo("mouse movement tracker started");
}

update(params) {
Expand All @@ -59,19 +55,21 @@ var MouseMovementTracker = class MouseMovementTracker {
Main.uiGroup.remove_child(this.icon_actor);
this.listener.remove();
this.icon_actor.destroy();
global.log(UUID, "mouse movement tracker finalized");
logInfo("mouse movement tracker finalized");
}

move_to(x, y) {
this.icon_actor.show();
this.icon_actor.set_position(
x - (this.size * global.ui_scale / 2),
y - (this.size * global.ui_scale / 2));
if (!this.persist_on_stopped)
this.handle_parade();
if (this.icon_actor) {
this.icon_actor.show();
this.icon_actor.set_position(
x - (this.size * global.ui_scale / 2),
y - (this.size * global.ui_scale / 2));
if (!this.persist_on_stopped)
this.handle_parade();
}
}

on_parade() {
this.icon_actor.hide();
}
handle_parade = (new Debouncer()).debounce(() => {
if (this.icon_actor) this.icon_actor.hide();
}, MOUSE_PARADE_DELAY_MS);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"style-section": {
"type": "section",
"title": "Colors",
"title": "Style",
"keys": [
"icon-mode",
"size",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"uuid": "mouse-click-effects@anaximeno",
"name": "Mouse Click Effects",
"version": "1.0.1",
"version": "1.0.2",
"description": "Display mouse click effects on Cinnamon.",
"url": "https://github.com/anaximeno/mouse-click-effects",
"website": "https://github.com/anaximeno/mouse-click-effects",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.4.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-09-21 22:17+0200\n"
"Last-Translator: Odyssey <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -32,14 +32,14 @@ msgid "General"
msgstr "General"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr "Estil"

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr "Efectes"

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Colors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-09-21 12:19-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -31,14 +31,14 @@ msgid "General"
msgstr "General"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr "Estilo"

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr "Efectos"

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Colores"
Expand Down Expand Up @@ -225,14 +225,13 @@ msgid ""
"This is still experimental and may interfere when clicking on the panel or "
"in some drag-and-drop operations."
msgstr ""
"Esto es todavía experimental y puede interferir al hacer clic en el panel "
"o en algunas operaciones de arrastrar y soltar."
"Esto es todavía experimental y puede interferir al hacer clic en el panel o "
"en algunas operaciones de arrastrar y soltar."

#. 5.4->settings-schema.json->mouse-movement-tracker-persist-on-stopped-
#. enabled->description
msgid "Persist Movement Tracker On Stopped (experimental)"
msgstr ""
"Rastreador de movimiento persistente en estado detenido (experimental)"
msgstr "Rastreador de movimiento persistente en estado detenido (experimental)"

#. 5.4->settings-schema.json->mouse-idle-watcher-enabled->description
msgid "Mouse Idle Watcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-05-30 9:50+1\n"
"Last-Translator: Muxutruk <[email protected]>\n"
"Language-Team: Basque <[email protected]>\n"
Expand All @@ -31,14 +31,14 @@ msgid "General"
msgstr "Orokorra"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr ""

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr ""

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Koloreak"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.4.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-07-26 07:08-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -32,14 +32,14 @@ msgid "General"
msgstr "Általános"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr ""

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr ""

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Színek"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 1.0.0\n"
"Project-Id-Version: mouse-click-effects@anaximeno 1.0.2\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -31,14 +31,14 @@ msgid "General"
msgstr ""

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr ""

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr ""

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.4.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-07-23 20:25+0200\n"
"Last-Translator: qadzek\n"
"Language-Team: \n"
Expand All @@ -30,14 +30,14 @@ msgid "General"
msgstr "Algemeen"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr ""

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr ""

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Kleuren"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: mouse-click-effects@anaximeno 0.1.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-20 22:01-0100\n"
"POT-Creation-Date: 2024-09-22 17:02-0100\n"
"PO-Revision-Date: 2024-09-20 22:03-0100\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -32,14 +32,14 @@ msgid "General"
msgstr "Geral"

#. 5.4->settings-schema.json->style-page->title
#. 5.4->settings-schema.json->style-section->title
msgid "Style"
msgstr "Estilo"

#. 5.4->settings-schema.json->effects-section->title
msgid "Effects"
msgstr "Efeitos"

#. 5.4->settings-schema.json->style-section->title
#. 5.4->settings-schema.json->colors-section->title
msgid "Colors"
msgstr "Cores"
Expand Down
Loading

0 comments on commit 47133e9

Please sign in to comment.