seperated gui and controller
authorRyan Campbell <ryan.campbell@ualberta.ca>
Thu, 15 Apr 2010 19:50:40 +0000 (13:50 -0600)
committerRyan Campbell <ryan.campbell@ualberta.ca>
Thu, 15 Apr 2010 19:50:40 +0000 (13:50 -0600)
mevemon.py
ui.py

index e69de29..86d51e9 100644 (file)
@@ -0,0 +1,17 @@
+import hildon
+import gtk
+
+import ui
+
+class mEveMon():
+    def __init__(self):
+        self.program = hildon.Program()
+        self.program.__init__()
+        self.config = None
+        self.ui = ui.mEveMonUI(self)
+
+    def run(self):
+        gtk.main()
+
+if __name__ == "__main__":
+    mEveMon.run()
diff --git a/ui.py b/ui.py
index 78d19c6..17d401a 100644 (file)
--- a/ui.py
+++ b/ui.py
@@ -8,109 +8,106 @@ import sys
 import gtk
 import hildon
 
+class mEveMonUI():
 
-about_name = 'mEveMon'
-about_text = ('Mobile character monitor for EVE Online')
-about_authors = ['Ryan Campbell']
-about_website = 'http://example.site.org'
-app_version = '0.1'
+    about_name = 'mEveMon'
+    about_text = ('Mobile character monitor for EVE Online')
+    about_authors = ['Ryan Campbell']
+    about_website = 'http://example.site.org'
+    app_version = '0.1'
 
-menu_items = ("Settings", "About", "Refresh")
+    menu_items = ("Settings", "About", "Refresh")
 
-def settings_clicked(button, window):
-   
-    dialog = gtk.Dialog()
-   
-    dialog.set_transient_for(window)
-    dialog.set_title("Settings")
-    dialog.show_all()
-    dialog.run()
-    dialog.destroy()
-
-
-def about_clicked(button):
-    
-    dialog = gtk.AboutDialog()
-    dialog.set_website(about_website)
-    dialog.set_website_label(about_website)
-    dialog.set_name(about_name)
-    dialog.set_authors(about_authors)
-    dialog.set_comments(about_text)
-    dialog.set_version(app_version)
-    dialog.run()
-    dialog.destroy()
-
-def refresh_clicked(button, window):
-    pass
-  
-
-def create_menu(window):
-    
-    menu = hildon.AppMenu()
-
-    for command in menu_items:
-        # Create menu entries
-        button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
-        button.set_label(command)
-
-       if command == "About":
-           button.connect("clicked", about_clicked)
-        elif command == "Settings":
-            button.connect("clicked", settings_clicked, window)
-       elif command == "Refresh":
-           button.connect("clicked", refresh_clicked, window)
-       else:
-           assert False, command
-
-        # Add entry to the view menu
-        menu.append(button)
+    def __init__(self):
+        program = hildon.Program.get_instance()
     
-
-    menu.show_all()
-
-    return menu
-
-def create_table(window):
+        gtk.set_application_name("mEveMon")
     
-    # create a table of 10 by 10 squares. 
-    table = gtk.Table (1, 10, False)
+        #create the main window
+        win = hildon.StackableWindow()
+        win.connect("destroy", gtk.main_quit, None)
 
-    table.show()
+        # Create menu
+        menu = create_menu(win)
+        # Attach menu to the window
+        win.set_app_menu(menu)
 
+        pannable_area = hildon.PannableArea()
+        table = create_table(win)
 
-    # this simply creates a grid of toggle buttons on the table
-    # to demonstrate the scrolled window. 
-    for i in range(10):
-        data_buffer = "button %d\n" % i
-        button = gtk.ToggleButton(data_buffer)
-        table.attach(button, 0, 1 , i, i+1)
+        pannable_area.add_with_viewport(table)
+       
+        win.add(pannable_area);
+       
+        win.show_all()
+  
+    def settings_clicked(button, window):
+   
+        dialog = gtk.Dialog()
+   
+        dialog.set_transient_for(window)
+        dialog.set_title("Settings")
+        dialog.show_all()
+        dialog.run()
+        dialog.destroy()
 
-    return table
 
-def main():
+    def about_clicked(button):
     
-    program = hildon.Program.get_instance()
+        dialog = gtk.AboutDialog()
+        dialog.set_website(about_website)
+        dialog.set_website_label(about_website)
+        dialog.set_name(about_name)
+        dialog.set_authors(about_authors)
+        dialog.set_comments(about_text)
+        dialog.set_version(app_version)
+        dialog.run()
+        dialog.destroy()
+
+    def refresh_clicked(button, window):
+        pass
+  
+
+    def create_menu(window):
     
-    gtk.set_application_name("mEveMon")
+        menu = hildon.AppMenu()
+
+        for command in menu_items:
+            # Create menu entries
+            button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+            button.set_label(command)
+
+               if command == "About":
+                   button.connect("clicked", about_clicked)
+            elif command == "Settings":
+                button.connect("clicked", settings_clicked, window)
+               elif command == "Refresh":
+                   button.connect("clicked", refresh_clicked, window)
+               else:
+                   assert False, command
+
+            # Add entry to the view menu
+            menu.append(button)
+        
+        menu.show_all()
+
+        return menu
+
+    def create_table(window):
     
-    #create the main window
-    win = hildon.StackableWindow()
-    win.connect("destroy", gtk.main_quit, None)
+        # create a table of 10 by 10 squares. 
+        table = gtk.Table (1, 10, False)
+        table.show()
 
-    # Create menu
-    menu = create_menu(win)
-    # Attach menu to the window
-    win.set_app_menu(menu)
+        # this simply creates a grid of toggle buttons on the table
+        # to demonstrate the scrolled window. 
+        for i in range(10):
+            data_buffer = "button %d\n" % i
+            button = gtk.ToggleButton(data_buffer)
+            table.attach(button, 0, 1 , i, i+1)
 
-    pannable_area = hildon.PannableArea()
-    table = create_table(win)
+        return table
 
-    pannable_area.add_with_viewport(table)
-       
-    win.add(pannable_area);
-       
-    win.show_all()
-    gtk.main()
 
 if __name__ == "__main__":
     main()