Reenable changing column order for all listviews

svn: r14179
This commit is contained in:
Benny Malengier 2010-02-01 13:04:19 +00:00
parent 377b0937f6
commit 140c7c6f7d
7 changed files with 108 additions and 161 deletions

14
README
View File

@ -1,4 +1,4 @@
Please read the COPYING file first. cPlease read the COPYING file first.
If building from source, also read the INSTALL file (at least through the If building from source, also read the INSTALL file (at least through the
"SUPER-SHORT VERSION") before going further. "SUPER-SHORT VERSION") before going further.
@ -7,7 +7,6 @@ Requirements
The following packages *MUST* be installed in order for Gramps to work: The following packages *MUST* be installed in order for Gramps to work:
Python 2.5 or greater Python 2.5 or greater
PyGTK2 2.12 or greater PyGTK2 2.12 or greater
Python Glade bindings
librsvg2 (svg icon view) librsvg2 (svg icon view)
xdg-utils xdg-utils
@ -27,13 +26,16 @@ The following packages are *STRONGLY RECOMMENDED* to be installed:
If WEBKIT ang GECKO are installed, webkit will be used. If WEBKIT ang GECKO are installed, webkit will be used.
The following packages are optional The following packages are optional
python gtkspell Enable spell checking in the notes python gtkspell & python enchant : Enable spell checking in the notes,
pyenchant Enable query of installed spell check dictionaries the first contains the libraries, the second is
needed to query the installed languages. Both must
be present for spell check to activate
ttf-freefont More font support in the reports ttf-freefont More font support in the reports
No longer needed in 3.x: No longer needed in 3.1:
yelp Gnome help browser. At the moment no help is shipped yelp Gnome help browser. At the moment no help is shipped
No longer needed in 3.2:
python glade bindings
Documentation Documentation
--------------------------------- ---------------------------------

View File

@ -841,7 +841,6 @@ src/glade/tipofday.glade
src/glade/displaystate.glade src/glade/displaystate.glade
src/glade/addmedia.glade src/glade/addmedia.glade
src/glade/questiondialog.glade src/glade/questiondialog.glade
src/glade/columnorder.glade
src/glade/configure.glade src/glade/configure.glade
src/glade/dateedit.glade src/glade/dateedit.glade
src/glade/editsource.glade src/glade/editsource.glade

View File

@ -18,7 +18,6 @@ dist_pkgdata_DATA = \
displaystate.glade \ displaystate.glade \
addmedia.glade \ addmedia.glade \
questiondialog.glade \ questiondialog.glade \
columnorder.glade \
configure.glade \ configure.glade \
dateedit.glade \ dateedit.glade \
editsource.glade \ editsource.glade \

View File

@ -1,94 +0,0 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="columnorder">
<property name="visible">True</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox15">
<property name="visible">True</property>
<child>
<object class="GtkTable" id="table46">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="n_rows">3</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow77">
<property name="width_request">400</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="reorderable">True</property>
</object>
</child>
</object>
<packing>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area15">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cancelbutton">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="okbutton">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">cancelbutton</action-widget>
<action-widget response="-5">okbutton</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -55,23 +55,50 @@ from glade import Glade
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
__LOG = logging.getLogger(".ColumnOrder") __LOG = logging.getLogger(".ColumnOrder")
class ColumnOrder(ManagedWindow.ManagedWindow): class ColumnOrder(gtk.VBox):
""" """
Column ordering selection dialog Column ordering selection widget
""" """
def __init__(self, win_name, uistate, arglist, column_names, callback): def __init__(self, config, column_names, on_apply, tree=False):
""" """
Create the Column Ordering dialog Create the Column Ordering widget based on config
"""
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.glade = Glade() config: a configuration file with column data
self.set_window(self.glade.toplevel, None, win_name) column_names: translated names for the possible 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
"""
gtk.VBox.__init__(self)
self.tree = self.glade.get_object('list') self.treeview = tree
self.arglist = arglist self.colnames = column_names
self.callback = callback self.config = config
self.on_apply = on_apply
self.startrow = 0
if self.treeview:
label = gtk.Label(
_('Tree View: first column "%s" cannot be changed') %
column_names[0])
self.startrow = 1
self.pack_start(label, expand=False, fill=False)
hbox = gtk.HBox()
hbox.set_spacing(10)
scroll = gtk.ScrolledWindow()
scroll.set_size_request(250,300)
hbox.pack_start(scroll)
self.tree = gtk.TreeView()
self.tree.set_reorderable(True)
scroll.add(self.tree)
self.apply_button = gtk.Button(stock='gtk-apply')
btns = gtk.HButtonBox()
btns.set_layout(gtk.BUTTONBOX_END)
btns.pack_start(self.apply_button)
hbox.pack_start(btns, expand=False)
self.pack_start(hbox)
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
gobject.TYPE_INT, object) gobject.TYPE_INT, object)
@ -90,45 +117,53 @@ class ColumnOrder(ManagedWindow.ManagedWindow):
column_n.set_min_width(225) column_n.set_min_width(225)
self.tree.append_column(column_n) self.tree.append_column(column_n)
self.glade.get_object('okbutton').connect('clicked', self.apply_button.connect('clicked', self.__on_apply)
self.ok_clicked)
self.glade.get_object('cancelbutton').connect('clicked',
self.cancel_clicked)
for item in self.arglist: #obtain the columns from config file
self.oldorder = self.config.get('columns.order')
self.oldsize = self.config.get('columns.sizecol')
self.oldvis = self.config.get('columns.visible')
colord = []
for val, size in zip(self.oldorder, self.oldsize):
if val in self.oldvis:
colord.append((1, val, size))
else:
colord.append((0, val, size))
for item in colord[self.startrow:]:
node = self.model.append() node = self.model.append()
self.model.set(node, self.model.set(node,
0, item[0], 0, item[0],
1, column_names[item[1]], 1, column_names[item[1]],
2, item[1], 2, item[1],
3, item) 3, item[2])
def build_menu_names(self, obj): def __on_apply(self, obj):
"""
Build the information for the Managed Window menu entries
"""
return (_('Column Editor'), _('Column Editor'))
def ok_clicked(self, obj):
""" """
called with the OK button is pressed called with the OK button is pressed
""" """
newlist = [] neworder = []
for i in range(0, len(self.arglist)): newsize = []
newvis = []
if self.treeview:
#first row is fixed
neworder.append(self.oldorder[0])
newvis.append(self.oldvis[0])
newsize.append(self.oldsize[0])
for i in range(0, len(self.colnames[self.startrow:])):
node = self.model.get_iter((int(i), )) node = self.model.get_iter((int(i), ))
enable = self.model.get_value(node, 0) enable = self.model.get_value(node, 0)
index = self.model.get_value(node, 2) index = self.model.get_value(node, 2)
value = self.model.get_value(node, 3) size = self.model.get_value(node, 3)
newlist.append((enable, index, value[2])) if enable:
newvis.append(index)
self.callback(newlist) neworder.append(index)
self.close() newsize.append(size)
self.config.set('columns.order', neworder)
def cancel_clicked(self, obj): self.config.set('columns.sizecol', newsize)
""" self.config.set('columns.visible', newvis)
Called with the Cancel button is pressed. self.config.save()
""" if self.on_apply:
self.close() self.on_apply()
def toggled(cell, path, model): def toggled(cell, path, model):
""" """

