Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected]: Add force refresh menu. #6718

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions [email protected]/files/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Mainloop = imports.mainloop;
const Lang = imports.lang;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;

const logging = false;

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

let refreshBg = new PopupMenu.PopupIconMenuItem(_("Refresh Now"), "view-refresh", St.IconType.SYMBOLIC);
refreshBg.connect('activate', Lang.bind(this, function() {
this._downloadMetaData()
}));
this._applet_context_menu.addMenuItem(refreshBg);

// Begin refresh loop
this._refresh();
},
Expand Down Expand Up @@ -140,7 +148,7 @@ BingWallpaperApplet.prototype = {

_downloadMetaData: function () {
const process_result = data => {

rcalixte marked this conversation as resolved.
Show resolved Hide resolved
// Write to meta data file
let gFile = Gio.file_new_for_path(this.metaDataPath);
let fStream = gFile.replace(null, false, Gio.FileCreateFlags.NONE, null);
Expand All @@ -157,7 +165,7 @@ BingWallpaperApplet.prototype = {
this._downloadImage();

};

// Retrieve json metadata, either from local file or remote
let request = Soup.Message.new('GET', `${bingHost}${bingRequestPath}`);
if (Soup.MAJOR_VERSION === 2) {
Expand All @@ -168,7 +176,7 @@ BingWallpaperApplet.prototype = {
log(`Failed to acquire image metadata (${message.status_code})`);
this._setTimeout(60) // Try again
}

});
} else { //version 3
_httpSession.send_and_read_async(request, Soup.MessagePriority.NORMAL, null, (_httpSession, message) => {
Expand Down
Loading