abstract the EVE API and settings code from the UI code.
"""
+
+ GCONF_DIR = "/apps/maemo/mevemon"
+
def __init__(self):
self.program = hildon.Program()
self.program.__init__()
self.gconf = gnome.gconf.client_get_default()
+ #NOTE: remove this after a few releases
+ self.update_settings()
self.cached_api = eveapi.EVEAPIConnection( cacheHandler = \
apicache.cache_handler(debug=False))
self.gui = gui.mEveMonUI(self)
def quit(self, *args):
gtk.main_quit()
+ def update_settings(self):
+ """
+ Update from the old pre 0.3 settings to the new settings layout.
+ We should remove this eventually, once no one is using pre-0.3 mEveMon
+ """
+ uid = self.gconf.get_string("%s/eve_uid" % self.GCONF_DIR)
+
+ if uid:
+ key = self.gconf.get_string("%s/eve_api_key" % self.GCONF_DIR)
+ self.add_account(uid, key)
+ self.gconf.unset("%s/eve_uid" % self.GCONF_DIR)
+ self.gconf.unset("%s/eve_api_key" % self.GCONF_DIR)
+
+
def get_accounts(self):
"""
Returns a dictionary containing uid:api_key pairs gathered from gconf
"""
accounts = {}
- entries = self.gconf.all_entries("/apps/maemo/mevemon/accounts")
+ entries = self.gconf.all_entries("%s/accounts" % self.GCONF_DIR)
for entry in entries:
key = os.path.basename(entry.get_key())
"""
Returns the api key associated with the given uid.
"""
- return self.gconf.get_string("/apps/maemo/mevemon/accounts/%s" % uid) or ''
+ return self.gconf.get_string("%s/accounts/%s" % (self.GCONF_DIR, uid)) or ''
def remove_account(self, uid):
"""
Removes the provided uid key from gconf
"""
- self.gconf.unset("/apps/maemo/mevemon/accounts/%s" % uid)
+ self.gconf.unset("%s/accounts/%s" % (self.GCONF_DIR, uid))
def add_account(self, uid, api_key):
"""
Adds the provided uid:api_key pair to gconf.
"""
- self.gconf.set_string("/apps/maemo/mevemon/accounts/%s" % uid, api_key)
+ self.gconf.set_string("%s/accounts/%s" % (self.GCONF_DIR, uid), api_key)
def get_auth(self, uid):
"""
hbox = gtk.HBox(False, 0)
info_vbox = gtk.VBox(False, 0)
- stats_vbox = gtk.VBox(False, 0)
portrait = gtk.Image()
portrait.set_from_file(self.controller.get_portrait(char_name, 256))
hbox.pack_start(portrait, False, False, 10)
hbox.pack_start(info_vbox, False, False, 5)
- hbox.pack_start(stats_vbox, False, False, 15)
+ hbox.show()
vbox = gtk.VBox(False, 0)
pannable_area.add_with_viewport(vbox)
self.fill_info(info_vbox)
- self.fill_stats(stats_vbox)
+ self.fill_stats(info_vbox)
+
+ separator = gtk.HSeparator()
+ vbox.pack_start(separator, False, False, 5)
+ separator.show()
self.add_label("<big>Skill in Training:</big>", vbox, align="normal")
skill = self.controller.get_skill_in_training(uid, self.char_id)
vbox, align="normal")
self.add_label("<small>start time: %s\t\tend time: %s</small>" %(time.ctime(skill.trainingStartTime),
time.ctime(skill.trainingEndTime)), vbox, align="normal")
+ progressbar = gtk.ProgressBar()
+ fraction_completed = (time.time() - skill.trainingStartTime) / \
+ (skill.trainingEndTime - skill.trainingStartTime)
+ progressbar.set_fraction(fraction_completed)
+ align = gtk.Alignment(0.5, 0.5, 0.5, 0)
+ vbox.pack_start(align, False, False, 5)
+ align.show()
+ align.add(progressbar)
+ progressbar.show()
else:
self.add_label("<small>No skills are currently being trained</small>", vbox, align="normal")
+ separator = gtk.HSeparator()
+ vbox.pack_start(separator, False, False, 0)
+ separator.show()
+
self.add_label("<big>Skills:</big>", vbox, align="normal")
win.show_all()
def fill_stats(self, box):
- self.add_label("", box, markup=False)
- self.add_label("", box, markup=False)
- self.add_label("", box, markup=False)
- self.add_label("<small><b>Intelligence: </b>%d</small>" % self.sheet.attributes.intelligence, box)
- self.add_label("<small><b>Memory:</b>\t%d</small>" % self.sheet.attributes.memory, box)
- self.add_label("<small><b>Charisma:</b>\t%d</small>" % self.sheet.attributes.charisma, box)
- self.add_label("<small><b>Perception:</b>\t%d</small>" % self.sheet.attributes.perception, box)
- self.add_label("<small><b>Willpower:</b>\t%d</small>" % self.sheet.attributes.willpower, box)
+
+ atr = self.sheet.attributes
+
+ self.add_label("<small><b>I: </b>%d <b>M: </b>%d <b>C: </b>%d " \
+ "<b>P: </b>%d <b>W: </b>%d</small>" % (atr.intelligence,
+ atr.memory, atr.charisma, atr.perception, atr.willpower), box)
def add_columns_to_skills_view(self, treeview):