19
19
const History = imports . misc . history ;
20
20
21
21
const ExtensionUtils = imports . misc . extensionUtils ;
22
- const Me = ExtensionUtils . getCurrentExtension ( ) ;
23
- const Convenience = Me . imports . convenience ;
24
- const Prefs = Me . imports . prefs ;
25
22
26
23
let historyManagerInjections = { } ;
27
24
let settings ;
28
25
26
+ /** GNOME Shell Extension API */
29
27
function enable ( ) {
28
+ settings = ExtensionUtils . getSettings ( ) ;
29
+
30
30
historyManagerInjections [ 'prevItemPrefix' ] = undefined ;
31
31
historyManagerInjections [ 'nextItemPrefix' ] = undefined ;
32
32
historyManagerInjections [ '_onEntryKeyPress' ] = undefined ;
@@ -83,6 +83,11 @@ function enable() {
83
83
} ) ;
84
84
}
85
85
86
+ /**
87
+ * @param {object } objectPrototype - object prototype to be modified
88
+ * @param {string } functionName - name of the function to be overriden
89
+ * @param {Function } injectedFunction - new function to be injected instead of @functionName
90
+ */
86
91
function overrideFunction ( objectPrototype , functionName , injectedFunction ) {
87
92
let originalFunction = objectPrototype [ functionName ] ;
88
93
@@ -98,6 +103,11 @@ function overrideFunction(objectPrototype, functionName, injectedFunction) {
98
103
return originalFunction ;
99
104
}
100
105
106
+ /**
107
+ * @param {object } objectPrototype - object prototype to be modified
108
+ * @param {string } functionName - name of the original function after which @injectedFunction will be executed
109
+ * @param {Function } injectedFunction - new function to be executed after @functionName
110
+ */
101
111
function injectAfterFunction ( objectPrototype , functionName , injectedFunction ) {
102
112
let originalFunction = objectPrototype [ functionName ] ;
103
113
@@ -117,23 +127,33 @@ function injectAfterFunction(objectPrototype, functionName, injectedFunction) {
117
127
return originalFunction ;
118
128
}
119
129
130
+ /**
131
+ * @param {object } objectPrototype - object prototype to be modified
132
+ * @param {Function } injection - original function to be returned to the @objectPrototype
133
+ * @param {Function } functionName - name of the function in the @objectPrototype
134
+ */
120
135
function removeInjection ( objectPrototype , injection , functionName ) {
121
136
if ( injection [ functionName ] === undefined )
122
137
delete objectPrototype [ functionName ] ;
123
138
else
124
139
objectPrototype [ functionName ] = injection [ functionName ] ;
125
140
}
126
141
142
+ /** GNOME Shell Extension API */
127
143
function disable ( ) {
128
144
for ( let i in historyManagerInjections )
129
145
removeInjection ( History . HistoryManager . prototype , historyManagerInjections , i ) ;
146
+
147
+ settings = null ;
130
148
}
131
149
150
+ /** GNOME Shell Extension API */
132
151
function init ( ) {
133
- settings = Convenience . getSettings ( Prefs . PREFS_SCHEMA ) ;
134
152
}
135
153
136
- // 3.0 API backward compatibility
154
+ /**
155
+ * 3.0 API backward compatibility
156
+ */
137
157
function main ( ) {
138
158
init ( ) ;
139
159
enable ( ) ;
0 commit comments