Skip to content

Commit 81a2f5c

Browse files
neffokrevadJAKuhr
authored
Version 37 (#133)
* Updated Swedish translation (#129) #14 * fix build instructions * remove lockscreen switch * use arrow functions * fix carousel, add view image button to gallery * fix purging of old images * fix missing declaration, carousel image sort * fix image cleanup #134 * fix deleteImage call * fix gtk3 gui issues * fix hidden elements in gtk4 settings * add info button to gallery * improved debug logging * dont save thumbs if delete-previous enabled * fix notify, opening images, & broken about logo * remove action from notification * update german translation (#137) * initial test import and export of JSON data #136 * fix bytearray toString() warnings * try fix ellipsized image labels #138 * purge missing files from imported image list * export bing.json by default * togglable auto export of JSON data and thumbnails * set background option in prefs fixes and don't force background zoom #38 * fix missing declaration * clean up gtk3 settings * unneeded method, fix icon switching and gtk4 prefs * code clean up remove unneeded code * switch to current image if invalid * remove functions implemented in extensionUtils.js * fix build script * code clean up * fix timeout reversions * fix carousel thumbnail logic * small tweaks to gallery ui Co-authored-by: krevad <[email protected]> Co-authored-by: JAKuhr <[email protected]>
1 parent 677b0aa commit 81a2f5c

21 files changed

+1107
-714
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ Also, check out my related [Google Earth View wallpaper extension](https://githu
1313

1414
## Features
1515

16-
* Fetches the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) and sets as both lock screen and desktop wallpaper
16+
* Automatically sets the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) as both lock screen and desktop wallpapers
1717
* Only attempts to download wallpapers when they have been updated - doesn't poll continuously
18-
* Optionally delete old images after a week, or keep them forever
19-
* Optionally force a specific region (i.e. what Bing calls a "market", some Wallpapers may relate to local holidays or locations)
18+
* Shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images)
19+
* Image gallery to view, select and curate stored images
20+
* Optionally delete old images after a week, or you can keep (and curate) them forever
21+
* Override the lockscreen blur
2022
* Language support: English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN), French (fr_FR), Portuguese (pt, pt_BR), Russian (ru_RU), Spanish (es), Korean (ko, ko_KR, ko_KP), Indonesian (id), Catalan (ca), Norwegian Bokmål (nb) & Nynorsk (ni), Swedish (sv), Arabic (ar), Hungarian (hu) and Japanese (ja) - a HUGE thanks to the translators
2123
* Image preview in menus & ability to manually set wallpapers individually or copy image to clipboard
2224
* A selection of different theme-aware indicator (tray) icons to choose (or hide it completely)
23-
* Override the lockscreen blur
24-
* NEW: shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images)
25-
* NEW: image gallery to view, select and manage stored images #115
2625

2726
## TODO
2827

