diff --git a/src/gui/columnorder.py b/src/gui/columnorder.py index 40550d098..6e4f4d089 100644 --- a/src/gui/columnorder.py +++ b/src/gui/columnorder.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2003 Donald N. Allingham # Copyright (C) 2010 Benny Malengier +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -61,12 +62,13 @@ class ColumnOrder(gtk.VBox): Column ordering selection widget """ - def __init__(self, config, column_names, on_apply, tree=False): + def __init__(self, config, column_names, widths, on_apply, tree=False): """ Create the Column Ordering widget based on config config: a configuration file with column data column_names: translated names for the possible columns + widths: the widths of the visible columns on_apply: function to run when apply is clicked tree: are the columns for a treeview, if so, the first columns is not changable @@ -132,8 +134,11 @@ class ColumnOrder(gtk.VBox): self.oldsize = self.config.get('columns.size') self.oldvis = self.config.get('columns.visible') colord = [] + index = 0 for val, size in zip(self.oldorder, self.oldsize): if val in self.oldvis: + size = widths[index] + index += 1 colord.append((1, val, size)) else: colord.append((0, val, size)) diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index 6020a662a..740feb1b2 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001-2007 Donald N. Allingham -# Copyright (C) 2009 Nick Hall +# Copyright (C) 2009-2010 Nick Hall # Copyright (C) 2009 Benny Malengier # # This program is free software; you can redistribute it and/or modify @@ -483,6 +483,9 @@ class ListView(NavigationView): colord.append((0, val, size)) return colord + def get_column_widths(self): + return [column.get_width() for column in self.columns] + def remove_selected_objects(self): """ Function to remove selected objects @@ -861,6 +864,24 @@ class ListView(NavigationView): self.edit_action.set_visible(True) self.edit_action.set_sensitive(not self.dbstate.db.readonly) + def on_delete(self): + """ + Save the column widths when the view is shutdown. + """ + widths = self.get_column_widths() + order = self._config.get('columns.rank') + size = self._config.get('columns.size') + vis = self._config.get('columns.visible') + newsize = [] + index = 0 + for val, size in zip(order, size): + if val in vis: + size = widths[index] + index += 1 + newsize.append(size) + self._config.set('columns.size', newsize) + self._config.save() + #################################################################### # Export data #################################################################### @@ -1067,6 +1088,7 @@ class ListView(NavigationView): """ def columnpage(configdialog): return _('Columns'), ColumnOrder(self._config, self.COLUMN_NAMES, + self.get_column_widths(), self.set_column_order, tree=self.type_list()==LISTTREE) return [columnpage]