[chrome-gnome-shell] extension: added light toolbar icon for dark themes.



commit a3ea0f04d882751448b13563d8fae0071a65e33d
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Sun Jan 28 12:48:14 2018 +0400

    extension: added light toolbar icon for dark themes.
    
    Fixes: https://github.com/nE0sIghT/chrome-gnome-shell-mirror/issues/85

 extension/_locales/en/messages.json    |    4 ++
 extension/extension.html               |    1 +
 extension/extension.js                 |    4 +-
 extension/icons/GnomeLogo-light-16.png |  Bin 0 -> 370 bytes
 extension/icons/GnomeLogo-light-32.png |  Bin 0 -> 884 bytes
 extension/include/constants.js         |    5 +-
 extension/include/toolbar.js           |   65 ++++++++++++++++++++++++++++++++
 extension/options.html                 |    7 +++
 extension/options.js                   |   45 ++++++++++++++--------
 po/template.pot                        |    7 +++-
 10 files changed, 118 insertions(+), 20 deletions(-)
---
diff --git a/extension/_locales/en/messages.json b/extension/_locales/en/messages.json
index 7eb13de..ae68ed8 100644
--- a/extension/_locales/en/messages.json
+++ b/extension/_locales/en/messages.json
@@ -119,6 +119,10 @@
                "message": "Next check",
                "description": "This is a start of phrase (followed by date/time) of next GNOME Shell 
extensions update check."
        },
