Commit 74a71b22 authored by John Stowers's avatar John Stowers

Report extension loading errors to user

parent a4869c79
......@@ -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")
......
......@@ -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):
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment