Skip to content

Commit

Permalink
Merge pull request #31 from neffo/version-14
Browse files Browse the repository at this point in the history
Version 14:
- add support for GNOME 42
- add translation for Arabic, Italian language
- fix opening prefs
  • Loading branch information
neffo authored Mar 26, 2022
2 parents 0de887b + 607eaf6 commit 7b98149
Show file tree
Hide file tree
Showing 16 changed files with 520 additions and 147 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Lightweight GNOME shell extension to set your wallpaper to a random Google Earth

## Requirements

GNOME Shell 3.38+ (Ubuntu Gnome 21.04+), legacy support exists for earlier GNOME Shell versions (3.28+)
GNOME Shell 3.36+ (Ubuntu Gnome 20.04 LTS+), legacy support exists for earlier GNOME Shell versions (3.28+)

## Install

Expand Down
2 changes: 1 addition & 1 deletion buildzip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ npm --version && (npm test; if [ $? -ne 0 ]; then exit 1; fi)
glib-compile-schemas schemas/
intltool-extract --type=gettext/glade ui/Settings.ui
intltool-extract --type=gettext/glade ui/Settings4.ui
xgettext -k -k_ -kN_ -o locale/GoogleEarthWallpaper.pot ui/Settings.ui.h ui/Settings4.ui.h extension.js prefs.js utils.js --from-code=UTF-8
xgettext -k -k_ -kN_ --omit-header -o locale/GoogleEarthWallpaper.pot ui/Settings.ui.h ui/Settings4.ui.h extension.js prefs.js utils.js --from-code=UTF-8

for D in locale/*; do
if [ -d "${D}" ]; then
Expand Down
63 changes: 0 additions & 63 deletions convenience.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,67 +32,6 @@ const Gio = imports.gi.Gio;

const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;

/**
* initTranslations:
* @domain: (optional): the gettext domain to use
*
* Initialize Gettext to load translations from extensionsdir/locale.
* If @domain is not provided, it will be taken from metadata['gettext-domain']
*/
function initTranslations(domain) {
let extension = ExtensionUtils.getCurrentExtension();

domain = domain || extension.metadata['gettext-domain'];

// check if this extension was built with "make zip-file", and thus
// has the locale files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell
let localeDir = extension.dir.get_child('locale');
if (localeDir.query_exists(null))
Gettext.bindtextdomain(domain, localeDir.get_path());
else
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
}

/**
* getSettings:
* @schema: (optional): the GSettings schema id
*
* Builds and return a GSettings schema for @schema, using schema files
* in extensionsdir/schemas. If @schema is not provided, it is taken from
* metadata['settings-schema'].
*/
function getSettings(schema) {
let extension = ExtensionUtils.getCurrentExtension();

schema = schema || extension.metadata['settings-schema'];

const GioSSS = Gio.SettingsSchemaSource;

// check if this extension was built with "make zip-file", and thus
// has the schema files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell (and therefore schemas are available
// in the standard folders)
let schemaDir = extension.dir.get_child('schemas');
let schemaSource;
if (schemaDir.query_exists(null))
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
GioSSS.get_default(),
false);
else
schemaSource = GioSSS.get_default();

let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj)
throw new Error('Schema ' + schema + ' could not be found for extension '
+ extension.metadata.uuid + '. Please check your installation.');

return new Gio.Settings({ settings_schema: schemaObj });
}

const versionArray = (v) => v.split(".").map(Number);

const zip = function(a, b, defaultValue) {
Expand Down Expand Up @@ -150,8 +89,6 @@ function currentVersionSmallerEqual(v) {
}

var exports = {
initTranslations,
getSettings,
currentVersion,
currentVersionEqual,
currentVersionGreater,
Expand Down
10 changes: 5 additions & 5 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GEWallpaperIndicator extends panelMenu.Button {
_init (params = {}) {
super._init(0, IndicatorName, false);

this._settings = Utils.getSettings();
this._settings = ExtensionUtils.getSettings(Utils.schema);
let gicon = Gio.icon_new_for_string(Me.dir.get_child('icons').get_path() + "/" + this._settings.get_string('icon') + "-symbolic.svg");
this.icon = new St.Icon({gicon: gicon, style_class: 'system-status-icon'});
this.x_fill = true;
Expand Down Expand Up @@ -126,7 +126,7 @@ class GEWallpaperIndicator extends panelMenu.Button {
}
this.menu.addMenuItem(new popupMenu.PopupSeparatorMenuItem());
this.refreshItem.connect('activate', this._refresh.bind(this));
this.settingsItem.connect('activate', this._open_prefs.bind(this));
this.settingsItem.connect('activate', this._openPrefs.bind(this));
this.menu.addMenuItem(new popupMenu.PopupMenuItem(_("On refresh:"), {reactive : false} ));
this.menu.addMenuItem(this.wallpaperToggle);
if (!Convenience.currentVersionGreaterEqual("3.36")) { // lockscreen and desktop wallpaper are the same in GNOME 3.36+
Expand All @@ -149,8 +149,8 @@ class GEWallpaperIndicator extends panelMenu.Button {
Util.spawn(["xdg-open", this.link]);
}

_open_prefs () {
Util.spawn(["gnome-shell-extension-prefs", Me.metadata.uuid]);
_openPrefs() {
ExtensionUtils.openPrefs();
}

_restorePreviousState () {
Expand Down Expand Up @@ -408,7 +408,7 @@ class GEWallpaperIndicator extends panelMenu.Button {
});

function init(extensionMeta) {
Convenience.initTranslations("GoogleEarthWallpaper");
ExtensionUtils.initTranslations("GoogleEarthWallpaper");
}

function enable() {
Expand Down
43 changes: 12 additions & 31 deletions locale/GoogleEarthWallpaper.pot
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-19 21:56+1000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ui/Settings.ui.h:1 ui/Settings4.ui.h:1
msgid "Hide the indicator"
msgstr ""
Expand Down Expand Up @@ -92,8 +73,8 @@ msgstr ""
#: ui/Settings.ui.h:19 ui/Settings4.ui.h:20
msgid ""
"<span size=\"small\">This program comes with ABSOLUTELY NO WARRANTY.\n"
"See the <a href=\"https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
"\">GNU General Public License, version 3 or later</a> for details.</span>"
"See the <a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">GNU General "
"Public License, version 3 or later</a> for details.</span>"
msgstr ""

#: ui/Settings.ui.h:21 ui/Settings4.ui.h:22
Expand Down Expand Up @@ -190,42 +171,42 @@ msgstr ""
msgid "Something went wrong..."
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "5 m"
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "10 m"
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "30 m"
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "60 m"
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "90 m"
msgstr ""

#: prefs.js:24
#: prefs.js:26
msgid "daily"
msgstr ""

#: utils.js:62 utils.js:65
#: utils.js:33 utils.js:36
msgid "minutes"
msgstr ""

#: utils.js:68
#: utils.js:39
msgid "days"
msgstr ""

#: utils.js:71
#: utils.js:42
msgid "hours"
msgstr ""

#: utils.js:98
#: utils.js:69
msgid "No change log found for this release"
msgstr ""
Binary file added locale/ar/LC_MESSAGES/ar.mo
Binary file not shown.
Loading

0 comments on commit 7b98149

Please sign in to comment.