[extensions-web] api: introduce v6 API (work in progress).



commit 262011760f14d12861344f2f08c87f4c7b39f1e5
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Mon Jan 7 22:19:55 2019 +0400

    api: introduce v6 API (work in progress).
    
    With new API version it's possible now to track and change some
    GNOME Shell settings.

 sweettooth/static/js/dbus.js                   |  4 +--
 sweettooth/static/js/versions/5/main.js        | 16 ++++++++-
 sweettooth/static/js/versions/6/main.js        | 45 ++++++++++++++++++++++++++
 sweettooth/static/js/versions/common/common.js | 29 +++++++++++++++++
 4 files changed, 91 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/static/js/dbus.js b/sweettooth/static/js/dbus.js
index aa0323e..3951a1f 100644
--- a/sweettooth/static/js/dbus.js
+++ b/sweettooth/static/js/dbus.js
@@ -1,7 +1,7 @@
 /*
     GNOME Shell extensions repository
     Copyright (C) 2011-2012  Jasper St. Pierre <jstpierre mecheye net>
-    Copyright (C) 2016-2017  Yuri Konotopov <ykonotopov gnome org>
+    Copyright (C) 2016-2019  Yuri Konotopov <ykonotopov gnome org>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU Affero General Public License as published by
@@ -19,7 +19,7 @@
 define(['jquery'], function ($) {
        "use strict";
 
-       const SUPPORTED_APIS = [5];
+       const SUPPORTED_APIS = [5, 6];
        var exports = {};
 
        var load = exports.load = function (name, req, onLoad, config) {
diff --git a/sweettooth/static/js/versions/5/main.js b/sweettooth/static/js/versions/5/main.js
index 53010d0..148a053 100644
--- a/sweettooth/static/js/versions/5/main.js
+++ b/sweettooth/static/js/versions/5/main.js
@@ -1,4 +1,13 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+/*
+    GNOME Shell extensions repository
+    Copyright (C) 2012  Jasper St. Pierre <jstpierre mecheye net>
+    Copyright (C) 2017-2019  Yuri Konotopov <ykonotopov gnome org>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+ */
 
 define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
     "use strict";
@@ -15,6 +24,11 @@ define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common
         UninstallExtension: common.UninstallExtension,
         LaunchExtensionPrefs: common.LaunchExtensionPrefs,
 
+        GetUserExtensionsDisabled: common.GetUserExtensionsDisabled,
+        GetVersionValidationDisabled: common.GetVersionValidationDisabled,
+        SetUserExtensionsDisabled: common.Reject,
+        SetVersionValidationDisabled: common.Reject,
+
         ShellVersion: API.shellVersion,
         VersionValidationEnabled: typeof(API.versionValidationEnabled) == 'undefined' || 
API.versionValidationEnabled,
 
diff --git a/sweettooth/static/js/versions/6/main.js b/sweettooth/static/js/versions/6/main.js
new file mode 100644
index 0000000..571e9ad
--- /dev/null
+++ b/sweettooth/static/js/versions/6/main.js
@@ -0,0 +1,45 @@
+/*
+    GNOME Shell extensions repository
+    Copyright (C) 2019  Yuri Konotopov <ykonotopov gnome org>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+ */
+
+define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
+    "use strict";
+
+    var proxy = {
+        IsDummy: false,
+
+        ListExtensions: common.ListExtensions,
+        GetExtensionInfo: common.GetExtensionInfo,
+        GetErrors: common.GetErrors,
+        EnableExtension: common.EnableExtension,
+        DisableExtension: common.DisableExtension,
+        InstallExtension: common.InstallExtensionAsync,
+        UninstallExtension: common.UninstallExtension,
+        LaunchExtensionPrefs: common.LaunchExtensionPrefs,
+
+        GetUserExtensionsDisabled: common.GetUserExtensionsDisabled,
+        GetVersionValidationDisabled: common.GetVersionValidationDisabled,
+        SetUserExtensionsDisabled: common.SetUserExtensionsDisabled,
+        SetVersionValidationDisabled: common.SetVersionValidationDisabled,
+
+        ShellVersion: API.shellVersion,
+        VersionValidationEnabled: typeof(API.versionValidationEnabled) == 'undefined' || 
API.versionValidationEnabled,
+        UserExtensionsDisabled: API.userExtensionsDisabled,
+
+        extensionStateChangedHandler: null,
+        shellRestartHandler: null,
+        shellSettingChangedHandler: null
+    };
+
+    API.onchange = common.API_onchange(proxy);
+    API.onshellrestart = common.API_onshellrestart(proxy);
+    API.onShellSettingChanged = common.API_onShellSettingChanged(proxy);
+
+    return proxy;
+});
diff --git a/sweettooth/static/js/versions/common/common.js b/sweettooth/static/js/versions/common/common.js
index 0d3d786..7b00cc3 100644
--- a/sweettooth/static/js/versions/common/common.js
+++ b/sweettooth/static/js/versions/common/common.js
@@ -84,6 +84,26 @@ define(['jquery', 'dbus!API'], function ($, API) {
                        return _makePromise(API.uninstallExtension(uuid));
                },
 
+               GetUserExtensionsDisabled: function(disabled) {
+                       return API.userExtensionsDisabled;
+               },
+
+               GetVersionValidationDisabled: function(disabled) {
+                       return !API.versionValidationEnabled;
+               },
+
+               SetUserExtensionsDisabled: function(disabled) {
+                       return API.setUserExtensionsDisabled(disabled);
+               },
+
+               SetVersionValidationDisabled: function(disabled) {
+                       return API.setVersionValidationDisabled(disabled);
+               },
+
+               Reject: function() {
+                       return Promise.reject();
+               },
+
                API_onchange: function (proxy) {
                        return function (uuid, newState, error) {
                                if (proxy.extensionStateChangedHandler !== null)
@@ -100,6 +120,15 @@ define(['jquery', 'dbus!API'], function ($, API) {
                                        proxy.shellRestartHandler();
                                }
                        };
+               },
+
+               API_onShellSettingChanged: function (proxy) {
+                       return function (key, value) {
+                               if (proxy.shellSettingChangedHandler !== null)
+                               {
+                                       proxy.shellSettingChangedHandler(key, value);
+                               }
+                       };
                }
        };
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]