0407 and 1447: Save column widths in configuration file
svn: r14953
This commit is contained in:
parent
e090d8d250
commit
f22febbea0
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2003 Donald N. Allingham
|
# Copyright (C) 2000-2003 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Benny Malengier
|
# Copyright (C) 2010 Benny Malengier
|
||||||
|
# Copyright (C) 2010 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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
|
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
|
Create the Column Ordering widget based on config
|
||||||
|
|
||||||
config: a configuration file with column data
|
config: a configuration file with column data
|
||||||
column_names: translated names for the possible columns
|
column_names: translated names for the possible columns
|
||||||
|
widths: the widths of the visible columns
|
||||||
on_apply: function to run when apply is clicked
|
on_apply: function to run when apply is clicked
|
||||||
tree: are the columns for a treeview, if so, the first columns is not
|
tree: are the columns for a treeview, if so, the first columns is not
|
||||||
changable
|
changable
|
||||||
@ -132,8 +134,11 @@ class ColumnOrder(gtk.VBox):
|
|||||||
self.oldsize = self.config.get('columns.size')
|
self.oldsize = self.config.get('columns.size')
|
||||||
self.oldvis = self.config.get('columns.visible')
|
self.oldvis = self.config.get('columns.visible')
|
||||||
colord = []
|
colord = []
|
||||||
|
index = 0
|
||||||
for val, size in zip(self.oldorder, self.oldsize):
|
for val, size in zip(self.oldorder, self.oldsize):
|
||||||
if val in self.oldvis:
|
if val in self.oldvis:
|
||||||
|
size = widths[index]
|
||||||
|
index += 1
|
||||||
colord.append((1, val, size))
|
colord.append((1, val, size))
|
||||||
else:
|
else:
|
||||||
colord.append((0, val, size))
|
colord.append((0, val, size))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2001-2007 Donald N. Allingham
|
# Copyright (C) 2001-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2009 Nick Hall
|
# Copyright (C) 2009-2010 Nick Hall
|
||||||
# Copyright (C) 2009 Benny Malengier
|
# Copyright (C) 2009 Benny Malengier
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -483,6 +483,9 @@ class ListView(NavigationView):
|
|||||||
colord.append((0, val, size))
|
colord.append((0, val, size))
|
||||||
return colord
|
return colord
|
||||||
|
|
||||||
|
def get_column_widths(self):
|
||||||
|
return [column.get_width() for column in self.columns]
|
||||||
|
|
||||||
def remove_selected_objects(self):
|
def remove_selected_objects(self):
|
||||||
"""
|
"""
|
||||||
Function to remove selected objects
|
Function to remove selected objects
|
||||||
@ -861,6 +864,24 @@ class ListView(NavigationView):
|
|||||||
self.edit_action.set_visible(True)
|
self.edit_action.set_visible(True)
|
||||||
self.edit_action.set_sensitive(not self.dbstate.db.readonly)
|
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
|
# Export data
|
||||||
####################################################################
|
####################################################################
|
||||||
@ -1067,6 +1088,7 @@ class ListView(NavigationView):
|
|||||||
"""
|
"""
|
||||||
def columnpage(configdialog):
|
def columnpage(configdialog):
|
||||||
return _('Columns'), ColumnOrder(self._config, self.COLUMN_NAMES,
|
return _('Columns'), ColumnOrder(self._config, self.COLUMN_NAMES,
|
||||||
|
self.get_column_widths(),
|
||||||
self.set_column_order,
|
self.set_column_order,
|
||||||
tree=self.type_list()==LISTTREE)
|
tree=self.type_list()==LISTTREE)
|
||||||
return [columnpage]
|
return [columnpage]
|
||||||
|
Loading…
Reference in New Issue
Block a user