X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=package%2Fsrc%2Fui%2Fmodels.py;h=8c4a620b946e38bcfdac6831152a88e353887ac2;hb=e1192b1185ce29505332045ae6c3641abe268279;hp=b4de05232996818a9f422e1c9cf65a4a7033a260;hpb=25c841d83f16562c5bcccbfdcb0381bc3049b71c;p=mevemon diff --git a/package/src/ui/models.py b/package/src/ui/models.py index b4de052..8c4a620 100644 --- a/package/src/ui/models.py +++ b/package/src/ui/models.py @@ -1,11 +1,32 @@ import gtk +class AccountsModel(gtk.ListStore): + C_UID, C_APIKEY = range(2) + + def __init__(self, controller): + gtk.ListStore.__init__(self, str, str) + self.controller = controller + self.get_accounts() + + def get_accounts(self): + self.clear() + + accts_dict = self.controller.get_accounts() + + if not accts_dict: + return None + + for uid, key in accts_dict.items(): + liter = self.append() + self.set(liter, self.C_UID, uid, self.C_APIKEY, key) + + class CharacterListModel(gtk.ListStore): - C_PORTRAIT, C_NAME = range(2) + C_PORTRAIT, C_NAME, C_UID = range(3) def __init__(self, controller): - gtk.ListStore.__init__(self, gtk.gdk.Pixbuf, str) + gtk.ListStore.__init__(self, gtk.gdk.Pixbuf, str, str) self.controller = controller # should we do this on initialization? self.get_characters() @@ -15,9 +36,9 @@ class CharacterListModel(gtk.ListStore): char_list = self.controller.get_characters() - for name, icon in char_list: + for name, icon, uid in char_list: liter = self.append() - self.set(liter, self.C_PORTRAIT, self._set_pix(icon), self.C_NAME, name) + self.set(liter, self.C_PORTRAIT, self._set_pix(icon), self.C_NAME, name, self.C_UID, uid) def _set_pix(self, filename): pixbuf = gtk.gdk.pixbuf_new_from_file(filename)