+       "options_use_light_icon": {
+               "message": "Use light icon (dark theme)",
+               "description": "Use light icon that is looked better with dark themes."
+       },
        "synchronization": {
                "message": "Synchronization",
                "description": "Link name for synchronization tab in options dialog."
diff --git a/extension/extension.html b/extension/extension.html
index c0b9f0c..a615296 100644
--- a/extension/extension.html
+++ b/extension/extension.html
@@ -15,6 +15,7 @@
                <script src="include/notifications.js"></script>
                <script src="include/update.js"></script>
                <script src="include/sync.js"></script>
+               <script src="include/toolbar.js"></script>
                <script src="extension.js"></script>
        </body>
 </html>
diff --git a/extension/extension.js b/extension/extension.js
index 89829ca..5994ae0 100644
--- a/extension/extension.js
+++ b/extension/extension.js
@@ -1,6 +1,6 @@
 /*
     GNOME Shell integration for Chrome
-    Copyright (C) 2016  Yuri Konotopov <ykonotopov gnome org>
+    Copyright (C) 2016-2018  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
@@ -184,3 +184,5 @@ chrome.runtime.getPlatformInfo(function(info) {
                GSC.sync.init();
        }
 });
+
+GSC.toolbar.init();
diff --git a/extension/icons/GnomeLogo-light-16.png b/extension/icons/GnomeLogo-light-16.png
new file mode 100644
index 0000000..c6d5a85
Binary files /dev/null and b/extension/icons/GnomeLogo-light-16.png differ
diff --git a/extension/icons/GnomeLogo-light-32.png b/extension/icons/GnomeLogo-light-32.png
new file mode 100644
index 0000000..5caa9a2
Binary files /dev/null and b/extension/icons/GnomeLogo-light-32.png differ
diff --git a/extension/include/constants.js b/extension/include/constants.js
index 34e9870..901dd96 100644
--- a/extension/include/constants.js
+++ b/extension/include/constants.js
@@ -1,6 +1,6 @@
 /*
     GNOME Shell integration for Chrome
-    Copyright (C) 2016  Yuri Konotopov <ykonotopov gnome org>
+    Copyright (C) 2016-2018  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
@@ -45,7 +45,8 @@ DEFAULT_SYNC_OPTIONS                  = {
 };
 
 DEFAULT_LOCAL_OPTIONS                  = {
-       syncExtensions:         false
+       syncExtensions:         false,
+       useLightIcon:           false
 };
 
 EXTERNAL_MESSAGES                      = [
diff --git a/extension/include/toolbar.js b/extension/include/toolbar.js
new file mode 100644
index 0000000..34e1a79
--- /dev/null
+++ b/extension/include/toolbar.js
@@ -0,0 +1,65 @@
+/*
+    GNOME Shell integration for Chrome
+    Copyright (C) 2018  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
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+ */
+
+/*
+ * Main object that handles toolbar icon.
+ */
+GSC.toolbar = (function($) {
+       /*
+        * Initialization rutines.
+        */
+       function init() {
+               chrome.storage.local.get(DEFAULT_LOCAL_OPTIONS, function (options) {
+                       if (options.useLightIcon)
+                       {
+                               setLightIcon();
+                       }
+               });
+
+               chrome.storage.onChanged.addListener(function(changes, areaName) {
+                       if(areaName === 'local' && changes.useLightIcon)
+                       {
+                               if(changes.useLightIcon.newValue)
+                               {
+                                       setLightIcon();
+                               }
+                               else
+                               {
+                                       setDarkicon();
+                               }
+                       }
+               });
+       }
+
+       function setLightIcon() {
+               chrome.browserAction.setIcon({
+                       path: {
+                               "16": "icons/GnomeLogo-light-16.png",
+                               "32": "icons/GnomeLogo-light-32.png"
+                       }
+               });
+       }
+
+       function setDarkicon() {
+               chrome.browserAction.setIcon({
+                       path: {
+                               "16": "icons/GnomeLogo-16.png",
+                           "32": "icons/GnomeLogo-32.png"
+                       }
+               });
+       }
+
+       /*
+        * Public methods.
+        */
+       return {
+               init: init
+       };
+})(jQuery);
diff --git a/extension/options.html b/extension/options.html
index 83c496b..6b1203b 100644
--- a/extension/options.html
+++ b/extension/options.html
@@ -64,6 +64,13 @@
                                                </dd>
                                        </dl>
                                        <dl>
+                                               <dt><span data-i18n="options_use_light_icon"></span>:</dt>
+                                               <dd>
+                                                       <label for='use_light_icon_yes' 
data-i18n="yes"></label> <input type='radio' id='use_light_icon_yes' name='use_light_icon' />
+                                                       <label for='use_light_icon_no' 
data-i18n="no"></label> <input type='radio' id='use_light_icon_no' name='use_light_icon' />
+                                               </dd>
+                                       </dl>
+                                       <dl>
                                                <dt><span data-i18n="options_show_release_notes"></span>:</dt>
                                                <dd>
                                                        <label for='show_release_notes_yes' 
data-i18n="yes"></label> <input type='radio' id='show_release_notes_yes' name='show_release_notes' />
diff --git a/extension/options.js b/extension/options.js
index 9fdd4ea..7278aa5 100644
--- a/extension/options.js
+++ b/extension/options.js
@@ -1,6 +1,6 @@
 /*
     GNOME Shell integration for Chrome
-    Copyright (C) 2016  Yuri Konotopov <ykonotopov gnome org>
+    Copyright (C) 2016-2018  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
@@ -15,6 +15,7 @@ function save_options()
        var updateCheck = $('#update_check_yes').prop('checked');
        var updateCheckEnabledOnly = $('#update_check_enabled_yes').prop('checked');
        var updateCheckPeriod = $('#update_check_period').val();
+       var useLightIcon = $('#use_light_icon_yes').prop('checked');
        updateCheckPeriod = Math.max(3, updateCheckPeriod);
 
        chrome.storage.sync.set({
@@ -24,7 +25,8 @@ function save_options()
                updateCheckPeriod:      updateCheckPeriod
        }, function () {
                chrome.storage.local.set({
-                       syncExtensions: syncExtensions
+                       syncExtensions: syncExtensions,
+                       useLightIcon:   useLightIcon
                }, function() {
                        if(syncExtensions)
                        {
@@ -138,20 +140,6 @@ function restore_options()
        if(COMPAT.SYNC_STORAGE)
        {
                updateSynchronizationStatus();
-               chrome.storage.local.get(DEFAULT_LOCAL_OPTIONS, function (items) {
-                       if(items.syncExtensions)
-                       {
-                               chrome.permissions.contains({
-                                       permissions: ["idle"]
-                               }, function (result) {
-                                       setSyncExtensions(result);
-                               });
-                       }
-                       else
-                       {
-                               setSyncExtensions(false);
-                       }
-               });
        }
        else
        {
@@ -159,6 +147,23 @@ function restore_options()
                $('#synchronize_extensions_yes').closest('dl').hide();
        }
 
+       chrome.storage.local.get(DEFAULT_LOCAL_OPTIONS, function (items) {
+               if(items.syncExtensions)
+               {
+                       chrome.permissions.contains({
+                               permissions: ["idle"]
+                       }, function (result) {
+                               setSyncExtensions(result);
+                       });
+               }
+               else if(COMPAT.SYNC_STORAGE)
+               {
+                       setSyncExtensions(false);
+               }
+
+               setLightIcon(items.useLightIcon);
+       });
+
        if(COMPAT.IS_FIREFOX)
        {
                $('dialog').hide();
@@ -213,6 +218,14 @@ function setCheckUpdateEnabledOnly(result)
                $('#update_check_enabled_no').prop('checked', true);
 }
 
+function setLightIcon(result)
+{
+       if(result)
+               $('#use_light_icon_yes').prop('checked', true);
+       else
+               $('#use_light_icon_no').prop('checked', true);
+}
+
 function setReleaseNotes(result)
 {
        if(result)
diff --git a/po/template.pot b/po/template.pot
index cec8cb9..25a83cf 100644
--- a/po/template.pot
+++ b/po/template.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 1.0\n"
 "Report-Msgid-Bugs-To: ykonotopov gnome org\n"
-"POT-Creation-Date: 2017-06-12 17:29+0000\n"
+"POT-Creation-Date: 2018-01-28 08:41+0000\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -194,6 +194,11 @@ msgid ""
 " updates. Probably python-requests package is missing."
 msgstr ""
 
+#. Use light icon that is looked better with dark themes.
+#: chrome-gnome-shell-key-options_use_light_icon:1
+msgid "Use light icon (dark theme)"
+msgstr ""
+
 #: chrome-gnome-shell-key-platform_not_supported:1
 msgid "Native host connector is not supported for your platform."
 msgstr ""


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