2 # Based on C code from:
3 # "Hildon Tutorial" version 2009-04-28
4 # Example 3.1, "Example of a Hildon application menu"
13 about_name = 'mEveMon'
14 about_text = ('Mobile character monitor for EVE Online')
15 about_authors = ['Ryan Campbell']
16 about_website = 'http://example.site.org'
19 menu_items = ("Settings", "About", "Refresh")
21 def __init__(self, controller):
22 self.controller = controller
24 gtk.set_application_name("mEveMon")
26 #create the main window
27 win = hildon.StackableWindow()
28 win.connect("destroy", self.controller.quit)
31 menu = self.create_menu(win)
32 # Attach menu to the window
33 win.set_app_menu(menu)
35 pannable_area = hildon.PannableArea()
36 table = self.create_table(win)
38 pannable_area.add_with_viewport(table)
40 win.add(pannable_area);
44 def settings_clicked(self, button, window):
48 #get the vbox to pack all the settings into
51 dialog.set_transient_for(window)
52 dialog.set_title("Settings")
54 uidLabel = gtk.Label("User ID:")
55 uidLabel.set_justify(gtk.JUSTIFY_LEFT)
58 uidEntry = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
59 uidEntry.set_placeholder("User ID")
60 uidEntry.set_property('is_focus', False)
64 apiLabel = gtk.Label("API key:")
65 apiLabel.set_justify(gtk.JUSTIFY_LEFT)
68 apiEntry = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
69 apiEntry.set_placeholder("API Key")
70 apiEntry.set_property('is_focus', False)
74 ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
75 help_button = dialog.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
80 #if result == gtk.RESPONSE_OK:
81 # self.set_api_key(apiEntry.get_text())
82 # self.set_uid(uidEntry.get_text())
88 def about_clicked(self, button):
90 dialog = gtk.AboutDialog()
91 dialog.set_website(self.about_website)
92 dialog.set_website_label(self.about_website)
93 dialog.set_name(self.about_name)
94 dialog.set_authors(self.about_authors)
95 dialog.set_comments(self.about_text)
96 dialog.set_version(self.app_version)
100 def refresh_clicked(self, button, window):
104 def create_menu(self, window):
106 menu = hildon.AppMenu()
108 for command in self.menu_items:
109 # Create menu entries
110 button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
111 button.set_label(command)
113 if command == "About":
114 button.connect("clicked", self.about_clicked)
115 elif command == "Settings":
116 button.connect("clicked", self.settings_clicked, window)
117 elif command == "Refresh":
118 button.connect("clicked", self.refresh_clicked, window)
120 assert False, command
122 # Add entry to the view menu
129 def create_table(self, window):
131 # create a table of 10 by 10 squares.
132 table = gtk.Table (1, 10, False)
135 # this simply creates a grid of toggle buttons on the table
136 # to demonstrate the scrolled window.
138 data_buffer = "button %d\n" % i
139 button = gtk.ToggleButton(data_buffer)
140 table.attach(button, 0, 1 , i, i+1)
145 if __name__ == "__main__":