From 8d23e8ee806def79744ae70a7f214123a45c2d74 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 17 Aug 2007 03:16:56 +0000 Subject: [PATCH] The column menu list now toggles visibility of the columns. --- deluge/ui/gtkui/listview.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index 6b3359614..262b05dc9 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtkui/listview.py @@ -110,8 +110,7 @@ class ListView: # Dictionary of 'header' or 'name' to ListViewColumn object self.columns = {} - # Column_index will keep track of the order that the visible columns - # are in. + # Column_index keeps track of the order of the visible columns. self.column_index = [] # The column types for the list store.. this may have more entries than # visible columns due to some columns utilizing more than 1 liststore @@ -130,7 +129,15 @@ class ListView: return self.columns[name].column_indices else: return self.columns[name].column_indices[0] - + + def on_menuitem_toggled(self, widget): + # Get the column name from the widget + name = widget.get_child().get_text() + + # Set the column's visibility based on the widgets active state + self.columns[name].column.set_visible(widget.get_active()) + return + def create_checklist_menu(self): self.menu = gtk.Menu() # Iterate through the column_index list to preserve order @@ -145,6 +152,8 @@ class ListView: # (or checked) in the menu. if column.column.get_visible() is True: menuitem.set_active(True) + # Connect to the 'toggled' event + menuitem.connect("toggled", self.on_menuitem_toggled) # Add the new checkmenuitem to the menu self.menu.append(menuitem) return self.menu