[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/release] Support += operations for list-model wrapper.
commit 6b4d1e8ff8d7872bb1cb4bf88bf17f31e61fee1e
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date: Sun Jul 24 03:57:47 2011 +0500
Support += operations for list-model wrapper.
---
src/gui/configPanel.py | 11 ++++-------
src/util/gtkTools.py | 14 +++++++++++++-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index e0fb8dc..a8d7f02 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -32,26 +32,23 @@ class ConfigPanel(object, CliConfigPanel):
listStore = self.builder.get_object('liststore_config')
self._confImportantContents = ConfContents(self.confImportantContents, listStore)
- self.confImportantContents = self.confImportantContents[-5:]
+ self.confImportantContents += self.confImportantContents[-5:]
@property
def confImportantContents(self):
if hasattr(self, '_confImportantContents'):
- return self._confImportantContents
+ return self._confImportantContents.container
else:
return []
@confImportantContents.setter
def confImportantContents(self, value):
if hasattr(self, '_confImportantContents'):
- try:
- self._confImportantContents.empty()
- except AttributeError:
- pass
+ self._confImportantContents.empty()
for entry in value:
self._confImportantContents.append(entry)
else:
- self._confImportantContents = value
+ self._confImportantContents = ConfContents(value)
def pack_widgets(self):
treeView = self.builder.get_object('treeview_config')
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 5ad321e..b60a829 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -21,7 +21,7 @@ class Theme:
self.colors[key] = getattr(widget.style, prop)[state]
class ListWrapper(object):
- def __init__(self, container, model):
+ def __init__(self, container, model=None):
self.container = []
self.model = model
@@ -63,17 +63,29 @@ class ListWrapper(object):
gobject.idle_add(self.__model_set, key, entry)
def __model_append(self, entry):
+ if not self.model:
+ return
+
row = self._create_row_from_entry(entry)
self.model.append(row)
def __model_clear(self):
+ if not self.model:
+ return
+
self.model.clear()
def __model_del(self, key):
+ if not self.model:
+ return
+
treeIter = self.model.get_iter(key)
self.model.remove(treeIter)
def __model_set(self, key, entry):
+ if not self.model:
+ return
+
row = self._create_row_from_entry(entry)
self.model[key] = row
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits