[gDesklets] Removing the last from a Control list



Ronny,

Thanks for taking care of this Ronny [1].  As I was looking over your
changes, I thought about the warning when setting the list length to 0.  It
seems to me that this could happen naturally and it wouldn't be a problem
worthy of warning.  For example:

A config list adds and removes Control instances.  Adding or subtracting
items from the list is easy (i.e. ctrl.length += 1), until you get to the
last item and the user removes it.  Then the programmer might expect the
Control is effectively disabled until the user adds something to the list
again.  (Currently he or she would have to take special care in this case.)

I propose that we set 'length' in ControlWrapper() to -1 if it was
initialized in the old-style, non-list way.  If the length is 0, we have to
re-__init__() when 'length' is increased to 1.  We can then allow a Control
initialized with a length to be decreased to length 0.

This may cause problems for Controls that don't clean up after themselves in
a _shutdown() function, but should be an easy thing to remedy.


All,

What do you think?

--
Joe

[1] https://bugs.launchpad.net/gdesklets/+bug/941337


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