diff --git a/ocarina/__init__.py b/ocarina/__init__.py index 340a7d65..c0426891 100644 --- a/ocarina/__init__.py +++ b/ocarina/__init__.py @@ -19,7 +19,7 @@ get_window = None # Global variables for some objects main_window = None -main_tabs = None +#main_tabs = None def startup(): global gtk @@ -35,25 +35,21 @@ def exit(widget, event): def get_tabs_once(): global tabs global get_tabs - global main_tabs import tabs - main_tabs = tabs.Tabs() - main_tabs + tabs.init() get_tabs = get_tabs_rest - return main_tabs + return tabs.tabs def get_tabs_rest(): - global main_tabs - return main_tabs + global tabs + return tabs.tabs get_tabs = get_tabs_once def add_tab(text, content): - global tabs_dict - tabs = get_tabs() + global tabs tabs.append_page(content, text) def remove_tab(text): global tabs - tabs = get_tabs() tabs.remove_page(text) diff --git a/ocarina/box.py b/ocarina/box.py new file mode 100644 index 00000000..bbdcad52 --- /dev/null +++ b/ocarina/box.py @@ -0,0 +1,16 @@ +# Bryan Schumaker (8/20/2010) + +import ocarina +gtk = ocarina.gtk + + +class VBox(gtk.VBox): + def __init__(self): + gtk.VBox.__init__(self) + self.show() + + +class HBox(gtk.HBox): + def __init__(self): + gtk.HBox.__init__(self) + self.show() diff --git a/ocarina/tabs.py b/ocarina/tabs.py index a180d483..94106a2e 100644 --- a/ocarina/tabs.py +++ b/ocarina/tabs.py @@ -3,7 +3,13 @@ import ocarina libsaria = ocarina.libsaria -gtk = ocarina.gtk +gtk = ocarina.gtk +Label = gtk.Label + + +tabs = None +contents = dict() +cur_page = 0 class TabPage(gtk.VBox): @@ -22,35 +28,39 @@ class TabPage(gtk.VBox): self.content.invisible() -class Tabs(gtk.Notebook): - def __init__(self): - gtk.Notebook.__init__(self) - self.set_tab_pos(gtk.POS_LEFT) - self.connect("switch-page", self.switch_page) - self.cur_page = 0 - self.contents = dict() - self.show() +def init(): + global tabs + tabs = gtk.Notebook() + tabs.set_tab_pos(gtk.POS_LEFT) + tabs.connect("switch-page", switch_page) + tabs.show() - def append_page(self, content, text): - label = gtk.Label(text) - label.set_angle(90) - page = TabPage(content) - self.contents[text] = page - gtk.Notebook.append_page(self, page, label) - self.set_tab_label_packing(page, True, True, gtk.PACK_START) +def append_page(content, text): + global Label + global contents + global tabs + label = Label(text) + label.set_angle(90) + page = TabPage(content) + contents[text] = page + tabs.append_page(page, label) + tabs.set_tab_label_packing(page, True, True, gtk.PACK_START) - def remove_page(self, text): - page = self.contents.get(text, None) - if page == None: - return - n = self.page_num(page) - if n > 0: - gtk.Notebook.remove_page(self, n) - del self.contents[text] +def remove_page(text): + global contents + global tabs + page = contents.get(text, None) + if page == None: + return + n = tabs.page_num(page) + if n > 0: + tabs.remove_page( n) + del contents[text] - def switch_page(self, notebook, page, page_num): - old = notebook.get_nth_page(self.cur_page) - old.invisible() - new = notebook.get_nth_page(page_num) - new.visible() - self.cur_page = page_num +def switch_page(notebook, page, page_num): + global cur_page + old = notebook.get_nth_page(cur_page) + old.invisible() + new = notebook.get_nth_page(page_num) + new.visible() + cur_page = page_num diff --git a/plugins/web_radio.py b/plugins/web_radio.py index 7f521051..dc1bd29c 100644 --- a/plugins/web_radio.py +++ b/plugins/web_radio.py @@ -33,6 +33,10 @@ def start(): global children import webkit + #google = WebPage("http://www.google.com") + #children.append("Google") + #ocarina.add_tab("Google", google) + pandora = WebPage("http://www.pandora.com") children.append("Pandora") ocarina.add_tab("Pandora", pandora)