def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], self.__class__) self.callback = uistate.pulse_progressbar self.batch_ops = [] self.build_batch_ops() self.assistant = Gtk.Assistant() self.set_window(self.assistant, None, _('Media Manager')) self.setup_configs('interface.mediaman', 780, 600) self.assistant.connect('close', self.do_close) self.assistant.connect('cancel', self.do_close) self.assistant.connect('apply', self.run) self.assistant.connect('prepare', self.prepare) intro = IntroductionPage() self.add_page(intro, Gtk.AssistantPageType.INTRO, _('Introduction')) self.selection = SelectionPage(self.batch_ops) self.add_page(self.selection, Gtk.AssistantPageType.CONTENT, _('Selection')) self.settings = SettingsPage(self.batch_ops, self.assistant) self.add_page(self.settings, Gtk.AssistantPageType.CONTENT) self.confirmation = ConfirmationPage(self.batch_ops) self.add_page(self.confirmation, Gtk.AssistantPageType.CONFIRM, _('Final confirmation')) self.conclusion = ConclusionPage(self.assistant) self.add_page(self.conclusion, Gtk.AssistantPageType.SUMMARY) self.show() self.assistant.set_forward_page_func(self.forward_page, None)
def __init__(self, dbstate, user, options_class, name, callback=None): # type: (Any, Any, Any, str, Callable) -> None tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, user.uistate, [], self.__class__, modal=False) self.user = user self.uistate = user.uistate self.dbstate = dbstate # self.track = [] self.frame = None self.categories = [ "Person", "Family", "Event", "Place", "Citation", "Source", "Repository", "Media", "Note", ] self.categories_translated = [_(cat) for cat in self.categories] self.colors = [ Gdk.RGBA(0.39, 0.39, 0.58, 0.999), Gdk.RGBA(0.39, 0.58, 0.39, 0.999), Gdk.RGBA(0.58, 0.58, 0.39, 0.999), Gdk.RGBA(0.58, 0.39, 0.39, 0.999), Gdk.RGBA(0.39, 0.58, 0.58, 0.999), Gdk.RGBA(0.58, 0.39, 0.58, 0.999), ] self.use_colors = True self.filterdb = gramps.gen.filters.CustomFilters self.dialog = self.create_gui() self.set_window(self.dialog, None, _("Filter Parameters"))
def close(self, *obj): """ Close relcalc tool. Remove non-gtk connections so garbage collection can do its magic. """ self.relationship.disconnect_db_signals(self.dbstate) self.sel.disconnect(self.changedkey) ManagedWindow.close(self, *obj)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Sources Index') self.base = os.path.dirname(__file__) ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.Tool.__init__(self, dbstate, options_class, name) glade_file = os.path.join(USER_PLUGINS, "SourceIndex", "index.glade") if gramps.gen.constfunc.lin(): import locale locale.setlocale(locale.LC_ALL, '') # This is needed to make gtk.Builder work by specifying the # translations directory locale.bindtextdomain("addon", self.base + "/locale") self.glade = Gtk.Builder() self.glade.set_translation_domain("addon") self.glade.add_from_file(glade_file) from gi.repository import GObject GObject.GObject.__init__(self.glade) self.top = self.glade.get_object('edit_index') self.set_window(self.top, self.glade.get_object('title'), self.label) self.birth_button = self.glade.get_object('add_b') self.death_button = self.glade.get_object('add_d') self.marriage_button = self.glade.get_object('add_m') self.census_button = self.glade.get_object('add_c') self.birth_button.connect('clicked', self.birth_editor) self.death_button.connect('clicked', self.death_editor) self.marriage_button.connect('clicked', self.marriage_editor) self.census_button.connect('clicked', self.census_editor) else: # Glade class from gui/glade.py and gui/managedwindow.py self.define_glade('edit_index', glade_file) self.set_window(self._gladeobj.toplevel, None, text=None, msg='Index') self.connect_button('add_b', self.birth_editor) self.connect_button('add_m', self.marriage_editor) self.connect_button('add_d', self.death_editor) self.connect_button('add_c', self.census_editor) #self.window.connect('delete-event', GladeHandlers.on_quit_clicked) self.window.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.dbstate = dbstate self.uistate = uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], self) self.qual = 0 self.filterDialog = Glade(toplevel="filters", also_load=["liststore1"]) self.filterDialog.connect_signals({ "on_apply_clicked": self.on_apply_clicked, "on_editor_clicked": self.filter_editor_clicked, "on_help_clicked": self.on_help_clicked, "destroy_passed_object": self.close, "on_write_table": self.__dummy, }) window = self.filterDialog.toplevel self.filters = self.filterDialog.get_object("filter_list") self.label = _('Event comparison filter selection') self.set_window(window, self.filterDialog.get_object('title'), self.label) self.setup_configs('interface.eventcomparison', 640, 220) self.on_filters_changed('Person') uistate.connect('filters-changed', self.on_filters_changed) self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.dbstate = dbstate self.uistate = uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], self) self.qual = 0 self.filterDialog = Glade(toplevel="filters") self.filterDialog.connect_signals( { "on_apply_clicked": self.on_apply_clicked, "on_editor_clicked": self.filter_editor_clicked, "on_help_clicked": self.on_help_clicked, "destroy_passed_object": self.close, "on_write_table": self.__dummy, } ) window = self.filterDialog.toplevel self.filters = self.filterDialog.get_object("filter_list") self.label = _("Event comparison filter selection") self.set_window(window, self.filterDialog.get_object("title"), self.label) self.on_filters_changed("Person") uistate.connect("filters-changed", self.on_filters_changed) self.show()
def __init__(self, uistate, track, data, name): self.name = name title = _("%(str1)s: %(str2)s") % { 'str1': _("Detailed Info"), 'str2': name } ManagedWindow.__init__(self, uistate, track, self) dlg = Gtk.Dialog(title="", transient_for=uistate.window, destroy_with_parent=True) dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE) self.set_window(dlg, None, title) self.setup_configs('interface.plugininfo', 720, 520) self.window.connect( 'response', # pylint: disable=no-member self.close) scrolled_window = Gtk.ScrolledWindow(expand=True) # scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, # Gtk.PolicyType.AUTOMATIC) self.text = Gtk.TextView() scrolled_window.add(self.text) self.text.get_buffer().set_text(data) # pylint: disable=no-member self.window.get_content_area().add(scrolled_window) self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Sources Index") self.base = os.path.dirname(__file__) ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), "") tool.Tool.__init__(self, dbstate, options_class, name) glade_file = os.path.join(USER_PLUGINS, "SourceIndex", "death.glade") if gramps.gen.constfunc.lin(): import locale locale.setlocale(locale.LC_ALL, "") # This is needed to make gtk.Builder work by specifying the # translations directory locale.bindtextdomain("addon", self.base + "/locale") self.glade = Gtk.Builder() self.glade.set_translation_domain("addon") self.glade.add_from_file(glade_file) from gi.repository import GObject GObject.GObject.__init__(self.glade) window = self.glade.get_object("edit_death") self.set_window(window, self.glade.get_object("title"), self.label) # self.wit_button = self.glade.get_object('add_wit') self.ok_button = self.glade.get_object("ok") self.quit_button = self.glade.get_object("cancel") else: # Glade class from gui/glade.py and gui/managedwindow.py self.top = Glade() window = self.top.toplevel self.set_window(window, None, glade_file) # self.wit_button = self.top.get_object('add_wit') self.ok_button = self.top.get_object("ok") self.quit_button = self.top.get_object("cancel") # self.wit_button.connect('clicked', GtkHandlers.on_witness_clicked) self.ok_button.connect("clicked", self.close) self.quit_button.connect("clicked", self.close) self.window.show() # tests filename = os.path.join(USER_PLUGINS, "SourceIndex", "test_death.xml") self.write_xml(filename, "D0001", "DATE", "NOM") self.parse_xml(filename)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) self.window_name = _('Media Verify Tool') ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate self.moved_files = [] self.titles = [_('Moved/Renamed Files'), _('Missing Files'), _('Duplicate Files'), _('Extra Files'), _('No md5 Generated'), _('Errors')] self.models = [] self.views = [] window = Gtk.Window() vbox = Gtk.VBox() self.notebook = Gtk.Notebook() self.notebook.set_scrollable(True) for title in self.titles: self.create_tab(title) vbox.pack_start(self.notebook, True, True, 5) bbox = Gtk.HButtonBox() vbox.pack_start(bbox, False, False, 5) close = Gtk.Button(_('Close')) close.set_tooltip_text(_('Close the Media Verify Tool')) close.connect('clicked', self.close) generate = Gtk.Button(_('Generate')) generate.set_tooltip_text(_('Generate md5 hashes for media objects')) generate.connect('clicked', self.generate_md5) verify = Gtk.Button(_('Verify')) verify.set_tooltip_text(_('Check media paths and report missing, ' 'duplicate and extra files')) verify.connect('clicked', self.verify_media) export = Gtk.Button(_('Export')) export.set_tooltip_text(_('Export the results to a text file')) export.connect('clicked', self.export_results) fix = Gtk.Button(_('Fix')) fix.set_tooltip_text(_('Fix media paths of moved and renamed files')) fix.connect('clicked', self.fix_media) bbox.add(close) bbox.add(generate) bbox.add(verify) bbox.add(export) bbox.add(fix) vbox.show_all() window.add(vbox) window.set_size_request(500, 300) window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.set_window(window, None, self.window_name) self.show() self.show_tabs()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Sources Index') self.base = os.path.dirname(__file__) ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.Tool.__init__(self, dbstate, options_class, name) glade_file = os.path.join(USER_PLUGINS, "SourceIndex", "death.glade") if gramps.gen.constfunc.lin(): import locale locale.setlocale(locale.LC_ALL, '') # This is needed to make gtk.Builder work by specifying the # translations directory locale.bindtextdomain("addon", self.base + "/locale") self.glade = Gtk.Builder() self.glade.set_translation_domain("addon") self.glade.add_from_file(glade_file) from gi.repository import GObject GObject.GObject.__init__(self.glade) window = self.glade.get_object('edit_death') self.set_window(window, self.glade.get_object('title'), self.label) #self.wit_button = self.glade.get_object('add_wit') self.ok_button = self.glade.get_object('ok') self.quit_button = self.glade.get_object('cancel') else: # Glade class from gui/glade.py and gui/managedwindow.py self.top = Glade() window = self.top.toplevel self.set_window(window, None, glade_file) #self.wit_button = self.top.get_object('add_wit') self.ok_button = self.top.get_object('ok') self.quit_button = self.top.get_object('cancel') #self.wit_button.connect('clicked', GtkHandlers.on_witness_clicked) self.ok_button.connect('clicked', self.close) self.quit_button.connect('clicked', self.close) self.window.show() # tests filename = os.path.join(USER_PLUGINS, 'SourceIndex', 'test_death.xml') self.write_xml(filename, 'D0001', 'DATE', 'NOM') self.parse_xml(filename)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Sources Index') self.base = os.path.dirname(__file__) ManagedWindow.__init__(self, uistate,[], self.__class__) self.set_window(Gtk.Window(),Gtk.Label(),'') tool.Tool.__init__(self, dbstate, options_class, name) glade_file = os.path.join(USER_PLUGINS, "SourceIndex", "index.glade") if gramps.gen.constfunc.lin(): import locale locale.setlocale(locale.LC_ALL, '') # This is needed to make gtk.Builder work by specifying the # translations directory locale.bindtextdomain("addon", self.base + "/locale") self.glade = Gtk.Builder() self.glade.set_translation_domain("addon") self.glade.add_from_file(glade_file) from gi.repository import GObject GObject.GObject.__init__(self.glade) self.top = self.glade.get_object('edit_index') self.set_window(self.top, self.glade.get_object('title'), self.label) self.birth_button = self.glade.get_object('add_b') self.death_button = self.glade.get_object('add_d') self.marriage_button = self.glade.get_object('add_m') self.census_button = self.glade.get_object('add_c') self.birth_button.connect('clicked', self.birth_editor) self.death_button.connect('clicked', self.death_editor) self.marriage_button.connect('clicked', self.marriage_editor) self.census_button.connect('clicked', self.census_editor) else: # Glade class from gui/glade.py and gui/managedwindow.py self.define_glade('edit_index', glade_file) self.set_window(self._gladeobj.toplevel, None, text=None, msg='Index') self.connect_button('add_b', self.birth_editor) self.connect_button('add_m', self.marriage_editor) self.connect_button('add_d', self.death_editor) self.connect_button('add_c', self.census_editor) #self.window.connect('delete-event', GladeHandlers.on_quit_clicked) self.window.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.title = _('Unused Objects') tool.Tool.__init__(self, dbstate, options_class, name) if self.db.readonly: return ManagedWindow.__init__(self, uistate,[], self.__class__) UpdateCallback.__init__(self, self.uistate.pulse_progressbar) self.dbstate = dbstate self.uistate = uistate self.tables = { 'events' : {'get_func': self.db.get_event_from_handle, 'remove' : self.db.remove_event, 'get_text': self.get_event_text, 'editor' : 'EditEvent', 'icon' : 'gramps-event', 'name_ix' : 4}, 'sources' : {'get_func': self.db.get_source_from_handle, 'remove' : self.db.remove_source, 'get_text': None, 'editor' : 'EditSource', 'icon' : 'gramps-source', 'name_ix' : 2}, 'places' : {'get_func': self.db.get_place_from_handle, 'remove' : self.db.remove_place, 'get_text': None, 'editor' : 'EditPlace', 'icon' : 'gramps-place', 'name_ix' : 2}, 'media' : {'get_func': self.db.get_object_from_handle, 'remove' : self.db.remove_object, 'get_text': None, 'editor' : 'EditMedia', 'icon' : 'gramps-media', 'name_ix' : 4}, 'repos' : {'get_func': self.db.get_repository_from_handle, 'remove' : self.db.remove_repository, 'get_text': None, 'editor' : 'EditRepository', 'icon' : 'gramps-repository', 'name_ix' : 3}, 'notes' : {'get_func': self.db.get_note_from_handle, 'remove' : self.db.remove_note, 'get_text': self.get_note_text, 'editor' : 'EditNote', 'icon' : 'gramps-notes', 'name_ix' : 2}, } self.init_gui()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) stats_list = [] for name, value in dbstate.db.genderStats.stats.items(): stats_list.append( (name,) + value + (_GENDER[dbstate.db.genderStats.guess_gender(name)],) ) if uistate: ManagedWindow.__init__(self, uistate, [], self.__class__) titles = [(_('Name'), 0, 100), (_('Male'), 1, 70, INTEGER), (_('Female'), 2, 70, INTEGER), (_('Unknown'), 3, 90, INTEGER), (_('Guess'), 4, 70)] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in sorted(stats_list): model.add(entry, entry[0]) s = Gtk.ScrolledWindow() s.add(treeview) dialog = Gtk.Dialog() dialog.add_button(_('_Close'), Gtk.ResponseType.CLOSE) dialog.connect('response', self._response) dialog.vbox.pack_start(s, expand=True, fill=True, padding=0) self.set_window(dialog, None, self.label) self.setup_configs('interface.dumpgenderstats', 420, 300) self.show() else: if len(_('Name')) < 16: print('%s%s%s' % (_('Name'), " " * (16 - len(_('Name'))), _('Male')), '\t%s'*3 % (_('Female'), _('Unknown'), _('Guess'))) else: print(_('Name'), '\t%s'*4 % (_('Male'), _('Female'), _('Unknown'), _('Guess'))) print() for entry in sorted(stats_list): if len(entry[0]) < 16: print('%s%s%s' % (entry[0], " " * (16 - len(entry[0])), entry[1]), '\t%s'*3 % (entry[2:])) else: print(entry[0], '\t%s'*4 % (entry[1:]))
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.title = _('Unused Objects') tool.Tool.__init__(self, dbstate, options_class, name) if self.db.readonly: return ManagedWindow.__init__(self, uistate,[], self.__class__) UpdateCallback.__init__(self, self.uistate.pulse_progressbar) self.dbstate = dbstate self.uistate = uistate self.tables = { 'events' : {'get_func': self.db.get_event_from_handle, 'remove' : self.db.remove_event, 'get_text': self.get_event_text, 'editor' : 'EditEvent', 'stock' : 'gramps-event', 'name_ix' : 4}, 'sources' : {'get_func': self.db.get_source_from_handle, 'remove' : self.db.remove_source, 'get_text': None, 'editor' : 'EditSource', 'stock' : 'gramps-source', 'name_ix' : 2}, 'places' : {'get_func': self.db.get_place_from_handle, 'remove' : self.db.remove_place, 'get_text': None, 'editor' : 'EditPlace', 'stock' : 'gramps-place', 'name_ix' : 2}, 'media' : {'get_func': self.db.get_object_from_handle, 'remove' : self.db.remove_object, 'get_text': None, 'editor' : 'EditMedia', 'stock' : 'gramps-media', 'name_ix' : 4}, 'repos' : {'get_func': self.db.get_repository_from_handle, 'remove' : self.db.remove_repository, 'get_text': None, 'editor' : 'EditRepository', 'stock' : 'gramps-repository', 'name_ix' : 3}, 'notes' : {'get_func': self.db.get_note_from_handle, 'remove' : self.db.remove_note, 'get_text': self.get_note_text, 'editor' : 'EditNote', 'stock' : 'gramps-notes', 'name_ix' : 2}, } self.init_gui()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Associations state tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self, uistate, [], self.__class__) stats_list = [] relationship = get_relationship_calculator() rel = "" plist = dbstate.db.get_person_handles(sort_handles=True) for handle in plist: person = dbstate.db.get_person_from_handle(handle) name1 = name_displayer.display(person) refs = person.get_person_ref_list() if refs: for ref in person.serialize()[-1]: (a, b, c, two, value) = ref person2 = dbstate.db.get_person_from_handle(two) name2 = name_displayer.display(person2) rel = relationship.get_one_relationship( dbstate.db, person2, person) stats_list.append((name1, value, name2, rel)) if uistate: titles = [ (_('Name'), 0, 200), (_('Type of link'), 1, 200), (_('Of'), 2, 200), (_('Relationship Calculator'), 2, 200), ] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(1000, 600) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s' * 4 % ('Name', 'Type of link', 'Of', 'RelCal')) print() for entry in stats_list: print('\t%s' * 4 % entry)
def __init__(self, dbstate, user, options_class, name, callback=None): self.uistate = user.uistate self.db = dbstate.db if self.uistate: tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return # user denied to modify Gramps IDs ManagedWindow.__init__(self, self.uistate, [], self.__class__) if not self.uistate: UpdateCallback.__init__(self, user.callback) self.object_status = True self.change_status = False self.start_zero = True self.step_cnt, self.step_list = 0, ['1', '2', '5', '10'] self.keep_status = True self.obj_values = {} # enable access to all internal values self.active_entries, self.format_entries = {}, {} self.change_entries = {} self.start_entries, self.step_entries = {}, {} self.keep_entries = {} self.prim_methods, self.obj_methods = {}, {} for prim_obj, prim_objs in self.xobjects: iter_handles = "iter_%s_handles" % prim_obj get_number_obj = "get_number_of_%s" % prim_objs prefix_fmt = "%s_prefix" % prim_obj get_from_id = "get_%s_from_gramps_id" % prim_obj get_from_handle = "get_%s_from_handle" % prim_obj next_from_id = "find_next_%s_gramps_id" % prim_obj commit = "commit_%s" % prim_obj self.prim_methods[prim_obj] = (getattr(self.db, prefix_fmt), getattr(self.db, get_number_obj)(), getattr(self.db, next_from_id)()) self.obj_methods[prim_obj] = (getattr(self.db, iter_handles), getattr(self.db, commit), getattr(self.db, get_from_id), getattr(self.db, get_from_handle), getattr(self.db, next_from_id)) object_fmt, quant_id, next_id = self.prim_methods[prim_obj] obj_value = ReorderEntry(object_fmt, quant_id, next_id, prim_obj) self.obj_values[prim_obj] = obj_value if self.uistate: self._display() else: self._execute()
def __init__(self, user, dbstate): ManagedWindow.__init__(self, user.uistate, [], self.__class__, modal=False) self.user = user self.uistate = user.uistate self.dbstate = dbstate self.db = dbstate.db self.csv_filename = None self.last_filename = None self.getfunc = None self.execute_func = None self.editfunc = None self.init()
def close(self, *args): """ Close the editor window. """ (width, height) = self.window.get_size() self._config.set('interface.census-width', width) self._config.set('interface.census-height', height) self._config.save() self.details.entry_grid.clean_up() self.details.clean_up() self.gallery_list.clean_up() ManagedWindow.close(self)
def __init__(self, dbstate, user, options_class, name, callback=None): self.uistate = user.uistate self.dbstate = dbstate.db if self.uistate: tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return # user denied to modify Gramps IDs ManagedWindow.__init__(self, self.uistate, [], self.__class__) if not self.uistate: UpdateCallback.__init__(self, user.callback) self.object_status = True self.change_status = False self.start_zero = True self.step_cnt, self.step_list = 0, ['1', '2', '5', '10'] self.keep_status = True self.obj_values = {} # enable access to all internal values self.active_entries, self.format_entries = {}, {} self.change_entries = {} self.start_entries, self.step_entries = {}, {} self.keep_entries = {} self.prim_methods, self.obj_methods = {}, {} for prim_obj, prim_objs in self.xobjects: class_type = prim_obj.title() iter_handles = "self.dbstate.iter_%s_handles" % prim_obj get_number_obj = "self.dbstate.get_number_of_%s" % prim_objs prefix_fmt = "self.dbstate.%s_prefix" % prim_obj get_from_id = "self.dbstate.get_%s_from_gramps_id" % prim_obj get_from_handle = "self.dbstate.get_%s_from_handle" % prim_obj next_from_id = "self.dbstate.find_next_%s_gramps_id" % prim_obj commit = "self.dbstate.commit_%s" % prim_obj self.prim_methods[prim_obj] = (eval(prefix_fmt), eval(get_number_obj)(), eval(next_from_id)()) self.obj_methods[prim_obj] = (eval(class_type), eval(iter_handles), eval(commit), eval(get_from_id), eval(get_from_handle), eval(next_from_id)) object_fmt, quant_id, next_id = self.prim_methods[prim_obj] obj_value = ReorderEntry(object_fmt, quant_id, next_id) self.obj_values[prim_obj] = obj_value if self.uistate: self._display() else: self._execute()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate self.uistate = uistate self.map = {} self.list = [] self.index = 0 self.merger = None self.mergee = None self.removed = {} self.update = callback self.use_soundex = 1 top = Glade() # retrieve options threshold = self.options.handler.options_dict['threshold'] use_soundex = self.options.handler.options_dict['soundex'] my_menu = Gtk.ListStore(str, object) for val in sorted(_val2label): my_menu.append([_val2label[val], val]) self.soundex_obj = top.get_object("soundex") self.soundex_obj.set_active(use_soundex) self.soundex_obj.show() self.menu = top.get_object("menu") self.menu.set_model(my_menu) self.menu.set_active(0) window = top.toplevel self.set_window(window, top.get_object('title'), _('Find Possible Duplicate People')) self.setup_configs('interface.duplicatepeopletool', 350, 220) top.connect_signals({ "on_do_merge_clicked" : self.__dummy, "on_help_show_clicked" : self.__dummy, "on_delete_show_event" : self.__dummy, "on_merge_ok_clicked" : self.on_merge_ok_clicked, "destroy_passed_object" : self.close, "on_help_clicked" : self.on_help_clicked, "on_delete_merge_event" : self.close, "on_delete_event" : self.close, }) self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate self.uistate = uistate self.map = {} self.list = [] self.index = 0 self.merger = None self.mergee = None self.removed = {} self.update = callback self.use_soundex = 1 top = Glade(toplevel="finddupes", also_load=["liststore1"]) # retrieve options threshold = self.options.handler.options_dict['threshold'] use_soundex = self.options.handler.options_dict['soundex'] my_menu = Gtk.ListStore(str, object) for val in sorted(_val2label): my_menu.append([_val2label[val], val]) self.soundex_obj = top.get_object("soundex") self.soundex_obj.set_active(use_soundex) self.soundex_obj.show() self.menu = top.get_object("menu") self.menu.set_model(my_menu) self.menu.set_active(0) window = top.toplevel self.set_window(window, top.get_object('title'), _('Find Possible Duplicate People')) self.setup_configs('interface.duplicatepeopletool', 350, 220) top.connect_signals({ "on_do_merge_clicked" : self.__dummy, "on_help_show_clicked" : self.__dummy, "on_delete_show_event" : self.__dummy, "on_merge_ok_clicked" : self.on_merge_ok_clicked, "destroy_passed_object" : self.close, "on_help_clicked" : self.on_help_clicked, "on_delete_merge_event" : self.close, "on_delete_event" : self.close, }) self.show()
def close(self, *args): """ Close the editor window. """ (width, height) = self.window.get_size() self._config.set('interface.form-width', width) self._config.set('interface.form-height', height) (width, height) = self.window.get_position() self._config.set('interface.form-horiz-position', width) self._config.set('interface.form-vert-position', height) self._config.save() self.gallery_list.clean_up() ManagedWindow.close(self)
def __init__(self, dbstate, user, options_class, name, callback=None): self.uistate = user.uistate self.label = _('Extract Place data') ManagedWindow.__init__(self, self.uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if not self.fail: self.uistate.set_busy_cursor(True) self.run(dbstate.db) self.uistate.set_busy_cursor(False)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate self.set_window(Gtk.Window(), Gtk.Label(), '') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if not self.fail: uistate.set_busy_cursor(True) self.run() uistate.set_busy_cursor(False)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) stats_list = [] for name, value in dbstate.db.genderStats.stats.items(): stats_list.append((name, ) + value + ( _GENDER[dbstate.db.genderStats.guess_gender(name)], )) if uistate: ManagedWindow.__init__(self, uistate, [], self.__class__) titles = [(_('Name'), 0, 100), (_('Male'), 1, 70, INTEGER), (_('Female'), 2, 70, INTEGER), (_('Unknown'), 3, 90, INTEGER), (_('Guess'), 4, 70)] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in sorted(stats_list): model.add(entry, entry[0]) s = Gtk.ScrolledWindow() s.add(treeview) dialog = Gtk.Dialog() dialog.add_button(_('_Close'), Gtk.ResponseType.CLOSE) dialog.connect('response', self._response) dialog.vbox.pack_start(s, expand=True, fill=True, padding=0) self.set_window(dialog, None, self.label) self.setup_configs('interface.dumpgenderstats', 420, 300) self.show() else: if len(_('Name')) < 16: print( '%s%s%s' % (_('Name'), " " * (16 - len(_('Name'))), _('Male')), '\t%s' * 3 % (_('Female'), _('Unknown'), _('Guess'))) else: print( _('Name'), '\t%s' * 4 % (_('Male'), _('Female'), _('Unknown'), _('Guess'))) print() for entry in sorted(stats_list): if len(entry[0]) < 16: print( '%s%s%s' % (entry[0], " " * (16 - len(entry[0])), entry[1]), '\t%s' * 3 % (entry[2:])) else: print(entry[0], '\t%s' * 4 % (entry[1:]))
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.user = user tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return if uistate: self.title = _('Change Event Types') ManagedWindow.__init__(self, uistate, [], self.__class__) self.init_gui() else: self.run_tool()
def __init__(self, dbstate, uistate, track, citation, callback): self.dbstate = dbstate self.uistate = uistate self.track = track self.db = dbstate.db self.citation = citation self.event = find_form_event(self.db, self.citation) self.callback = callback ManagedWindow.__init__(self, uistate, track, citation) self.widgets = {} top = self.__create_gui() self.set_window(top, None, self.get_menu_title()) self.date_field = MonitoredDate(self.widgets['date_text'], self.widgets['date_button'], self.event.get_date_object(), self.uistate, self.track, self.db.readonly) self.place_field = PlaceEntry(self.dbstate, self.uistate, self.track, self.widgets['place_text'], self.widgets['place_event_box'], self.event.set_place_handle, self.event.get_place_handle, self.widgets['place_add'], self.widgets['place_share']) self.ref_field = MonitoredEntry( self.widgets['ref_entry'], self.citation.set_page, self.citation.get_page, self.db.readonly) self.__populate_gui(self.event) self.show() self._config = config.get_manager('form') width = self._config.get('interface.form-width') height = self._config.get('interface.form-height') self.window.resize(width, height) horiz_position = self._config.get('interface.form-horiz-position') vert_position = self._config.get('interface.form-vert-position') if horiz_position != -1: self.window.move(horiz_position, vert_position)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Sources Index') self.base = os.path.dirname(__file__) ManagedWindow.__init__(self, uistate,[], self.__class__) self.set_window(Gtk.Window(),Gtk.Label(),'') tool.Tool.__init__(self, dbstate, options_class, name) glade_file = os.path.join(USER_PLUGINS, "SourceIndex", "witness.glade") if gramps.gen.constfunc.lin(): import locale locale.setlocale(locale.LC_ALL, '') # This is needed to make gtk.Builder work by specifying the # translations directory locale.bindtextdomain("addon", self.base + "/locale") self.glade = Gtk.Builder() self.glade.set_translation_domain("addon") self.glade.add_from_file(glade_file) from gi.repository import GObject GObject.GObject.__init__(self.glade) window = self.glade.get_object('witness_editor') self.set_window(window, self.glade.get_object('title'), self.label) self.ok_button = self.glade.get_object('ok') self.quit_button = self.glade.get_object('cancel') else: # Glade class from gui/glade.py and gui/managedwindow.py self.top = Glade() window = self.top.toplevel self.set_window(window, None, glade_file) self.ok_button = self.top.get_object('ok') self.quit_button = self.top.get_object('cancel') self.ok_button.connect('clicked', self.close) self.quit_button.connect('clicked', self.close) self.window.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Associations state tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self,uistate,[], self.__class__) stats_list = [] plist = dbstate.db.get_person_handles(sort_handles=True) for handle in plist: person = dbstate.db.get_person_from_handle(handle) name1 = name_displayer.display(person) refs = person.get_person_ref_list() if refs: for ref in person.serialize()[-1]: (a, b, c, two, value) = ref person2 = dbstate.db.get_person_from_handle(two) name2 = name_displayer.display(person2) stats_list.append((name1, value, name2)) if uistate: titles = [ (_('Name'), 0, 200), (_('Type of link'), 1, 200), (_('Of'), 2, 200), ] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(800, 600) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s'*3 % ('Name','Type of link','Of')) print() for entry in stats_list: print('\t%s'*3 % entry)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.user = user tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return if uistate: self.title = _('Change Event Types') ManagedWindow.__init__(self,uistate,[], self.__class__) self.init_gui() else: self.run_tool()
def __init__(self, dbstate, user, options_class, name, callback=None): set_det_id(True) uistate = user.uistate if not uistate: return tool.Tool.__init__(self, dbstate, options_class, name) self.window_name = _('Deterministic ID Tool') ManagedWindow.__init__(self, uistate, [], self.__class__) window = MyWindow(dbstate, self.uistate, []) self.set_window(window, None, self.window_name) WarningDialog(self.window_name, _("The ID and handles now start at 0x00000000, and increment by 0x100000001"), self.window) self.close()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Check Place title') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return ManagedWindow.__init__(self,uistate,[], self.__class__) self.set_window(Gtk.Window(),Gtk.Label(),'') # retrieve options CLI? #copy = self.options.handler.options_dict['copy'] #clean = self.options.handler.options_dict['clean'] self.db = dbstate.db self.total = self.db.get_number_of_places() self.progress = ProgressMeter(_('Checking Place Titles'), '', parent=uistate.window) self.progress.set_pass(_('Looking for place fields'), self.total) self.name_list = [] count = 0 for handle in self.db.get_place_handles(True): self.progress.step() place = self.db.get_place_from_handle(handle) title = place.title descr = place_displayer.display(self.db, place) if title != (descr and ""): count += 1 if title != "": self.name_list.append((handle.decode('utf8'), title, descr)) self.progress.close() if self.name_list: self.display() OkDialog(_('Differences'), '%s/%s' % (count, self.total), parent=uistate.window) else: self.progress.close() self.close() OkDialog(_('No need modifications'), _("No changes need."), parent=uistate.window)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Check Place title') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') # retrieve options CLI? #copy = self.options.handler.options_dict['copy'] #clean = self.options.handler.options_dict['clean'] self.db = dbstate.db self.total = self.db.get_number_of_places() self.progress = ProgressMeter(_('Checking Place Titles'), '', parent=uistate.window) self.progress.set_pass(_('Looking for place fields'), self.total) self.name_list = [] count = 0 for handle in self.db.get_place_handles(True): self.progress.step() place = self.db.get_place_from_handle(handle) title = place.title descr = place_displayer.display(self.db, place) if title != (descr and ""): count += 1 if title != "": self.name_list.append((handle.decode('utf8'), title, descr)) self.progress.close() if self.name_list: self.display() OkDialog(_('Differences'), '%s/%s' % (count, self.total), parent=uistate.window) else: self.progress.close() self.close() OkDialog(_('No need modifications'), _("No changes need."), parent=uistate.window)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = 'Populate sources and citations tool' ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.Tool.__init__(self, dbstate, options_class, name) dialog = self.display() response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.ACCEPT: self.on_ok_clicked() OkDialog('Data generated', "The requested sources and citations were generated") self.close()
def __init__(self, dbstate, uistate, track, citation, callback): self.dbstate = dbstate self.uistate = uistate self.track = track self.db = dbstate.db self.citation = citation self.event = find_form_event(self.db, self.citation) self.callback = callback ManagedWindow.__init__(self, uistate, track, citation) self.widgets = {} top = self.__create_gui() self.set_window(top, None, self.get_menu_title()) self.date_field = MonitoredDate(self.widgets['date_text'], self.widgets['date_button'], self.event.get_date_object(), self.uistate, self.track, self.db.readonly) self.place_field = PlaceEntry( self.dbstate, self.uistate, self.track, self.widgets['place_text'], self.widgets['place_event_box'], self.event.set_place_handle, self.event.get_place_handle, self.widgets['place_add'], self.widgets['place_share']) self.ref_field = MonitoredEntry(self.widgets['ref_entry'], self.citation.set_page, self.citation.get_page, self.db.readonly) self.__populate_gui(self.event) self.show() self._config = config.get_manager('form') width = self._config.get('interface.form-width') height = self._config.get('interface.form-height') self.window.resize(width, height) horiz_position = self._config.get('interface.form-horiz-position') vert_position = self._config.get('interface.form-vert-position') if horiz_position != -1: self.window.move(horiz_position, vert_position)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Download media") ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), "") tool.Tool.__init__(self, dbstate, options_class, name) self.num_downloads = 0 dialog = self.display() response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.ACCEPT: self.on_ok_clicked() OkDialog(_("Media downloaded"), _("%d media files downloaded") % self.num_downloads) self.close()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Download media') ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.Tool.__init__(self, dbstate, options_class, name) self.num_downloads = 0 dialog = self.display() response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.ACCEPT: self.on_ok_clicked() OkDialog(_('Media downloaded'), _("%d media files downloaded") % self.num_downloads) self.close()
def __init__(self,dbstate,uistate,people_list,track): self.dbstate = dbstate self.uistate = uistate ManagedWindow.__init__(self, uistate, track, self) self.db = dbstate.db self.my_list = people_list self.row_data = [] self.save_form = None self.topDialog = Glade() self.topDialog.connect_signals({ "on_write_table" : self.on_write_table, "destroy_passed_object" : self.close, "on_help_clicked" : self.on_help_clicked, "on_apply_clicked" : self.__dummy, "on_editor_clicked" : self.__dummy, }) window = self.topDialog.toplevel self.set_window(window, self.topDialog.get_object('title'), _('Event Comparison Results')) self.setup_configs('interface.eventcomparisonresults', 750, 400) self.eventlist = self.topDialog.get_object('treeview') self.sort = Sort(self.db) self.my_list.sort(key=self.sort.by_last_name_key) self.event_titles = self.make_event_titles() self.table_titles = [_("Person"),_("ID")] for event_name in self.event_titles: self.table_titles.append(_("%(event_name)s Date") % {'event_name' :event_name} ) self.table_titles.append('sort') # This won't be shown in a tree self.table_titles.append(_("%(event_name)s Place") % {'event_name' :event_name} ) self.build_row_data() self.draw_display() self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self,uistate,[], self.__class__) stats_list = [] for name, value in dbstate.db.genderStats.stats.items(): stats_list.append( (name,) + value + (_GENDER[dbstate.db.genderStats.guess_gender(name)],) ) if uistate: titles = [ (_('Name'),0,100), (_('Male'),1,70,INTEGER), (_('Female'),2,70,INTEGER), (_('Unknown'),3,70,INTEGER), (_('Guess'),4,70) ] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(400, 300) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s'*5 % ('Name','Male','Female','Unknown','Guess')) print() for entry in stats_list: print('\t%s'*5 % entry)
def __init__(self, dbstate, uistate, people_list, track): self.dbstate = dbstate self.uistate = uistate ManagedWindow.__init__(self, uistate, track, self) self.db = dbstate.db self.my_list = people_list self.row_data = [] self.save_form = None self.topDialog = Glade(toplevel="eventcmp") self.topDialog.connect_signals({ "on_write_table": self.on_write_table, "destroy_passed_object": self.close, "on_help_clicked": self.on_help_clicked, "on_apply_clicked": self.__dummy, "on_editor_clicked": self.__dummy, }) window = self.topDialog.toplevel self.set_window(window, self.topDialog.get_object('title'), _('Event Comparison Results')) self.setup_configs('interface.eventcomparisonresults', 750, 400) self.eventlist = self.topDialog.get_object('treeview') self.sort = Sort(self.db) self.my_list.sort(key=self.sort.by_last_name_key) self.event_titles = self.make_event_titles() self.table_titles = [_("Person"), _("ID")] for event_name in self.event_titles: self.table_titles.append( _("%(event_name)s Date") % {'event_name': event_name}) self.table_titles.append('sort') # This won't be shown in a tree self.table_titles.append( _("%(event_name)s Place") % {'event_name': event_name}) self.build_row_data() self.draw_display() self.show()
def __init__(self, dbstate, uistate, track, the_list, the_map, callback): ManagedWindow.__init__(self,uistate,track,self.__class__) self.dellist = set() self.list = the_list self.map = the_map self.length = len(self.list) self.update = callback self.db = dbstate.db self.dbstate = dbstate self.uistate = uistate top = Glade(toplevel="mergelist") window = top.toplevel self.set_window(window, top.get_object('title'), _('Potential Merges')) self.setup_configs('interface.duplicatepeopletoolmatches', 500, 350) self.mlist = top.get_object("mlist") top.connect_signals({ "destroy_passed_object" : self.close, "on_do_merge_clicked" : self.on_do_merge_clicked, "on_help_show_clicked" : self.on_help_clicked, "on_delete_show_event" : self.close, "on_merge_ok_clicked" : self.__dummy, "on_help_clicked" : self.__dummy, "on_delete_merge_event" : self.__dummy, "on_delete_event" : self.__dummy, }) self.db.connect("person-delete", self.person_delete) mtitles = [ (_('Rating'),3,75), (_('First Person'),1,200), (_('Second Person'),2,200), ('',-1,0) ] self.list = ListModel(self.mlist,mtitles, event_func=self.on_do_merge_clicked) self.redraw() self.show()
def __init__(self, dbstate, uistate, track, the_list, the_map, callback): ManagedWindow.__init__(self,uistate,track,self.__class__) self.dellist = {} self.list = the_list self.map = the_map self.length = len(self.list) self.update = callback self.db = dbstate.db self.dbstate = dbstate self.uistate = uistate top = Glade(toplevel="mergelist") window = top.toplevel self.set_window(window, top.get_object('title'), _('Potential Merges')) self.setup_configs('interface.duplicatepeopletoolmatches', 500, 350) self.mlist = top.get_object("mlist") top.connect_signals({ "destroy_passed_object" : self.close, "on_do_merge_clicked" : self.on_do_merge_clicked, "on_help_show_clicked" : self.on_help_clicked, "on_delete_show_event" : self.close, "on_merge_ok_clicked" : self.__dummy, "on_help_clicked" : self.__dummy, "on_delete_merge_event" : self.__dummy, "on_delete_event" : self.__dummy, }) mtitles = [ (_('Rating'),3,75), (_('First Person'),1,200), (_('Second Person'),2,200), ('',-1,0) ] self.list = ListModel(self.mlist,mtitles, event_func=self.on_do_merge_clicked) self.redraw() self.show()
def __init__(self, dbstate, uistate, track): self.uistate = uistate self.dbstate = dbstate self._show_builtins = None self._show_hidden = None self.options = PluginManagerOptions('pluginmanager') #tool.Tool.__init__(self, dbstate, options_class, 'pluginmanager') self.options.load_previous_values() self.options_dict = self.options.handler.options_dict self.window = Gtk.Dialog(title=TITLE) ManagedWindow.__init__(self, uistate, track, self.__class__) self.set_window(self.window, None, TITLE, None) self._pmgr = GuiPluginManager.get_instance() self._preg = PluginRegister.get_instance() #obtain hidden plugins from the pluginmanager self.hidden = self._pmgr.get_hidden_plugin_ids() self.setup_configs('interface.pluginstatus', 750, 400) help_btn = self.window.add_button( # pylint: disable=no-member _("_Help"), Gtk.ResponseType.HELP) update_btn = self.window.add_button( # pylint: disable=no-member _("Check for updated addons now"), UPDATE_RES) btn_box = help_btn.get_parent() btn_box.set_child_non_homogeneous(update_btn, True) if __debug__: # Only show the "Reload" button when in debug mode # (without -O on the command line) reload_btn = self.window.add_button( # pylint: disable=no-member _("Reload"), RELOAD_RES) btn_box.set_child_non_homogeneous(reload_btn, True) self.window.add_button(_('_Close'), Gtk.ResponseType.CLOSE) labeltitle, widget = self.registered_plugins_panel(None) self.window.vbox.pack_start(widget, True, True, 0) sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL) self.window.vbox.pack_start(sep, False, False, 3) self.restart_needed = False self.window.connect('response', self.done) self.show() self.__populate_reg_list()
def __init__(self, dbstate, uistate, track, event): self.dbstate = dbstate self.uistate = uistate self.track = track self.db = dbstate.db self.event = event self.citation = get_census_citation(self.db, self.event) if self.citation is None: self.citation = Citation() ManagedWindow.__init__(self, uistate, track, event) self.widgets = {} top = self.__create_gui() self.set_window(top, None, self.get_menu_title()) self._config = config.get_manager('census') width = self._config.get('interface.census-width') height = self._config.get('interface.census-height') self.window.resize(width, height) self.place_field = PlaceEntry(self.dbstate, self.uistate, self.track, self.widgets['place_text'], self.event.set_place_handle, self.event.get_place_handle, self.widgets['place_add'], self.widgets['place_share']) self.ref_field = MonitoredEntry( self.widgets['ref_entry'], self.citation.set_page, self.citation.get_page, self.db.readonly) if self.event.get_handle(): self.widgets['census_combo'].set_sensitive(False) self.__populate_gui(event) self.details.populate_gui(event)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Capitalization changes') self.dbstate = dbstate self.uistate = uistate self.cb = callback ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return given_name_dict = self.get_given_name_dict() self.progress = ProgressMeter(_('Checking Given Names'), '', parent=uistate.window) self.progress.set_pass(_('Searching given names'), len(given_name_dict.keys())) self.name_list = [] for name in given_name_dict.keys(): if name != capitalize(name): self.name_list.append((name, given_name_dict[name])) if uistate: self.progress.step() if self.name_list: self.display() else: self.progress.close() self.close() OkDialog(_('No modifications made'), _("No capitalization changes were detected."), parent=uistate.window)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.user = user self.label = _('Download media') ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.Tool.__init__(self, dbstate, options_class, name) self.num_downloads = 0 dialog = self.display() response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.ACCEPT: self.on_ok_clicked() if hasattr(self.user.uistate, 'window'): parent_window = self.user.uistate.window else: parent_window = None OkDialog(_('Media downloaded'), _("%d media files downloaded") % self.num_downloads, parent=parent_window) self.close()
def __init__(self, uistate, dbstate, names): self.uistate = uistate self.dbstate = dbstate self.db = dbstate.db self.names = names self.nametypes = set() for rownum, row in enumerate(self.names): row.rownum = rownum code, text = row.nametype.serialize() self.nametypes.add((code, text)) ManagedWindow.__init__(self, self.uistate, [], self.__class__, modal=False) # the self.top.run() below makes Gtk make it modal, so any change to # the previous line's "modal" would require that line to be changed DbGUIElement.__init__(self, dbstate.db) self.draw_window() self.set_window(self.top, None, _("Name editor")) self.setup_configs('interface.names', 400, 350) self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Capitalization changes') self.dbstate = dbstate self.uistate = uistate self.cb = callback ManagedWindow.__init__(self,uistate,[],self.__class__) self.set_window(Gtk.Window(),Gtk.Label(),'') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return given_name_dict = self.get_given_name_dict() self.progress = ProgressMeter(_('Checking Given Names'),'', parent=uistate.window) self.progress.set_pass(_('Searching given names'), len(given_name_dict.keys())) self.name_list = [] for name in given_name_dict.keys(): if name != capitalize(name): self.name_list.append((name, given_name_dict[name])) if uistate: self.progress.step() if self.name_list: self.display() else: self.progress.close() self.close() OkDialog(_('No modifications made'), _("No capitalization changes were detected."), parent=uistate.window)
def __init__(self, uistate, track, data, name): self.name = name title = _("%(str1)s: %(str2)s") % {'str1': _("Detailed Info"), 'str2': name} ManagedWindow.__init__(self, uistate, track, self) dlg = Gtk.Dialog(title="", transient_for=uistate.window, destroy_with_parent=True) dlg.add_button(_('_Close'), Gtk.ResponseType.CLOSE) self.set_window(dlg, None, title) self.setup_configs('interface.plugininfo', 720, 520) self.window.connect('response', # pylint: disable=no-member self.close) scrolled_window = Gtk.ScrolledWindow(expand=True) # scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, # Gtk.PolicyType.AUTOMATIC) self.text = Gtk.TextView() scrolled_window.add(self.text) self.text.get_buffer().set_text(data) # pylint: disable=no-member self.window.get_content_area().add(scrolled_window) self.show()
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) if uistate: ManagedWindow.__init__(self, uistate, [], self.__class__) stats_list = [] for name, value in dbstate.db.genderStats.stats.items(): stats_list.append((name, ) + value + ( _GENDER[dbstate.db.genderStats.guess_gender(name)], )) if uistate: titles = [(_('Name'), 0, 100), (_('Male'), 1, 70, INTEGER), (_('Female'), 2, 70, INTEGER), (_('Unknown'), 3, 70, INTEGER), (_('Guess'), 4, 70)] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in stats_list: model.add(entry, entry[0]) window = Gtk.Window() window.set_default_size(400, 300) s = Gtk.ScrolledWindow() s.add(treeview) window.add(s) window.show_all() self.set_window(window, None, self.label) self.show() else: print('\t%s' * 5 % ('Name', 'Male', 'Female', 'Unknown', 'Guess')) print() for entry in stats_list: print('\t%s' * 5 % entry)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Capitalization changes') self.cb = callback ManagedWindow.__init__(self,uistate,[],self.__class__) self.set_window(Gtk.Window(),Gtk.Label(),'') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return self.progress = ProgressMeter(_('Checking Family Names'),'') self.progress.set_pass(_('Searching family names'), len(self.db.get_surname_list())) self.name_list = [] for name in self.db.get_surname_list(): name.strip() namesplitSP= name.split() lSP = len(namesplitSP) namesplitHY= name.split('-') lHY = len(namesplitHY) if lSP == lHY == 1: if name != name.capitalize(): # Single surname without hyphen(s) self.name_list.append(name) #if lSP == 1 and lHY > 1: #print "LSP==1", name, name.capitalize() #if name != name.capitalize(): # Single surname with hyphen(s) #self.name_list.append(name) if lSP>1 and lHY == 1: # more than one string in surname but no hyphen # check if first string is in prefix_list, if so test for cap in rest s1 = 0 if namesplitSP[0].lower() in prefix_list: s1 = 1 for x in range(len(namesplitSP)-s1): # check if any subsurname is not cap notcap = False if namesplitSP[s1+x] != namesplitSP[s1+x].capitalize(): notcap = True break if notcap: # Multiple surnames possibly after prefix self.name_list.append(name) if lHY > 1: # more than one string in surname but hyphen(s) exists # check if first string is in prefix_list, if so test for cap if namesplitSP[0].lower() in prefix_list: namesplitHY[0] = namesplitHY[0].replace(namesplitSP[0],'').strip() for x in range(len(namesplitHY)): # check if any subsurname is not cap notcap = False if namesplitHY[x] != namesplitHY[x].capitalize(): notcap = True break if notcap: # Multiple surnames possibly after frefix self.name_list.append(name) if uistate: self.progress.step() if self.name_list: self.display() else: self.progress.close() self.close() OkDialog(_('No modifications made'), _("No capitalization changes were detected."), parent=uistate.window)
def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate self.label = _('Name and title extraction tool') ManagedWindow.__init__(self, uistate, [], self.__class__) self.set_window(Gtk.Window(), Gtk.Label(), '') tool.BatchTool.__init__(self, dbstate, user, options_class, name) if self.fail: return winprefix = Gtk.Dialog( _("Default prefix and connector settings"), self.uistate.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (_('_OK'), Gtk.ResponseType.ACCEPT)) winprefix.vbox.set_spacing(5) hboxpref = Gtk.Box() label = Gtk.Label(label=_('Prefixes to search for:')) hboxpref.pack_start(label, False, False, 5) self.prefixbox = Gtk.Entry() self.prefixbox.set_text(', '.join(PREFIX_LIST)) hboxpref.pack_start(self.prefixbox, True, True, 0) winprefix.vbox.pack_start(hboxpref, True, True, 0) hboxcon = Gtk.Box() label = Gtk.Label(label=_('Connectors splitting surnames:')) hboxcon.pack_start(label, False, False, 5) self.conbox = Gtk.Entry() self.conbox.set_text(', '.join(CONNECTOR_LIST)) hboxcon.pack_start(self.conbox, True, True, 0) winprefix.vbox.pack_start(hboxcon, True, True, 0) hboxconns = Gtk.Box() label = Gtk.Label(label=_('Connectors not splitting surnames:')) hboxconns.pack_start(label, False, False, 5) self.connsbox = Gtk.Entry() self.connsbox.set_text(', '.join(CONNECTOR_LIST_NONSPLIT)) hboxconns.pack_start(self.connsbox, True, True, 0) winprefix.vbox.pack_start(hboxconns, True, True, 0) winprefix.show_all() winprefix.resize(700, 100) response = winprefix.run() self.prefix_list = self.prefixbox.get_text().split(',') self.prefix_list = list(map(strip, self.prefix_list)) self.prefixbox = None self.connector_list = self.conbox.get_text().split(',') self.connector_list = list(map(strip, self.connector_list)) self.conbox = None self.connector_list_nonsplit = self.connsbox.get_text().split(',') self.connector_list_nonsplit = list( map(strip, self.connector_list_nonsplit)) self.connsbox = None # Find a prefix in the first_name self._fn_prefix_re = re.compile( "(\S+)\s+(%s)\s*$" % '|'.join(self.prefix_list), re.IGNORECASE) # Find a prefix in the surname self._sn_prefix_re = re.compile( "^\s*(%s)\s+(.+)" % '|'.join(self.prefix_list), re.IGNORECASE) # Find a connector in the surname self._sn_con_re = re.compile( "^\s*(.+)\s+(%s)\s+(.+)" % '|'.join(self.connector_list), re.IGNORECASE) winprefix.destroy() self.cb = callback self.handle_to_action = {} self.progress = ProgressMeter( # parent-OK _('Extracting Information from Names'), '', parent=self.uistate.window) self.progress.set_pass(_('Analyzing names'), self.db.get_number_of_people()) for person in self.db.iter_people(): key = person.handle name = person.get_primary_name() first = name.get_first_name() sname = name.get_surname() old_prefix = [] old_surn = [] old_con = [] old_prim = [] old_orig = [] for surn in name.get_surname_list(): old_prefix.append(surn.get_prefix()) old_surn.append(surn.get_surname()) old_con.append(surn.get_connector()) old_prim.append(surn.get_primary()) old_orig.append(surn.get_origintype()) if name.get_title(): old_title = [name.get_title()] else: old_title = [] new_title = [] match = _title_re.match(first) while match: groups = match.groups() first = groups[1] new_title.append(groups[0]) match = _title_re.match(first) matchnick = _nick_re.match(first) if new_title: titleval = (" ".join(old_title + new_title), first) if key in self.handle_to_action: self.handle_to_action[key][self.titleid] = titleval else: self.handle_to_action[key] = {self.titleid: titleval} elif matchnick: # we check for nick, which changes given name like title groups = matchnick.groups() nickval = (groups[0], groups[1]) if key in self.handle_to_action: self.handle_to_action[key][self.nickid] = nickval else: self.handle_to_action[key] = {self.nickid: nickval} else: # Try to find the name prefix in the given name, also this # changes given name match = self._fn_prefix_re.match(first) if match: groups = match.groups() if old_prefix[0]: # Put the found prefix before the old prefix new_prefix = " ".join([groups[1], old_prefix[0]]) else: new_prefix = groups[1] pref1val = (groups[0], new_prefix, groups[1]) if key in self.handle_to_action: self.handle_to_action[key][self.pref1id] = pref1val else: self.handle_to_action[key] = {self.pref1id: pref1val} #check for Gedcom import of compound surnames if len(old_surn) == 1 and old_con[0] == '': prefixes = old_prefix[0].split(',') surnames = old_surn[0].split(',') if len(prefixes) > 1 and len(prefixes) == len(surnames): #assume a list of prefix and a list of surnames prefixes = list(map(strip, prefixes)) surnames = list(map(strip, surnames)) primaries = [False] * len(prefixes) primaries[0] = True origs = [] for ind in range(len(prefixes)): origs.append(NameOriginType()) origs[0] = old_orig[0] compoundval = (surnames, prefixes, [''] * len(prefixes), primaries, origs) if key in self.handle_to_action: self.handle_to_action[key][self.compid] = compoundval else: self.handle_to_action[key] = {self.compid: compoundval} #we cannot check compound surnames, so continue the loop continue # Next, try to split surname in compounds: prefix surname connector found = False new_prefix_list = [] new_surname_list = [] new_connector_list = [] new_prim_list = [] new_orig_list = [] ind = 0 cont = True for pref, surn, con, prim, orig in zip(old_prefix, old_surn, old_con, old_prim, old_orig): surnval = surn.split() if surnval == []: new_prefix_list.append(pref) new_surname_list.append('') new_connector_list.append(con) new_prim_list.append(prim) new_orig_list.append(orig) cont = False continue val = surnval.pop(0) while cont: new_prefix_list.append(pref) new_surname_list.append('') new_connector_list.append(con) new_prim_list.append(prim) new_orig_list.append(orig) while cont and (val.lower() in self.prefix_list): found = True if new_prefix_list[-1]: new_prefix_list[-1] += ' ' + val else: new_prefix_list[-1] = val try: val = surnval.pop(0) except IndexError: val = '' cont = False #after prefix we have a surname if cont: new_surname_list[-1] = val try: val = surnval.pop(0) except IndexError: val = '' cont = False #if value after surname indicates continue, then continue while cont and (val.lower() in self.connector_list_nonsplit): #add this val to the current surname new_surname_list[-1] += ' ' + val try: val = surnval.pop(0) except IndexError: val = '' cont = False # if previous is non-splitting connector, then add new val to # current surname if cont and (new_surname_list[-1].split()[-1].lower() in self.connector_list_nonsplit): new_surname_list[-1] += ' ' + val try: val = surnval.pop(0) except IndexError: val = '' cont = False #if next is a connector, add it to the surname if cont and val.lower() in self.connector_list: found = True if new_connector_list[-1]: new_connector_list[-1] = ' ' + val else: new_connector_list[-1] = val try: val = surnval.pop(0) except IndexError: val = '' cont = False #initialize for a next surname in case there are still #val if cont: found = True # we split surname pref = '' con = '' prim = False orig = NameOriginType() ind += 1 if found: compoundval = (new_surname_list, new_prefix_list, new_connector_list, new_prim_list, new_orig_list) if key in self.handle_to_action: self.handle_to_action[key][self.compid] = compoundval else: self.handle_to_action[key] = {self.compid: compoundval} self.progress.step() if self.handle_to_action: self.display() else: self.progress.close() self.close() OkDialog( _('No modifications made'), # parent-OK _("No titles, nicknames or prefixes were found"), parent=self.uistate.window)