From: Ryan Campbell Date: Fri, 30 Apr 2010 02:32:45 +0000 (-0600) Subject: clean up layout and add backwards compatibility X-Git-Tag: v0.3-1~1 X-Git-Url: http://vcs.maemo.org/git/?p=mevemon;a=commitdiff_plain;h=004f31616f4e3f3fd844dc6c5cab1f6540581713 clean up layout and add backwards compatibility Cleaned up the fremantle layout for the character sheet. Added function in mevemon.py to automatically convert from pre-0.3 gconf key layout to the new layout used for multiple account support. This way, ugrading should keep the existing account settings. --- diff --git a/package/src/mevemon.py b/package/src/mevemon.py index 602f3b1..29cde5d 100755 --- a/package/src/mevemon.py +++ b/package/src/mevemon.py @@ -40,10 +40,15 @@ class mEveMon(): 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) @@ -54,12 +59,26 @@ class mEveMon(): 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()) @@ -72,19 +91,19 @@ class mEveMon(): """ 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): """ diff --git a/package/src/ui/fremantle/gui.py b/package/src/ui/fremantle/gui.py index c905160..4e437fb 100644 --- a/package/src/ui/fremantle/gui.py +++ b/package/src/ui/fremantle/gui.py @@ -309,7 +309,6 @@ class CharacterSheetUI(BaseUI): 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)) @@ -317,7 +316,7 @@ class CharacterSheetUI(BaseUI): 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) @@ -326,7 +325,11 @@ class CharacterSheetUI(BaseUI): 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("Skill in Training:", vbox, align="normal") skill = self.controller.get_skill_in_training(uid, self.char_id) @@ -346,9 +349,22 @@ class CharacterSheetUI(BaseUI): vbox, align="normal") self.add_label("start time: %s\t\tend time: %s" %(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("No skills are currently being trained", vbox, align="normal") + separator = gtk.HSeparator() + vbox.pack_start(separator, False, False, 0) + separator.show() + self.add_label("Skills:", vbox, align="normal") win.show_all() @@ -373,14 +389,12 @@ class CharacterSheetUI(BaseUI): 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("Intelligence: %d" % self.sheet.attributes.intelligence, box) - self.add_label("Memory:\t%d" % self.sheet.attributes.memory, box) - self.add_label("Charisma:\t%d" % self.sheet.attributes.charisma, box) - self.add_label("Perception:\t%d" % self.sheet.attributes.perception, box) - self.add_label("Willpower:\t%d" % self.sheet.attributes.willpower, box) + + atr = self.sheet.attributes + + self.add_label("I: %d M: %d C: %d " \ + "P: %d W: %d" % (atr.intelligence, + atr.memory, atr.charisma, atr.perception, atr.willpower), box) def add_columns_to_skills_view(self, treeview):