-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
181 lines (159 loc) · 6.3 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
170
171
172
173
174
175
176
177
178
179
180
181
/* ========================================================================================================
* extension.js - gnome shell extension
* --------------------------------------------------------------------------------------------------------
* CREDITS: This code was copied from the dash-to-dock extension https://github.com/micheleg/dash-to-dock
* and modified to create a workspaces dock. Many thanks to michele_g for a great extension.
* ========================================================================================================
*/
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const St = imports.gi.St;
const Main = imports.ui.main;
const Config = imports.misc.config;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Intellihide = Me.imports.intellihide;
const DockedWorkspaces = Me.imports.dockedWorkspaces;
var intellihide = null;
var dock = null;
var settings = null;
var workspacesToDockStylesheet = null;
function loadStylesheet() {
// Get css filename
let filename = "workspaces-to-dock.css";
// Get default stylesheet
let themeStylesheet = Main._getDefaultStylesheet();
// Get current theme stylesheet
if (Main.getThemeStylesheet())
themeStylesheet = Main.getThemeStylesheet();
// Get theme directory
let themeDirectory = themeStylesheet.get_path() ? GLib.path_get_dirname(themeStylesheet.get_path()) : "";
// Test for workspacesToDock stylesheet
if (themeDirectory != "")
workspacesToDockStylesheet = Gio.file_new_for_path(themeDirectory + '/extensions/workspaces-to-dock/' + filename);
if (!workspacesToDockStylesheet || !workspacesToDockStylesheet.query_exists(null)) {
let defaultStylesheet = Gio.File.new_for_path(Me.path + "/themes/default/" + filename);
if (defaultStylesheet.query_exists(null)) {
workspacesToDockStylesheet = defaultStylesheet;
} else {
throw new Error(_("No Workspaces-To-Dock stylesheet found") + " (extension.js).");
}
}
let themeContext = St.ThemeContext.get_for_stage(global.stage);
if (!themeContext)
return false;
let theme = themeContext.get_theme();
if (!theme)
return false;
// Load workspacesToDock stylesheet
theme.load_stylesheet(workspacesToDockStylesheet);
return true;
}
function unloadStylesheet() {
let themeContext = St.ThemeContext.get_for_stage(global.stage);
if (!themeContext)
return false;
let theme = themeContext.get_theme();
if (!theme)
return false;
// Unload workspacesToDock stylesheet
if (workspacesToDockStylesheet)
theme.unload_stylesheet(workspacesToDockStylesheet);
workspacesToDockStylesheet = null;
return true;
}
function init() {
Convenience.initTranslations();
}
function enable() {
loadStylesheet();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
settings = Convenience.getSettings('org.gnome.shell.extensions.workspaces-to-dock');
bindSettingsChanges();
}
function disable() {
unloadStylesheet();
intellihide.destroy();
dock.destroy();
settings.run_dispose();
dock = null;
intellihide = null;
settings = null;
}
function bindSettingsChanges() {
// It's easier to just reload the extension when the dock position changes
// rather than working out all changes to the different containers.
settings.connect('changed::dock-position', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::horizontal-workspace-switching', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::dock-fixed', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::autohide-in-fullscreen', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::intellihide', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::intellihide-action', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::shortcuts-panel-orientation', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::customize-height', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::customize-height-option', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::center-thumbnails-on-dock', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::center-thumbnails-option', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
settings.connect('changed::shortcuts-panel-appsbutton-animation', function(){
intellihide.destroy();
dock.destroy();
dock = new DockedWorkspaces.DockedWorkspaces();
intellihide = new Intellihide.Intellihide(dock);
});
}