[chrome-gnome-shell] api: add setUserExtensionsDisabled & setVersionValidationDisabled methods



commit 76dd6b854abb10c7b4f09cd0c28e21fe01aa7a5a
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Mon Jan 7 01:13:18 2019 +0400

    api: add setUserExtensionsDisabled & setVersionValidationDisabled methods

 connector/chrome-gnome-shell.py     | 29 ++++++++++++++++++++++++++++-
 extension/include/sweettooth-api.js | 26 +++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/connector/chrome-gnome-shell.py b/connector/chrome-gnome-shell.py
index 7914af3..2609536 100755
--- a/connector/chrome-gnome-shell.py
+++ b/connector/chrome-gnome-shell.py
@@ -3,7 +3,7 @@
 
 """
     GNOME Shell integration for Chrome
-    Copyright (C) 2016-2018  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 General Public License as published by
@@ -357,6 +357,17 @@ class ChromeGNOMEShell(Gio.Application):
         else:
             raise Exception("Unknown data type: %s" % type(data))
 
+    def set_shell_boolean(self, key, value):
+        source = Gio.SettingsSchemaSource.get_default()
+
+        if source is not None and source.lookup(SHELL_SCHEMA, True) is not None:
+            settings = Gio.Settings.new(SHELL_SCHEMA)
+
+            if key in settings.keys():
+                return settings.set_boolean(key, True if value else False)
+
+        return False
+
     def process_request(self, request):
         debug('Execute: to %s' % request['execute'])
 
@@ -481,6 +492,22 @@ class ChromeGNOMEShell(Gio.Application):
                                     GLib.Variant.new_tuple(GLib.Variant.new_string(request['uuid'])),
                                     "status")
 
+        elif request['execute'] == 'setUserExtensionsDisabled':
+            self.send_message({
+                'success': self.set_shell_boolean(
+                    DISABLE_USER_EXTENSIONS_KEY,
+                    request['disable']
+                )
+            })
+
+        elif request['execute'] == 'setVersionValidationDisabled':
+            self.send_message({
+                'success': self.set_shell_boolean(
+                    EXTENSION_DISABLE_VERSION_CHECK_KEY,
+                    request['disable']
+                )
+            })
+
         elif request['execute'] == 'checkUpdate':
             update_url = 'https://extensions.gnome.org/update-info/'
             enabled_only = True
diff --git a/extension/include/sweettooth-api.js b/extension/include/sweettooth-api.js
index c1c4f31..b512a0c 100644
--- a/extension/include/sweettooth-api.js
+++ b/extension/include/sweettooth-api.js
@@ -1,6 +1,6 @@
 /*
     GNOME Shell integration for Chrome
-    Copyright (C) 2016  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 General Public License as published by
@@ -65,6 +65,30 @@ window.SweetTooth = function () {
                        return sendResolveExtensionMessage("uninstallExtension", "status", {uuid: uuid});
                },
 
+               setUserExtensionsDisabled: function (disable) {
+                       return sendResolveExtensionMessage("setUserExtensionsDisabled", "success", {disable: 
disable})
+                               .then(success => {
+                                       if(success)
+                                       {
+                                               apiObject.userExtensionsDisabled = disable;
+                                       }
+
+                                       return success;
+                               });
+               },
+
+               setVersionValidationDisabled: function (disable) {
+                       return sendResolveExtensionMessage("setVersionValidationDisabled", "success", 
{disable: disable})
+                               .then(success => {
+                                       if(success)
+                                       {
+                                               apiObject.versionValidationEnabled = !disable;
+                                       }
+
+                                       return success;
+                               });
+               },
+
                initialize: function () {
                        if (SweetTooth.shellVersion !== '-1')
                        {


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