[gnome-tweak-tool] Report extension loading errors to user
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Report extension loading errors to user
- Date: Mon, 20 Jun 2011 09:17:03 +0000 (UTC)
commit 74a71b225520334c7cd3ba7bc693b6f7cd7edf45
Author: John Stowers <john stowers gmail com>
Date: Mon Jun 20 17:41:31 2011 +1200
Report extension loading errors to user
gtweak/gshellwrapper.py | 12 ++++++------
gtweak/tweaks/tweak_shell_extensions.py | 20 +++++++++++++++++---
gtweak/widgets.py | 24 ++++++++++++------------
3 files changed, 35 insertions(+), 21 deletions(-)
---
diff --git a/gtweak/gshellwrapper.py b/gtweak/gshellwrapper.py
index 73d20b0..5946392 100644
--- a/gtweak/gshellwrapper.py
+++ b/gtweak/gshellwrapper.py
@@ -40,15 +40,15 @@ class _ShellProxy:
class GnomeShell:
EXTENSION_STATE = {
- 1 : "ENABLED",
- 2 : "DISABLED",
- 3 : "ERROR",
- 4 : "OUT_OF_DATE"
+ "ENABLED" : 1,
+ "DISABLED" : 2,
+ "ERROR" : 3,
+ "OUT_OF_DATE" : 4
}
EXTENSION_TYPE = {
- 1 : "SYSTEM",
- 2 : "PER_USER"
+ "SYSTEM" : 1,
+ "PER_USER" : 2
}
DATA_DIR = os.path.join(GLib.get_user_data_dir(), "gnome-shell")
diff --git a/gtweak/tweaks/tweak_shell_extensions.py b/gtweak/tweaks/tweak_shell_extensions.py
index f942dcc..6d9bc47 100644
--- a/gtweak/tweaks/tweak_shell_extensions.py
+++ b/gtweak/tweaks/tweak_shell_extensions.py
@@ -27,15 +27,29 @@ class _ShellExtensionTweak(Tweak):
sw = Gtk.Switch()
state = ext.get("state")
sw.set_active(
- state == 1 and \
+ state == GnomeShell.EXTENSION_STATE["ENABLED"] and \
not self._settings.setting_is_in_list(self.EXTENSION_DISABLED_KEY, ext["uuid"])
)
- sw.set_sensitive(state in (1,2))
sw.connect('notify::active', self._on_extension_toggled, ext["uuid"])
+ warning = None
+ sensitive = False
+ if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
+ state == GnomeShell.EXTENSION_STATE["DISABLED"]:
+ sensitive = True
+ elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
+ warning = "Error loading"
+ elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
+ warning = "Extension does not support shell version"
+ else:
+ warning = "Unknown extension state"
+ logging.critical(warning)
+ sw.set_sensitive(sensitive)
+
self.widget = build_label_beside_widget(
"%s Extension" % ext["name"],
- sw)
+ sw,
+ warning=warning)
self.widget_for_size_group = sw
def _on_extension_toggled(self, sw, active, uuid):
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index 6945614..e589c16 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -30,6 +30,11 @@ def build_label_beside_widget(txt, *widget, **kwargs):
info: Informational text to be shown after the label
warning: Warning text to be shown after the label
"""
+ def make_image(icon, tip):
+ image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)
+ image.set_tooltip_text(tip)
+ return image
+
if kwargs.get("hbox"):
hbox = kwargs.get("hbox")
else:
@@ -41,18 +46,13 @@ def build_label_beside_widget(txt, *widget, **kwargs):
hbox.pack_start(lbl, True, True, 0)
if kwargs.get("info"):
- icon = "dialog-information-symbolic"
- tip = kwargs.get("info")
- elif kwargs.get("warning"):
- icon = "dialog-warning-symbolic"
- tip = kwargs.get("warning")
- else:
- icon = ""
-
- if icon:
- image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)
- image.set_tooltip_text(tip)
- hbox.pack_start(image, False, False, 0)
+ hbox.pack_start(
+ make_image("dialog-information-symbolic", kwargs.get("info")),
+ False, False, 0)
+ if kwargs.get("warning"):
+ hbox.pack_start(
+ make_image("dialog-warning-symbolic", kwargs.get("warning")),
+ False, False, 0)
for w in widget:
hbox.pack_start(w, False, False, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]