=== modified file 'config/ConfigList.py'
--- config/ConfigList.py 2010-12-14 10:24:59 +0000
+++ config/ConfigList.py 2012-03-13 23:27:03 +0000
@@ -187,12 +187,36 @@
def _setp_items(self, key, items):
- # set the items property
+
+ # just for convenience we compare the former items
+ # and selection with the new one such that adding/
+ # removing an item to/from the list does not destroy
+ # the complete old selection
+ # Renaming items in the item list however always
+ # unchecks the renamed item
+ old_selection = self.get_prop("value")
+ old_items = self.get_prop("items")
+ new_selection = []
+
+ # doing it this way results in the behavior that if
+ # values in the old_items list appear multiple times
+ # and one of them is selected, all items in the new
+ # item list with the same value are selected duplicates
+ # within the list will be removed in the _setp_value()
+ # method anyway
+ for v, k in items:
+ for ov, ok in old_items:
+ if ok == k:
+ if ok in old_selection:
+ new_selection.append(k)
+
+ # set the items property
self._set_items(items)
- self._set_config(items)
+ # we store values but no item lists
+ #self._set_config(items)
self._setp(key, items)
- # re-set the selection
- self.set_prop("value", self.get_prop("value"))
+ # re-set the selection according to new selection
+ self.set_prop("value", new_selection)
@@ -210,7 +234,9 @@
else: newheight = h
self.__scrolledwindow.set_size_request(-1, newheight)
self.__scrolledwindow.resize_children()
- self._set_selection('value', self._getp('value'))
+
+ # do not update the selection pattern here but in _setp_items()
+ #self._set_selection('value', self._getp('value'))
def _set_selection(self, key, value):
@@ -222,18 +248,30 @@
if str(v) == str(self.__liststore[path][2]):
self.__liststore[path][0] = True
item = self.__liststore.iter_next(item)
-
def _setp_value(self, key, value):
+ # remove all selections that do not refer
+ # to any item key currently known
+ tmplist = []
+ for v in value:
+ if v in self.__items_values:
+ tmplist.append(v)
+
+ # remove duplicates from the list
+ tmplist = list(set(tmplist))
+
+ # update the selection according to tmplist
+ self._set_selection(key, tmplist)
+
# set the value (selection) property
- try:
- index = self.__items_values.index(value)
- except:
- index = 0
+ #try:
+ # index = self.__items_values.index(value)
+ #except:
+ # index = 0
- if index:
- self.__listview.set_cursor(index)
- self.__listview.scroll_to_cell(index)
+ #if index:
+ # self.__listview.set_cursor(index)
+ # self.__listview.scroll_to_cell(index)
self._set_config(value)
self._setp(key, value)
=== modified file 'scripting/ControlWrapper.py'
--- scripting/ControlWrapper.py 2010-10-06 00:52:07 +0000
+++ scripting/ControlWrapper.py 2012-03-13 23:27:03 +0000
@@ -36,6 +36,9 @@
# Keep an original copy around for extending the array
self.__dict__["_ControlWrapper__original_control"] = Vault(control)
+ # deactivate the original control
+ ctl = self.__dict__["_ControlWrapper__original_control"](open)
+ ctl.stop()
# Create a property handler for each deep copy of control
self.__dict__["_ControlWrapper__properties"] = \
[ PropertyInterface(self.__control(open)[i])
@@ -50,7 +53,6 @@
Vault( tuple(ids + taz_ids) )
-
def __len__(self):
return self.__length
@@ -63,33 +65,36 @@
if name == "length":
# A little bounds checking
- if value <= 0:
- log(_("Warning: Value of property \"length\" must be greater than 0 (setting to 1)"))
- value = 1
+ size = value
+ if value < 0:
+ value = 0
+ log(_("Warning: Value of property \"length\" must be greater than or equal to 0 (setting to 0)"))
+ if value == 0:
+ log(_("Warning: Value of property \"length\" set to 0 disables list mode"))
+ size = 1
# Don't do anything if value isn't changing
- if value != self.__length:
- if value > self.__length:
+ if size != self.__length:
+ if size > self.__length:
# Append new copies of the control
self.__dict__["_ControlWrapper__control"] = \
Vault( self.__control(open) + \
[ deepcopy(self.__original_control(open)) \
- for i in range(self.__length, value) ] )
+ for i in range(self.__length, size) ] )
# Initialize all new copies of the control
for ctl in [ self.__dict__["_ControlWrapper__control"](open)[i] \
- for i in range(self.__length, value) ]:
+ for i in range(self.__length, size) ]:
ctl.__init__()
# Append new PropertyInterface instances
self.__dict__["_ControlWrapper__properties"] = \
self.__properties + \
[ PropertyInterface(self.__control(open)[i]) \
- for i in range(self.__length, value) ]
- elif value < self.__length:
+ for i in range(self.__length, size) ]
+ elif size < self.__length:
# We want to leave the "0th" item alone, which is
# handled by the above conditionals
- start_deleting_at = value #if value != 0 else 1
- for i in range(start_deleting_at, self.__length):
- del self[i]
+ for i in range(size, self.__length):
+ del self[size]
self.__dict__["_ControlWrapper__length"] = value
else: # name != "length"
@@ -171,6 +176,7 @@
# no property that uses that Control
del self.__dict__["_ControlWrapper__properties"][idx]
new_ctrl_list = self.__dict__["_ControlWrapper__control"](open)
+ new_ctrl_list[idx].stop()
del new_ctrl_list[idx]
#del self.__dict__["_ControlWrapper__control"]
self.__dict__["_ControlWrapper__control"] = Vault( new_ctrl_list )
@@ -184,6 +190,21 @@
log(_("Warning: Control not initialized as an array in Desklet; not deleting anything."))
+ def stop(self):
+
+ for c in self.__dict__["_ControlWrapper__control"](open):
+ try:
+ c.stop()
+ except StandardError, exc:
+ import traceback; traceback.print_exc()
+ log("Could not stop control %s" % c)
+ del c
+
+ # original control is already stopped
+ c = self.__dict__["_ControlWrapper__original_control"](open)
+ del c
+
+
def get_interfaces_id(self):
=== modified file 'scripting/Script.py'
--- scripting/Script.py 2011-11-07 04:12:46 +0000
+++ scripting/Script.py 2012-03-13 23:27:03 +0000
@@ -37,8 +37,12 @@
self.__environment = {}
# the list of loaded controls
+ # (deprecated since we create lists of wrapped controls)
self.__loaded_controls = []
+ # the list of created control wrappers
+ self.__control_wrappers = []
+
# flag indicating whether the display has been stopped
self.__is_stopped = False
@@ -212,8 +216,11 @@
factory = ControlFactory()
ctrl = factory.get_control(interface)
if (ctrl):
- self.__loaded_controls.append(ctrl)
+ #self.__loaded_controls.append(ctrl)
+ # created a list of wrapped controls from the template
wrapped = ControlWrapper(ctrl, size)
+ # remember the control wrapper for cleanup on stop()
+ self.__control_wrappers.append(wrapped)
return wrapped
raise UserError(_("No Control could be found for interface %s") % \
@@ -304,13 +311,25 @@
self.__is_stopped = True
del self.__environment
+
+ # delete all wrapped controls
+ for w in self.__control_wrappers:
+ try:
+ w.stop()
+ except StandardError, exc:
+ import traceback; traceback.print_exc()
+ log("Could not stop control wrapper %s" % w)
+ del w
+ del self.__control_wrappers
+
+ # delete other controls
for c in self.__loaded_controls:
try:
c.stop()
except StandardError, exc:
import traceback; traceback.print_exc()
log("Could not stop control %s" % c)
- del c
+ del c
del self.__loaded_controls
=== modified file 'utils/Element.py'
--- utils/Element.py 2010-06-20 19:52:22 +0000
+++ utils/Element.py 2012-03-13 23:27:03 +0000
@@ -14,7 +14,7 @@
and can be read with
- get_prop(key, value)
+ get_prop(key)
If you don't need any special setter or getter methods, then you can use
=== modified file 'utils/render.c'
--- utils/render.c 2010-05-24 10:59:53 +0000
+++ utils/render.c 2012-03-13 23:27:03 +0000
@@ -89,7 +89,10 @@
/* set image */
gtk_image_set_from_pixbuf (image, scaled);
+// this condition is causing a memory leak since rev. 142
+/*
if (srcwidth != width || srcheight != height)
+*/
g_object_unref (scaled);
}