From 3518581e455dd99a992238a04f6dc5532b8fa315 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 10 Apr 2006 05:49:20 +0000 Subject: [PATCH] * src/ViewManager.py (ViewManager.create_pages): Use toggle buttons on the sidebar. (ViewManager.change_page): Turn off previously active button. svn: r6299 --- gramps2/ChangeLog | 5 +++++ gramps2/src/ViewManager.py | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d94bdab96..6ba4dbaff 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2006-04-09 Alex Roitman + * src/ViewManager.py (ViewManager.create_pages): Use toggle + buttons on the sidebar. + (ViewManager.change_page): Turn off previously active button. + 2006-04-09 Brian Matherly * src/docgen/ODFDoc.py: Improve graphic alignment (Bug 1370498) * src/docgen/OpenOfficeDoc.py: Improve graphic alignment (Bug 1370498) diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index af6a02c87..b589beef7 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -202,6 +202,7 @@ class ViewManager: hbox = gtk.HBox() self.ebox = gtk.EventBox() self.bbox = gtk.VBox() + self.buttons = [] self.ebox.add(self.bbox) hbox.pack_start(self.ebox, False) hbox.show_all() @@ -512,13 +513,15 @@ class ViewManager: index = 0 for page_def in self.views: page = page_def(self.state, self.uistate) + page_title = page.get_title() + page_stock = page.get_stock() # create icon/label for notebook hbox = gtk.HBox() image = gtk.Image() - image.set_from_stock(page.get_stock(), gtk.ICON_SIZE_MENU) + image.set_from_stock(page_stock, gtk.ICON_SIZE_MENU) hbox.pack_start(image, False) - hbox.add(gtk.Label(page.get_title())) + hbox.add(gtk.Label(page_title)) hbox.show_all() # create notebook page and add to notebook @@ -528,18 +531,26 @@ class ViewManager: self.notebook.append_page(page_display, hbox) self.pages.append(page) - # create the button add it to the sidebar - button = gtk.Button(stock=page.get_stock(), label=page.get_title()) + # create the button and add it to the sidebar + button = gtk.ToggleButton() + if page_stock: + button.set_use_stock(True) + button.set_label(page_stock) + else: + button.set_label(page_title) button.set_border_width(4) button.set_relief(gtk.RELIEF_NONE) button.set_alignment(0, 0.5) - button.connect('clicked', - lambda x, y : self.notebook.set_current_page(y), index) + button.connect('clicked', + lambda x, y : self.notebook.set_current_page(y), + index) button.show() index += 1 self.bbox.pack_start(button, False) + self.buttons.append(button) self.active_page = self.pages[0] + self.buttons[0].set_active(True) self.active_page.set_active() def change_page(self, obj, page, num=-1): @@ -548,6 +559,10 @@ class ViewManager: if self.state.open: + for ix in range(len(self.buttons)): + if ix != num and self.buttons[ix].get_active(): + self.buttons[ix].set_active(False) + for mergeid in self.merge_ids: self.uimanager.remove_ui(mergeid)