From 58fa6edd9222e4518e22ecc0f1ea0edbc045ae07 Mon Sep 17 00:00:00 2001 From: Jason DeRose Date: Mon, 3 May 2021 09:46:24 -0400 Subject: [PATCH] Remove new version checker --- Makefile | 8 +- Settings.ui | 141 ----------- extension.js | 1 - prefs.js | 16 -- ...shell.extensions.dash-to-panel.gschema.xml | 9 - update.js | 235 ------------------ 6 files changed, 2 insertions(+), 408 deletions(-) delete mode 100644 update.js diff --git a/Makefile b/Makefile index b29aff1..ecb8803 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ UUID = dash-to-panel@jderose9.github.com BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md -EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelSettings.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui +EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelSettings.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js utils.js Settings.ui EXTRA_IMAGES = highlight_stacked_bg.svg highlight_stacked_bg_2.svg highlight_stacked_bg_3.svg -TOLOCALIZE = prefs.js appIcons.js update.js +TOLOCALIZE = prefs.js appIcons.js MSGSRC = $(wildcard po/*.po) ifeq ($(strip $(DESTDIR)),) INSTALLBASE = $(HOME)/.local/share/gnome-shell/extensions @@ -77,10 +77,6 @@ _build: all mkdir -p _build cp $(BASE_MODULES) $(EXTRA_MODULES) _build -ifeq ($(TARGET),ego) - find _build -name '*.js' -exec sed -i '/\/\/!start-update/,/\/\/!end-update/d' {} + -endif - mkdir -p _build/img cd img ; cp $(EXTRA_IMAGES) ../_build/img/ mkdir -p _build/schemas diff --git a/Settings.ui b/Settings.ui index 5e0aa08..9589a20 100644 --- a/Settings.ui +++ b/Settings.ui @@ -8129,147 +8129,6 @@ 1 - - - False - 20 - 0 - in - - - True - False - none - - - True - True - - - True - False - 12 - 12 - 12 - 12 - 6 - 32 - - - True - False - True - This allows you to update the extension directly from the GitHub repository. - True - True - 0 - - - - 0 - 1 - 2 - - - - - True - False - start - Updates - - - 0 - 0 - 2 - - - - - True - False - start - Periodically check for updates - - - 0 - 3 - - - - - True - False - end - 6 - - - True - True - end - center - - - False - True - 0 - - - - - Check now - True - True - True - end - center - - - False - True - 1 - - - - - 1 - 3 - - - - - True - False - 12 - <span weight="bold" color="#B42B30">Be aware, these official Dash to Panel releases might not be reviewed yet on extensions.gnome.org!</span> <a href="https://extensions.gnome.org/about/">Read more</a> - True - True - 0 - - - 0 - 2 - 2 - - - - - - - - - - - - - - False - True - 2 - - True diff --git a/extension.js b/extension.js index eb41e83..8ab108f 100644 --- a/extension.js +++ b/extension.js @@ -91,7 +91,6 @@ function _enable() { Me.settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel'); Me.desktopSettings = Convenience.getSettings('org.gnome.desktop.interface'); - Me.imports.update.init(); panelManager = new PanelManager.dtpPanelManager(); panelManager.enable(); diff --git a/prefs.js b/prefs.js index 2579fe2..d402d6b 100644 --- a/prefs.js +++ b/prefs.js @@ -34,7 +34,6 @@ const Convenience = Me.imports.convenience; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; const N_ = function(e) { return e }; -const Update = Me.imports.update; const PanelSettings = Me.imports.panelSettings; const Pos = Me.imports.panelPositions; @@ -2165,21 +2164,6 @@ const Settings = new Lang.Class({ ); }); - let updateCheckSwitch = this._builder.get_object('updates_check_switch'); - - updateCheckSwitch.set_sensitive(false); - - this._builder.get_object('updates_check_now_button').connect('clicked', widget => { - this._settings.set_boolean('force-check-update', true); - }); - -//!start-update - updateCheckSwitch.set_sensitive(true); - this._settings.bind('check-update', - updateCheckSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT); -//!end-update }, _setPreviewTitlePosition: function() { diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 6e269db..2c9e86a 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -64,15 +64,6 @@ - - false - - - false - - - '' - 'BOTTOM' Panel position (Deprecated) diff --git a/update.js b/update.js deleted file mode 100644 index e8b2982..0000000 --- a/update.js +++ /dev/null @@ -1,235 +0,0 @@ -/* - * This file is part of the Dash-To-Panel extension for Gnome 3 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const Soup = imports.gi.Soup; -const FileUtils = imports.misc.fileUtils; - -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - -let apiUrl = ''; - -function init() { - Me.settings.connect('changed::force-check-update', () => { - if (Me.settings.get_boolean('force-check-update')) { - checkForUpdate(true); - Me.settings.set_boolean('force-check-update', false); - } - }); - -//!start-update - //check for update now, then every 4 hours - checkForUpdate(); - imports.mainloop.timeout_add(14400000, () => checkForUpdate()); - - Me.settings.connect('changed::version-to-install', () => installRelease(Me.settings.get_string('version-to-install'), true)); -//!end-update -} - -function checkForUpdate(fromSettings) { - if (!apiUrl) { - return notifyError(_('Unavailable when installed from extensions.gnome.org')); - } - -//!start-update - if (fromSettings || Me.settings.get_boolean('check-update')) { - getLatestReleaseInfo((err, latestRelease) => { - if (err) { - return notifyError(err); - } - - let latestVersion = latestRelease.tag.substring(1); - - if (Me.metadata.version < latestVersion && latestRelease.zipUrl) { - notify( - _('Version %s (%s) is available').format(latestVersion, latestRelease.name), - [{ text: _('Details'), func: () => imports.misc.util.spawn(['xdg-open', latestRelease.url]) }, - { text: _('Update'), func: () => installRelease(latestRelease.zipUrl, fromSettings) }] - ); - } else if (fromSettings) { - notify(_('Already up to date')); - } - }); - } -//!end-update -} - -function notifyError(err) { - Me.imports.utils.notify(_('Error: ') + err, 'dialog-error', null, true); -} - -function notify(msg, action) { - Me.imports.utils.notify(msg, 'dialog-information', action, true); -} - -//!start-update -apiUrl = 'https://api.github.com/repos/home-sweet-gnome/dash-to-panel/'; -const tagsApiUrl = apiUrl + 'tags'; -const releasesApiUrl = apiUrl + 'releases'; - -let httpSession; - -function getLatestReleaseInfo(cb) { - getReleaseInfo('/latest', cb); -} - -function getTaggedReleaseInfo(releaseTag, cb) { - getReleaseInfo('/tags/' + releaseTag, cb); -} - -function getReleaseInfo(suffix, cb) { - getHttpMessageResponseBody(createGet(releasesApiUrl + suffix), (err, body) => { - if (err) { - return cb(err); - } - - try { - let release = JSON.parse(body.data); - let releaseInfo = { - name: release.name, - tag: release.tag_name, - url: release.html_url, - zipUrl: (release.assets.length ? release.assets[0].browser_download_url : 0), - }; - - cb(null, releaseInfo); - } catch (e) { - cb(e.message); - } - }); -} - -function installRelease(releaseAssetUrl, fromSettings) { - getHttpMessageResponseBody(createGet(releaseAssetUrl), (err, body) => { - if (err) { - return notifyInstallResult(err); - } - - let name = 'dtp_install'; - let zipFile = createTmp(name + '.zip'); - let stream = zipFile.replace(null, false, Gio.FileCreateFlags.NONE, null); - let extDir = Gio.file_new_for_path(Me.path); - let tmpDir = createTmp(name, true); - let bckDir = createTmp(Me.uuid, true); - - stream.write_bytes(body.flatten().get_as_bytes(), null); - stream.close(null); - - unzipFile(zipFile, tmpDir, err => { - if (err) { - return notifyInstallResult(err); - } - - try { - FileUtils.recursivelyMoveDir(extDir, bckDir); - FileUtils.recursivelyMoveDir(tmpDir, extDir); - - if (fromSettings) { - let [success, out, err, exitCode] = GLib.spawn_command_line_sync('pidof "gnome-shell-extension-prefs"'); - - if (success && !exitCode) { - GLib.spawn_command_line_sync('kill -9 ' + imports.byteArray.toString(out)); - } - } - } catch (e) { - FileUtils.recursivelyDeleteDir(extDir, false); - FileUtils.recursivelyMoveDir(bckDir, extDir); - - return notifyInstallResult(e.message); - } - - notifyInstallResult(null); - }); - }); -} - -function notifyInstallResult(err) { - if (err) { - notifyError(err); - } else if (imports.gi.Meta.is_wayland_compositor()) { - notify( - _('Update successful, please log out/in'), - { text: _('Log out'), func: () => new imports.misc.systemActions.getDefault().activateLogout() } - ); - } else { - notify( - _('Update successful, please restart GNOME Shell'), - { text: _('Restart GNOME Shell'), func: () => imports.gi.Meta.restart(_("Restarting GNOME Shell...")) } - ); - } -} - -function createTmp(name, isDir) { - let tmp = Gio.file_new_for_path('/tmp/' + name); - - if (isDir && tmp.query_exists(null)) { - FileUtils.recursivelyDeleteDir(tmp, false); - } - - return tmp; -} - -function unzipFile(zipFile, destDir, cb) { - let [success, pid] = GLib.spawn_async( - null, - ['unzip', '-uod', destDir.get_path(), '--', zipFile.get_path()], - null, - GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.STDOUT_TO_DEV_NULL, - null - ); - - if (!success) { - return cb('unzip spawn error'); - } - - GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, (pid, status) => { - GLib.spawn_close_pid(pid); - - if (status != 0) { - return cb('extraction error') - } - - return cb(null); - }); -} - -function createGet(url, params) { - return Soup.form_request_new_from_hash('GET', url, params || {}); -} - -function getHttpMessageResponseBody(message, cb) { - if (!httpSession) { - httpSession = new Soup.Session(); - httpSession.user_agent = Me.metadata.uuid; - } - - httpSession.queue_message(message, (httpSession, message) => { - try { - if (!message.response_body || !message.response_body.data) { - return cb('No data received'); - } - - return cb(null, message.response_body); - } catch (e) { - return cb(e.message); - } - }); -} -//!end-update