[gnome-tweak-tool] Improve appearance by sorting tweaks in small-large size order



commit dde2a7381f043490093035b5b59e226176c7b904
Author: John Stowers <john stowers gmail com>
Date:   Tue Aug 7 16:13:44 2012 +0200

    Improve appearance by sorting tweaks in small-large size order

 gtweak/tweakmodel.py |    2 --
 gtweak/tweakview.py  |   15 +++++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gtweak/tweakmodel.py b/gtweak/tweakmodel.py
index 9db79e7..b4e82e9 100644
--- a/gtweak/tweakmodel.py
+++ b/gtweak/tweakmodel.py
@@ -152,8 +152,6 @@ class TweakModel(Gtk.ListStore):
             LOG.critical("Tweak group named: %s already exists" % tweakgroup.name)
             return
 
-        print "ssssssssssssssssssssssS",tweakgroup.name
-
         _iter = self.append([tweakgroup.name, tweakgroup])
         self._tweak_group_names[tweakgroup.name] = tweakgroup
         self._tweak_group_iters[tweakgroup.name] = _iter
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
index 5346f50..ddf4f5e 100644
--- a/gtweak/tweakview.py
+++ b/gtweak/tweakview.py
@@ -23,7 +23,18 @@ from gi.repository import Gtk, Gdk, GObject
 import gtweak.tweakmodel
 from gtweak.tweakmodel import TweakModel
 
-DEFAULT_TWEAKGROUP = gtweak.tweakmodel.TWEAK_GROUP_DESKTOP
+DEFAULT_TWEAKGROUP = gtweak.tweakmodel.TWEAK_GROUP_SHELL
+WIDGET_SORT_ORDER = (Gtk.Switch, Gtk.SpinButton, Gtk.ComboBox)
+
+def _sort_tweak_widgets_by_widget_type(tweak):
+    #for appearance tries to make small widgets be packed first, followed by larger widgets,
+    #followed by widgets of the same type
+    if not tweak.widget_for_size_group:
+        return -1
+    try:
+        return WIDGET_SORT_ORDER.index(type(tweak.widget_for_size_group))
+    except ValueError:
+        return len(WIDGET_SORT_ORDER) #last
 
 class TweakView:
     def __init__(self, builder, model):
@@ -59,7 +70,7 @@ class TweakView:
 
         #add all tweaks
         self._tweak_vbox = builder.get_object('tweak_vbox')
-        for t in self._model.tweaks:
+        for t in sorted(self._model.tweaks, key=_sort_tweak_widgets_by_widget_type):
             self._tweak_vbox.pack_start(t.widget, False, False, 0)
             t.set_notify_cb(self._on_tweak_notify)
 



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