forked from leonardo-bartoli/gnome-shell-extension-Recents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
81 lines (64 loc) · 2.43 KB
/
settings.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
const Lang = imports.lang;
const Gio = imports.gi.Gio;
const Me = imports.misc.extensionUtils.getCurrentExtension();
function getFromSchema(extension) {
let schema = 'org.gnome.shell.extensions.recents';
const GioSSS = Gio.SettingsSchemaSource;
let schemaDir = extension.dir.get_child('schemas');
let schemaSource;
if (schemaDir.query_exists(null)) {
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
GioSSS.get_default(),
false);
} else {
schemaSource = GioSSS.get_default();
}
let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj) {
throw new Error('Schema ' + schema + ' could not be found for extension ' +
extension.metadata.uuid + '. Please check your installation.');
}
return new Gio.Settings({settings_schema: schemaObj});
}
const Settings = new Lang.Class({
Name: 'Settings',
Extends: Gio.Settings,
ItemIconSize: 16,
Position: {
RIGHT: 0,
LEFT: 1
},
_init: function() {
let schema = 'org.gnome.shell.extensions.recents';
const GioSSS = Gio.SettingsSchemaSource;
let schemaDir = Me.dir.get_child('schemas');
let schemaSource;
if (schemaDir.query_exists(null)) {
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
GioSSS.get_default(),
false);
} else {
schemaSource = GioSSS.get_default();
}
let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj) {
throw new Error('Schema ' + schema + ' could not be found for extension ' +
extension.metadata.uuid + '. Please check your installation.');
}
this.parent({settings_schema: schemaObj});
},
getPopupMenuStyle: function() {
let style = '';
let _popupMenuWidth = this.get_int('popup-menu-width');
if (_popupMenuWidth !== undefined && _popupMenuWidth !== 0) {
style += 'width:' + _popupMenuWidth + 'px;';
}
return style;
},
getPosition: function() {
if (this.get_enum('position') === this.Position.LEFT) {
return 'left';
}
return 'right';
}
});