some cleanup and start of character window
authorRyan Campbell <campbellr@gmail.com>
Mon, 19 Apr 2010 04:46:23 +0000 (22:46 -0600)
committerRyan Campbell <campbellr@gmail.com>
Mon, 19 Apr 2010 04:46:23 +0000 (22:46 -0600)
mevemon.py
ui/fremantle/ui.py

index 0650ca2..d39e708 100644 (file)
@@ -21,7 +21,6 @@ class mEveMon():
         self.gconf = gnome.gconf.client_get_default()
         self.ui = ui.mEveMonUI(self)
 
-
     def run(self):
         gtk.main()
     
@@ -40,32 +39,54 @@ class mEveMon():
     def set_uid(self, uid):
         self.gconf.set_string("/apps/maemo/mevemon/eve_uid", uid)
 
-    # really quick hack to get character list. doesn't handle errors well, and if it can't get the gconf settings it just returns the placeholders, when in reality it should tell the UI or something. basically half finished, just uploading to show ry... FIXME --danny
+    def eveapi_connect(self):
+        uid = self.get_uid()
+        api_key = self.get_api_key()
+        cached_api = eveapi.EVEAPIConnection( cacheHandler = apicache.cache_handler( debug = False ) )
+
+        try:
+            auth = cached_api.auth( userID = uid, apiKey = api_key )
+        except eveapi.Error, e:
+            # if we can't, return the error message/pic --danny
+            return None
+        except Exception, e:
+            # unknown exception, dunno if this needs to be here if I just
+            # ignore it... probably a bad idea, but it was in the 
+            # apitest.py example... --danny
+            raise
+
+        return auth
+
+    def get_alliances(self, charID):
+        auth = eveapi_connect()
+
+        if auth:
+            alliance_list = auth.character(charID)
+            
+
+
+        
+
+    # really quick hack to get character list. doesn't handle errors well, and
+    # if it can't get the gconf settings it just returns the placeholders, when
+    # in reality it should tell the UI or something. basically half finished,
+    # just uploading to show ry... FIXME --danny
     def get_characters( self ):
         ui_char_list = []
         # error message --danny
         placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
-        cached_api = eveapi.EVEAPIConnection( cacheHandler = apicache.cache_handler( debug = False ) )
-        uid = self.get_uid()
-        api_key = self.get_api_key()
-        # if they are entered into gconf, try getting api data --danny
-        if ( uid and api_key ):
-            auth = cached_api.auth( userID = uid, apiKey = api_key )
-            try:
-                api_char_list = auth.account.Characters()
-            except eveapi.Error, e:
-                # if we can't, return the error message/pic --danny
-                return placeholder_chars
-            except Exception, e:
-                # unknown exception, dunno if this needs to be here if I just ignore it... probably a bad idea, but it was in the apitest.py example... --danny
-                ##return placeholder_chars
-                raise
+        
+        auth = self.eveapi_connect()
+
+        try:
+            api_char_list = auth.account.Characters()
             # append each char we get to the list we'll return to the UI --danny
             for character in api_char_list.characters:
-                ui_char_list.append( ( character.name, fetchimg.portrait_filename( character.characterID, 64 ) ) )
+                ui_char_list.append( ( character.name, 
+                    fetchimg.portrait_filename( character.characterID, 64 ) ) )
             return ui_char_list
         # if not entered into gconf, error message --danny
-        else:
+        except eveapi.Error, e:
             return placeholder_chars
 
 if __name__ == "__main__":
index 748678e..c52d4c4 100644 (file)
@@ -38,6 +38,7 @@ class mEveMonUI():
         # gtk.HILDON_UI_MODE_NORMAL -> not selection in the treeview
         # gtk.HILDON_UI_MODE_EDIT -> selection in the treeview
         treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL)
+        treeview.connect('row-activated', self.build_window)
 
         self.char_model = self.create_char_model()
         treeview.set_model(self.char_model)
@@ -50,6 +51,12 @@ class mEveMonUI():
         
         win.show_all()
 
+    def build_window(self, treeview, path, view_column):
+        print "triggered treeview"
+        print treeview
+        print path
+        print view_column
+
     
     def create_char_model(self):
         lstore = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING)