clean up layout and add backwards compatibility
authorRyan Campbell <campbellr@gmail.com>
Fri, 30 Apr 2010 02:32:45 +0000 (20:32 -0600)
committerRyan Campbell <campbellr@gmail.com>
Fri, 30 Apr 2010 02:32:45 +0000 (20:32 -0600)
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.

package/src/mevemon.py
package/src/ui/fremantle/gui.py

index 602f3b1..29cde5d 100755 (executable)
@@ -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):
         """
index c905160..4e437fb 100644 (file)
@@ -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("<big>Skill in Training:</big>", 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("<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()
@@ -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("<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):