Merge pull request #12 from ifl0w/develop

Develop
This commit is contained in:
ifl0w 2017-07-26 18:48:48 +02:00 committed by GitHub
commit 48e60c212b
10 changed files with 70 additions and 26 deletions

2
.gitignore vendored
View file

@ -1,7 +1,7 @@
.idea
# ready to deploy to gnome extensions
random-wallpaper-gnome3.zip
randomwallpaper@iflow.space.zip
# Temporary ui files
**/*~

Binary file not shown.

Before

Width:  |  Height:  |  Size: 746 KiB

After

Width:  |  Height:  |  Size: 603 KiB

View file

@ -1,7 +1,7 @@
#!/bin/bash
BASEDIR='randomwallpaper@iflow.space'
ZIPNAME='random-wallpaper-gnome3.zip'
BASEDIR="randomwallpaper@iflow.space"
ZIPNAME="$BASEDIR.zip"
rm $ZIPNAME
rm $BASEDIR/schemas/gschemas.compiled

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [[ $1 == 'prefs' ]]; then
if [ "$1" = "prefs" ]; then
gnome-shell-extension-prefs randomwallpaper@iflow.space
else
journalctl -f /usr/bin/gnome-shell

View file

@ -4,12 +4,12 @@ extensionFolder="randomwallpaper@iflow.space"
sourcepath="$PWD/$extensionFolder"
targetpath="/home/$USER/.local/share/gnome-shell/extensions"
if [[ $1 == 'uninstall' ]]; then
if [ "$1" = "uninstall" ]; then
echo "# Removing $targetpath/$extensionFolder"
rm "$targetpath/$extensionFolder"
else
echo "# Making extension directory"
mkdir -p $targetpath
echo "# Linking extension folder"
ln -s $sourcepath "$targetpath/$extensionFolder"
ln -s "$sourcepath" "$targetpath"
fi

View file

@ -3,19 +3,30 @@ const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const Tweener = imports.ui.tweener;
const Util = imports.misc.util;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Clutter = imports.gi.Clutter;
const Cogl = imports.gi.Cogl;
// Filesystem
const Gio = imports.gi.Gio;
const Self = imports.misc.extensionUtils.getCurrentExtension();
const LoggerModule = Self.imports.logger;
const Timer = Self.imports.timer;
const HistoryElement = new Lang.Class({
Name: 'HistoryElement',
Extends: PopupMenu.PopupSubMenuMenuItem,
logger: null,
historyEntry: null,
setAsWallpaperItem: null,
previewItem: null,
_previewActor: null,
_init: function (historyEntry, index) {
this.parent("", false);
this.logger = new LoggerModule.Logger('RWG3', 'HistoryElement');
let timestamp = historyEntry.timestamp;
let date = new Date(timestamp);
@ -25,12 +36,12 @@ const HistoryElement = new Lang.Class({
let prefixText;
if (index === 0) {
prefixtext = "Current Background";
prefixText = "Current Background";
} else {
prefixtext = String(index) + '.';
prefixText = String(index) + '.';
}
this.prefixLabel = new St.Label({
text: prefixtext,
text: prefixText,
style_class: 'rwg-history-index'
});
@ -60,8 +71,9 @@ const HistoryElement = new Lang.Class({
this.actor.insert_child_above(this._container, this.prefixLabel);
}
if (this.historyEntry.source && this.historyEntry.source !== null) {
this.menu.addMenuItem( new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false})); // theme independent spacing
if (this.historyEntry.source && this.historyEntry.source !== null) {
if (this.historyEntry.source.author !== null
&& this.historyEntry.source.authorUrl !== null) {
this.authorItem = new PopupMenu.PopupMenuItem('Image By: ' + this.historyEntry.source.author);
@ -88,17 +100,53 @@ const HistoryElement = new Lang.Class({
});
this.menu.addMenuItem(this.imageUrlItem);
this.setAsWallpaperItem = new PopupMenu.PopupMenuItem('Set As Wallpaper');
this.setAsWallpaperItem.connect('activate', () => {
this.emit('activate');
});
this.menu.addMenuItem(this.setAsWallpaperItem);
} else {
this.menu.addMenuItem(new PopupMenu.PopupMenuItem('Unknown source.'));
}
this.setAsWallpaperItem = new PopupMenu.PopupMenuItem('Set As Wallpaper');
this.setAsWallpaperItem.connect('activate', () => {
this.emit('activate');
});
this.previewItem = new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false});
this.menu.addMenuItem(new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false})); // theme independent spacing
this.menu.addMenuItem(this.setAsWallpaperItem);
this.menu.addMenuItem(this.previewItem);
this.menu.addMenuItem(new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false})); // theme independent spacing
/*
Load the image on first opening of the sub menu instead of during creation of the history list.
*/
this.menu.connect('open-state-changed', (self, open) => {
if (open) {
if (this._previewActor !== null) {
return;
}
try {
let width = 250; // TODO: get width or add option in settings.
let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(this.historyEntry.path, width, -1, true);
let height = pixbuf.get_height();
let image = new Clutter.Image();
let pixelFormat = pixbuf.get_has_alpha() ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888;
image.set_data(
pixbuf.get_pixels(),
pixelFormat,
width,
height,
pixbuf.get_rowstride()
);
this._previewActor = new Clutter.Actor({height: height, width: width});
this._previewActor.set_content(image);
this.previewItem.actor.add_actor(this._previewActor);
} catch (exeption) {
this.logger.error(exeption);
}
}
})
}
});

View file

@ -121,10 +121,10 @@ let RandomWallpaperEntry = new Lang.Class({
// reset it if needed
this.menu.actor.connect('hide', () => {
wallpaperController.resetWallpaper();
this.setHistoryList();
this.setHistoryList(); // TODO: move this call to a new background changed hook (because overhead on close)
});
this.menu.actor.connect('leave-event', function(e, t, a) {
this.menu.actor.connect('leave-event', () => {
wallpaperController.resetWallpaper();
});

View file

@ -109,7 +109,7 @@ let HistoryController = new Lang.Class({
* Clear the history and delete all photos except the current one.
* @returns {boolean}
*/
clear() {
clear: function() {
let firstHistoryElement = this.history[0];
if (firstHistoryElement)

View file

@ -11,7 +11,7 @@ let Logger = new Lang.Class({
},
_log: function(level, message) {
global.log(`${this._prefix} [${level}] >> ${this._callingClass} :: ${message}`);
global.log(this._prefix + " [" + level + "] >> " + this._callingClass + " :: " + message);
},
debug: function (message) {

View file

@ -1,9 +1,5 @@
{
"shell-version": [
"3.12",
"3.14",
"3.16",
"3.18",
"3.20",
"3.22",
"3.24"
@ -12,6 +8,6 @@
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
"name": "Random Wallpaper",
"description": "Fetches a random wallpaper from an online source and sets it as desktop background. \nThe desktop background can be updated periodically or manually.",
"version": "2.0.1",
"version": "2.1.0",
"url": "https://github.com/ifl0w/RandomWallpaperGnome3"
}