Connect UI to source adapter. Closes #17

This commit is contained in:
Wolfgang Rumpler 2017-08-09 05:49:49 +02:00
parent 281c2ae555
commit 56afb665ea
6 changed files with 16 additions and 3 deletions

View file

@ -161,6 +161,10 @@ const RandomWallpaperSettings = new Lang.Class({
this._builder.get_object('unsplash-image-height'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._unsplash_settings.bind('featured-only',
this._builder.get_object('unsplash-featured-only'),
'active',
Gio.SettingsBindFlags.DEFAULT);
},
bindWallheaven: function () {

View file

@ -94,6 +94,11 @@
<summary>Image Width</summary>
<description>The height of the image.</description>
</key>
<key type='b' name='featured-only'>
<default>false</default>
<summary>Featured images only</summary>
<description>This results in a smaller wallpaper pool but the images are considered to have higher quality.</description>
</key>
</schema>
<schema path="/org/gnome/shell/extensions/space-iflow-randomwallpaper-sources/"

View file

@ -886,7 +886,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="valign">start</property>
</object>
<packing>
<property name="left_attach">1</property>

View file

@ -95,6 +95,7 @@ let UnsplashAdapter = new Lang.Class({
'query': '',
'w': 1920,
'h': 1080,
'featured': false
},
_init: function () {
@ -152,12 +153,14 @@ let UnsplashAdapter = new Lang.Class({
this.options.query = this._settings.get('unsplash-keyword', 'string');
this.options.username = this._settings.get('username', 'string');
if (this.options.username[0] === '@') {
if (this.options.username && this.options.username[0] === '@') {
this.options.username = this.options.username.substring(1); // remove @ prefix
}
this.options.w = this._settings.get('image-width', 'int');
this.options.h = this._settings.get('image-height', 'int');
this.options.featured = this._settings.get('featured-only', 'boolean');
}
});

View file

@ -178,7 +178,8 @@ let WallpaperController = new Lang.Class({
*/
if (settings.is_writable("picture-uri")) {
// Set a new Background-Image (should show up immediately):
if (settings.set_string("picture-uri", path)) {
let rc = settings.set_string("picture-uri", path);
if (rc) {
Gio.Settings.sync(); // Necessary: http://stackoverflow.com/questions/9985140
// call callback if given