View File

@ -461,11 +461,11 @@ class ListView(NavigationView):
sel_data.set(sel_data.target, 8 , pickle.dumps(data)) sel_data.set(sel_data.target, 8 , pickle.dumps(data))
return True return True
def set_column_order(self, clist): def set_column_order(self):
""" """
change the order of the columns to that given in clist change the order of the columns to that given in config file
after config file changed. We reset the sort to the first column
""" """
self.column_ord_setfunc(clist)
#now we need to rebuild the model so it contains correct column info #now we need to rebuild the model so it contains correct column info
self.dirty = True self.dirty = True
#make sure we sort on first column. We have no idea where the #make sure we sort on first column. We have no idea where the
@ -496,20 +496,6 @@ class ListView(NavigationView):
colord.append((0, val, size)) colord.append((0, val, size))
return colord return colord
def column_ord_setfunc(self, clist):
"""
Must be set by children. The method that stores the column order
given by clist (result of ColumnOrder class).
"""
raise NotImplementedError
def _column_editor(self, obj):
"""
Causes the View to display a column editor. This should be overridden
by any class that provides columns (such as a list based view)
"""
raise NotImplemented
def remove_selected_objects(self): def remove_selected_objects(self):
""" """
Function to remove selected objects Function to remove selected objects
@ -1077,7 +1063,8 @@ class ListView(NavigationView):
def config_connect(self): def config_connect(self):
""" """
Overwriten from :class:`~gui.views.pageview.PageView method Overwriten from :class:`~gui.views.pageview.PageView method
This method will be called after the ini file is initialized This method will be called after the ini file is initialized,
use it to monitor changes in the ini file
""" """
#func = self.config_callback(self.build_tree) #func = self.config_callback(self.build_tree)
#self._config.connect('columns.visible', func) #self._config.connect('columns.visible', func)
@ -1092,6 +1079,7 @@ class ListView(NavigationView):
:return: list of functions :return: list of functions
""" """
def columnpage(): def columnpage():
return _('Columns', ColumnOrder(self._config, COLUMN_NAMES, return _('Columns'), ColumnOrder(self._config, self.COLUMN_NAMES,
tree=False)) self.set_column_order,
tree=self.type_list()==LISTTREE)
return [columnpage] return [columnpage]

View File

@ -444,9 +444,12 @@ class PageView(DbGUIElement):
title = _("Configure %(cat)s - %(view)s") % \ title = _("Configure %(cat)s - %(view)s") % \
{'cat': self.get_category(), 'view': self.get_title()} {'cat': self.get_category(), 'view': self.get_title()}
try: try:
ConfigureDialog(self.uistate, self.dbstate, ViewConfigureDialog(self.uistate, self.dbstate,
self.__configure_content, self.__configure_content,
self, self._config, dialogtitle=title) self, self._config, dialogtitle=title,
ident=_("%(cat)s - %(view)s") %
{'cat': self.get_category(),
'view': self.get_title()})
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
@ -458,3 +461,18 @@ class PageView(DbGUIElement):
:return: list of functions :return: list of functions
""" """
raise NotImplementedError raise NotImplementedError
class ViewConfigureDialog(ConfigureDialog):
"""
All PageViews can have their own configuration dialog
"""
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
configmanager,
dialogtitle=_("Preferences"), on_close=None, ident=''):
self.ident = ident
ConfigureDialog.__init__(self, uistate, dbstate, configure_page_funcs,
configobj, configmanager,
dialogtitle=dialogtitle, on_close=on_close)
def build_menu_names(self, obj):
return (_('Configure %s View') % self.ident, None)