forked from mmod/mmod-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
169 lines (142 loc) · 4.62 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* package: mmod-panel
* version: 1.1.1-7
* author: Richard B. Winters <a href='mailto:[email protected]'>rik AT mmogp DOT com</a>
* copyright: 2011-2015 Massively Modified, Inc.
* license: Apache, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
*/
// Deps
const main = imports.ui.main;
const lang = imports.lang;
const sver = imports.misc.config.PACKAGE_VERSION.split( '.' );
const eutils = imports.misc.extensionUtils;
const esys = eutils.getCurrentExtension();
const lib = esys.imports.lib;
/**
* Class provides the Entry Point to MMOD-Panel for the Gnome-Shell
*
* @since 0.1.0
*/
function mmodge()
{
this.init();
}
/**
* Initializes MMOD-Panel
*
* @since 0.1.0
*/
mmodge.prototype.init = function()
{
// Setup some stuffs
this.rig = new lib.mmod.settings.rig( sver );
this.steward = new lib.mmod.settings.steward( { rig: this.rig } );
this.firstRun = false;
if( this.rig.settings.get_boolean( 'first-run' ) )
{
this.firstRun = true;
this.rig.settings.set_boolean( 'first-run', false );
}
};
/**
* Enables MMOD-Panel
*
* @since 0.1.0
*/
mmodge.prototype.enable = function()
{
this.steward.modify();
this.connect();
if( this.firstRun )
{
this.loadPreferences();
}
};
/**
* Disables MMOD-Panel
*/
mmodge.prototype.disable = function( r )
{
this.disconnect();
this.steward.unmodify();
};
/**
* Registers event handlers for the preference window signals so that we can actively
* extend the shell in real-time without requiring manual restart of the extension
* by the user
*
* @since 0.1.0
*/
mmodge.prototype.connect = function()
{
this.connections =
[
this.rig.settings.connect( 'changed::mmod-panel-enabled', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::comfort-level', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::panel-position', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::show-in-tray-menu', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::panel-button-enabled', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::panel-button-icon', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::panel-button-icon-path', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::display-favorites-enabled', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::show-running-apps', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::favorites-before-preferences', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::date-in-sys-tray', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::autohide-panel', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::autohide-pressure-threshold', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::autohide-delay', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::autohide-animation-time', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::autohide-animation-delay', lang.bind( this, this.onPreferenceChanged ) ),
this.rig.settings.connect( 'changed::hot-corner-enabled', lang.bind( this, this.onPreferenceChanged ) )
];
};
/**
* Disconnects our event handlers from the signals they are registered to
*
* @since 0.1.0
*/
mmodge.prototype.disconnect = function()
{
if( this.connections )
{
this.connections.forEach
(
function( connectionId )
{
this.rig.settings.disconnect( connectionId );
},
this
);
this.connections = null;
}
}
/**
* Restarts the extension when a preference is changed within the extension preferences
* window or ai tweak tool, or any other valid method
*
* @since 0.1.0
*/
mmodge.prototype.onPreferenceChanged = function()
{
this.disable();
this.enable();
};
/**
* Attempts to launch the extension preferences window for MMOD-Panel for the
* user
*
* @since 0.1.0
*/
mmodge.prototype.loadPreferences = function()
{
main.Util.trySpawnCommandLine( 'gnome-shell-extension-prefs ' + esys.metadata.uuid );
};
/**
* Main entry point to the application
*
* @returns { mmodge }
*/
function init()
{
return new mmodge();
}