import hildon
import gobject
-import glib
-
from ui import models
import validation
+import util
class BaseUI():
menu_items = ("Settings", "About", "Refresh")
while not valid_credentials:
if result == gtk.RESPONSE_OK:
uid = uidEntry.get_text()
- api_key = apiEntry.get_text()
+ # auth() fails if api_key has lower-case characters
+ api_key = apiEntry.get_text().upper()
try:
validation.uid(uid)
self.win.show_all()
hildon.hildon_gtk_window_set_progress_indicator(self.win, 0)
+
+ # if we start the timer too early, get_is_topmost() returns False
+ self.timer = gobject.timeout_add_seconds(self.UPDATE_INTERVAL, self.update_live_sp)
+
+ self.win.connect("destroy", self.back)
+
+ def back(self, widget):
+ gobject.source_remove(self.timer)
+ gtk.Window.destroy(self.win)
+
def display_skill_in_training(self, vbox):
skill = self.controller.get_skill_in_training(self.uid, self.char_id)
self.sheet.race, self.sheet.bloodLine), box)
self.add_label("", box, markup=False)
self.add_label("<small><b>Corp:</b> %s</small>" % self.sheet.corporationName, box)
- self.add_label("<small><b>Balance:</b> %s ISK</small>" % self.sheet.balance, box)
+ self.add_label("<small><b>Balance:</b> %s ISK</small>" %
+ util.comma(self.sheet.balance), box)
self.live_sp_val = self.controller.get_sp(self.uid, self.char_id)
- self.live_sp = self.add_label("<small><b>Total SP:</b> %d</small>" %
- self.live_sp_val, box)
+ self.live_sp = self.add_label("<small><b>Total SP:</b> %s</small>" %
+ util.comma(int(self.live_sp_val)), box)
self.spps = self.controller.get_spps(self.uid, self.char_id)[0]
- glib.timeout_add_seconds(self.UPDATE_INTERVAL, self.update_live_sp)
def fill_stats(self, box):
def update_live_sp(self):
- # we don't want to keep the timer running in the background
- # when this callback returns False, the timer destorys itself
-
- # TODO: figure out why this doesn't work on the real device
- #
- #if not self.win.get_is_topmost():
- # return False
-
self.live_sp_val = self.live_sp_val + self.spps * self.UPDATE_INTERVAL
- self.live_sp.set_label("<small><b>Total SP:</b> %d</small>" %
- self.live_sp_val)
+ self.live_sp.set_label("<small><b>Total SP:</b> %s</small>" %
+ util.comma(int(self.live_sp_val)))
return True