Skip to content

Commit

Permalink
Version 37 (#133)
Browse files Browse the repository at this point in the history
* 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 <krevad@users.noreply.github.com>
Co-authored-by: JAKuhr <9527705+JAKuhr@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 14, 2021
1 parent 677b0aa commit 81a2f5c
Show file tree
Hide file tree
Showing 21 changed files with 1,107 additions and 714 deletions.
46 changes: 23 additions & 23 deletions README.md
Expand Up @@ -13,16 +13,15 @@ Also, check out my related [Google Earth View wallpaper extension](https://githu

## Features

* 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
* Automatically sets the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) as both lock screen and desktop wallpapers
* Only attempts to download wallpapers when they have been updated - doesn't poll continuously
* Optionally delete old images after a week, or keep them forever
* Optionally force a specific region (i.e. what Bing calls a "market", some Wallpapers may relate to local holidays or locations)
* Shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images)
* Image gallery to view, select and curate stored images
* Optionally delete old images after a week, or you can keep (and curate) them forever
* Override the lockscreen blur
* 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
* Image preview in menus & ability to manually set wallpapers individually or copy image to clipboard
* A selection of different theme-aware indicator (tray) icons to choose (or hide it completely)
* Override the lockscreen blur
* NEW: shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images)
* NEW: image gallery to view, select and manage stored images #115

## TODO

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

## Requirements

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.
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).

## Install

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

```
git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com
```

or create a zip file by doing this

```
mkdir ~/Desktop/source
cd ~/Desktop/source
git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git
cd bing-wallpaper-gnome-extension
sh buildzip.sh
sh install.sh
```

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.

## Enable debug logging

