<list> prefs item doesn't save software-created items

Bug #604103 reported by Joe Sapp
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gDesklets
Status tracked in 0.3x
0.3x
Confirmed
High
gDesklets Core Team

Bug Description

I'm trying to add items to a <list> preferences setting when the user fills out a form and presses a button. So I do something like this in the button callback:

  def addToList():
    global my_list

    if Prefs.lbl.value:
      my_list.append(lbl, my_value)
      Prefs.my_list.items = my_list

my_list is bound to Prefs.my_list, lbl is bound to Prefs.lbl.

This code adds items to the list but doesn't bring them back when I restart the desklet. Some debugging 'print' statements tell me that my_list is populated on the restart, but they don't appear in the prefs dialog nor is Prefs.my_list.items populated with anything. The prefs code is:

  <button label="Add item" callback="addCalendarToList"/>

  <list label="Test list:" id="my_list" callback="list_callback_test" bind="calendar_list">
    <!-- items go here, empty to begin with -->
    <item id="default"/>
  </list>

Revision history for this message
Bjoern Koch (h.humpel) wrote :

I remember running into this one, too.
Tried to fix it back then when starting to write ConfigList (back in 2004/5) but couldn't figure it out back then :/.

Maybe the other Configuration elements using lists (like ConfigTogle) have the same problem ?!

Changed in gdesklets:
assignee: nobody → gDesklets Core Team (gdesklets-core-team)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Joe Sapp (sappj) wrote :

Doing some basic debugging (I still don't understand how the config system works), it looks like the "value" property gets set on a restart; that is _setp_value() gets called with key = "value" and value = <stored value>. I called self.get_prop("items") in that function, but it contains [('', '')] (the default?).

(By the way: in the sample code above, "calendar_list" should read "my_list".) So when I read the bound variable "my_list" in the test desklet into a local variable "new_list", I get the saved value in "new_list" (but it's not in Prefs.my_list.items). I then append a new tuple to be displayed in the config <list> to "new_list" and assign that to Prefs.my_list.items:

  new_list = my_list
  new_list.append(("blah", "blah"))
  Prefs.my_list.items = new_list

Then it shows up in my config <list>.

If I can help more, I can run some more tests for you. Hopefully since you know something about this code you can do something with this information :)

Revision history for this message
Bjoern Koch (h.humpel) wrote :

Sigh... OK, I've been digging into this a bit for the few last hours.
It's been a while but I (kind of ) start to remember things.

And the same problems and thoughts about it are back... :/
Apart from the "items" property not being stored and/or loaded etc. there are some other questions regarding "changable" lists:
- what happens if an element that has been selected is deleted from the list ?
- what happens if (on startup) a selected item is not in the item list ?
- does gDesklet has to look for multiple entries/values (or does the programmer has to?)
...

I remember spending a few hours (back then) on getting the list to be more flexible and finally putting it aside as more and more questions and problems popped up... :/.
Same thing today: the deeper I digged into it the more "ifs" and "whens" and problems showed up...

Anyway: do you really think we should keep on trying to have this fixed in 0.36.3 ?
Or shall we just keep it "non-editable" for 0.36.3 and try to implement this in 0.36.4 ?
Right now it seems to be working fine for pre-defined lists (AFAIK).

Revision history for this message
Joe Sapp (sappj) wrote :

It sounds like there's some things we should discuss on the list. I think you're right: let's push it off to 0.36.4.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.