mirror of
https://github.com/Hopiu/RandomWallpaperGnome3.git
synced 2026-05-03 04:44:43 +00:00
Merge branch 'develop' into feature/wallheaven-controller
This commit is contained in:
commit
0815caa19f
6 changed files with 67 additions and 47 deletions
|
|
@ -3,13 +3,13 @@ RandomWallpaperGnome3
|
|||
|
||||
Random Wallpapers for Gnome 3 is a gnome shell extension which fetches a random wallpaper from an online source and sets it as desktop background.
|
||||
|
||||
## Installation
|
||||
## Installation
|
||||
|
||||
Open the commandline and type following lines
|
||||
Open the commandline and type the following lines:
|
||||
|
||||
```
|
||||
git clone git@github.com:ifl0w/RandomWallpaperGnome3.git
|
||||
ln -s RandomWallpaperGnome3/randomwallpaper@iflow.productions ~/.local/share/gnome-shell/extensions/
|
||||
cp RandomWallpaperGnome3/randomwallpaper@iflow.productions ~/.local/share/gnome-shell/extensions/
|
||||
```
|
||||
|
||||
Then open the command prompt (Alt+F2) end enter `r` without qotes.
|
||||
|
|
|
|||
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
|
|
@ -20,7 +20,7 @@ const HistoryElement = new Lang.Class({
|
|||
let timeString = date.toLocaleTimeString();
|
||||
let dateString = date.toLocaleDateString();
|
||||
|
||||
this.label = new St.Label({
|
||||
this.label = new St.Label({
|
||||
text: index,
|
||||
style_class: 'rwg-history-index'
|
||||
});
|
||||
|
|
@ -31,13 +31,13 @@ const HistoryElement = new Lang.Class({
|
|||
vertical: true
|
||||
});
|
||||
|
||||
this.dateLabel = new St.Label({
|
||||
this.dateLabel = new St.Label({
|
||||
text: dateString,
|
||||
style_class: 'rwg-history-date'
|
||||
});
|
||||
this._container.add_child(this.dateLabel);
|
||||
|
||||
this.timeLabel = new St.Label({
|
||||
this.timeLabel = new St.Label({
|
||||
text: timeString,
|
||||
style_class: 'rwg-history-time'
|
||||
});
|
||||
|
|
@ -53,9 +53,9 @@ const HistoryElement = new Lang.Class({
|
|||
const StatusElement = new Lang.Class({
|
||||
Name: 'StatusElement',
|
||||
Extends: St.Icon,
|
||||
|
||||
|
||||
_init: function() {
|
||||
|
||||
|
||||
this.parent({
|
||||
icon_name: 'preferences-desktop-wallpaper-symbolic',
|
||||
style_class: 'system-status-icon'
|
||||
|
|
@ -64,8 +64,8 @@ const StatusElement = new Lang.Class({
|
|||
let _this = this;
|
||||
|
||||
this.loadingTweenIn = {
|
||||
opacity:20,
|
||||
time:1,
|
||||
opacity:20,
|
||||
time:1,
|
||||
transition:'easeInOutSine',
|
||||
onComplete: function() {
|
||||
Tweener.addTween(_this, _this.loadingTweenOut);
|
||||
|
|
@ -73,14 +73,14 @@ const StatusElement = new Lang.Class({
|
|||
}
|
||||
|
||||
this.loadingTweenOut = {
|
||||
opacity:255,
|
||||
time:1,
|
||||
opacity:255,
|
||||
time:1,
|
||||
transition:'easeInOutSine',
|
||||
onComplete: function() {
|
||||
if (_this.isLoading) {
|
||||
Tweener.addTween(_this, _this.loadingTweenIn);
|
||||
} else {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -196,4 +196,4 @@ const DelaySlider = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
this.setHistoryList();
|
||||
|
||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||
|
||||
|
||||
// clear history button
|
||||
this.clearHistoryItem = new PopupMenu.PopupMenuItem('Clear History');
|
||||
this.menu.addMenuItem(this.clearHistoryItem);
|
||||
|
|
@ -71,6 +71,7 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
/*
|
||||
add eventlistener
|
||||
*/
|
||||
|
||||
let _this = this;
|
||||
// new wallpaper event
|
||||
this.newWallpaperItem.connect('activate', function() {
|
||||
|
|
@ -88,22 +89,25 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
|
||||
// Open Wallpaper Folder
|
||||
this.openFolder.connect('activate', function(event) {
|
||||
let now = new Date().getTime()/1000;
|
||||
let uri = GLib.filename_to_uri(wallpaperController.wallpaperlocation, "");
|
||||
Gio.AppInfo.launch_default_for_uri(uri, global.create_app_launch_context(now, -1))
|
||||
Gio.AppInfo.launch_default_for_uri(uri, global.create_app_launch_context(0, -1))
|
||||
});
|
||||
|
||||
this.menu.actor.connect('show', function() {
|
||||
wallpaperController.menuShowHook();
|
||||
});
|
||||
|
||||
// when the popupmenu disapears, check if the wallpaper is the original and
|
||||
// reset it if needed
|
||||
this.menu.actor.connect('hide', function() {
|
||||
wallpaperController.setWallpaper(_this.history[0], true);
|
||||
wallpaperController.resetWallpaper();
|
||||
_this.setHistoryList();
|
||||
});
|
||||
|
||||
this.menu.actor.connect('leave-event', function() {
|
||||
wallpaperController.previewWallpaper(_this.history[0], 400, true);
|
||||
this.menu.actor.connect('leave-event', function(e, t, a) {
|
||||
wallpaperController.resetWallpaper();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
setHistoryList: function() {
|
||||
|
|
@ -123,14 +127,14 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
tmp.actor.connect('key-focus-in', onEnter);
|
||||
tmp.actor.connect('key-focus-out', onLeave);
|
||||
tmp.actor.connect('enter-event', onEnter);
|
||||
|
||||
|
||||
tmp.connect('activate', onSelect);
|
||||
|
||||
this.historySection.addMenuItem(tmp);
|
||||
};
|
||||
|
||||
function onLeave(actor) {
|
||||
wallpaperController.previewWallpaper(history[0], 400, true);
|
||||
wallpaperController.resetWallpaper();
|
||||
}
|
||||
|
||||
function onEnter(actor) {
|
||||
|
|
@ -171,4 +175,4 @@ function enable() {
|
|||
function disable() {
|
||||
// Extension disabled
|
||||
panelEntry.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@
|
|||
"3.12",
|
||||
"3.14",
|
||||
"3.16",
|
||||
"3.18"
|
||||
"3.18",
|
||||
"3.20",
|
||||
"3.22"
|
||||
],
|
||||
"uuid": "randomwallpaper@iflow.space",
|
||||
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
|
||||
"name": "Random Wallpaper",
|
||||
"description": "Fetches a random wallpaper from desktopper.co and sets it as desktop background"
|
||||
"description": "Fetches a random wallpaper from desktopper.co and sets it as desktop background",
|
||||
"version": 1.1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ let WallpaperController = new Lang.Class({
|
|||
this.extensionMeta = extensionMeta;
|
||||
this.wallpaperlocation = this.extensionMeta.path + '/wallpapers/';
|
||||
this.history = this._loadHistory();
|
||||
this.currentWallpaper = this._getCurrentWallpaper();
|
||||
this.currentWallpaper = this._getCurrentWallpaper();
|
||||
this.imageSourceAdapter = new SourceAdapter.DesktopperAdapter();
|
||||
this.imageSourceAdapter = new SourceAdapter.WallheavenAdapter();
|
||||
},
|
||||
|
||||
/*
|
||||
/*
|
||||
forwards the request to the adapter
|
||||
*/
|
||||
_requestRandomImageFromAdapter: function(callback){
|
||||
|
|
@ -39,8 +39,8 @@ let WallpaperController = new Lang.Class({
|
|||
},
|
||||
|
||||
/*
|
||||
copy file from uri to local wallpaper direcotry and calls
|
||||
the given callback with the name and the full filepath of
|
||||
copy file from uri to local wallpaper direcotry and calls
|
||||
the given callback with the name and the full filepath of
|
||||
the written file as parameter.
|
||||
*/
|
||||
_fetchFile: function(uri, callback){
|
||||
|
|
@ -97,7 +97,7 @@ let WallpaperController = new Lang.Class({
|
|||
|
||||
_setBackground: function(path, callback){
|
||||
let background_setting = new Gio.Settings({schema: "org.gnome.desktop.background"});
|
||||
|
||||
|
||||
/*
|
||||
inspired from:
|
||||
https://bitbucket.org/LukasKnuth/backslide/src/7e36a49fc5e1439fa9ed21e39b09b61eca8df41a/backslide@codeisland.org/settings.js?at=master
|
||||
|
|
@ -123,13 +123,13 @@ let WallpaperController = new Lang.Class({
|
|||
|
||||
_getCurrentWallpaper: function() {
|
||||
let background_setting = new Gio.Settings({schema: "org.gnome.desktop.background"});
|
||||
return background_setting.get_string("picture-uri");
|
||||
return background_setting.get_string("picture-uri").replace(/^(file:\/\/)/, "");
|
||||
},
|
||||
|
||||
_loadHistory: function () {
|
||||
let directory = Gio.file_new_for_path(this.wallpaperlocation);
|
||||
let enumerator = directory.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null);
|
||||
|
||||
|
||||
let fileinfo;
|
||||
let history = [];
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ let WallpaperController = new Lang.Class({
|
|||
};
|
||||
|
||||
let name = fileinfo.get_name();
|
||||
|
||||
|
||||
// ignore hidden files
|
||||
if (name[0] != '.') {
|
||||
history.push(fileinfo.get_name());
|
||||
|
|
@ -168,6 +168,7 @@ let WallpaperController = new Lang.Class({
|
|||
historyEntry = this._setNewFileName(historyEntry);
|
||||
}
|
||||
this._setBackground(this.wallpaperlocation + historyEntry);
|
||||
this.currentWallpaper = this._getCurrentWallpaper();
|
||||
},
|
||||
|
||||
fetchNewWallpaper: function(callback) {
|
||||
|
|
@ -187,20 +188,19 @@ let WallpaperController = new Lang.Class({
|
|||
});
|
||||
},
|
||||
|
||||
previewWallpaper: function(historyid, delay, setWallpaper) {
|
||||
this.previewId = historyid;
|
||||
let _this = this;
|
||||
|
||||
delay = delay || 200;
|
||||
|
||||
if (_this.timeout) {
|
||||
_backgroundTimout: function(delay) {
|
||||
if (this.timeout) {
|
||||
return;
|
||||
};
|
||||
|
||||
let _this = this;
|
||||
delay = delay || 200;
|
||||
|
||||
this.timeout = Mainloop.timeout_add(Mainloop.PRIORITY_DEFAULT, delay, function(){
|
||||
_this.timeout = null;
|
||||
if (setWallpaper) {
|
||||
_this.setWallpaper(_this.previewId, true);
|
||||
if (_this._resetWallpaper) {
|
||||
_this._setBackground(_this.currentWallpaper);
|
||||
_this._resetWallpaper = false;
|
||||
} else {
|
||||
_this._setBackground(_this.wallpaperlocation + _this.previewId);
|
||||
}
|
||||
|
|
@ -208,7 +208,16 @@ let WallpaperController = new Lang.Class({
|
|||
});
|
||||
},
|
||||
|
||||
previewWallpaper: function(historyid, delay) {
|
||||
this.previewId = historyid;
|
||||
this._resetWallpaper = false;
|
||||
|
||||
this._backgroundTimout(delay);
|
||||
},
|
||||
|
||||
resetWallpaper: function() {
|
||||
this._resetWallpaper = true;
|
||||
this._backgroundTimout();
|
||||
},
|
||||
|
||||
getHistory: function() {
|
||||
|
|
@ -223,12 +232,12 @@ let WallpaperController = new Lang.Class({
|
|||
|
||||
let directory = Gio.file_new_for_path(this.wallpaperlocation);
|
||||
let enumerator = directory.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null);
|
||||
|
||||
|
||||
let fileinfo;
|
||||
let deleteFile;
|
||||
|
||||
do {
|
||||
|
||||
|
||||
fileinfo = enumerator.next_file(null);
|
||||
|
||||
if (!fileinfo) {
|
||||
|
|
@ -236,7 +245,7 @@ let WallpaperController = new Lang.Class({
|
|||
};
|
||||
|
||||
let name = fileinfo.get_name();
|
||||
|
||||
|
||||
// ignore hidden files and first element
|
||||
if (name[0] != '.' && name != firstHistoryElement) {
|
||||
deleteFile = Gio.file_new_for_path(this.wallpaperlocation + name);
|
||||
|
|
@ -246,6 +255,10 @@ let WallpaperController = new Lang.Class({
|
|||
} while(fileinfo);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
menuShowHook: function() {
|
||||
this.currentWallpaper = this._getCurrentWallpaper();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue