Skip to content

Commit

Permalink
EGO code review
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed Nov 20, 2021
1 parent a3be105 commit 3f0637e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A GNOME Shell extension providing customizable sticky notes.

Version 20 has been released the 20/02/2021

| GNOME Shell version | Extension version 21 | 20 | 19 | 18 | 17 |
| GNOME Shell version | Extension version 22 | 20 | 19 | 18 | 17 |
|---------------------|----------------------|-----|-----|-----|-----|
| **41** | No | | | | |
| **40** | No | | | | |
Expand Down
4 changes: 4 additions & 0 deletions build-a-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ zip -r ../[email protected] schemas
zip -r ../[email protected] locale
zip -r ../[email protected] screenshots

shopt -s globstar

zip -d ../[email protected] **/*.pot
zip -d ../[email protected] **/*.po

Binary file modified [email protected]
Binary file not shown.
27 changes: 19 additions & 8 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const Mainloop = imports.mainloop;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

const NoteBox = Me.imports.noteBox;

Expand All @@ -28,7 +27,7 @@ var LAYER_SETTING;
var AUTO_FOCUS;

function init() {
Convenience.initTranslations();
ExtensionUtils.initTranslations();
try {
let a = Gio.file_new_for_path(PATH);
if (!a.query_exists(null)) {
Expand All @@ -41,14 +40,22 @@ function init() {
}

function enable() {
SETTINGS = Convenience.getSettings();
SETTINGS = ExtensionUtils.getSettings();
AUTO_FOCUS = SETTINGS.get_boolean('auto-focus'); // XXX crado

NOTES_MANAGER = new NotesManager();
}

function disable() {
NOTES_MANAGER.destroy();

if (NOTES_MANAGER) {
NOTES_MANAGER = null;
}

if (SETTINGS) {
SETTINGS = null;
}
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -92,11 +99,11 @@ class NotesManager {
}

_bindVisibilityShortcut () {
this.USE_SHORTCUT = Convenience.getSettings().get_boolean('use-shortcut');
this.USE_SHORTCUT = ExtensionUtils.getSettings().get_boolean('use-shortcut');
if (this.USE_SHORTCUT) {
Main.wm.addKeybinding(
'notes-kb-shortcut',
Convenience.getSettings(),
ExtensionUtils.getSettings(),
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.ALL,
this._onButtonPressed.bind(this)
Expand Down Expand Up @@ -180,13 +187,13 @@ class NotesManager {

_hideNotes () {
this._onlyHideNotes();
let timeout_id = Mainloop.timeout_add(10, () => {
this._timeout_id = Mainloop.timeout_add(10, () => {
// saving to the disk is slightly delayed to give the illusion that
// the extension doesn't freeze the system
this._allNotes.forEach(function (n) {
n.onlySave(false);
});
Mainloop.source_remove(timeout_id);
return GLib.SOURCE_REMOVE;
});
}

Expand Down Expand Up @@ -295,7 +302,7 @@ class NotesManager {
}

_updateIconVisibility () {
let now_visible = !Convenience.getSettings().get_boolean('hide-icon');
let now_visible = !ExtensionUtils.getSettings().get_boolean('hide-icon');
this.panel_button.visible = now_visible;
}

Expand Down Expand Up @@ -350,6 +357,10 @@ class NotesManager {
}

this.panel_button.destroy();

Mainloop.source_remove(this._timeout_id);
// "Source ID xxxx was not found when attempting to remove it" but ok
this._timeout_id = null;
}
};

Expand Down
5 changes: 2 additions & 3 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ const _ = Gettext.gettext;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

function init() {
Convenience.initTranslations();
ExtensionUtils.initTranslations();
}

let SETTINGS = Convenience.getSettings();
let SETTINGS = ExtensionUtils.getSettings();

//------------------------------------------------------------------------------

Expand Down

0 comments on commit 3f0637e

Please sign in to comment.