[gnome-tweak-tool] Can configure extension prefs
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Can configure extension prefs
- Date: Mon, 13 Aug 2012 16:00:54 +0000 (UTC)
commit 0849d933a3f20d32c6163badf71154f05ffe53e2
Author: John Stowers <john stowers gmail com>
Date: Mon Aug 13 18:01:38 2012 +0200
Can configure extension prefs
NEWS | 3 +++
gtweak/gconf.py | 9 +++------
gtweak/gshellwrapper.py | 4 ++++
gtweak/tweaks/tweak_shell_extensions.py | 28 ++++++++++++++++++++--------
gtweak/utils.py | 9 +++++++++
gtweak/widgets.py | 19 +++++++++++++++++++
6 files changed, 58 insertions(+), 14 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6f87da4..71e7d67 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+3.5.x
+ * Can configure extension preferences
+
3.5.5
* Now appear as "Tweak Tool" in (bug 678778)
* Fix incompatibility with new gnome-shell extensions (Alban Browaeys, bug 678778)
diff --git a/gtweak/gconf.py b/gtweak/gconf.py
index 16f0a92..4738146 100644
--- a/gtweak/gconf.py
+++ b/gtweak/gconf.py
@@ -15,10 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with gnome-tweak-tool. If not, see <http://www.gnu.org/licenses/>.
-import subprocess
import logging
import gtweak
+import gtweak.utils
from gi.repository import GConf
@@ -34,11 +34,8 @@ class GConfSetting:
def _run_gconftool(self, command):
if command not in self._cmd_cache:
- p = subprocess.Popen(
- ["gconftool-2", command, self._key],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
- stdout, stderr = p.communicate()
- if p.returncode == 0:
+ stdout, stderr, returncode = gtweak.utils.execute_subprocess(["gconftool-2", command, self._key], block=True)
+ if returncode == 0:
self._cmd_cache[command] = stdout.strip()
else:
self._cmd_cache[command] = "ERROR: %s" % stderr.strip()
diff --git a/gtweak/gshellwrapper.py b/gtweak/gshellwrapper.py
index d458cff..98c2771 100644
--- a/gtweak/gshellwrapper.py
+++ b/gtweak/gshellwrapper.py
@@ -77,6 +77,7 @@ class GnomeShell:
}
DATA_DIR = os.path.join(GLib.get_user_data_dir(), "gnome-shell")
+ EXTENSION_DIR = os.path.join(GLib.get_user_data_dir(), "gnome-shell", "extensions")
def __init__(self, shellproxy, shellsettings):
self._proxy = shellproxy
@@ -102,6 +103,7 @@ class GnomeShell32(GnomeShell):
EXTENSION_ENABLED_KEY = "enabled-extensions"
EXTENSION_NEED_RESTART = False
+ SUPPORTS_EXTENSION_PREFS = False
def list_extensions(self):
return self._proxy.proxy.ListExtensions()
@@ -118,6 +120,8 @@ class GnomeShell32(GnomeShell):
class GnomeShell34(GnomeShell32):
+ SUPPORTS_EXTENSION_PREFS = True
+
def restart(self):
logging.warning("Restarting Shell Not Supported")
diff --git a/gtweak/tweaks/tweak_shell_extensions.py b/gtweak/tweaks/tweak_shell_extensions.py
index 834a627..982d37b 100644
--- a/gtweak/tweaks/tweak_shell_extensions.py
+++ b/gtweak/tweaks/tweak_shell_extensions.py
@@ -7,10 +7,10 @@ import json
from gi.repository import Gtk
from gi.repository import GLib
-from gtweak.utils import extract_zip_file
+from gtweak.utils import extract_zip_file, execute_subprocess
from gtweak.gshellwrapper import GnomeShell, GnomeShellFactory
from gtweak.tweakmodel import Tweak, TweakGroup
-from gtweak.widgets import ZipFileChooserButton, build_label_beside_widget, build_horizontal_sizegroup, UI_BOX_SPACING
+from gtweak.widgets import ZipFileChooserButton, build_label_beside_widget, build_horizontal_sizegroup, build_tight_button, UI_BOX_SPACING
class _ShellExtensionTweak(Tweak):
@@ -19,10 +19,11 @@ class _ShellExtensionTweak(Tweak):
self._shell = shell
state = ext.get("state")
+ uuid = ext["uuid"]
sw = Gtk.Switch()
- sw.set_active(self._shell.extension_is_active(state, ext["uuid"]))
- sw.connect('notify::active', self._on_extension_toggled, ext["uuid"])
+ sw.set_active(self._shell.extension_is_active(state, uuid))
+ sw.connect('notify::active', self._on_extension_toggled, uuid)
info = None
warning = None
@@ -42,12 +43,25 @@ class _ShellExtensionTweak(Tweak):
logging.critical(warning)
sw.set_sensitive(sensitive)
+ widgets = []
+ if self._shell.SUPPORTS_EXTENSION_PREFS:
+ prefs = os.path.join(self._shell.EXTENSION_DIR, uuid, "prefs.js")
+ if os.path.exists(prefs):
+ cfg = build_tight_button(Gtk.STOCK_PREFERENCES)
+ cfg.connect("clicked", self._on_configure_clicked, uuid)
+ widgets.append(cfg)
+
+ widgets.append(sw)
+
self.widget = build_label_beside_widget(
_("%s Extension") % ext["name"],
- sw,
+ *widgets,
warning=warning)
self.widget_for_size_group = None
+ def _on_configure_clicked(self, btn, uuid):
+ execute_subprocess(['gnome-shell-extension-prefs', uuid], block=False)
+
def _on_extension_toggled(self, sw, active, uuid):
if not sw.get_active():
self._shell.disable_extension(uuid)
@@ -62,8 +76,6 @@ class _ShellExtensionTweak(Tweak):
class _ShellExtensionInstallerTweak(Tweak):
- EXTENSION_DIR = os.path.join(GLib.get_user_data_dir(), "gnome-shell", "extensions")
-
def __init__(self, shell, **options):
Tweak.__init__(self, _("Install Shell Extension"), "", **options)
@@ -118,7 +130,7 @@ class _ShellExtensionInstallerTweak(Tweak):
ok, updated = extract_zip_file(
z,
"/".join(fragment),
- os.path.join(self.EXTENSION_DIR, extension_uuid))
+ os.path.join(self._shell.EXTENSION_DIR, extension_uuid))
if ok:
if updated:
diff --git a/gtweak/utils.py b/gtweak/utils.py
index 85f052f..d3e5411 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -19,6 +19,7 @@ import os.path
import logging
import tempfile
import shutil
+import subprocess
import gtweak
from gtweak.gsettings import GSettingsSetting
@@ -102,6 +103,14 @@ def extract_zip_file(z, members_path, dest):
return ok, updated
+def execute_subprocess(cmd_then_args, block=True):
+ p = subprocess.Popen(
+ cmd_then_args,
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
+ if block:
+ stdout, stderr = p.communicate()
+ return stdout, stderr, p.returncode
+
class AutostartManager:
def __init__(self, desktop_filename, autostart_desktop_filename="", exec_cmd="", extra_exec_args=""):
self.desktop_filename = desktop_filename
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index b1b3eb7..f0d83ea 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -99,6 +99,25 @@ def build_horizontal_sizegroup():
sg.props.ignore_hidden = True
return sg
+def build_tight_button(stock_id):
+ button = Gtk.Button()
+ button.set_relief(Gtk.ReliefStyle.NONE)
+ button.set_focus_on_click(False)
+ button.add(Gtk.Image.new_from_stock(stock_id, Gtk.IconSize.MENU))
+ data = ".button {\n" \
+ "-GtkButton-default-border : 0px;\n" \
+ "-GtkButton-default-outside-border : 0px;\n" \
+ "-GtkButton-inner-border: 0px;\n" \
+ "-GtkWidget-focus-line-width : 0px;\n" \
+ "-GtkWidget-focus-padding : 0px;\n" \
+ "padding: 0px;\n" \
+ "}"
+ provider = Gtk.CssProvider()
+ provider.load_from_data(data)
+ # 600 = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
+ button.get_style_context().add_provider(provider, 600)
+ return button
+
class _GSettingsTweak(Tweak):
def __init__(self, schema_name, key_name, **options):
self.schema_name = schema_name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]