Update for Soup3 and split from official owm on ego.

Signed-off-by: Jens Lody <jens@jenslody.de>
master
Jens Lody 2 years ago
parent d714eb171c
commit 6d9003ff3d
  1. 2
      Makefile.am
  2. 2
      configure.ac
  3. 2
      data/Makefile.am
  4. 2
      data/metadata.json.in
  5. 2
      src/Makefile.am
  6. 36
      src/extension.js
  7. 35
      src/prefs.js

@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = src data po
uuid = "openweather-extension@jenslody.de"
uuid = "my-openweather-extension@jenslody.de"
localprefix = $(HOME)/.local/share/gnome-shell/extensions

@ -46,7 +46,7 @@ AC_ARG_WITH([local-install],
AC_SUBST(use_local_install)
AM_CONDITIONAL(LOCAL_INSTALL, test "x${use_local_install}" == "xyes")
extensiontopdir=${datadir}/gnome-shell/extensions/openweather-extension@jenslody.de
extensiontopdir=${datadir}/gnome-shell/extensions/my-openweather-extension@jenslody.de
dnl This is beyond ugly. Suggestions accepted.
if test "x${use_local_install}" == "xyes"; then

@ -3,7 +3,7 @@ extensionurl = https://gitlab.com/jenslody/gnome-shell-extension-openweather
# Change these to modify how installation is performed
topextensiondir = $(datadir)/gnome-shell/extensions
uuid = openweather-extension@jenslody.de
uuid = my-openweather-extension@jenslody.de
extensiondir = $(topextensiondir)/$(uuid)

@ -2,7 +2,7 @@
"uuid": "@uuid@",
"name": "OpenWeather",
"description": "Weather extension to display weather information from https://openweathermap.org/ or https://darksky.net for almost all locations in the world.\nFor openweathermap.org, you can either use the extensions default-key or register at https://openweathermap.org/appid and set the appropriate switch in the preferences dialog to \"off\".\nFor Dark Sky you have to register at https://darksky.net/dev/register and get a personal API-key.\n\nSince version 29 this extensions uses coordinates to store the locations and makes the names editable to support multiple weather-providers!\nIf you update from versions prior to 29 to 29 or greater (with darksky.net - support) you have to recreate your locations.",
"shell-version": [ "40" ],
"shell-version": [ "40", "41", "42", "43" ],
"localedir": "@LOCALEDIR@",
"url": "@url@",
"version": "@version@"

@ -1,7 +1,7 @@
# Change these to modify how installation is performed
topextensiondir = $(datadir)/gnome-shell/extensions
uuid = openweather-extension@jenslody.de
uuid = my-openweather-extension@jenslody.de
extensiondir = $(topextensiondir)/$(uuid)

@ -45,7 +45,7 @@ const OpenweathermapOrg = Me.imports.openweathermap_org;
const {
Clutter, Gio, Gtk, GLib, GObject, Soup, St
} = imports.gi;
const ByteArray = imports.byteArray;
const Gettext = imports.gettext.domain('gnome-shell-extension-openweather');
const Lang = imports.lang;
@ -965,14 +965,10 @@ class OpenweatherMenuButton extends PanelMenu.Button {
_onPreferencesActivate() {
this.menu.actor.hide();
if (typeof ExtensionUtils.openPrefs === 'function') {
ExtensionUtils.openPrefs();
} else {
Util.spawn([
"gnome-shell-extension-prefs",
Me.uuid
]);
}
Util.spawn([
"gnome-shell-extension-prefs",
Me.uuid
]);
return 0;
}
@ -1119,22 +1115,30 @@ class OpenweatherMenuButton extends PanelMenu.Button {
// abort previous requests.
_httpSession.abort();
}
let _paramsHash = Soup.form_encode_hash(params);
let _message = Soup.Message.new_from_encoded_form('GET', url, _paramsHash);
let message = Soup.form_request_new_from_hash('GET', url, params);
_httpSession.send_and_read_async(_message, GLib.PRIORITY_DEFAULT, null, (_httpSession, _message) => {
_httpSession.queue_message(message, Lang.bind(this, function(_httpSession, message) {
let _jsonString = _httpSession.send_and_read_finish(_message).get_data();
if (_jsonString instanceof Uint8Array) {
_jsonString = ByteArray.toString(_jsonString);
}
try {
if (!message.response_body.data) {
if (!_jsonString) {
fun.call(this, 0);
return;
}
let jp = JSON.parse(message.response_body.data);
let jp = JSON.parse(_jsonString);
fun.call(this, jp);
} catch (e) {
return 0;
}
catch (e) {
_httpSession.abort();
fun.call(this, 0);
return;
return 0;
}
}));
});
return;
}

@ -29,12 +29,13 @@
* <http://www.gnu.org/licenses/>.
*
*/
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const GObject = imports.gi.GObject;
const {
Gtk, Gdk, GLib, GObject, Soup
} = imports.gi;
const ByteArray = imports.byteArray;
const Gettext = imports.gettext.domain('gnome-shell-extension-openweather');
const _ = Gettext.gettext;
const Soup = imports.gi.Soup;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@ -667,7 +668,8 @@ const WeatherPrefsWidget = new GObject.Class({
let here = this;
let message = Soup.form_request_new_from_hash('GET', url, params);
let _paramsHash = Soup.form_encode_hash(params);
let _message = Soup.Message.new_from_encoded_form('GET', url, _paramsHash);
if (this.asyncSession === undefined)
this.asyncSession = {};
@ -678,21 +680,26 @@ const WeatherPrefsWidget = new GObject.Class({
}
this.asyncSession[id] = 1;
_httpSession.queue_message(message, function(_httpSession, message) {
here.asyncSession[id] = 0;
if (!message.response_body.data) {
fun.call(here, 0);
return 0;
_httpSession.send_and_read_async(_message, GLib.PRIORITY_DEFAULT, null, (_httpSession, _message) => {
let _jsonString = _httpSession.send_and_read_finish(_message).get_data();
if (_jsonString instanceof Uint8Array) {
_jsonString = ByteArray.toString(_jsonString);
}
here.asyncSession[id] = 0;
try {
let jp = JSON.parse(message.response_body.data);
if (!_jsonString) {
fun.call(here, 0);
return;
}
let jp = JSON.parse(_jsonString);
fun.call(here, jp);
} catch (e) {
return 0;
}
catch (e) {
_httpSession.abort();
fun.call(here, 0);
return 0;
}
return 0;
});
},

Loading…
Cancel
Save