diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 273d557c0..c21c9e23d 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -187,20 +187,12 @@ register('interface.address-height', 450) register('interface.address-width', 650) register('interface.attribute-height', 350) register('interface.attribute-width', 600) -register('interface.book-selector-height', 600) -register('interface.book-selector-horiz-position', 100) -register('interface.book-selector-vert-position', 200) -register('interface.book-selector-width', 700) register('interface.child-ref-height', 450) register('interface.child-ref-width', 600) register('interface.citation-height', 450) register('interface.citation-sel-height', 450) register('interface.citation-sel-width', 600) register('interface.citation-width', 600) -register('interface.clipboard-height', 300) -register('interface.clipboard-horiz-position', 100) -register('interface.clipboard-vert-position', 200) -register('interface.clipboard-width', 300) register('interface.dont-ask', False) register('interface.view-categories', ["Dashboard", "People", "Relationships", "Families", diff --git a/gramps/gui/clipboard.py b/gramps/gui/clipboard.py index 84db1da2c..26c3cc2f0 100644 --- a/gramps/gui/clipboard.py +++ b/gramps/gui/clipboard.py @@ -1383,15 +1383,9 @@ class ClipboardWindow(ManagedWindow): self.database_changed(self.dbstate.db) self.dbstate.connect('database-changed', self.database_changed) - self.width_key = 'interface.clipboard-width' - self.height_key = 'interface.clipboard-height' - self.horiz_position_key = 'interface.clipboard-horiz-position' - self.vert_position_key = 'interface.clipboard-vert-position' - self.top = Glade() self.set_window(self.top.toplevel, None, None, msg=_("Clipboard")) - self._set_size() - self._set_position() + self.setup_configs('interface.clipboard', 500, 300, 100, 200) self.clear_all_btn = self.top.get_object("btn_clear_all") self.clear_btn = self.top.get_object("btn_clear") diff --git a/gramps/gui/glade/clipboard.glade b/gramps/gui/glade/clipboard.glade index 845da678f..7f12a37ad 100644 --- a/gramps/gui/glade/clipboard.glade +++ b/gramps/gui/glade/clipboard.glade @@ -5,8 +5,6 @@ False Clipboard - 500 - 300 dialog diff --git a/gramps/gui/managedwindow.py b/gramps/gui/managedwindow.py index 70e9e7654..a682d782b 100644 --- a/gramps/gui/managedwindow.py +++ b/gramps/gui/managedwindow.py @@ -569,7 +569,7 @@ class ManagedWindow: """ Set the dimensions of the window """ - # self.width_key is set in the subclass, typically in its _local_init + # self.width_key is set in the subclass (or in setup_configs) if self.width_key is not None: width = config.get(self.width_key) height = config.get(self.height_key) @@ -579,7 +579,7 @@ class ManagedWindow: """ Save the dimensions of the window to the config file """ - # self.width_key is set in the subclass, typically in its _local_init + # self.width_key is set in the subclass (or in setup_configs) if self.width_key is not None: (width, height) = self.window.get_size() config.set(self.width_key, width) @@ -590,7 +590,7 @@ class ManagedWindow: """ Set the position of the window """ - # self.horiz_position_key is set in the subclass + # self.horiz_position_key is set in the subclass (or in setup_configs) if self.horiz_position_key is not None: horiz_position = config.get(self.horiz_position_key) vert_position = config.get(self.vert_position_key) @@ -600,12 +600,37 @@ class ManagedWindow: """ Save the window's position to the config file """ + # self.horiz_position_key is set in the subclass (or in setup_configs) if self.horiz_position_key is not None: (horiz_position, vert_position) = self.window.get_position() config.set(self.horiz_position_key, horiz_position) config.set(self.vert_position_key, vert_position) config.save() + def setup_configs(self, config_base, + default_width, default_height, + default_horiz_position, default_vert_position): + """ + Helper method to setup the window's configuration settings + + @param config_base: the common config name, e.g. 'interface.clipboard' + @type config_base: str + @param default_width, default_height: the default width and height + @type default_width, default_height: int + @param default_horiz_position, default_vert_position: the defaults + @type default_horiz_position, default_vert_position: int + """ + self.width_key = config_base + '-width' + self.height_key = config_base + '-height' + self.horiz_position_key = config_base + '-horiz-position' + self.vert_position_key = config_base + '-vert-position' + config.register(self.width_key, default_width) + config.register(self.height_key, default_height) + config.register(self.horiz_position_key, default_horiz_position) + config.register(self.vert_position_key, default_vert_position) + self._set_size() + self._set_position() + def track_ref_for_deletion(self, ref): """ Record references of instance variables that need to be removed diff --git a/gramps/gui/plug/report/_bookdialog.py b/gramps/gui/plug/report/_bookdialog.py index 5a97f687b..bfddad433 100644 --- a/gramps/gui/plug/report/_bookdialog.py +++ b/gramps/gui/plug/report/_bookdialog.py @@ -329,12 +329,7 @@ class BookSelector(ManagedWindow): title_label = self.xml.get_object('title') self.set_window(window, title_label, self.title) - self.height_key = 'interface.book-selector-height' - self.width_key = 'interface.book-selector-width' - self._set_size() - self.horiz_position_key = 'interface.book-selector-horiz-position' - self.vert_position_key = 'interface.book-selector-vert-position' - self._set_position() + self.setup_configs('interface.book-selector', 700, 600, 100, 200) window.show() self.xml.connect_signals({ "on_add_clicked" : self.on_add_clicked,