mirror of
https://github.com/Hopiu/RandomWallpaperGnome3.git
synced 2026-05-24 06:33:43 +00:00
Merge branch 'develop'
This commit is contained in:
commit
0ac21855ad
10 changed files with 54 additions and 50 deletions
|
|
@ -14,7 +14,7 @@ const Self = imports.misc.extensionUtils.getCurrentExtension();
|
|||
const LoggerModule = Self.imports.logger;
|
||||
const Timer = Self.imports.timer;
|
||||
|
||||
const HistoryElement = new Lang.Class({
|
||||
var HistoryElement = new Lang.Class({
|
||||
Name: 'HistoryElement',
|
||||
Extends: PopupMenu.PopupSubMenuMenuItem,
|
||||
logger: null,
|
||||
|
|
@ -150,7 +150,7 @@ const HistoryElement = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
const CurrentImageElement = new Lang.Class({
|
||||
var CurrentImageElement = new Lang.Class({
|
||||
Name: 'CurrentImageElement',
|
||||
Extends: HistoryElement,
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ const CurrentImageElement = new Lang.Class({
|
|||
*
|
||||
* @type {Lang.Class}
|
||||
*/
|
||||
const NewWallpaperElement = new Lang.Class({
|
||||
var NewWallpaperElement = new Lang.Class({
|
||||
Name: 'NewWallpaperElement',
|
||||
Extends: PopupMenu.PopupBaseMenuItem,
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ const NewWallpaperElement = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
const StatusElement = new Lang.Class({
|
||||
var StatusElement = new Lang.Class({
|
||||
Name: 'StatusElement',
|
||||
Extends: St.Icon,
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,28 @@ const Convenience = Self.imports.convenience;
|
|||
|
||||
let wallpaperController;
|
||||
let extensionMeta;
|
||||
let panelEntry;
|
||||
|
||||
function init(metaData) {
|
||||
extensionMeta = metaData;
|
||||
wallpaperController = new WallpaperController.WallpaperController(metaData);
|
||||
}
|
||||
|
||||
let panelEntry;
|
||||
function enable() {
|
||||
// enable Extension
|
||||
// UI
|
||||
panelEntry = new RandomWallpaperEntry(0, "Random wallpaper");
|
||||
|
||||
let RandomWallpaperEntry = new Lang.Class({
|
||||
// add to panel
|
||||
Main.panel.addToStatusArea("random-wallpaper-menu", panelEntry);
|
||||
}
|
||||
|
||||
function disable() {
|
||||
// disable Extension
|
||||
panelEntry.destroy();
|
||||
}
|
||||
|
||||
var RandomWallpaperEntry = new Lang.Class({
|
||||
Extends: PanelMenu.Button,
|
||||
Name: "RandomWallpaperEntry",
|
||||
logger: null,
|
||||
|
|
@ -80,7 +93,6 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
/*
|
||||
add eventlistener
|
||||
*/
|
||||
|
||||
wallpaperController.registerStartLoadingHook(this.statusIcon.startLoading.bind(this.statusIcon));
|
||||
wallpaperController.registerStopLoadingHook(this.statusIcon.stopLoading.bind(this.statusIcon));
|
||||
wallpaperController.registerStopLoadingHook(this.setHistoryList.bind(this));
|
||||
|
|
@ -168,8 +180,6 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
this.historySection.addMenuItem(tmp);
|
||||
}
|
||||
|
||||
let _this = this;
|
||||
|
||||
function onLeave(actor) {
|
||||
wallpaperController.resetWallpaper();
|
||||
}
|
||||
|
|
@ -196,18 +206,3 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
},
|
||||
|
||||
});
|
||||
|
||||
function enable() {
|
||||
// Extension enabled
|
||||
|
||||
// UI
|
||||
panelEntry = new RandomWallpaperEntry(0, "Random wallpaper");
|
||||
|
||||
// add to panel
|
||||
Main.panel.addToStatusArea("random-wallpaper-menu", panelEntry);
|
||||
}
|
||||
|
||||
function disable() {
|
||||
// Extension disabled
|
||||
panelEntry.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const Prefs = Self.imports.settings;
|
|||
|
||||
const LoggerModule = Self.imports.logger;
|
||||
|
||||
let HistoryEntry = new Lang.Class({
|
||||
var HistoryEntry = new Lang.Class({
|
||||
Name: "HistoryEntry",
|
||||
timestamp: null,
|
||||
id: null,
|
||||
|
|
@ -29,7 +29,7 @@ let HistoryEntry = new Lang.Class({
|
|||
},
|
||||
});
|
||||
|
||||
let HistoryController = new Lang.Class({
|
||||
var HistoryController = new Lang.Class({
|
||||
Name: "HistoryController",
|
||||
_settings: null,
|
||||
_wallpaperlocation: null,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
let JSONPathParser = function () {
|
||||
var JSONPathParser = function () {
|
||||
|
||||
/**
|
||||
* Access a simple json path expression of an object.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const Lang = imports.lang;
|
||||
|
||||
let Logger = new Lang.Class({
|
||||
var Logger = new Lang.Class({
|
||||
Name: "Logger",
|
||||
_prefix: null,
|
||||
_callingClass: null,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function buildPrefsWidget() {
|
|||
}
|
||||
|
||||
/* UI Setup */
|
||||
const RandomWallpaperSettings = new Lang.Class({
|
||||
var RandomWallpaperSettings = new Lang.Class({
|
||||
Name: 'RandomWallpaper.Settings',
|
||||
logger: null,
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const Gio = imports.gi.Gio;
|
|||
const Self = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const Convenience = Self.imports.convenience;
|
||||
|
||||
let Settings = new Lang.Class({
|
||||
var Settings = new Lang.Class({
|
||||
Name: "Settings",
|
||||
_settings: null,
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const HistoryModule = Self.imports.history;
|
|||
const LoggerModule = Self.imports.logger;
|
||||
const JSONPath = Self.imports.jsonpath.jsonpath;
|
||||
|
||||
let BaseAdapter = new Lang.Class({
|
||||
var BaseAdapter = new Lang.Class({
|
||||
Name: "BaseAdapter",
|
||||
logger: null,
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ let BaseAdapter = new Lang.Class({
|
|||
fileName: function (uri) {
|
||||
let base = decodeURIComponent(uri);
|
||||
base = base.substring(base.lastIndexOf('/') + 1);
|
||||
if(base.indexOf('?') >= 0) {
|
||||
if (base.indexOf('?') >= 0) {
|
||||
base = base.substr(0, base.indexOf('?'));
|
||||
}
|
||||
return base;
|
||||
|
|
@ -45,7 +45,7 @@ let BaseAdapter = new Lang.Class({
|
|||
|
||||
});
|
||||
|
||||
let DesktopperAdapter = new Lang.Class({
|
||||
var DesktopperAdapter = new Lang.Class({
|
||||
Name: "DesktopperAdapter",
|
||||
Extends: BaseAdapter,
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ let DesktopperAdapter = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
let UnsplashAdapter = new Lang.Class({
|
||||
var UnsplashAdapter = new Lang.Class({
|
||||
Name: "UnsplashAdapter",
|
||||
Extends: BaseAdapter,
|
||||
|
||||
|
|
@ -114,27 +114,36 @@ let UnsplashAdapter = new Lang.Class({
|
|||
|
||||
this._readOptionsFromSettings();
|
||||
let optionsString = this._generateOptionsString();
|
||||
let url = 'https://api.unsplash.com/photos/random?' + optionsString;
|
||||
url += 'client_id=64daf439e9b579dd566620c0b07022706522d87b255d06dd01d5470b7f193b8d';
|
||||
let clientParam = 'client_id=64daf439e9b579dd566620c0b07022706522d87b255d06dd01d5470b7f193b8d';
|
||||
|
||||
let url = 'https://api.unsplash.com/photos/random?' + optionsString + clientParam;
|
||||
url = encodeURI(url);
|
||||
|
||||
let message = Soup.Message.new('GET', url);
|
||||
|
||||
let utmParameters = '?utm_source=RandomWallpaperGnome3&utm_medium=referral&utm_campaign=api-credit';
|
||||
let utmParameters = 'utm_source=RandomWallpaperGnome3&utm_medium=referral&utm_campaign=api-credit';
|
||||
|
||||
session.queue_message(message, (session, message) => {
|
||||
let data = JSON.parse(message.response_body.data);
|
||||
|
||||
let imageUrl = encodeURI(data.links.download + utmParameters);
|
||||
let authorName = data.user.name;
|
||||
let authorUrl = encodeURI(data.user.links.html);
|
||||
|
||||
if (callback) {
|
||||
let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(imageUrl));
|
||||
historyEntry.source.sourceUrl = encodeURI(this.sourceUrl + utmParameters);
|
||||
historyEntry.source.authorUrl = encodeURI(authorUrl + utmParameters);
|
||||
callback(historyEntry);
|
||||
}
|
||||
let downloadLocation = data.links.download_location + '?' + clientParam;
|
||||
let downloadMessage = Soup.Message.new('GET', downloadLocation);
|
||||
|
||||
session.queue_message(downloadMessage, (session, message) => {
|
||||
let downloadData = JSON.parse(message.response_body.data);
|
||||
|
||||
let imageUrl = encodeURI(downloadData.url + '&' + utmParameters);
|
||||
|
||||
if (callback) {
|
||||
let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(imageUrl));
|
||||
historyEntry.source.sourceUrl = encodeURI(this.sourceUrl + '?' + utmParameters);
|
||||
historyEntry.source.authorUrl = encodeURI(authorUrl + '?' + utmParameters);
|
||||
callback(historyEntry);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -168,7 +177,7 @@ let UnsplashAdapter = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
let WallheavenAdapter = new Lang.Class({
|
||||
var WallheavenAdapter = new Lang.Class({
|
||||
Name: "WallheavenAdapter",
|
||||
Extends: BaseAdapter,
|
||||
_settings: null,
|
||||
|
|
@ -271,7 +280,7 @@ let WallheavenAdapter = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
let GenericJsonAdapter = new Lang.Class({
|
||||
var GenericJsonAdapter = new Lang.Class({
|
||||
Name: "GenericJsonAdapter",
|
||||
Extends: BaseAdapter,
|
||||
|
||||
|
|
@ -296,7 +305,7 @@ let GenericJsonAdapter = new Lang.Class({
|
|||
let response = JSON.parse(message.response_body.data);
|
||||
let JSONPath = this._settings.get("generic-json-response-path", "string");
|
||||
let imageUrl = this._jsonPathParser.access(response, JSONPath);
|
||||
imageUrl = this._settings.get("generic-json-url-prefix", "string")+imageUrl;
|
||||
imageUrl = this._settings.get("generic-json-url-prefix", "string") + imageUrl;
|
||||
|
||||
if (callback) {
|
||||
let historyEntry = new HistoryModule.HistoryEntry(null, 'Generic JSON Source', imageUrl);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const Prefs = Self.imports.settings;
|
|||
let _afTimerInstance = null;
|
||||
|
||||
// Singleton implementation of _AFTimer
|
||||
let AFTimer = function() {
|
||||
var AFTimer = function() {
|
||||
if (!_afTimerInstance) {
|
||||
_afTimerInstance = new _AFTimer();
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ let AFTimer = function() {
|
|||
* TODO: find way to store elapsed time on shutdown/logout/gnome-shell-restart/etc.
|
||||
* @type {Lang}
|
||||
*/
|
||||
let _AFTimer = new Lang.Class({
|
||||
var _AFTimer = new Lang.Class({
|
||||
Name: 'AFTimer',
|
||||
|
||||
_timeout: null,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const HistoryModule = Self.imports.history;
|
|||
|
||||
const LoggerModule = Self.imports.logger;
|
||||
|
||||
let WallpaperController = new Lang.Class({
|
||||
var WallpaperController = new Lang.Class({
|
||||
Name: "WallpaperController",
|
||||
extensionMeta: null,
|
||||
logger: null,
|
||||
|
|
|
|||
Loading…
Reference in a new issue