Skip to content

Commit

Permalink
Update gnome-shell-extensions submodule + fix coding standard issues
Browse files Browse the repository at this point in the history
Notes:
- gnome-shell-extensions default branch was renamed to "main"
- Fixed issues from new ESLint rules
- Fixed issues from review https://extensions.gnome.org/review/27899
- Removed compatibility with pre-v3.34 versions of GNOME Shell
  since initTranslations() and getSettings() are present
  in extensionUtils only since
  • Loading branch information
sustmi committed Dec 3, 2022
1 parent 3c77ecc commit 09de472
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "gnome-shell-extensions"]
path = gnome-shell-extensions
url = https://gitlab.gnome.org/GNOME/gnome-shell-extensions.git
branch = main
96 changes: 0 additions & 96 deletions convenience.js

This file was deleted.

30 changes: 25 additions & 5 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
const History = imports.misc.history;

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

let historyManagerInjections = {};
let settings;

/** GNOME Shell Extension API */
function enable() {
settings = ExtensionUtils.getSettings();

historyManagerInjections['prevItemPrefix'] = undefined;
historyManagerInjections['nextItemPrefix'] = undefined;
historyManagerInjections['_onEntryKeyPress'] = undefined;
Expand Down Expand Up @@ -83,6 +83,11 @@ function enable() {
});
}

/**
* @param {object} objectPrototype - object prototype to be modified
* @param {string} functionName - name of the function to be overriden
* @param {Function} injectedFunction - new function to be injected instead of @functionName
*/
function overrideFunction(objectPrototype, functionName, injectedFunction) {
let originalFunction = objectPrototype[functionName];

Expand All @@ -98,6 +103,11 @@ function overrideFunction(objectPrototype, functionName, injectedFunction) {
return originalFunction;
}

/**
* @param {object} objectPrototype - object prototype to be modified
* @param {string} functionName - name of the original function after which @injectedFunction will be executed
* @param {Function} injectedFunction - new function to be executed after @functionName
*/
function injectAfterFunction(objectPrototype, functionName, injectedFunction) {
let originalFunction = objectPrototype[functionName];

Expand All @@ -117,23 +127,33 @@ function injectAfterFunction(objectPrototype, functionName, injectedFunction) {
return originalFunction;
}

/**
* @param {object} objectPrototype - object prototype to be modified
* @param {Function} injection - original function to be returned to the @objectPrototype
* @param {Function} functionName - name of the function in the @objectPrototype
*/
function removeInjection(objectPrototype, injection, functionName) {
if (injection[functionName] === undefined)
delete objectPrototype[functionName];
else
objectPrototype[functionName] = injection[functionName];
}

/** GNOME Shell Extension API */
function disable() {
for (let i in historyManagerInjections)
removeInjection(History.HistoryManager.prototype, historyManagerInjections, i);

settings = null;
}

/** GNOME Shell Extension API */
function init() {
settings = Convenience.getSettings(Prefs.PREFS_SCHEMA);
}

// 3.0 API backward compatibility
/**
* 3.0 API backward compatibility
*/
function main() {
init();
enable();
Expand Down
2 changes: 1 addition & 1 deletion gnome-shell-extensions
Submodule gnome-shell-extensions updated from 83c4ce to 5729d0
15 changes: 1 addition & 14 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
{
"shell-version": [
"3.6",
"3.7",
"3.7.3",
"3.8",
"3.10",
"3.12",
"3.14",
"3.16",
"3.18",
"3.20",
"3.22",
"3.24",
"3.26",
"3.28",
"3.34",
"40",
"41",
"42",
Expand Down
Loading

0 comments on commit 09de472

Please sign in to comment.