If you run into problems, you can enable debugging using dconf-editor with this command:
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:
```
GSETTINGS_SCHEMA_DIR=$HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas dconf-editor /org/gnome/shell/extensions/bingwallpaper/
```
Expand All @@ -69,16 +62,23 @@ Please include logs from your journal when submitting bug notices (make sure not

## Screenshots

Image gallery:
### Image gallery

![Settings](/screenshot/settings5.png)

Preferences:
![Settings](/screenshot/settings.png)![Settings](/screenshot/settings2.png)
![Settings](/screenshot/settings3.png)![Settings](/screenshot/settings4.png)
### Preferences

![Settings](/screenshot/settings.png)
![Settings](/screenshot/settings2.png)
![Settings](/screenshot/settings3.png)
![Settings](/screenshot/settings4.png)


Examples of adjustable blur on the lockscreen:
(from left to right: no blur/no dimming, slight blur/default dimming, default blur/default dimming)
### Lockscreen blur control
From left to right:
* no blur/no dimming
* slight blur/default dimming
* default blur/default dimming
![Blur example](/screenshot/blurexample.jpg)

## Toss a coin to your coder
Expand Down
2 changes: 1 addition & 1 deletion buildzip.sh
Expand Up @@ -5,7 +5,7 @@ intltool-extract --type=gettext/glade ui/Settings.ui
intltool-extract --type=gettext/glade ui/Settings4.ui
intltool-extract --type=gettext/glade ui/carousel.ui
intltool-extract --type=gettext/glade ui/carousel4.ui
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
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

echo "Translation status" > translations.txt
for D in locale/*; do
Expand Down
80 changes: 44 additions & 36 deletions carousel.js
Expand Up @@ -11,22 +11,21 @@ const { Gtk, Gdk, GdkPixbuf, Gio, GLib } = imports.gi;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;

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

const GALLERY_THUMB_WIDTH = 320;
const GALLERY_THUMB_HEIGHT = 180;

var Carousel = class Carousel {
constructor(settings, button = null, callbackfunc = null) {
//create_gallery(widget, settings);
log('create carousel...');
this.settings = settings;
this.button = button;
this.callbackfunc = callbackfunc;
this.imageList = Utils.getImageList(this.settings).reverse(); // get images and reverse order
this.imageList = Utils.imageListSortByDate(Utils.getImageList(this.settings)).reverse(); // get images and reverse order
this.log('create carousel...');
// disable the button
//if (this.button)
// this.button.set_sensitive(false);
Expand Down Expand Up @@ -65,25 +64,23 @@ var Carousel = class Carousel {
}

_create_gallery() {
let that = this;
Utils.randomIntervals.forEach(function (seconds, i) {
let item = that._create_random_item(seconds, Utils.randomIntervalsTitle[i]);
Utils.randomIntervals.forEach((seconds, i) => {
let item = this._create_random_item(seconds, Utils.randomIntervalsTitle[i]);
if (Gtk.get_major_version() < 4)
that.flowBox.add(item);
this.flowBox.add(item);
else
that.flowBox.insert(item, -1);
this.flowBox.insert(item, -1);
});
this.imageList.forEach(function (image) {
let item = that._create_gallery_item(image);
this.imageList.forEach((image) => {
let item = this._create_gallery_item(image);
if (Gtk.get_major_version() < 4)
that.flowBox.add(item);
this.flowBox.add(item);
else
that.flowBox.insert(item, -1);
this.flowBox.insert(item, -1);
});
}

_create_gallery_item(image) {
let that = this;
let buildable = new Gtk.Builder();
if (Gtk.get_major_version() < 4) // grab appropriate object from UI file
buildable.add_objects_from_file(Me.dir.get_path() + '/ui/carousel.ui', ["flowBoxChild"]);
Expand All @@ -92,7 +89,9 @@ var Carousel = class Carousel {
let galleryImage = buildable.get_object('galleryImage');
let imageLabel = buildable.get_object('imageLabel');
let filename = Utils.imageToFilename(this.settings, image);
let viewButton = buildable.get_object('viewButton');
let applyButton = buildable.get_object('applyButton');
let infoButton = buildable.get_object('infoButton');
let deleteButton = buildable.get_object('deleteButton');
try {
this._load_image(galleryImage, filename);
Expand All @@ -105,33 +104,36 @@ var Carousel = class Carousel {
galleryImage.set_from_icon_name('image-missing');
}
galleryImage.set_icon_size = 2; // Gtk.GTK_ICON_SIZE_LARGE;
log('create_gallery_image: '+e);
this.log('create_gallery_image: '+e);
}
galleryImage.set_tooltip_text(Utils.getImageTitle(image));
galleryImage.set_tooltip_text(image.copyright);
imageLabel.set_width_chars(60);
imageLabel.set_label(Utils.shortenName(Utils.getImageTitle(image), 60));
/*galleryImage.connect('clicked', function (widget) {
viewButton.connect('clicked', () => {
Utils.openInSystemViewer(filename);
});*/
applyButton.connect('clicked', function(widget) {
that.settings.set_string('selected-image', Utils.getImageUrlBase(image));
log('gallery selected '+Utils.getImageUrlBase(image));
});
deleteButton.connect('clicked', function(widget) {
log('Delete requested for '+filename);
applyButton.connect('clicked', () => {
this.settings.set_string('selected-image', Utils.getImageUrlBase(image));
this.log('gallery selected '+Utils.getImageUrlBase(image));
});
infoButton.connect('clicked', () => {
Utils.openInSystemViewer(image.copyrightlink, false);
this.log('info page link opened '+image.copyrightlink);
});
deleteButton.connect('clicked', (widget) => {
this.log('Delete requested for '+filename);
Utils.deleteImage(filename);
Utils.cleanupImageList(that.settings);
widget.get_parent().get_parent().destroy(); // bit of a hack
if (that.callbackfunc)
that.callbackfunc();
Utils.cleanupImageList(this.settings);
widget.get_parent().get_parent().set_visible(false); // bit of a hack
if (this.callbackfunc)
this.callbackfunc();
});
//deleteButton.set_sensitive(false);
let item = buildable.get_object('flowBoxChild');
return item;
}

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

applyButton.connect('clicked', function(widget) {
that.settings.set_string('selected-image', filename);
that.settings.set_int('random-interval', seconds);
log('gallery selected random with interval '+seconds);
applyButton.connect('clicked', (widget) => {
this.settings.set_string('selected-image', filename);
this.settings.set_int('random-interval', seconds);
this.log('gallery selected random with interval '+seconds);
});
let item = buildable.get_object('flowBoxRandom');
return item;
Expand All @@ -154,11 +156,11 @@ var Carousel = class Carousel {
_load_image(galleryImage, filename) {
let thumb_path = Utils.getWallpaperDir(this.settings)+'.thumbs/';
let thumb_dir = Gio.file_new_for_path(thumb_path);
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
if (!thumb_dir.query_exists(null)) {
thumb_dir.make_directory_with_parents(null);
}
let image_file = Gio.file_new_for_path(filename);
//log('thumbpath -> '+ thumb_path);
if (!image_file.query_exists(null)){
this._set_blank_image(galleryImage);
}
Expand All @@ -170,9 +172,10 @@ var Carousel = class Carousel {
if (image_thumb.query_exists(null)) { // use thumbnail if available
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_thumb_path);
}
else {
else { // significantly speeds up gallery loading, but costs some addtional disk space
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, GALLERY_THUMB_WIDTH, GALLERY_THUMB_HEIGHT);
pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']);
if (save_thumbs)
pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']);
}
if (Gtk.get_major_version() < 4) {
galleryImage.set_from_pixbuf(pixbuf);
Expand All @@ -184,7 +187,7 @@ var Carousel = class Carousel {
}
catch (e) {
this._set_blank_image(galleryImage);
log('create_gallery_image: '+e);
this.log('create_gallery_image: '+e);
}
}
}
Expand All @@ -200,4 +203,9 @@ var Carousel = class Carousel {
}

}

log(msg) {
if (this.settings.get_boolean('debug-logging'))
print("BingWallpaper extension: " + msg); // disable to keep the noise down in journal
}
};
67 changes: 0 additions & 67 deletions convenience.js
Expand Up @@ -25,72 +25,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

const Gettext = imports.gettext;
const Gio = imports.gi.Gio;

const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
const Local = ExtensionUtils.getCurrentExtension();

/**
* initTranslations:
* @domain: (optional): the gettext domain to use
*
* Initialize Gettext to load translations from extensionsdir/locale.
* If @domain is not provided, it will be taken from metadata['gettext-domain']
*/
function initTranslations(domain) {
let extension = ExtensionUtils.getCurrentExtension();

domain = domain || extension.metadata['gettext-domain'];

// check if this extension was built with "make zip-file", and thus
// has the locale files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell
let localeDir = extension.dir.get_child('locale');
if (localeDir.query_exists(null))
Gettext.bindtextdomain(domain, localeDir.get_path());
else
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
}

/**
* 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) {
let extension = ExtensionUtils.getCurrentExtension();

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 = extension.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 '
+ extension.metadata.uuid + '. Please check your installation.');

return new Gio.Settings({settings_schema: schemaObj});
}

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

Expand Down Expand Up @@ -149,8 +84,6 @@ function currentVersionSmallerEqual(v) {
}

var exports = {
initTranslations,
getSettings,
currentVersion,
currentVersionEqual,
currentVersionGreater,
Expand Down

0 comments on commit 81a2f5c

Please sign in to comment.