@@ -36,7 +35,7 @@ Also, check out my related [Google Earth View wallpaper extension](https://githu
3635

3736
## Requirements
3837

39-
GNOME 3.28+ (Ubuntu Gnome 18.04+, Fedora 23+, older versions of the extension work with 3.18+, but are no longer supported). Blur control requires GNOME 3.36+, and may be unreliable on 3.36.3 or below. GNOME 40+ is still beta quality.
38+
GNOME 3.36+ or 40+ (Ubuntu 20.04 LTS or later, older versions of the extension work with 3.18+, but are no longer supported).
4039

4140
## Install
4241

@@ -45,22 +44,16 @@ GNOME 3.28+ (Ubuntu Gnome 18.04+, Fedora 23+, older versions of the extension wo
4544
or install directly to your GNOME extensions directory (useful if you want to hack on it)
4645

4746
```
48-
git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git $HOME/.local/share/gnome-shell/extensions/[email protected]
49-
```
50-
51-
or create a zip file by doing this
52-
53-
```
47+
mkdir ~/Desktop/source
48+
cd ~/Desktop/source
5449
git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git
5550
cd bing-wallpaper-gnome-extension
56-
sh buildzip.sh
51+
sh install.sh
5752
```
5853

59-
You can then install this file using the GNOME Tweak Tool. Please note to install an extension correctly the zip must have the metadata.json file in the base directory (not in a sub-directory), so you can't use the Github zip file to do this.
60-
6154
## Enable debug logging
6255

63-
If you run into problems, you can enable debugging using dconf-editor with this command:
56+
Enable debug logging through the exptension preferences 'Debug options' tab or if unable to open preferences you can enable debugging using dconf-editor with this command:
6457
```
6558
GSETTINGS_SCHEMA_DIR=$HOME/.local/share/gnome-shell/extensions/[email protected]/schemas dconf-editor /org/gnome/shell/extensions/bingwallpaper/
6659
```
@@ -69,16 +62,23 @@ Please include logs from your journal when submitting bug notices (make sure not
6962

7063
## Screenshots
7164

72-
Image gallery:
65+
### Image gallery
66+
7367
![Settings](/screenshot/settings5.png)
7468

75-
Preferences:
76-
![Settings](/screenshot/settings.png)![Settings](/screenshot/settings2.png)
77-
![Settings](/screenshot/settings3.png)![Settings](/screenshot/settings4.png)
69+
### Preferences
70+
71+
![Settings](/screenshot/settings.png)
72+
![Settings](/screenshot/settings2.png)
73+
![Settings](/screenshot/settings3.png)
74+
![Settings](/screenshot/settings4.png)
7875

7976

80-
Examples of adjustable blur on the lockscreen:
81-
(from left to right: no blur/no dimming, slight blur/default dimming, default blur/default dimming)
77+
### Lockscreen blur control
78+
From left to right:
79+
* no blur/no dimming
80+
* slight blur/default dimming
81+
* default blur/default dimming
8282
![Blur example](/screenshot/blurexample.jpg)
8383

8484
## Toss a coin to your coder

buildzip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ intltool-extract --type=gettext/glade ui/Settings.ui
55
intltool-extract --type=gettext/glade ui/Settings4.ui
66
intltool-extract --type=gettext/glade ui/carousel.ui
77
intltool-extract --type=gettext/glade ui/carousel4.ui
8-
xgettext -k -k_ -kN_ -o locale/BingWallpaper.pot Settings.ui.h Settings4.ui.h extension.js prefs.js blur.js utils.js convenience.js carousel.ui carousel4.ui --from-code=UTF-8
8+
xgettext -k -k_ -kN_ -o locale/BingWallpaper.pot ui/Settings.ui.h ui/Settings4.ui.h ui/carousel.ui.h ui/carousel4.ui.h extension.js prefs.js blur.js utils.js convenience.js --from-code=UTF-8
99

1010
echo "Translation status" > translations.txt
1111
for D in locale/*; do

carousel.js

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@ const { Gtk, Gdk, GdkPixbuf, Gio, GLib } = imports.gi;
1111
const Me = imports.misc.extensionUtils.getCurrentExtension();
1212
const Utils = Me.imports.utils;
1313

14-
const Convenience = Me.imports.convenience;
1514
const Gettext = imports.gettext.domain('BingWallpaper');
1615
const _ = Gettext.gettext;
17-
const default_dimensions = [30, 30, 1500, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok
16+
const default_dimensions = [30, 30, 1650, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok
1817

1918
const GALLERY_THUMB_WIDTH = 320;
2019
const GALLERY_THUMB_HEIGHT = 180;
2120

2221
var Carousel = class Carousel {
2322
constructor(settings, button = null, callbackfunc = null) {
2423
//create_gallery(widget, settings);
25-
log('create carousel...');
2624
this.settings = settings;
2725
this.button = button;
2826
this.callbackfunc = callbackfunc;
29-
this.imageList = Utils.getImageList(this.settings).reverse(); // get images and reverse order
27+
this.imageList = Utils.imageListSortByDate(Utils.getImageList(this.settings)).reverse(); // get images and reverse order
28+
this.log('create carousel...');
3029
// disable the button
3130
//if (this.button)
3231
// this.button.set_sensitive(false);
@@ -65,25 +64,23 @@ var Carousel = class Carousel {
6564
}
6665

6766
_create_gallery() {
68-
let that = this;
69-
Utils.randomIntervals.forEach(function (seconds, i) {
70-
let item = that._create_random_item(seconds, Utils.randomIntervalsTitle[i]);
67+
Utils.randomIntervals.forEach((seconds, i) => {
68+
let item = this._create_random_item(seconds, Utils.randomIntervalsTitle[i]);
7169
if (Gtk.get_major_version() < 4)
72-
that.flowBox.add(item);
70+
this.flowBox.add(item);
7371
else
74-
that.flowBox.insert(item, -1);
72+
this.flowBox.insert(item, -1);
7573
});
76-
this.imageList.forEach(function (image) {
77-
let item = that._create_gallery_item(image);
74+
this.imageList.forEach((image) => {
75+
let item = this._create_gallery_item(image);
7876
if (Gtk.get_major_version() < 4)
79-
that.flowBox.add(item);
77+
this.flowBox.add(item);
8078
else
81-
that.flowBox.insert(item, -1);
79+
this.flowBox.insert(item, -1);
8280
});
8381
}
8482

8583
_create_gallery_item(image) {
86-
let that = this;
8784
let buildable = new Gtk.Builder();
8885
if (Gtk.get_major_version() < 4) // grab appropriate object from UI file
8986
buildable.add_objects_from_file(Me.dir.get_path() + '/ui/carousel.ui', ["flowBoxChild"]);
@@ -92,7 +89,9 @@ var Carousel = class Carousel {
9289
let galleryImage = buildable.get_object('galleryImage');
9390
let imageLabel = buildable.get_object('imageLabel');
9491
let filename = Utils.imageToFilename(this.settings, image);
92+
let viewButton = buildable.get_object('viewButton');
9593
let applyButton = buildable.get_object('applyButton');
94+
let infoButton = buildable.get_object('infoButton');
9695
let deleteButton = buildable.get_object('deleteButton');
9796
try {
9897
this._load_image(galleryImage, filename);
@@ -105,33 +104,36 @@ var Carousel = class Carousel {
105104
galleryImage.set_from_icon_name('image-missing');
106105
}
107106
galleryImage.set_icon_size = 2; // Gtk.GTK_ICON_SIZE_LARGE;
108-
log('create_gallery_image: '+e);
107+
this.log('create_gallery_image: '+e);
109108
}
110-
galleryImage.set_tooltip_text(Utils.getImageTitle(image));
109+
galleryImage.set_tooltip_text(image.copyright);
111110
imageLabel.set_width_chars(60);
112111
imageLabel.set_label(Utils.shortenName(Utils.getImageTitle(image), 60));
113-
/*galleryImage.connect('clicked', function (widget) {
112+
viewButton.connect('clicked', () => {
114113
Utils.openInSystemViewer(filename);
115-
});*/
116-
applyButton.connect('clicked', function(widget) {
117-
that.settings.set_string('selected-image', Utils.getImageUrlBase(image));
118-
log('gallery selected '+Utils.getImageUrlBase(image));
119114
});
120-
deleteButton.connect('clicked', function(widget) {
121-
log('Delete requested for '+filename);
115+
applyButton.connect('clicked', () => {
116+
this.settings.set_string('selected-image', Utils.getImageUrlBase(image));
117+
this.log('gallery selected '+Utils.getImageUrlBase(image));
118+
});
119+
infoButton.connect('clicked', () => {
120+
Utils.openInSystemViewer(image.copyrightlink, false);
121+
this.log('info page link opened '+image.copyrightlink);
122+
});
123+
deleteButton.connect('clicked', (widget) => {
124+
this.log('Delete requested for '+filename);
122125
Utils.deleteImage(filename);
123-
Utils.cleanupImageList(that.settings);
124-
widget.get_parent().get_parent().destroy(); // bit of a hack
125-
if (that.callbackfunc)
126-
that.callbackfunc();
126+
Utils.cleanupImageList(this.settings);
127+
widget.get_parent().get_parent().set_visible(false); // bit of a hack
128+
if (this.callbackfunc)
129+
this.callbackfunc();
127130
});
128131
//deleteButton.set_sensitive(false);
129132
let item = buildable.get_object('flowBoxChild');
130133
return item;
131134
}
132135

133136
_create_random_item(seconds, title) {
134-
let that = this;
135137
let buildable = new Gtk.Builder();
136138
if (Gtk.get_major_version() < 4) // grab appropriate object from UI file
137139
buildable.add_objects_from_file(Me.dir.get_path() + '/ui/carousel.ui', ["flowBoxRandom"]);
@@ -142,10 +144,10 @@ var Carousel = class Carousel {
142144
let filename = 'random';
143145
let applyButton = buildable.get_object('randomButton');
144146

145-
applyButton.connect('clicked', function(widget) {
146-
that.settings.set_string('selected-image', filename);
147-
that.settings.set_int('random-interval', seconds);
148-
log('gallery selected random with interval '+seconds);
147+
applyButton.connect('clicked', (widget) => {
148+
this.settings.set_string('selected-image', filename);
149+
this.settings.set_int('random-interval', seconds);
150+
this.log('gallery selected random with interval '+seconds);
149151
});
150152
let item = buildable.get_object('flowBoxRandom');
151153
return item;
@@ -154,11 +156,11 @@ var Carousel = class Carousel {
154156
_load_image(galleryImage, filename) {
155157
let thumb_path = Utils.getWallpaperDir(this.settings)+'.thumbs/';
156158
let thumb_dir = Gio.file_new_for_path(thumb_path);
159+
let save_thumbs = !this.settings.get_boolean('delete-previous') && this.settings.get_boolean('create-thumbs'); // create thumbs only if not deleting previous and thumbs are enabled
157160
if (!thumb_dir.query_exists(null)) {
158161
thumb_dir.make_directory_with_parents(null);
159162
}
160163
let image_file = Gio.file_new_for_path(filename);
161-
//log('thumbpath -> '+ thumb_path);
162164
if (!image_file.query_exists(null)){
163165
this._set_blank_image(galleryImage);
164166
}
@@ -170,9 +172,10 @@ var Carousel = class Carousel {
170172
if (image_thumb.query_exists(null)) { // use thumbnail if available
171173
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_thumb_path);
172174
}
173-
else {
175+
else { // significantly speeds up gallery loading, but costs some addtional disk space
174176
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, GALLERY_THUMB_WIDTH, GALLERY_THUMB_HEIGHT);
175-
pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']);
177+
if (save_thumbs)
178+
pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']);
176179
}
177180
if (Gtk.get_major_version() < 4) {
178181
galleryImage.set_from_pixbuf(pixbuf);
@@ -184,7 +187,7 @@ var Carousel = class Carousel {
184187
}
185188
catch (e) {
186189
this._set_blank_image(galleryImage);
187-
log('create_gallery_image: '+e);
190+
this.log('create_gallery_image: '+e);
188191
}
189192
}
190193
}
@@ -200,4 +203,9 @@ var Carousel = class Carousel {
200203
}
201204

202205
}
206+
207+
log(msg) {
208+
if (this.settings.get_boolean('debug-logging'))
209+
print("BingWallpaper extension: " + msg); // disable to keep the noise down in journal
210+
}
203211
};

convenience.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -25,72 +25,7 @@
2525
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
*/
2727

28-
const Gettext = imports.gettext;
29-
const Gio = imports.gi.Gio;
30-
3128
const Config = imports.misc.config;
32-
const ExtensionUtils = imports.misc.extensionUtils;
33-
const Local = ExtensionUtils.getCurrentExtension();
34-
35-
/**
36-
* initTranslations:
37-
* @domain: (optional): the gettext domain to use
38-
*
39-
* Initialize Gettext to load translations from extensionsdir/locale.
40-
* If @domain is not provided, it will be taken from metadata['gettext-domain']
41-
*/
42-
function initTranslations(domain) {
43-
let extension = ExtensionUtils.getCurrentExtension();
44-
45-
domain = domain || extension.metadata['gettext-domain'];
46-
47-
// check if this extension was built with "make zip-file", and thus
48-
// has the locale files in a subfolder
49-
// otherwise assume that extension has been installed in the
50-
// same prefix as gnome-shell
51-
let localeDir = extension.dir.get_child('locale');
52-
if (localeDir.query_exists(null))
53-
Gettext.bindtextdomain(domain, localeDir.get_path());
54-
else
55-
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
56-
}
57-
58-
/**
59-
* getSettings:
60-
* @schema: (optional): the GSettings schema id
61-
*
62-
* Builds and return a GSettings schema for @schema, using schema files
63-
* in extensionsdir/schemas. If @schema is not provided, it is taken from
64-
* metadata['settings-schema'].
65-
*/
66-
function getSettings(schema) {
67-
let extension = ExtensionUtils.getCurrentExtension();
68-
69-
schema = schema || extension.metadata['settings-schema'];
70-
71-
const GioSSS = Gio.SettingsSchemaSource;
72-
73-
// check if this extension was built with "make zip-file", and thus
74-
// has the schema files in a subfolder
75-
// otherwise assume that extension has been installed in the
76-
// same prefix as gnome-shell (and therefore schemas are available
77-
// in the standard folders)
78-
let schemaDir = extension.dir.get_child('schemas');
79-
let schemaSource;
80-
if (schemaDir.query_exists(null))
81-
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
82-
GioSSS.get_default(),
83-
false);
84-
else
85-
schemaSource = GioSSS.get_default();
86-
87-
let schemaObj = schemaSource.lookup(schema, true);
88-
if (!schemaObj)
89-
throw new Error('Schema ' + schema + ' could not be found for extension '
90-
+ extension.metadata.uuid + '. Please check your installation.');
91-
92-
return new Gio.Settings({settings_schema: schemaObj});
93-
}
9429

9530
const versionArray = (v) => v.split(".").map(Number);
9631

@@ -149,8 +84,6 @@ function currentVersionSmallerEqual(v) {
14984
}
15085

15186
var exports = {
152-
initTranslations,
153-
getSettings,
15487
currentVersion,
15588
currentVersionEqual,
15689
currentVersionGreater,

0 commit comments

Comments
 (0)