Skip to content

Commit

Permalink
Remove custom getSettings in favour of ExtensionUtils.getSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
RensAlthuis committed Sep 30, 2021
1 parent f0f0dcf commit bf521f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
4 changes: 2 additions & 2 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const BuilderScope = GObject.registerClass({
}, class BuilderScope extends GObject.Object {
_init() {
super._init()
this.settings = Util.getSettings('org.gnome.shell.extensions.vertical-overview');
this.settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.vertical-overview');
}

vfunc_create_closure(builder, handlerName, flags, connectObject) {
Expand Down Expand Up @@ -50,7 +50,7 @@ function buildPrefsWidget() {
builder.set_translation_domain('gettext-domain');
builder.add_from_file(Self.dir.get_path() + '/settings.ui');

let settings = Util.getSettings('org.gnome.shell.extensions.vertical-overview');
let settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.vertical-overview');
for (var key of settings.list_keys()) {
let obj = builder.get_object(key);
let value = settings.get_value(key);
Expand Down
40 changes: 3 additions & 37 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,9 @@
const Gi = imports._gi;
const Gio = imports.gi.Gio;
const GioSSS = Gio.SettingsSchemaSource;
const ExtensionUtils = imports.misc.extensionUtils;

const Self = imports.misc.extensionUtils.getCurrentExtension();

/**
* getSettings:
* @schema: (optional): the GSettings schema id
*
* Builds and return a GSettings schema for @schema, using schema files
* in extensionsdir/schemas. If @schema is not provided, it is taken from
* metadata['settings-schema'].
*/
function getSettings(schema) {

schema = schema || extension.metadata['settings-schema'];

const GioSSS = Gio.SettingsSchemaSource;

// check if this extension was built with "make zip-file", and thus
// has the schema files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell (and therefore schemas are available
// in the standard folders)
let schemaDir = Self.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 ' + Self.metadata.uuid + '. Please check your installation.');

return new Gio.Settings({
settings_schema: schemaObj
});
}
const Self = ExtensionUtils.getCurrentExtension();

function hookVfunc(proto, symbol, func) {
proto[Gi.hook_up_vfunc_symbol](symbol, func);
Expand Down Expand Up @@ -76,7 +42,7 @@ function bindSetting(label, callback, executeOnBind = true) {
let settings = global.vertical_overview.settings;
if (!settings) {
settings = global.vertical_overview.settings = {
object: getSettings('org.gnome.shell.extensions.vertical-overview'),
object: ExtensionUtils.getSettings('org.gnome.shell.extensions.vertical-overview'),
signals: {},
callbacks: {}
};
Expand Down

0 comments on commit bf521f1

Please sign in to comment.