try:
chars = self.cached_api.eve.CharacterID(names=name).characters
char_id = chars[0].characterID
+ char_name = chars[0].name
except eveapi.Error:
return None
return char_id
-
+ def get_chars_from_acct(self, uid):
+ """
+ Returns a list of characters associated with the provided user ID.
+ """
+ auth = self.get_auth(uid)
+ if not auth:
+ return None
+ else:
+ try:
+ api_char_list = auth.account.Characters()
+ char_list = [char.name for char in api_char_list.characters]
+ except eveapi.Error:
+ return None
+
+ return char_list
+
def get_characters(self):
"""
- Returns a list of (character_name, image_path) pairs from all the
+ Returns a list of (character_name, image_path, uid) tuples from all the
accounts that are registered to mEveMon.
If there is an authentication issue, then instead of adding a valid
if not acct_dict:
return [placeholder_chars]
- for uid, api_key in acct_dict.items():
- auth = self.cached_api.auth(userID=uid, apiKey=api_key)
- try:
- api_char_list = auth.account.Characters()
+ for uid in acct_dict.keys():
+ char_names = self.get_chars_from_acct(uid)
+
+ if not char_names:
+ ui_char_list.append(placeholder_chars)
+ else:
# 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 ), uid) )
- except eveapi.Error:
- ui_char_list.append(placeholder_chars)
-
+ for char_name in char_names:
+ ui_char_list.append((char_name, self.get_portrait(char_name, 64) , uid) )
+
return ui_char_list
def get_portrait(self, char_name, size):
"""
- Returns the relative path of the retrieved portrait
+ Returns the file path of the retrieved portrait
"""
char_id = self.char_name2id(char_name)
+
return fetchimg.portrait_filename(char_id, size)
def get_skill_tree(self):
vbox = gtk.VBox(False, 1)
- acctsLabel = gtk.Label("Accounts:")
- acctsLabel.set_justify(gtk.JUSTIFY_LEFT)
+ #acctsLabel = gtk.Label("Accounts:")
+ #acctsLabel.set_justify(gtk.JUSTIFY_LEFT)
- vbox.pack_start(acctsLabel, False, False, 1)
+ #vbox.pack_start(acctsLabel, False, False, 1)
self.accounts_model = models.AccountsModel(self.controller)
accounts_treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL)
accounts_treeview.set_model(self.accounts_model)
+ accounts_treeview.set_headers_visible(True)
self.add_columns_to_accounts(accounts_treeview)
vbox.pack_start(accounts_treeview, False, False, 1)
while(result != gtk.RESPONSE_DELETE_EVENT):
if result == RESPONSE_NEW:
self.new_account_clicked(window)
- elif result == RESPONSE_EDIT:
- # get the selected treeview item and pop up the account_box
- self.edit_account(accounts_treeview)
+ #elif result == RESPONSE_EDIT:
+ # # get the selected treeview item and pop up the account_box
+ # self.edit_account(accounts_treeview)
elif result == RESPONSE_DELETE:
# get the selected treeview item, and delete the gconf keys
self.delete_account(accounts_treeview)
def add_columns_to_accounts(self, treeview):
#Column 0 for the treeview
renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn('Account ID', renderer, text=0)
+ column = gtk.TreeViewColumn('User ID', renderer,
+ text=models.AccountsModel.C_UID)
column.set_property("expand", True)
treeview.append_column(column)
+ #Column 2 (characters) for the treeview
+ column = gtk.TreeViewColumn('Characters', renderer,
+ markup=models.AccountsModel.C_CHARS)
+ column.set_property("expand", True)
+ treeview.append_column(column)
def new_account_clicked(self, window):
dialog = gtk.Dialog()
renderer = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn()
column.pack_start(renderer, True)
- column.add_attribute(renderer, "pixbuf", 0)
+ column.add_attribute(renderer, "pixbuf",
+ models.CharacterListModel.C_PORTRAIT)
treeview.append_column(column)
#Column 1 for the treeview
renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn('Character Name', renderer, text=1)
+ column = gtk.TreeViewColumn('Character Name', renderer,
+ text=models.CharacterListModel.C_NAME)
column.set_property("expand", True)
treeview.append_column(column)
portrait = gtk.Image()
portrait.set_from_file(self.controller.get_portrait(char_name, 256))
- portrait.show()
hbox.pack_start(portrait, False, False, 10)
hbox.pack_start(info_vbox, False, False, 5)
- hbox.show()
vbox = gtk.VBox(False, 0)
pannable_area.add_with_viewport(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)
self.add_label("%s <small>(Level %d)</small>" % (skill_name, skill.trainingToLevel),
vbox, align="normal")
- self.add_label("<small>start time: %s\t\tend time: %s</small>" %(time.ctime(skill.trainingStartTime),
+ 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) / \
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")
+ 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()
-
skills_treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL)
self.skills_model = models.CharacterSkillsModel(self.controller, self.char_id)
skills_treeview.set_model(self.skills_model)
def fill_info(self, box):
self.add_label("<big><big>%s</big></big>" % self.sheet.name, box)
- self.add_label("<small>%s %s %s</small>" % (self.sheet.gender, self.sheet.race, self.sheet.bloodLine), box)
+ self.add_label("<small>%s %s %s</small>" % (self.sheet.gender,
+ 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)
def add_columns_to_skills_view(self, treeview):
#Column 0 for the treeview
renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn('Skill Name', renderer, markup=0)
+ column = gtk.TreeViewColumn('Skill Name', renderer,
+ markup=models.CharacterSkillsModel.C_NAME)
column.set_property("expand", True)
treeview.append_column(column)
#Column 1 for the treeview
- column = gtk.TreeViewColumn('Rank', renderer, markup=1)
+ column = gtk.TreeViewColumn('Rank', renderer,
+ markup=models.CharacterSkillsModel.C_RANK)
column.set_property("expand", True)
treeview.append_column(column)
- column = gtk.TreeViewColumn('Points', renderer, markup=2)
+ column = gtk.TreeViewColumn('Points', renderer,
+ markup=models.CharacterSkillsModel.C_SKILLPOINTS)
column.set_property("expand", True)
treeview.append_column(column)
-
- column = gtk.TreeViewColumn('Level', renderer, markup=3)
+ column = gtk.TreeViewColumn('Level', renderer,
+ markup=models.CharacterSkillsModel.C_LEVEL)
column.set_property("expand", True)
treeview.append_column(column)