2004-03-10 10:45:06 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-24 09:36:17 +05:30
|
|
|
# Copyright (C) 2000-2003 Donald N. Allingham
|
2004-03-10 10:45:06 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2007-05-20 10:05:46 +05:30
|
|
|
"""
|
|
|
|
Handle the column ordering
|
|
|
|
"""
|
|
|
|
|
2004-03-10 10:45:06 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2007-05-20 10:05:46 +05:30
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
import logging
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK modules
|
2004-03-10 10:45:06 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-19 01:37:09 +05:30
|
|
|
import gtk
|
2008-01-22 03:33:43 +05:30
|
|
|
import gobject
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-05-20 10:05:46 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-03-10 10:45:06 +05:30
|
|
|
import const
|
2006-04-24 03:44:28 +05:30
|
|
|
import ManagedWindow
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
|
|
|
|
2006-04-24 03:44:28 +05:30
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-05-20 10:05:46 +05:30
|
|
|
__LOG = logging.getLogger(".ColumnOrder")
|
2006-03-05 10:15:44 +05:30
|
|
|
|
2006-04-24 03:44:28 +05:30
|
|
|
class ColumnOrder(ManagedWindow.ManagedWindow):
|
2007-05-20 10:05:46 +05:30
|
|
|
"""
|
|
|
|
Column ordering selection dialog
|
|
|
|
"""
|
2006-04-24 03:44:28 +05:30
|
|
|
|
2006-04-24 09:36:17 +05:30
|
|
|
def __init__(self, win_name, uistate, arglist, column_names, callback):
|
2007-05-20 10:05:46 +05:30
|
|
|
"""
|
|
|
|
Create the Column Ordering dialog
|
|
|
|
"""
|
2006-04-24 03:44:28 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
|
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.glade = Glade()
|
|
|
|
self.set_window(self.glade.toplevel, None, win_name)
|
2006-04-24 03:44:28 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.tree = self.glade.get_object('list')
|
2004-03-10 10:45:06 +05:30
|
|
|
self.arglist = arglist
|
|
|
|
self.callback = callback
|
|
|
|
|
2008-01-22 03:33:43 +05:30
|
|
|
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_INT, object)
|
2004-03-10 10:45:06 +05:30
|
|
|
|
|
|
|
self.tree.set_model(self.model)
|
|
|
|
|
|
|
|
checkbox = gtk.CellRendererToggle()
|
2007-07-08 08:57:06 +05:30
|
|
|
checkbox.connect('toggled', toggled, self.model)
|
2004-03-10 10:45:06 +05:30
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
|
|
|
|
column_n = gtk.TreeViewColumn(_('Display'), checkbox, active=0)
|
|
|
|
column_n.set_min_width(50)
|
|
|
|
self.tree.append_column(column_n)
|
|
|
|
|
|
|
|
column_n = gtk.TreeViewColumn(_('Column Name'), renderer, text=1)
|
|
|
|
column_n.set_min_width(225)
|
|
|
|
self.tree.append_column(column_n)
|
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
self.glade.get_object('okbutton').connect('clicked',
|
2006-04-24 03:28:17 +05:30
|
|
|
self.ok_clicked)
|
2009-05-06 20:14:22 +05:30
|
|
|
self.glade.get_object('cancelbutton').connect('clicked',
|
2006-04-24 03:28:17 +05:30
|
|
|
self.cancel_clicked)
|
2004-03-10 10:45:06 +05:30
|
|
|
|
|
|
|
for item in self.arglist:
|
2004-08-11 09:12:38 +05:30
|
|
|
node = self.model.append()
|
2006-04-24 03:28:17 +05:30
|
|
|
self.model.set(node,
|
|
|
|
0, item[0],
|
|
|
|
1, column_names[item[1]],
|
|
|
|
2, item[1],
|
|
|
|
3, item)
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2007-05-20 10:05:46 +05:30
|
|
|
def build_menu_names(self, obj):
|
|
|
|
"""
|
|
|
|
Build the information for the Managed Window menu entries
|
|
|
|
"""
|
2006-04-24 09:36:17 +05:30
|
|
|
return (_('Column Editor'), _('Column Editor'))
|
2006-04-24 03:44:28 +05:30
|
|
|
|
2007-05-20 10:05:46 +05:30
|
|
|
def ok_clicked(self, obj):
|
|
|
|
"""
|
|
|
|
called with the OK button is pressed
|
|
|
|
"""
|
2004-03-10 10:45:06 +05:30
|
|
|
newlist = []
|
2007-05-20 10:05:46 +05:30
|
|
|
for i in range(0, len(self.arglist)):
|
|
|
|
node = self.model.get_iter((int(i), ))
|
2006-04-24 03:28:17 +05:30
|
|
|
enable = self.model.get_value(node, 0)
|
|
|
|
index = self.model.get_value(node, 2)
|
2007-05-20 10:05:46 +05:30
|
|
|
value = self.model.get_value(node, 3)
|
2006-04-24 03:28:17 +05:30
|
|
|
newlist.append((enable, index, value[2]))
|
|
|
|
|
2004-03-10 10:45:06 +05:30
|
|
|
self.callback(newlist)
|
2006-04-24 03:44:28 +05:30
|
|
|
self.close()
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2007-05-20 10:05:46 +05:30
|
|
|
def cancel_clicked(self, obj):
|
|
|
|
"""
|
|
|
|
Called with the Cancel button is pressed.
|
|
|
|
"""
|
2006-04-24 03:44:28 +05:30
|
|
|
self.close()
|
2004-03-10 10:45:06 +05:30
|
|
|
|
2007-07-08 08:57:06 +05:30
|
|
|
def toggled(cell, path, model):
|
2007-05-20 10:05:46 +05:30
|
|
|
"""
|
|
|
|
Called when the cell information is changed, updating the
|
|
|
|
data model so the that change occurs.
|
|
|
|
"""
|
|
|
|
node = model.get_iter((int(path), ))
|
|
|
|
value = not model.get_value(node, 0)
|
|
|
|
model.set(node, 0, value)
|