|
|
006048 |
From f82a109c1db0497e62f22bace42f6ccf8db30821 Mon Sep 17 00:00:00 2001
|
|
|
006048 |
From: Rui Matos <tiagomatos@gmail.com>
|
|
|
006048 |
Date: Thu, 7 Nov 2013 21:39:47 +0100
|
|
|
006048 |
Subject: [PATCH 3/6] Add a way to reload tweaks when there are changes after
|
|
|
006048 |
startup
|
|
|
006048 |
|
|
|
006048 |
---
|
|
|
006048 |
gtweak/tweakmodel.py | 7 +++++++
|
|
|
006048 |
gtweak/tweakview.py | 30 ++++++++++++++++++++++++++++--
|
|
|
006048 |
2 files changed, 35 insertions(+), 2 deletions(-)
|
|
|
006048 |
|
|
|
006048 |
diff --git a/gtweak/tweakmodel.py b/gtweak/tweakmodel.py
|
|
|
006048 |
index faa920b..0fa3053 100644
|
|
|
006048 |
--- a/gtweak/tweakmodel.py
|
|
|
006048 |
+++ b/gtweak/tweakmodel.py
|
|
|
006048 |
@@ -90,6 +90,7 @@ class TweakGroup:
|
|
|
006048 |
def __init__(self, name, *tweaks):
|
|
|
006048 |
self.name = name
|
|
|
006048 |
self.tweaks = []
|
|
|
006048 |
+ self.model = None
|
|
|
006048 |
|
|
|
006048 |
self._sg = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
|
|
|
006048 |
self._sg.props.ignore_hidden = True
|
|
|
006048 |
@@ -165,6 +166,12 @@ class TweakModel(Gtk.ListStore):
|
|
|
006048 |
_iter = self.append([gettext(tweakgroup.name), tweakgroup])
|
|
|
006048 |
self._tweak_group_names[tweakgroup.name] = tweakgroup
|
|
|
006048 |
self._tweak_group_iters[tweakgroup.name] = _iter
|
|
|
006048 |
+ tweakgroup.model = self
|
|
|
006048 |
+
|
|
|
006048 |
+ def tweaks_changed(self, group):
|
|
|
006048 |
+ _iter = self._tweak_group_iters[group.name]
|
|
|
006048 |
+ _path = self.get_path(_iter)
|
|
|
006048 |
+ self.row_changed(_path, _iter)
|
|
|
006048 |
|
|
|
006048 |
def add_tweak_auto_to_group(self, tweak):
|
|
|
006048 |
if not tweak.loaded:
|
|
|
006048 |
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
|
|
|
006048 |
index ac8ae45..9de821c 100644
|
|
|
006048 |
--- a/gtweak/tweakview.py
|
|
|
006048 |
+++ b/gtweak/tweakview.py
|
|
|
006048 |
@@ -73,14 +73,40 @@ class TweakView:
|
|
|
006048 |
ctx.add_provider (provider,6000)
|
|
|
006048 |
|
|
|
006048 |
#add all tweaks
|
|
|
006048 |
+ self._tweak_set = set()
|
|
|
006048 |
self._tweak_vbox = builder.get_object('tweak_vbox')
|
|
|
006048 |
+ self.reload_tweaks()
|
|
|
006048 |
+
|
|
|
006048 |
+ self._model.connect('row-changed', self._on_model_row_changed)
|
|
|
006048 |
+
|
|
|
006048 |
+ #dict of pending notifications, the key is the function to be called
|
|
|
006048 |
+ self._notification_functions = {}
|
|
|
006048 |
+
|
|
|
006048 |
+ def reload_tweaks(self):
|
|
|
006048 |
+ new_tweak_set = set()
|
|
|
006048 |
+
|
|
|
006048 |
for t in sorted(self._model.tweaks, key=_sort_tweak_widgets_by_widget_type):
|
|
|
006048 |
+ new_tweak_set.add(t)
|
|
|
006048 |
+ if t in self._tweak_set:
|
|
|
006048 |
+ continue
|
|
|
006048 |
+
|
|
|
006048 |
t.main_window = self._main_window
|
|
|
006048 |
self._tweak_vbox.pack_start(t.widget, False, False, 0)
|
|
|
006048 |
t.set_notify_cb(self._on_tweak_notify)
|
|
|
006048 |
|
|
|
006048 |
- #dict of pending notifications, the key is the function to be called
|
|
|
006048 |
- self._notification_functions = {}
|
|
|
006048 |
+ self._tweak_set.add(t)
|
|
|
006048 |
+
|
|
|
006048 |
+ for t in self._tweak_set - new_tweak_set:
|
|
|
006048 |
+ self._tweak_vbox.remove(t.widget)
|
|
|
006048 |
+
|
|
|
006048 |
+ self._tweak_set = new_tweak_set
|
|
|
006048 |
+
|
|
|
006048 |
+ def _on_model_row_changed(self, model, path, titer):
|
|
|
006048 |
+ model, selected = self.treeview.get_selection().get_selected_rows()
|
|
|
006048 |
+ self.select_none()
|
|
|
006048 |
+ self.reload_tweaks()
|
|
|
006048 |
+ if len(selected) > 0:
|
|
|
006048 |
+ self.treeview.get_selection().select_path(selected[0])
|
|
|
006048 |
|
|
|
006048 |
def run(self):
|
|
|
006048 |
self._main_window.show_all()
|
|
|
006048 |
--
|
|
|
006048 |
1.8.3.1
|
|
|
006048 |
|