Skip to content

Commit feba0da

Browse files
authored
bing-wallpaper@starcross.dev: Add force refresh menu (#6718)
1 parent d8d12f7 commit feba0da

File tree

1 file changed

+11
-3
lines changed
  • bing-wallpaper@starcross.dev/files/bing-wallpaper@starcross.dev

1 file changed

+11
-3
lines changed

bing-wallpaper@starcross.dev/files/bing-wallpaper@starcross.dev/applet.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const Gio = imports.gi.Gio;
55
const GLib = imports.gi.GLib;
66
const Mainloop = imports.mainloop;
77
const Lang = imports.lang;
8+
const PopupMenu = imports.ui.popupMenu;
9+
const St = imports.gi.St;
810

911
const logging = false;
1012

@@ -45,6 +47,12 @@ BingWallpaperApplet.prototype = {
4547
this.wallpaperPath = `${this.wallpaperDir}/BingWallpaper.jpg`;
4648
this.metaDataPath = `${this.wallpaperDir}/meta.json`;
4749

50+
let refreshBg = new PopupMenu.PopupIconMenuItem(_("Refresh Now"), "view-refresh", St.IconType.SYMBOLIC);
51+
refreshBg.connect('activate', Lang.bind(this, function() {
52+
this._downloadMetaData()
53+
}));
54+
this._applet_context_menu.addMenuItem(refreshBg);
55+
4856
// Begin refresh loop
4957
this._refresh();
5058
},
@@ -140,7 +148,7 @@ BingWallpaperApplet.prototype = {
140148

141149
_downloadMetaData: function () {
142150
const process_result = data => {
143-
151+
144152
// Write to meta data file
145153
let gFile = Gio.file_new_for_path(this.metaDataPath);
146154
let fStream = gFile.replace(null, false, Gio.FileCreateFlags.NONE, null);
@@ -157,7 +165,7 @@ BingWallpaperApplet.prototype = {
157165
this._downloadImage();
158166

159167
};
160-
168+
161169
// Retrieve json metadata, either from local file or remote
162170
let request = Soup.Message.new('GET', `${bingHost}${bingRequestPath}`);
163171
if (Soup.MAJOR_VERSION === 2) {
@@ -168,7 +176,7 @@ BingWallpaperApplet.prototype = {
168176
log(`Failed to acquire image metadata (${message.status_code})`);
169177
this._setTimeout(60) // Try again
170178
}
171-
179+
172180
});
173181
} else { //version 3
174182
_httpSession.send_and_read_async(request, Soup.MessagePriority.NORMAL, null, (_httpSession, message) => {

0 commit comments

Comments
 (0)