Check.py - convert to use gtkbuilder instead of libglade

svn: r12409
This commit is contained in:
Gerald Britton 2009-04-08 19:41:22 +00:00
parent 0b61b4a8a4
commit a3f82400ef
2 changed files with 182 additions and 176 deletions

View File

@ -49,7 +49,6 @@ log = logging.getLogger(".CheckRepair")
#
#-------------------------------------------------------------------------
import gtk
from gtk import glade
#-------------------------------------------------------------------------
#
@ -376,13 +375,15 @@ class CheckIntegrity:
self.broken_parent_links.append((mother_handle,family_handle))
mother_handle = None
if father_handle and father and family_handle not in father.get_family_handle_list():
if father_handle and father and \
family_handle not in father.get_family_handle_list():
# The referenced father has no reference back to the family
self.broken_parent_links.append((father_handle,family_handle))
father.add_family_handle(family_handle)
self.db.commit_person(father,self.trans)
if mother_handle and mother \
and (family_handle not in mother.get_family_handle_list()):
if mother_handle and mother and \
family_handle not in mother.get_family_handle_list():
# The referenced mother has no reference back to the family
self.broken_parent_links.append((mother_handle,family_handle))
mother.add_family_handle(family_handle)
@ -655,13 +656,13 @@ class CheckIntegrity:
CHANGE_NOTE),
'remove' : self.db.remove_note},
}
for the_type in tables.keys():
cursor = tables[the_type]['cursor_func']()
total = tables[the_type]['total_func']()
check = tables[the_type]['check_func']
remove_func = tables[the_type]['remove']
for the_type, the_func in tables.iteritems():
cursor = the_func['cursor_func']()
total = the_func['total_func']()
check = the_func['check_func']
remove_func = the_func['remove']
self.progress.set_pass(tables[the_type]['progress'],total)
self.progress.set_pass(the_func['progress'],total)
item = cursor.first()
while item:
@ -1057,11 +1058,15 @@ class CheckIntegrity:
def check_source_references(self):
known_handles = self.db.get_source_handles()
total = self.db.get_number_of_people() + self.db.get_number_of_families() + \
self.db.get_number_of_events() + self.db.get_number_of_places() + \
self.db.get_number_of_media_objects() + \
self.db.get_number_of_sources() + \
total = (
self.db.get_number_of_people() +
self.db.get_number_of_families() +
self.db.get_number_of_events() +
self.db.get_number_of_places() +
self.db.get_number_of_media_objects() +
self.db.get_number_of_sources() +
self.db.get_number_of_repositories()
)
self.progress.set_pass(_('Looking for source reference problems'),
total)
@ -1182,9 +1187,13 @@ class CheckIntegrity:
def check_media_references(self):
known_handles = self.db.get_media_object_handles(False)
total = self.db.get_number_of_people() + self.db.get_number_of_families() + \
self.db.get_number_of_events() + self.db.get_number_of_places() + \
total = (
self.db.get_number_of_people() +
self.db.get_number_of_families() +
self.db.get_number_of_events() +
self.db.get_number_of_places() +
self.db.get_number_of_sources()
)
self.progress.set_pass(_('Looking for media object reference problems'),
total)
@ -1272,11 +1281,15 @@ class CheckIntegrity:
def check_note_references(self):
known_handles = self.db.get_note_handles()
total = self.db.get_number_of_people() + self.db.get_number_of_families() + \
self.db.get_number_of_events() + self.db.get_number_of_places() + \
self.db.get_number_of_media_objects() + \
self.db.get_number_of_sources() + \
total = (
self.db.get_number_of_people() +
self.db.get_number_of_families() +
self.db.get_number_of_events() +
self.db.get_number_of_places() +
self.db.get_number_of_media_objects() +
self.db.get_number_of_sources() +
self.db.get_number_of_repositories()
)
self.progress.set_pass(_('Looking for note reference problems'),
total)
@ -1423,21 +1436,22 @@ class CheckIntegrity:
media_references = len(self.invalid_media_references)
note_references = len(self.invalid_note_references)
name_format = len(self.removed_name_format)
empty_objs = ( len(self.empty_objects['persons'])
+ len(self.empty_objects['families'])
+ len(self.empty_objects['events'])
+ len(self.empty_objects['sources'])
+ len(self.empty_objects['media'])
+ len(self.empty_objects['places'])
+ len(self.empty_objects['repos'])
+ len(self.empty_objects['notes'])
empty_objs = (
len(self.empty_objects['persons']) +
len(self.empty_objects['families']) +
len(self.empty_objects['events']) +
len(self.empty_objects['sources']) +
len(self.empty_objects['media']) +
len(self.empty_objects['places']) +
len(self.empty_objects['repos']) +
len(self.empty_objects['notes'])
)
errors = (photos + efam + blink + plink + slink + rel
+ event_invalid + person
+ person_references + place_references + source_references
+ repo_references + media_references + note_references
+ name_format + empty_objs + invalid_dates
errors = (photos + efam + blink + plink + slink + rel +
event_invalid + person +
person_references + place_references + source_references +
repo_references + media_references + note_references +
name_format + empty_objs + invalid_dates
)
if errors == 0:
@ -1609,15 +1623,16 @@ class Report(ManagedWindow.ManagedWindow):
base = os.path.dirname(__file__)
glade_file = base + os.sep + "summary.glade"
topDialog = glade.XML(glade_file,"summary","gramps")
topDialog.get_widget("close").connect('clicked',self.close)
window = topDialog.get_widget("summary")
textwindow = topDialog.get_widget("textwindow")
topDialog = gtk.Builder()
topDialog.add_from_file(glade_file)
topDialog.get_object("close").connect('clicked',self.close)
window = topDialog.get_object ("summary")
textwindow = topDialog.get_object("textwindow")
textwindow.get_buffer().set_text(text)
self.set_window(window,
topDialog.get_widget("title"),
#topDialog.get_widget("title"),
topDialog.get_object("title"),
_("Integrity Check Results"))
self.show()

View File

@ -1,137 +1,128 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkDialog" id="summary">
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">450</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<signal name="delete_event" handler="on_delete_event" last_modification_time="Thu, 24 Mar 2005 18:53:09 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="destroy_passed_object" object="summary"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</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="padding">8</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_OUT</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="textwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
<object class="GtkDialog" id="summary">
<property name="visible">True</property>
<property name="title" translatable="yes"/>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">450</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<signal handler="on_delete_event" last_modification_time="Thu, 24 Mar 2005 18:53:09 GMT" name="delete_event"/>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<object class="GtkButton" id="close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal handler="destroy_passed_object" name="clicked" object="summary"/>
</object>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="label" translatable="yes"/>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</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>
</object>
<packing>
<property name="padding">8</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_OUT</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<object class="GtkTextView" id="textwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
</object>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">close</action-widget>
</action-widgets>
</object>
</interface>