Skip to content

Commit

Permalink
Version 36 - hotfix (#126)
Browse files Browse the repository at this point in the history
* fix issues flagged at review
* add install script, fix fetch log
  • Loading branch information
neffo authored Sep 27, 2021
1 parent 294685b commit 3675ba7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion buildzip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ rm [email protected]

zip -r [email protected] *

zip -d [email protected] screenshot/* screenshot buildzip.sh npm-debug.log icons/original/* .* translations.txt *.h package.json
zip -d [email protected] screenshot/* screenshot *.sh npm-debug.log icons/original/* .* translations.txt *.h package.json *.po *.pot
1 change: 0 additions & 1 deletion carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
const { Gtk, Gdk, GdkPixbuf, Gio, GLib } = imports.gi;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const Lang = imports.lang;

const Convenience = Me.imports.convenience;
const Gettext = imports.gettext.domain('BingWallpaper');
Expand Down
11 changes: 5 additions & 6 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Utils = Me.imports.utils;
const Blur = Me.imports.blur;
const Thumbnail = Me.imports.thumbnail;
const BWClipboard = Me.imports.BWClipboard;
//const Carousel = Me.imports.carousel;
const Convenience = Me.imports.convenience;
const Gettext = imports.gettext.domain('BingWallpaper');
const _ = Gettext.gettext;
Expand Down Expand Up @@ -69,9 +68,6 @@ function doSetBackground(uri, schema) {
return (prev != uri); // return true if background uri has changed
}

let httpSession = new Soup.SessionAsync();
Soup.Session.prototype.add_feature.call(httpSession, new Soup.ProxyResolverDefault());

const BingWallpaperIndicator = GObject.registerClass(
class BingWallpaperIndicator extends PanelMenu.Button {
_init(params = {}) {
Expand Down Expand Up @@ -101,6 +97,9 @@ class BingWallpaperIndicator extends PanelMenu.Button {
// take a variety of actions when the gsettings values are modified by prefs
this._settings = Utils.getSettings();

this.httpSession = new Soup.SessionAsync();
Soup.Session.prototype.add_feature.call(this.httpSession, new Soup.ProxyResolverDefault());

getActorCompat(this).visible = !this._settings.get_boolean('hide');

// enable unsafe features on Wayland if the user overrides it
Expand Down Expand Up @@ -430,7 +429,7 @@ class BingWallpaperIndicator extends PanelMenu.Button {
log("fetching: " + BingImageURL + (market != 'auto' ? market : ''));

// queue the http request
httpSession.queue_message(request, function(httpSession, message) {
this.httpSession.queue_message(request, function(httpSession, message) {
if (message.status_code == 200) {
let data = message.response_body.data;
log("Recieved " + data.length + " bytes ");
Expand Down Expand Up @@ -653,7 +652,7 @@ class BingWallpaperIndicator extends PanelMenu.Button {
});

// queue the http request
httpSession.queue_message(request, function(httpSession, message) {
this.httpSession.queue_message(request, function(httpSession, message) {
// request completed
fstream.close(null);
that._updatePending = false;
Expand Down
9 changes: 9 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

[email protected]
INSTALL_PATH=~/.local/share/gnome-shell/extensions
[email protected]

./buildzip.sh

unzip -o $ZIP_NAME -d $INSTALL_PATH/$EXTENSION_NAME/
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "Bing Wallpaper",
"settings-schema": "org.gnome.shell.extensions.bingwallpaper",
"description": "Lightweight GNOME shell extension to set your wallpaper to today's Microsoft Bing image of the day (the image you see when you visit Bing.com).\n\n *Disclaimer*: this extension is unofficial and not affiliated with Bing or Microsoft in any way. Images are protected by copyright and are licensed only for use as wallpapers.\n\nThis extension is based extensively on the NASA APOD extension by Elinvention (https://github.com/Elinvention) and inspired by Bing Desktop Wallpaper Changer by Utkarsh Gupta (https://github.com/UtkarshGpta).\n\nFeatures:\n* Fetches Bing wallpaper of the day and sets as both lock screen and desktop wallpaper (user selectable on GNOME versions that support it)\n* Optionally force a specific region (i.e. locale)\n* UHD supported resolutions\n* Only attempts to download wallpapers when they have been updated\n* Doesn't poll continuously - only once per day and on startup (schedules a refresh when Bing is due to update)\n *NEW: random mode\n *NEW: select wallpaper from previously downloaded images\n* 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 Finnish (fi_FI) - a HUGE thanks to the translators\n\nAlways restart GNOME after manually updating extensions. Please report bugs to the GitHub page below:",
"version": "35",
"version": "36",
"url": "https://github.com/neffo/bing-wallpaper-gnome-extension"
}
16 changes: 9 additions & 7 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
// See the GNU General Public License, version 3 or later for details.
// Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod

const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
imports.gi.versions.Soup = '2.4';

const {Gtk, Gdk, GdkPixbuf, Gio, GLib, Soup} = imports.gi;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const Convenience = Me.imports.convenience;
Expand All @@ -27,11 +25,11 @@ let lastreq = null;
let provider = new Gtk.CssProvider();

let carousel = null;
let httpSession = null;

const BingImageURL = Utils.BingImageURL;

function init() {
settings = Utils.getSettings(Me);
Convenience.initTranslations("BingWallpaper");
}

Expand Down Expand Up @@ -83,6 +81,10 @@ function buildPrefsWidget() {
let buttonGDMdefault = buildable.get_object('button_default_gnome');
let buttonnoblur = buildable.get_object('button_no_blur');
let buttonslightblur = buildable.get_object('button_slight_blur');

settings = Utils.getSettings(Me);
httpSession = new Soup.SessionAsync();
Soup.Session.prototype.add_feature.call(httpSession, new Soup.ProxyResolverDefault());

// check that these are valid (can be edited through dconf-editor)
//Utils.validate_market(settings, marketDescription);
Expand Down Expand Up @@ -230,7 +232,7 @@ function buildPrefsWidget() {
box.show_all();

// fetch
Utils.fetch_change_log(Me.metadata.version.toString(), change_log);
Utils.fetch_change_log(Me.metadata.version.toString(), change_log, httpSession);
lastreq = GLib.DateTime.new_now_utc();

return box;
Expand Down
7 changes: 2 additions & 5 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ const Convenience = Me.imports.convenience;
const Gettext = imports.gettext.domain('BingWallpaper');
const _ = Gettext.gettext;

let httpSession = new Soup.SessionAsync();
Soup.Session.prototype.add_feature.call(httpSession, new Soup.ProxyResolverDefault());

var PRESET_GNOME_DEFAULT = { blur: 60, dim: 55 }; // as at GNOME 40
var PRESET_NO_BLUR = { blur: 0, dim: 60 };
var PRESET_SLIGHT_BLUR = { blur: 2, dim: 60 };
Expand Down Expand Up @@ -130,7 +127,7 @@ function validate_imagename(settings) {
}
}

function validate_market(settings, marketDescription = null, lastreq = null) {
function validate_market(settings, marketDescription = null, lastreq = null, httpSession) {
let market = settings.get_string('market');
if (market == "" || markets.indexOf(market) == -1) { // if not a valid market
settings.reset('market');
Expand Down Expand Up @@ -175,7 +172,7 @@ function get_current_bg(schema) {

let gitreleaseurl = 'https://api.github.com/repos/neffo/bing-wallpaper-gnome-extension/releases/tags/';

function fetch_change_log(version, label) {
function fetch_change_log(version, label, httpSession) {
// create an http message
let url = gitreleaseurl + "v" + version;
let request = Soup.Message.new('GET', url);
Expand Down

0 comments on commit 3675ba7

Please sign in to comment.