From c9d1d253587d07ace69da5894ff9ce6631a06d52 Mon Sep 17 00:00:00 2001 From: Wolfgang Rumpler Date: Fri, 21 Jul 2017 01:10:26 +0200 Subject: [PATCH] Add missing 'Set As Wallpaper' button to the HistoryEntry --- randomwallpaper@iflow.space/elements.js | 14 +++++++++++++- randomwallpaper@iflow.space/extension.js | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/randomwallpaper@iflow.space/elements.js b/randomwallpaper@iflow.space/elements.js index 856cd1f..4687f94 100644 --- a/randomwallpaper@iflow.space/elements.js +++ b/randomwallpaper@iflow.space/elements.js @@ -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(); + } } }); diff --git a/randomwallpaper@iflow.space/extension.js b/randomwallpaper@iflow.space/extension.js index 0dc81e8..5a5c099 100644 --- a/randomwallpaper@iflow.space/extension.js +++ b/randomwallpaper@iflow.space/extension.js @@ -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); } },