import glib
+import validation
+
from ui import models
class BaseUI():
about_name = 'mEveMon'
about_text = ('Mobile character monitor for EVE Online')
- about_authors = ['Ryan Campbell', 'Danny Campbell']
+ about_authors = ['Ryan Campbell <campbellr@gmail.com>',
+ 'Danny Campbell <danny.campbell@gmail.com>']
+
about_website = 'http://mevemon.garage.maemo.org'
- app_version = '0.3'
+ app_version = '0.4'
menu_items = ("Settings", "About", "Refresh")
ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
dialog.show_all()
+
result = dialog.run()
- if result == gtk.RESPONSE_OK:
- self.controller.add_account(uidEntry.get_text(), apiEntry.get_text())
- self.accounts_model.get_accounts()
-
+ valid_credentials = False
+
+ while not valid_credentials:
+ if result == gtk.RESPONSE_OK:
+ uid = uidEntry.get_text()
+ api_key = apiEntry.get_text()
+
+ try:
+ validation.uid(uid)
+ validation.api_key(api_key)
+ except validation.ValidationError, e:
+ self.report_error(e.message)
+ result = dialog.run()
+ else:
+ valid_credentials = True
+ self.controller.add_account(uid, api_key)
+ self.accounts_model.get_accounts()
+ else:
+ break
+
dialog.destroy()
- return result
+
+ def report_error(self, error):
+ hildon.hildon_banner_show_information(self.win, '', error)
-
def about_clicked(self, button):
dialog = gtk.AboutDialog()
dialog.set_website(self.about_website)
gtk.set_application_name("mEveMon")
#create the main window
- win = hildon.StackableWindow()
- win.connect("destroy", self.controller.quit)
- win.show_all()
- hildon.hildon_gtk_window_set_progress_indicator(win, 1)
+ self.win = hildon.StackableWindow()
+ self.win.connect("destroy", self.controller.quit)
+ self.win.show_all()
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 1)
# Create menu
- menu = self.create_menu(win)
+ menu = self.create_menu(self.win)
# Attach menu to the window
- win.set_app_menu(menu)
+ self.win.set_app_menu(menu)
pannable_area = hildon.PannableArea()
pannable_area.add(treeview)
- win.add(pannable_area);
+ self.win.add(pannable_area);
- win.show_all()
+ self.win.show_all()
- hildon.hildon_gtk_window_set_progress_indicator(win, 0)
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 0)
def add_columns_to_treeview(self, treeview):
def build_window(self, treeview, path, view_column):
# TODO: this is a really long and ugly function, split it up somehow
- win = hildon.StackableWindow()
- win.show_all()
- hildon.hildon_gtk_window_set_progress_indicator(win, 1)
+ self.win = hildon.StackableWindow()
+ #win.show_all()
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 1)
# Create menu
# NOTE: we probably want a window-specific menu for this page, but the
# main appmenu works for now
- menu = self.create_menu(win)
+ menu = self.create_menu(self.win)
# Attach menu to the window
- win.set_app_menu(menu)
+ self.win.set_app_menu(menu)
pannable_area = hildon.PannableArea()
self.sheet = self.controller.get_char_sheet(self.uid, self.char_id)
- win.set_title(char_name)
+ self.win.set_title(char_name)
hbox = gtk.HBox(False, 0)
self.add_columns_to_skills_view(skills_treeview)
vbox.pack_start(skills_treeview, False, False, 1)
- win.add(pannable_area)
- win.show_all()
+ self.win.add(pannable_area)
+ self.win.show_all()
- hildon.hildon_gtk_window_set_progress_indicator(win, 0)
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 0)
def display_skill_in_training(self, vbox):
skill = self.controller.get_skill_in_training(self.uid, self.char_id)
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)
self.live_sp_val = self.controller.get_sp(self.uid, self.char_id)
- print self.live_sp_val
self.live_sp = self.add_label("<small><b>Total SP:</b> %s</small>" %
self.live_sp_val, box)
treeview.append_column(column)
- def refresh_clicked(self, button, window):
- hildon.hildon_gtk_window_set_progress_indicator(window, 1)
+ def refresh_clicked(self, button):
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 1)
self.skills_model.get_skills()
- hildon.hildon_gtk_window_set_progress_indicator(window, 0)
+ hildon.hildon_gtk_window_set_progress_indicator(self.win, 0)
def update_live_sp(self):
+ # we don't want to keep the timer running in the background
+ # when this callback returns False, the timer destorys itself
+ if not self.win.get_is_topmost():
+ return False
+
self.live_sp_val = self.live_sp_val + self.spps * self.UPDATE_INTERVAL
self.live_sp.set_label("<small><b>Total SP:</b> %d</small>" %
self.live_sp_val)