Blob Blame History Raw
From 61012b50f73e08089d9afc65ea069ce50af95a72 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Thu, 7 Nov 2013 13:06:23 +0100
Subject: [PATCH 2/6] tweak_shell_extensions.py: Disable widget if extension
 can't work

---
 gtweak/gshellwrapper.py                 |  4 ++++
 gtweak/tweaks/tweak_shell_extensions.py | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/gtweak/gshellwrapper.py b/gtweak/gshellwrapper.py
index d102b34..3b0cf16 100644
--- a/gtweak/gshellwrapper.py
+++ b/gtweak/gshellwrapper.py
@@ -124,6 +124,10 @@ class GnomeShell:
     def version(self):
         return self._proxy.version
 
+    @property
+    def extensions_proxy(self):
+        return self._proxy.proxy_extensions
+
 class GnomeShell32(GnomeShell):
 
     EXTENSION_ENABLED_KEY = "enabled-extensions"
diff --git a/gtweak/tweaks/tweak_shell_extensions.py b/gtweak/tweaks/tweak_shell_extensions.py
index 80c8d3e..648a4ca 100644
--- a/gtweak/tweaks/tweak_shell_extensions.py
+++ b/gtweak/tweaks/tweak_shell_extensions.py
@@ -67,6 +67,8 @@ class _ShellExtensionTweak(Tweak):
                         warning=warning)
         self.widget_for_size_group = None
 
+        self._shell.extensions_proxy.connect('g-signal', self._extensions_signal, uuid)
+
     def _on_configure_clicked(self, btn, uuid):
         execute_subprocess(['gnome-shell-extension-prefs', uuid], block=False)
 
@@ -99,6 +101,15 @@ class _ShellExtensionTweak(Tweak):
                 self.widget.set_sensitive(False)
             dialog.destroy()
 
+    def _extensions_signal(self, proxy, sender, signal, params, uuid):
+        if signal != 'ExtensionStatusChanged' or params[0] != uuid:
+            return
+
+        state = params[1]
+        self.widget.set_sensitive(state == GnomeShell.EXTENSION_STATE["ENABLED"] or
+                                  state == GnomeShell.EXTENSION_STATE["DISABLED"] or
+                                  state == GnomeShell.EXTENSION_STATE["INITIALIZED"])
+
 class _ShellExtensionInstallerTweak(Tweak):
 
     def __init__(self, shell, **options):
-- 
1.8.3.1