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 _display(self): """ organize Glade 'Import Pro-Gen' window """ # get the main window from glade self.glade = Glade('importprogen.glade') self.set_window(self.glade.toplevel, self.glade.get_object('title'), _('Import Pro-Gen')) # calculate all entries and update Glade window # Text for Source / Citation objects for obj in ('source_btn', 'citation_btn'): widget = self.glade.get_object('imp_%s' % obj) set_import = eval('self.imp_values.%s.set_value' % obj) get_import = eval('self.imp_values.%s.get_value' % obj) self.import_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) for obj in ('source_title', 'source_attr', 'citation_page', 'citation_attr'): widget = self.glade.get_object('imp_%s' % obj) set_import = eval('self.imp_values.%s.set_entry' % obj) get_import = eval('self.imp_values.%s.get_entry' % obj) self.import_methods[obj] = MonitoredEntry(\ widget, set_import, get_import, self.dbase.readonly) widget = self.glade.get_object('imp_citation_conf') self.import_methods['conf'] = MonitoredMenu( widget, self.imp_values.citation_conf.set_value, self.imp_values.citation_conf.get_value, [(_('Very Low'), Citation.CONF_VERY_LOW), (_('Low'), Citation.CONF_LOW), (_('Normal'), Citation.CONF_NORMAL), (_('High'), Citation.CONF_HIGH), (_('Very High'), Citation.CONF_VERY_HIGH)], self.dbase.readonly) widget = self.glade.get_object('imp_source_priv') get_import = eval('self.imp_values.source_priv') self.import_methods['source_priv'] = PrivacyButton(\ widget, get_import, self.dbase.readonly) widget = self.glade.get_object('imp_citation_priv') get_import = eval('self.imp_values.citation_priv') self.import_methods['citation_priv'] = PrivacyButton(\ widget, get_import, self.dbase.readonly) # Text (w. Defaults) for Tags for obj in ('text', 'fname'): widget = self.glade.get_object('tag_default_%s' % obj) set_import = eval('self.default_values.%s.set_entry' % obj) get_import = eval('self.default_values.%s.get_entry' % obj) self.default_methods[obj] = MonitoredEntry(\ widget, set_import, get_import, self.dbase.readonly) date = Today() datebase = DateBase() datebase.set_date_object(date) self.default_methods['date'] = MonitoredDate(\ self.glade.get_object('tag_default_date'), self.glade.get_object('tag_default_date_btn'), datebase.get_date_object(), self.uistate, [], self.dbase.readonly) for obj in libprogen.TAGOBJECTS: # populate object fields with values widget = self.glade.get_object('tag_%s_obj' % obj) self.tagobj_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_obj.set_value, self.tagobj_values[obj].tag_obj.get_value) widget = self.glade.get_object('tag_%s_text' % obj) self.tagtext_methods[obj] = MonitoredEntry( widget, self.tagobj_values[obj].tag_text.set_entry, self.tagobj_values[obj].tag_text.get_entry) widget = self.glade.get_object('tag_%s_fname' % obj) self.tagfname_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_fname.set_value, self.tagobj_values[obj].tag_fname.get_value) widget = self.glade.get_object('tag_%s_date' % obj) self.tagdate_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_date.set_value, self.tagobj_values[obj].tag_date.get_value) # button's for primary objects for obj in libprogen.PRIMOBJECTS: # populate pirm. Object buttons with values widget = self.glade.get_object('prim_%s_btn' % obj) set_import = eval("self.primobj_values['%s'].set_value" % obj) get_import = eval("self.primobj_values['%s'].get_value" % obj) self.primobj_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) # button's for miscallaneous option's for obj in libprogen.OPTOBJECTS: # populate option buttons with values widget = self.glade.get_object('opt_%s_btn' % obj) set_import = eval("self.option_values['%s'].set_value" % obj) get_import = eval("self.option_values['%s'].get_value" % obj) self.option_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) # connect signals self.glade.connect_signals({ "on_source_button_toggled": self.__on_source_button_toggled, "on_citation_button_toggled": self.__on_citation_button_toggled, "on_import_entry_keyrelease": self.__on_import_entry_keyrelease, "on_tagtext_entry_keyrelease": self.__on_tagtext_entry_keyrelease, "on_object_button_clicked": self.__on_object_button_clicked, "on_object_button_toggled": self.__on_object_button_toggled, "on_text_button_clicked": self.__on_text_button_clicked, "on_fname_button_clicked": self.__on_fname_button_clicked, "on_fname_button_toggled": self.__on_fname_button_toggled, "on_date_button_clicked": self.__on_date_button_clicked, "on_date_button_toggled": self.__on_date_button_toggled, "on_primobj_button_toggled": self.__on_primobj_button_toggled, "on_surname_button_toggled": self.__on_surname_button_toggled, "on_x_button_clicked": self.__on_x_button_clicked, "on_help_button_clicked": self.__on_help_button_clicked, "on_cancel_button_clicked": self.__on_cancel_button_clicked, "on_ok_button_clicked": self.__on_ok_button_clicked }) # state of two objects trigged form configuration widget = self.glade.get_object('imp_source_btn') self.__on_source_button_toggled(widget) widget = self.glade.get_object('imp_citation_btn') self.__on_citation_button_toggled(widget) widget = self.glade.get_object('import_ok') widget.grab_focus() # creates a modal window and display immediatly! self.show() self.glade.toplevel.run()
def __create_gui(self): vbox = Gtk.VBox(orientation=Gtk.Orientation.VERTICAL) vbox.set_spacing(4) label = Gtk.Label( _("This gramplet allows setting properties for multiple places at the same time" )) label.set_halign(Gtk.Align.START) label.set_line_wrap(True) vbox.pack_start(label, False, True, 0) pt_label = Gtk.Label(_('Place type:')) pt_label.set_halign(Gtk.Align.START) self.typecombo = Gtk.ComboBoxText.new_with_entry() self.typecombo.set_tooltip_text( _("New place type for the selected places")) self.__fill_combo(self.typecombo, list(self.__typenames()), wrap_width=4) tag_label = Gtk.Label(_('Tag:')) tag_label.set_halign(Gtk.Align.START) self.tagcombo = Gtk.ComboBoxText.new_with_entry() self.tagcombo.set_tooltip_text(_("New tag for the selected places")) self.__fill_combo(self.tagcombo, list(self.__tagnames())) date_label = Gtk.Label(_('Timespan:')) date_label.set_halign(Gtk.Align.START) self.date_entry = ValidatableMaskedEntry() date_button = Gtk.Button.new_from_icon_name("gramps-date", -1) timespan_tooltip = _("Set timespan for enclosing places") date_label.set_tooltip_text(timespan_tooltip) date_button.set_tooltip_text(timespan_tooltip) self.date_entry.set_tooltip_text(timespan_tooltip) self.date_object = Date() self.track = [] self.date_field = MonitoredDate(self.date_entry, date_button, self.date_object, self.uistate, self.track) label1 = Gtk.Label(_("New enclosing place:")) label1.set_halign(Gtk.Align.START) label1.set_line_wrap(True) self.label1 = label1 self.enclosing_place = Gtk.Label(_("None")) self.enclosing_place.set_halign(Gtk.Align.START) self.enclosing_place.set_tooltip_text( _("New enclosing place for the selected places")) pt_grid = Gtk.Grid(column_spacing=10, row_spacing=2) pt_grid.attach(pt_label, 0, 0, 1, 1) pt_grid.attach(self.typecombo, 1, 0, 1, 1) pt_grid.attach(tag_label, 0, 1, 1, 1) pt_grid.attach(self.tagcombo, 1, 1, 1, 1) pt_grid.attach(date_label, 0, 2, 1, 1) pt_grid.attach(self.date_entry, 1, 2, 1, 1) pt_grid.attach(date_button, 2, 2, 1, 1) pt_grid.attach(label1, 0, 3, 1, 1) pt_grid.attach(self.enclosing_place, 1, 3, 1, 1) vbox.pack_start(pt_grid, False, True, 0) but_set_enclosing = Gtk.Button(label=_('Select enclosing place')) but_set_enclosing.connect("clicked", self.cb_select) but_set_enclosing.set_tooltip_text( _("Select a new enclosing place for the selected places")) vbox.pack_start(but_set_enclosing, False, True, 10) self.clear_enclosing = Gtk.CheckButton( _("Clear original enclosing places")) self.clear_enclosing.set_tooltip_text( _("If checked then any previous enclosing place will be removed from the selected places" )) vbox.pack_start(self.clear_enclosing, False, True, 0) self.clear_tags = Gtk.CheckButton(_("Clear tags")) self.clear_tags.set_tooltip_text( _("If checked then any previous tag will be removed from the selected places" )) vbox.pack_start(self.clear_tags, False, True, 0) self.generate_hierarchy = Gtk.CheckButton(_("Generate hierarchy")) self.generate_hierarchy.connect("clicked", self.cb_select_generate_hierarchy) self.generate_hierarchy.set_tooltip_text( _("If checked then a place hierarchy will be generated, based on the names of the original places" )) vbox.pack_start(self.generate_hierarchy, False, True, 0) box1 = Gtk.VBox() box1.set_margin_left(20) box2 = Gtk.HBox() box2.pack_start(Gtk.Label(_("Separator:")), False, True, 0) group = None rownum = 0 group = Gtk.RadioButton.new_with_label_from_widget(group, _("Comma")) group.connect("toggled", self.cb_set_sep, ',') group.set_tooltip_text( _("If selected then the original names will be split at commas to create the new hierarchy" )) group.set_sensitive(False) box2.pack_start(group, False, True, 0) group.set_active(True) rownum += 1 group = Gtk.RadioButton.new_with_label_from_widget(group, _("Space")) group.connect("toggled", self.cb_set_sep, None) group.set_tooltip_text( _("If selected then the original names will be split at blank spaces to create the new hierarchy" )) group.set_sensitive(False) box2.pack_start(group, False, True, 0) self.sep_group = group box1.pack_start(box2, False, True, 0) self.reverse = Gtk.CheckButton(_("reverse hierarchy")) self.reverse.set_tooltip_text( _("If checked then the original name is assumed to start with the largest place in the hierarchy" )) self.reverse.set_sensitive(False) box1.pack_start(self.reverse, False, True, 0) vbox.pack_start(box1, False, True, 0) self.replace_text = Gtk.CheckButton(_("Replace text")) self.replace_text.set_tooltip_text( _("If checked then a specified text is replaced with a new text in the selected place names" )) self.replace_text.connect("clicked", self.cb_select_replace_text) self.use_regex = Gtk.CheckButton(_("Use regex")) self.use_regex.set_tooltip_text( _("If checked then the old text can be a regular expression and the new text can contain substitutions (\\1, \\2 etc.)" )) self.use_regex.set_sensitive(False) replace_text_box = Gtk.HBox() replace_text_box.pack_start(self.replace_text, False, True, 0) replace_text_box.pack_start(self.use_regex, False, True, 0) vbox.pack_start(replace_text_box, False, True, 0) old_text_label = Gtk.Label(_("Old text:")) self.old_text = Gtk.Entry() self.old_text.set_sensitive(False) self.old_text.set_tooltip_text( _("The original text (or regular expression) to be replaced")) new_text_label = Gtk.Label(_("New text:")) self.new_text = Gtk.Entry() self.new_text.set_sensitive(False) self.new_text.set_tooltip_text( _("The new text that will replace the old text")) replace_grid = Gtk.Grid(column_spacing=10) replace_grid.set_margin_left(20) replace_grid.attach(old_text_label, 1, 0, 1, 1) replace_grid.attach(self.old_text, 2, 0, 1, 1) replace_grid.attach(new_text_label, 1, 1, 1, 1) replace_grid.attach(self.new_text, 2, 1, 1, 1) vbox.pack_start(replace_grid, False, True, 0) but_clear = Gtk.Button(label=_('Clear selections')) but_clear.connect("clicked", self.cb_clear) but_clear.set_tooltip_text(_("Clears all settings")) vbox.pack_start(but_clear, False, True, 10) but_apply = Gtk.Button(label=_('Apply to selected places')) but_apply.connect("clicked", self.cb__apply) but_apply.set_tooltip_text( _("Executes all specified operations for selected places")) vbox.pack_start(but_apply, False, True, 0) vbox.show_all() return vbox
def __create_gui(self): vbox = Gtk.VBox(orientation=Gtk.Orientation.VERTICAL) vbox.set_spacing(4) label = Gtk.Label( _("This gramplet allows setting properties for multiple places at the same time" )) label.set_halign(Gtk.Align.START) label.set_line_wrap(True) vbox.pack_start(label, False, True, 0) pt_label = Gtk.Label(_('Place type:')) pt_label.set_halign(Gtk.Align.START) self.typecombo = Gtk.ComboBoxText.new_with_entry() self.__fill_combo(self.typecombo, list(self.__typenames()), wrap_width=4) tag_label = Gtk.Label(_('Tag:')) tag_label.set_halign(Gtk.Align.START) self.tagcombo = Gtk.ComboBoxText.new_with_entry() self.__fill_combo(self.tagcombo, list(self.__tagnames())) label1 = Gtk.Label(_("New enclosing place")) label1.set_halign(Gtk.Align.START) label1.set_line_wrap(True) self.label1 = label1 self.enclosing_place = Gtk.Label(_("None")) self.enclosing_place.set_halign(Gtk.Align.START) date_label = Gtk.Label(_('Timespan:')) date_label.set_halign(Gtk.Align.START) self.date_entry = ValidatableMaskedEntry() date_button = Gtk.Button.new_from_icon_name("gramps-date", -1) timespan_tooltip = _("Set timespan for enclosing places") date_label.set_tooltip_text(timespan_tooltip) date_button.set_tooltip_text(timespan_tooltip) self.date_entry.set_tooltip_text(timespan_tooltip) self.date_object = Date() self.track = [] self.date_field = MonitoredDate(self.date_entry, date_button, self.date_object, self.uistate, self.track) pt_grid = Gtk.Grid(column_spacing=10) pt_grid.attach(pt_label, 0, 0, 1, 1) pt_grid.attach(self.typecombo, 1, 0, 1, 1) pt_grid.attach(tag_label, 0, 1, 1, 1) pt_grid.attach(self.tagcombo, 1, 1, 1, 1) pt_grid.attach(label1, 0, 2, 1, 1) pl_grid = Gtk.Grid(column_spacing=10) pl_grid.set_margin_left(20) #pt_grid.attach(self.enclosing_place, 1, 2, 1, 1) pl_grid.attach(date_label, 1, 4, 1, 1) pl_grid.attach(self.date_entry, 2, 4, 1, 1) pl_grid.attach(date_button, 3, 4, 1, 1) vbox.pack_start(pt_grid, False, True, 0) vbox.pack_start(pl_grid, False, True, 0) self.but_set_enclosing = Gtk.Button(label=_('Select')) self.but_set_enclosing.connect("clicked", self.cb_select) #vbox.pack_start(self.but_set_enclosing, False, True, 10) pt_grid.attach(self.but_set_enclosing, 1, 2, 1, 1) self.clear_enclosing = Gtk.CheckButton( _("Clear original enclosing places")) vbox.pack_start(self.clear_enclosing, False, True, 0) self.clear_tags = Gtk.CheckButton(_("Clear tags")) vbox.pack_start(self.clear_tags, False, True, 0) self.generate_hierarchy = Gtk.CheckButton(_("Generate hierarchy")) self.generate_hierarchy.connect("clicked", self.cb_select_generate_hierarchy) vbox.pack_start(self.generate_hierarchy, False, True, 0) butbox1 = Gtk.VBox() butbox1.set_margin_left(20) self.spaces = Gtk.CheckButton(_("use spaces as separator")) self.spaces.set_sensitive(False) butbox1.pack_start(self.spaces, False, True, 0) self.reverse = Gtk.CheckButton(_("reverse hierarchy")) self.reverse.set_sensitive(False) butbox1.pack_start(self.reverse, False, True, 0) vbox.pack_start(butbox1, False, True, 0) self.replace_text = Gtk.CheckButton(_("Replace text")) self.replace_text.connect("clicked", self.cb_select_replace_text) self.use_regex = Gtk.CheckButton(_("Use regex")) self.use_regex.set_sensitive(False) replace_text_box = Gtk.HBox() replace_text_box.pack_start(self.replace_text, False, True, 0) replace_text_box.pack_start(self.use_regex, False, True, 0) vbox.pack_start(replace_text_box, False, True, 0) old_text_label = Gtk.Label(_("Old text:")) self.old_text = Gtk.Entry() self.old_text.set_sensitive(False) new_text_label = Gtk.Label(_("New text:")) self.new_text = Gtk.Entry() self.new_text.set_sensitive(False) replace_grid = Gtk.Grid(column_spacing=10) replace_grid.set_margin_left(20) replace_grid.attach(old_text_label, 1, 0, 1, 1) replace_grid.attach(self.old_text, 2, 0, 1, 1) replace_grid.attach(new_text_label, 1, 1, 1, 1) replace_grid.attach(self.new_text, 2, 1, 1, 1) vbox.pack_start(replace_grid, False, True, 0) but_clear = Gtk.Button(label=_('Clear selections')) but_clear.connect("clicked", self.cb_clear) vbox.pack_start(but_clear, False, True, 10) but_apply = Gtk.Button(label=_('Apply to selected places')) but_apply.connect("clicked", self.cb__apply) vbox.pack_start(but_apply, False, True, 0) vbox.show_all() return vbox