RandomWallpaperGnome3/randomwallpaper@iflow.space/prefs.js

79 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-02-04 23:48:52 +00:00
const Gio = imports.gi.Gio;
2016-04-08 16:40:52 +00:00
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Lang = imports.lang;
2017-02-04 23:48:52 +00:00
const ExtensionUtils = imports.misc.extensionUtils;
2016-04-08 16:40:52 +00:00
2017-02-04 23:48:52 +00:00
const Self = ExtensionUtils.getCurrentExtension();
const Convenience = Self.imports.convenience;
2016-04-08 16:40:52 +00:00
2017-02-04 23:48:52 +00:00
const Gettext = imports.gettext.domain('space.iflow.randomwallpaper');
2016-04-08 16:40:52 +00:00
//const _ = Gettext.gettext;
2017-02-04 23:48:52 +00:00
const RWG_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.space.iflow.randomwallpaper';
2016-04-08 16:40:52 +00:00
function init() {
//Convenience.initTranslations();
2016-04-08 16:40:52 +00:00
}
function buildPrefsWidget() {
let settings = new RandomWallpaperSettings();
let widget = settings.widget;
widget.show_all();
2016-04-08 16:40:52 +00:00
return widget;
2016-04-08 16:40:52 +00:00
}
/* UI Setup */
2017-02-04 23:48:52 +00:00
const RandomWallpaperSettings = new Lang.Class({
Name: 'RandomWallpaper.Settings',
2017-02-04 23:48:52 +00:00
_init: function () {
this._settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA);
this._builder = new Gtk.Builder();
//this._builder.set_translation_domain(Self.metadata['gettext-domain']);
this._builder.add_from_file(Self.path + '/settings.ui');
2017-02-04 23:48:52 +00:00
this._toggleAfSliders();
2017-02-04 23:48:52 +00:00
this.widget = this._builder.get_object('main-widget');
2017-02-04 23:48:52 +00:00
this._builder.get_object('af-switch').connect('notify::active', function (toggleSwitch) {
this._toggleAfSliders();
}.bind(this));
2017-02-04 23:48:52 +00:00
this._settings.bind('history-length',
this._builder.get_object('history-length'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('minutes',
this._builder.get_object('duration-minutes'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('hours',
this._builder.get_object('duration-hours'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('source',
this._builder.get_object('source-combo'),
'active-id',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('auto-fetch',
this._builder.get_object('af-switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
},
2016-04-08 16:40:52 +00:00
_toggleAfSliders: function () {
if (this._builder.get_object('af-switch').active) {
this._builder.get_object('duration-slider-hours').set_sensitive(true);
this._builder.get_object('duration-slider-minutes').set_sensitive(true);
} else {
this._builder.get_object('duration-slider-hours').set_sensitive(false);
this._builder.get_object('duration-slider-minutes').set_sensitive(false);
}
}
2017-02-04 23:48:52 +00:00
});