[gnome-tweak-tool] extensions: Add blank state



commit 86cd7471eb4582432de838fbcdba3e84d94db210
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 9 17:38:19 2017 +0100

    extensions: Add blank state
    
    Empty lists are hardly useful, so the GNOME guidelines advocate
    for special blank states that provide guidance for the user.
    For extensions, we can point to Software for finding and installing
    extensions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778677

 gtweak/tweaks/tweak_group_shell_extensions.py |   32 +++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_shell_extensions.py b/gtweak/tweaks/tweak_group_shell_extensions.py
index fc8d629..680f681 100644
--- a/gtweak/tweaks/tweak_group_shell_extensions.py
+++ b/gtweak/tweaks/tweak_group_shell_extensions.py
@@ -33,6 +33,33 @@ def _fix_shell_version_for_ego(version):
 def _get_shell_major_minor_version(version):
     return '.'.join(version.split('.')[0:2])
 
+class _ExtensionsBlankState(Gtk.Box):
+
+    def __init__(self):
+        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=18,
+                               valign=Gtk.Align.CENTER)
+
+        self.add(Gtk.Image(icon_name="gnome-tweak-tool-symbolic",
+                 pixel_size=128, opacity=0.3))
+
+        self.add(Gtk.Label(label="<b>" + _("No Extensions Installed") + "</b>",
+                 use_markup=True, opacity=0.3))
+
+        self._swInfo = Gio.DesktopAppInfo.new("org.gnome.Software.desktop")
+
+        if self._swInfo:
+            btn = Gtk.Button(label=_("Browse in Software"),
+                             always_show_image=True, halign=Gtk.Align.CENTER,
+                             image=Gtk.Image(icon_name="org.gnome.Software-symbolic"))
+            btn.connect("clicked", self._on_browse_clicked)
+            self.add(btn)
+
+        self.show_all()
+
+    def _on_browse_clicked(self, btn):
+        self._swInfo.launch([], None)
+
+
 class _ShellExtensionTweak(Gtk.ListBoxRow, Tweak):
 
     def __init__(self, shell, ext, **options):
@@ -198,6 +225,8 @@ class ShellExtensionTweakGroup(ListBoxTweakGroup):
                                    _("Extensions"),
                                    *extension_tweaks)
         
+        self.props.valign = Gtk.Align.FILL
+
         self.titlebar_widget = Gtk.Switch(visible=True)
         shell._settings.bind("disable-user-extensions", self.titlebar_widget,
                              "active", Gio.SettingsBindFlags.INVERT_BOOLEAN)
@@ -205,6 +234,9 @@ class ShellExtensionTweakGroup(ListBoxTweakGroup):
         self.set_header_func(self._list_header_func, None)
         self.connect("row-activated", self._on_row_activated, None);
 
+        if not len(extension_tweaks):
+            self.set_placeholder(_ExtensionsBlankState())
+
     def _got_info(self, ego, resp, uuid, extension, widget):
         if uuid == extension["uuid"]:
             resp = resp['shell_version_map']


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