Add missing 'Set As Wallpaper' button to the HistoryEntry

This commit is contained in:
Wolfgang Rumpler 2017-07-21 01:10:26 +02:00
parent 608f45c63b
commit c9d1d25358
2 changed files with 16 additions and 3 deletions

View file

@ -12,6 +12,8 @@ const HistoryElement = new Lang.Class({
Extends: PopupMenu.PopupSubMenuMenuItem,
historyEntry: null,
setAsWallpaperItem: null,
_init: function (historyEntry, index) {
this.parent("", false);
@ -87,6 +89,12 @@ 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.'));
}
@ -98,8 +106,12 @@ const CurrentImageElement = new Lang.Class({
Name: 'CurrentImageElement',
Extends: HistoryElement,
_init: function(historyElement) {
_init: function (historyElement) {
this.parent(historyElement, 0);
if (this.setAsWallpaperItem !== null) {
this.setAsWallpaperItem.destroy();
}
}
});

View file

@ -168,6 +168,8 @@ let RandomWallpaperEntry = new Lang.Class({
this.historySection.addMenuItem(tmp);
}
let _this = this;
function onLeave(actor) {
wallpaperController.resetWallpaper();
}
@ -175,9 +177,8 @@ let RandomWallpaperEntry = new Lang.Class({
function onEnter(actor) {
wallpaperController.previewWallpaper(actor.historyId);
}
function onSelect(actor) {
wallpaperController.setWallpaper(actor.historyId);
wallpaperController.setWallpaper(actor.historyEntry.id);
}
},