2006-05-26 Alex Roitman <shura@gramps-project.org>
* src/plugins/verify.glade: update interface. * src/plugins/Verify.py: More improvements. Still need to finish filtering and object editing on double click. svn: r6792
This commit is contained in:
parent
c5f3eed5b6
commit
b9cd8ee6c8
@ -1,3 +1,8 @@
|
||||
2006-05-26 Alex Roitman <shura@gramps-project.org>
|
||||
* src/plugins/verify.glade: update interface.
|
||||
* src/plugins/Verify.py: More improvements. Still need to finish
|
||||
filtering and object editing on double click.
|
||||
|
||||
2006-05-26 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_RelationView.py: build skip list for SelectFamily
|
||||
so that a person cannot be his own parent
|
||||
|
@ -33,6 +33,11 @@ This is the research tool, not the low-level data ingerity check.
|
||||
import os
|
||||
from gettext import gettext as _
|
||||
import cPickle
|
||||
import md5
|
||||
try:
|
||||
set()
|
||||
except NameError:
|
||||
from sets import Set as set
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -47,6 +52,7 @@ import gtk.glade
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import const
|
||||
import RelLib
|
||||
import Utils
|
||||
import GrampsDisplay
|
||||
@ -312,11 +318,9 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback):
|
||||
self.top.get_widget(
|
||||
"estimate").get_active()
|
||||
|
||||
# FIXME: Initialize trees and models for normal and hidden warnings
|
||||
# Then create a new class here, fill things
|
||||
vr = VerifyResults(self.uistate, self.track)
|
||||
|
||||
self.add_results = vr.add_results
|
||||
vr.load_ignored(self.db.full_name)
|
||||
|
||||
self.uistate.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
self.uistate.progress.show()
|
||||
@ -333,24 +337,6 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback):
|
||||
# Save options
|
||||
self.options.handler.save_options()
|
||||
|
||||
def load_ignored(self,filename):
|
||||
try:
|
||||
f = open(filename)
|
||||
self.ignores = cPickle.load(f)
|
||||
f.close()
|
||||
return True
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
def save_ignored(self,filename):
|
||||
try:
|
||||
f = open(filename,'w')
|
||||
cPickle.dump(self.ignores,f)
|
||||
f.close()
|
||||
return True
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
def run_tool(self,cli=False):
|
||||
|
||||
person_handles = self.db.get_person_handles(sort_handles=False)
|
||||
@ -451,45 +437,107 @@ class VerifyResults(ManagedWindow):
|
||||
"destroy_passed_object" : self.close,
|
||||
})
|
||||
|
||||
self.warn_model = gtk.ListStore(str,str,str,str,int,str,str)
|
||||
self.hide_model = gtk.ListStore(str,str,str,str,int,str,str)
|
||||
self.warn_tree = self.top.get_widget('warn_tree')
|
||||
self.hide_tree = self.top.get_widget('hide_tree')
|
||||
self.hide_button = self.top.get_widget('hide_button')
|
||||
self.hide_button.connect('toggled',self.hide_toggled)
|
||||
|
||||
self.warn_model = gtk.ListStore(bool,bool,str,str,str,str,int,str,str)
|
||||
self.warn_tree.set_model(self.warn_model)
|
||||
self.hide_tree.set_model(self.hide_model)
|
||||
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.img_renderer = gtk.CellRendererPixbuf()
|
||||
self.bool_renderer = gtk.CellRendererToggle()
|
||||
self.bool_renderer.connect('toggled',self.selection_toggled)
|
||||
|
||||
self.img_column = gtk.TreeViewColumn(None, self.img_renderer )
|
||||
self.warn_tree.append_column(self.img_column)
|
||||
self.img_column.set_cell_data_func(self.img_renderer,self.get_image)
|
||||
self.warn_tree.append_column(
|
||||
gtk.TreeViewColumn(_('Hide'),self.bool_renderer,active=1))
|
||||
|
||||
img_column = gtk.TreeViewColumn(None, self.img_renderer )
|
||||
img_column.set_cell_data_func(self.img_renderer,self.get_image)
|
||||
self.warn_tree.append_column(img_column)
|
||||
|
||||
self.warn_tree.append_column(
|
||||
gtk.TreeViewColumn(_('Warning'), self.renderer,
|
||||
text=0,foreground=6))
|
||||
text=2,foreground=8))
|
||||
self.warn_tree.append_column(
|
||||
gtk.TreeViewColumn(_('ID'), self.renderer,
|
||||
text=1,foreground=6))
|
||||
text=3,foreground=8))
|
||||
self.warn_tree.append_column(
|
||||
gtk.TreeViewColumn(_('Name'), self.renderer,
|
||||
text=2,foreground=6))
|
||||
|
||||
self.hide_tree.append_column(
|
||||
gtk.TreeViewColumn(_('Warning'), self.renderer,
|
||||
text=0,foreground=6))
|
||||
self.hide_tree.append_column(
|
||||
gtk.TreeViewColumn(_('ID'), self.renderer,
|
||||
text=1,foreground=6))
|
||||
self.hide_tree.append_column(
|
||||
gtk.TreeViewColumn(_('Name'), self.renderer,
|
||||
text=2,foreground=6))
|
||||
text=4,foreground=8))
|
||||
|
||||
self.window.show_all()
|
||||
self.window_shown = False
|
||||
|
||||
def load_ignored(self,db_filename):
|
||||
md5sum = md5.md5(db_filename)
|
||||
self.ignores_filename = os.path.join(
|
||||
const.home_dir,md5sum.hexdigest() + os.path.extsep + 'vfm')
|
||||
if not self._load_ignored(self.ignores_filename):
|
||||
self.ignores = {}
|
||||
|
||||
def _load_ignored(self,filename):
|
||||
try:
|
||||
f = open(filename)
|
||||
self.ignores = cPickle.load(f)
|
||||
f.close()
|
||||
return True
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
def save_ignored(self,new_ignores):
|
||||
self.ignores = new_ignores
|
||||
self._save_ignored(self.ignores_filename)
|
||||
|
||||
def _save_ignored(self,filename):
|
||||
try:
|
||||
f = open(filename,'w')
|
||||
cPickle.dump(self.ignores,f,1)
|
||||
f.close()
|
||||
return True
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
def get_marking(self,handle,rule_id):
|
||||
try:
|
||||
return (rule_id in self.ignores[handle])
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
def get_new_marking(self):
|
||||
new_ignores = {}
|
||||
for row_num in range(len(self.warn_model)):
|
||||
path = (row_num,)
|
||||
row = self.warn_model[path]
|
||||
ignore = row[1]
|
||||
if ignore:
|
||||
handle = row[7]
|
||||
rule_id = row[6]
|
||||
if not new_ignores.has_key(handle):
|
||||
new_ignores[handle] = set()
|
||||
new_ignores[handle].add(rule_id)
|
||||
return new_ignores
|
||||
|
||||
def close(self,*obj):
|
||||
new_ignores = self.get_new_marking()
|
||||
self.save_ignored(new_ignores)
|
||||
|
||||
ManagedWindow.close(self,*obj)
|
||||
|
||||
def hide_toggled(self,button):
|
||||
if button.get_active():
|
||||
button.set_label(_("_Show selected"))
|
||||
else:
|
||||
button.set_label(_("_Hide selected"))
|
||||
|
||||
def selection_toggled(self,cell,path_string):
|
||||
path = tuple([int (i) for i in path_string.split(':')])
|
||||
row = self.warn_model[path]
|
||||
row[1] = not row[1]
|
||||
self.warn_model.row_changed(path,row.iter)
|
||||
|
||||
def get_image(self, column, cell, model, iter, user_data=None):
|
||||
the_type = model.get_value(iter, 3)
|
||||
the_type = model.get_value(iter, 5)
|
||||
if the_type == 'Person':
|
||||
cell.set_property('stock-id', 'gramps-person' )
|
||||
elif the_type == 'Family':
|
||||
@ -497,6 +545,7 @@ class VerifyResults(ManagedWindow):
|
||||
|
||||
def add_results(self,results):
|
||||
(msg,gramps_id,name,the_type,rule_id,severity,handle) = results
|
||||
ignore = self.get_marking(handle,rule_id)
|
||||
if severity == Rule.ERROR:
|
||||
fg = 'red'
|
||||
## fg = '#8b008b'
|
||||
@ -504,7 +553,7 @@ class VerifyResults(ManagedWindow):
|
||||
## fg = '#008b00'
|
||||
else:
|
||||
fg = None
|
||||
self.warn_model.append(row=[msg,gramps_id,name,
|
||||
self.warn_model.append(row=[True,ignore,msg,gramps_id,name,
|
||||
the_type,rule_id,handle,fg])
|
||||
|
||||
if not self.window_shown:
|
||||
|
@ -1164,8 +1164,8 @@
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
@ -1192,57 +1192,20 @@
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox7">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="hide_sel_button">
|
||||
<widget class="GtkToggleButton" id="hide_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Mark selected rows as ignored</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Hide selected</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image5">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-delete</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="hide_all_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Mark all rows as ignored</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image4">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-clear</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
@ -1252,7 +1215,7 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="padding">6</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
@ -1264,149 +1227,6 @@
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkExpander" id="expander1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expanded">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="hide_tree">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">True</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="fixed_height_mode">False</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox8">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="unhide_sel_rows">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Unmark selected rows to not be ignored</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image8">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-undelete</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="unhide_all_rows">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Unmark all rows to not be ignored</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image7">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-clear</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label27">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Show ignored warnings</b></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">6</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
Loading…
Reference in New Issue
Block a user