From 5537aa6ffbb6b622713f2f304676458cda39a870 Mon Sep 17 00:00:00 2001 From: Wolfgang Rumpler Date: Fri, 27 Jul 2018 19:34:10 +0200 Subject: [PATCH] implement collections filter for unsplash closes #23 --- randomwallpaper@iflow.space/prefs.js | 7 +++- .../schemas/gschemas.compiled | Bin 2836 -> 2916 bytes ...ns.space.iflow.randomwallpaper.gschema.xml | 7 +++- randomwallpaper@iflow.space/settings.ui | 38 +++++++++++++++--- randomwallpaper@iflow.space/sourceAdapter.js | 10 ++++- 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/randomwallpaper@iflow.space/prefs.js b/randomwallpaper@iflow.space/prefs.js index 94829e1..9a373aa 100644 --- a/randomwallpaper@iflow.space/prefs.js +++ b/randomwallpaper@iflow.space/prefs.js @@ -161,11 +161,14 @@ var RandomWallpaperSettings = new Lang.Class({ this._builder.get_object('unsplash-keyword'), 'text', Gio.SettingsBindFlags.DEFAULT); - this._unsplash_settings.bind('username', + this._unsplash_settings.bind('unsplash-username', this._builder.get_object('unsplash-username'), 'text', Gio.SettingsBindFlags.DEFAULT); - + this._unsplash_settings.bind('unsplash-collections', + this._builder.get_object('unsplash-collections'), + 'text', + Gio.SettingsBindFlags.DEFAULT); this._unsplash_settings.bind('image-width', this._builder.get_object('unsplash-image-width'), 'value', diff --git a/randomwallpaper@iflow.space/schemas/gschemas.compiled b/randomwallpaper@iflow.space/schemas/gschemas.compiled index ec85d2230604ceff05ca37669814e0557f77112d..5ec90358666130fe5076be0b4d9e3d070a8bc084 100644 GIT binary patch delta 1061 zcmYk5Ur1A77{=eTIj2r@x@H-HQW=XF5tw9uEhvU4iAiY`HMf&n%x#_R%z|ud&p||gE=0i~N+gJ|i^!hm#G(Ta&$Hk6e&0Fo_kHWHn62mw zcK)=8sGg^7HWB$@6=@KkY|aze25?BTz9T=AFR~jv18=j74BX#7MeZ&TsRM6m9f8cHw8087D2PYt}sO z>>&xDtVB{0hwG3!G4qm~*=anmRQYdlWW$$sQf3FL$Ke@hWM;0FoVgf03x5w)wHz!b zXI={a4bE-QqltLLp9p#NgsMgT-70FtD6t+WJFfbZx~2xbv1sJ9h^N!|WvM)hQMSZ3 zxHD`8tC&x?+ux;nd&0qF$ozedgP!oZzdWRdyFy70aM#KIy*dz!MASes9E&E5NA{h@ zM{9{OYpqT5XxN(%eje%=7=FdQWiA813Lk_7lLQt6Hw-C zuY!<;z962*H$h3<^b~&OlW}bfi8bt-%ZZUBWs5rfpYhQ znfK!uoOer86S0VHHafPDH>jj}$yQ)u9IivTiOigM3Vs0!+NPf?Ak529KLo!CHD-4`;}J2F z55XTom98E8$eG>XS@>H>?{EA-&RhgO4gUn?nqg)$pW($tB5Nl%&9j~vyP1}1gso6& zamz{$Fy~_-AAFen&6QGeX0uE93ngmJn&j*ey-PChnd_5 MZ+48;6;3IC0MF0ehyVZp delta 1010 zcmXw&Ur1A77{=e@Hl5Dp`ZKc#ifS>*5ru{ti3OHOkyuFu!KV9i%l(mac4iVeZ|bH3 z;V4DWMHF2M}>tVs(8nzmZhq_dt zHyTbwWPmT=k5-z7(i5S$!Vja;Oc*_}kP!)VtG?c(9=6=J_J++_5f$x|J+`mM;D z!Sm3_{Y)EkdJpm-s31*uoncO2%yvN&8o$%;;y%zjkPmGpBbWcj6V4~edfWXw!OlL>`k?$|dQSF()lk^+>l2R#{Z7=kf|sFuH}vc#2tJ42SHGQRJ$(i8agZmnOC^*Z z?F`&Bl8Jz>MmvjqT87872t|!x6Vx(u>LWLXo_QKeyword The keyword will be used to search images. - + "" Username Only fetch random images of a given user. + + "" + Collections + Only fetch random images from a comma separated list of collections. + 1920 Image Width diff --git a/randomwallpaper@iflow.space/settings.ui b/randomwallpaper@iflow.space/settings.ui index b4f0d43..3248240 100644 --- a/randomwallpaper@iflow.space/settings.ui +++ b/randomwallpaper@iflow.space/settings.ui @@ -1,5 +1,5 @@ - + @@ -1007,7 +1007,7 @@ You can also define a prefix that will be added to the image URL. True False start - Keyword + Collections False @@ -1016,11 +1016,11 @@ You can also define a prefix that will be added to the image URL. - + True True 10 - Enter a keyword ... + ID1, ID2, ... False @@ -1028,6 +1028,32 @@ You can also define a prefix that will be added to the image URL. 3 + + + True + False + start + Keyword + + + False + True + 4 + + + + + True + True + 10 + Some keyword ... + + + False + True + 5 + + True @@ -1116,7 +1142,7 @@ You can also define a prefix that will be added to the image URL. False True - 4 + 6 @@ -1183,7 +1209,7 @@ You can also define a prefix that will be added to the image URL. False True 10 - 5 + 7 diff --git a/randomwallpaper@iflow.space/sourceAdapter.js b/randomwallpaper@iflow.space/sourceAdapter.js index 12ac24b..c4ec1fc 100644 --- a/randomwallpaper@iflow.space/sourceAdapter.js +++ b/randomwallpaper@iflow.space/sourceAdapter.js @@ -51,7 +51,7 @@ var BaseAdapter = new Lang.Class({ try { return uri !== decodeURIComponent(uri); - } catch(err) { + } catch (err) { this.logger.error(err); return false; } @@ -112,6 +112,7 @@ var UnsplashAdapter = new Lang.Class({ options: { 'username': '', 'query': '', + 'collections': [], 'w': 1920, 'h': 1080, 'featured': false @@ -179,11 +180,16 @@ var UnsplashAdapter = new Lang.Class({ _readOptionsFromSettings: function () { this.options.query = this._settings.get('unsplash-keyword', 'string'); - this.options.username = this._settings.get('username', 'string'); + this.options.username = this._settings.get('unsplash-username', 'string'); if (this.options.username && this.options.username[0] === '@') { this.options.username = this.options.username.substring(1); // remove @ prefix } + this.options.collections = this._settings.get('unsplash-collections', 'string').split(',').map( + (elem) => { + return elem.trim(); + }); + this.options.w = this._settings.get('image-width', 'int'); this.options.h = this._settings.get('image-height', 'int');