9795: remember the last location of windows [partial: some tools]

This commit is contained in:
Paul Franklin 2016-12-17 10:34:06 -08:00
parent 2577367f01
commit 341d48bd40
19 changed files with 37 additions and 35 deletions

View File

@ -336,7 +336,7 @@ class ManagedWindow:
from .managedwindow import ManagedWindow
class SomeWindowClass(ManagedWindow):
def __init__(self, uistate, dbstate, track, modal):
def __init__(self, uistate, track, obj, modal):
window_id = self # Or e.g. window_id = person.handle
ManagedWindow.__init__(self,
uistate,
@ -354,10 +354,11 @@ class ManagedWindow:
:param track: {list of parent windows, [] if the main GRAMPS window
is the parent}
:param obj: The object that is used to id the managed window,
The inheriting object needs a method build_menu_names(self, obj)
The inheriting object needs a method
build_menu_names(self, obj)
which works on this obj and creates menu labels
for use in the Gramps Window Menu.
If self.submenu_label ='' then leaf, otherwise branch
If self.submenu_label ='' then leaf, else branch
:param modal: True/False, if True, this window is made modal
(always on top, and always has focus). Any child
windows are also automatically made modal by moving
@ -425,8 +426,10 @@ class ManagedWindow:
"""
Set the window that is managed.
:param window: if isWindow=False window must be a Gtk.Window() object, otherwise None
:param title: a label widget in which to write the title, None if not needed
:param window: if isWindow=False window must be a Gtk.Window() object
(or a subclass such as Gtk.Dialog), otherwise None
:param title: a label widget in which to write the title,
else None if not needed
:param text: text to use as title of window and in title param
:param msg: if not None, use msg as title of window instead of text
:param isWindow: {if isWindow than self is the window

View File

@ -883,7 +883,7 @@ class ToolManagedWindowBase(ManagedWindow):
def pre_run(self):
from ..utils import ProgressMeter
self.progress = ProgressMeter(self.get_title(),
parent=self.uistate.window)
parent=self.window)
def run(self):
raise NotImplementedError("tool needs to define a run() method")

View File

@ -5,8 +5,6 @@
<object class="GtkWindow" id="changenames">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="default_width">500</property>
<property name="default_height">450</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<child>
<object class="GtkBox" id="vbox2">

View File

@ -186,6 +186,7 @@ class ChangeNames(tool.BatchTool, ManagedWindow):
self.list = self.top.get_object("list")
self.set_window(window,self.top.get_object('title'),self.label)
self.setup_configs('interface.changenames', 500, 450)
self.model = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING,
GObject.TYPE_STRING)

View File

@ -94,6 +94,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow):
window = self.glade.toplevel
self.set_window(window,self.glade.get_object('title'),self.title)
self.setup_configs('interface.changetypes', 640, 260)
self.glade.connect_signals({
"on_close_clicked" : self.close,

View File

@ -68,16 +68,16 @@ class DumpGenderStats(tool.Tool, ManagedWindow):
treeview = Gtk.TreeView()
model = ListModel(treeview, titles)
for entry in stats_list:
for entry in sorted(stats_list):
model.add(entry, entry[0])
window = Gtk.Window()
window.set_default_size(400, 300)
window = Gtk.Window() # TODO there needs to be a way to "close" it
s = Gtk.ScrolledWindow()
s.add(treeview)
window.add(s)
window.show_all()
self.set_window(window, None, self.label)
self.setup_configs('interface.dumpgenderstats', 400, 300)
self.show()
else:

View File

@ -4,8 +4,6 @@
<requires lib="gtk+" version="3.10"/>
<object class="GtkDialog" id="eventcmp">
<property name="can_focus">False</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
@ -139,7 +137,6 @@
</object>
<object class="GtkDialog" id="filters">
<property name="can_focus">False</property>
<property name="default_width">400</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox5">

View File

@ -138,6 +138,7 @@ class EventComparison(tool.Tool,ManagedWindow):
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)
@ -193,7 +194,7 @@ class EventComparison(tool.Tool,ManagedWindow):
WarningDialog(_("No matches were found"),
parent=self.window)
else:
DisplayChart(self.dbstate,self.uistate,plist,self.track)
EventComparisonResults(self.dbstate, self.uistate, plist, self.track)
#-------------------------------------------------------------------------
#
@ -217,7 +218,7 @@ def fix(line):
#
#
#-------------------------------------------------------------------------
class DisplayChart(ManagedWindow):
class EventComparisonResults(ManagedWindow):
def __init__(self,dbstate,uistate,people_list,track):
self.dbstate = dbstate
self.uistate = uistate
@ -241,6 +242,7 @@ class DisplayChart(ManagedWindow):
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)
@ -307,7 +309,7 @@ class DisplayChart(ManagedWindow):
def build_row_data(self):
self.progress_bar = ProgressMeter(
_('Comparing Events'), '', parent=self.window)
_('Comparing Events'), '', parent=self.uistate.window)
self.progress_bar.set_pass(_('Building data'),len(self.my_list))
for individual_id in self.my_list:
individual = self.db.get_person_from_handle(individual_id)

View File

@ -10,7 +10,6 @@
</object>
<object class="GtkDialog" id="finddupes">
<property name="can_focus">False</property>
<property name="default_width">350</property>
<property name="type_hint">dialog</property>
<signal name="delete-event" handler="on_delete_merge_event" swapped="no"/>
<child internal-child="vbox">

View File

@ -84,7 +84,7 @@ def is_initial(name):
# The Actual tool.
#
#-------------------------------------------------------------------------
class Merge(tool.Tool,ManagedWindow):
class DuplicatePeopleTool(tool.Tool, ManagedWindow):
def __init__(self, dbstate, user, options_class, name, callback=None):
uistate = user.uistate
@ -124,6 +124,7 @@ class Merge(tool.Tool,ManagedWindow):
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,
@ -178,8 +179,9 @@ class Merge(tool.Tool,ManagedWindow):
parent=self.window)
else:
try:
ShowMatches(self.dbstate,self.uistate,self.track,
self.list,self.map,self.update)
DuplicatePeopleToolMatches(self.dbstate, self.uistate,
self.track, self.list, self.map,
self.update)
except WindowActiveError:
pass
@ -533,7 +535,7 @@ class Merge(tool.Tool,ManagedWindow):
pass
class ShowMatches(ManagedWindow):
class DuplicatePeopleToolMatches(ManagedWindow):
def __init__(self, dbstate, uistate, track, the_list, the_map, callback):
ManagedWindow.__init__(self,uistate,track,self.__class__)
@ -551,6 +553,7 @@ class ShowMatches(ManagedWindow):
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({
@ -665,7 +668,7 @@ def get_surnames(name):
#
#
#------------------------------------------------------------------------
class MergeOptions(tool.ToolOptions):
class DuplicatePeopleToolOptions(tool.ToolOptions):
"""
Defines options and provides handling interface.
"""

View File

@ -10,7 +10,6 @@
</object>
<object class="GtkDialog" id="mergecitations">
<property name="can_focus">False</property>
<property name="default_width">350</property>
<property name="type_hint">dialog</property>
<signal name="delete-event" handler="on_delete_merge_event" swapped="no"/>
<child internal-child="vbox">

View File

@ -132,6 +132,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
self.set_window(window, top.get_object('title2'),
_("Notes, media objects and data-items of matching "
"citations will be combined."))
self.setup_configs('interface.mergecitations', 700, 230)
top.connect_signals({
"on_merge_ok_clicked" : self.on_merge_ok_clicked,
@ -182,7 +183,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
self.options.handler.save_options()
self.progress = ProgressMeter(_('Checking Sources'), '',
parent=self.user.uistate.window)
parent=self.window)
self.progress.set_pass(_('Looking for citation fields'),
self.db.get_number_of_citations())
@ -234,7 +235,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
ngettext("{number_of} citation merged",
"{number_of} citations merged", num_merges
).format(number_of=num_merges),
parent=self.user.uistate.window)
parent=self.window)
self.close(obj)
#------------------------------------------------------------------------

View File

@ -4,8 +4,6 @@
<requires lib="gtk+" version="3.10"/>
<object class="GtkDialog" id="notrelated">
<property name="can_focus">False</property>
<property name="default_width">450</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<child internal-child="vbox">

View File

@ -93,6 +93,7 @@ class NotRelated(tool.ActivePersonTool, ManagedWindow) :
window = topDialog.toplevel
title = topDialog.get_object("title")
self.set_window(window, title, self.title)
self.setup_configs('interface.notrelated', 450, 400)
self.tagcombo = topDialog.get_object("tagcombo")
tagmodel = Gtk.ListStore(str)
@ -108,7 +109,7 @@ class NotRelated(tool.ActivePersonTool, ManagedWindow) :
# start the progress indicator
self.progress = ProgressMeter(self.title, _('Starting'),
parent=self.window)
parent=self.uistate.window)
# setup the columns
self.model = Gtk.TreeStore(

View File

@ -35,7 +35,6 @@
<object class="GtkWindow" id="ownereditor">
<property name="can_focus">False</property>
<property name="window_position">center</property>
<property name="default_width">500</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<child>
<object class="GtkEventBox" id="eventbox">

View File

@ -100,6 +100,7 @@ class OwnerEditor(tool.Tool, ManagedWindow):
self.set_window(window,
topDialog.get_object("title"),
_("Database Owner Editor"))
self.setup_configs('interface.ownereditor', 500, 400)
# move help button to the left side
action_area = topDialog.get_object("action_area")

View File

@ -4,8 +4,6 @@
<requires lib="gtk+" version="3.10"/>
<object class="GtkDialog" id="removeunused">
<property name="can_focus">False</property>
<property name="default_width">500</property>
<property name="default_height">300</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2">

View File

@ -130,6 +130,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
self.top = Glade()
window = self.top.toplevel
self.set_window(window, self.top.get_object('title'), self.title)
self.setup_configs('interface.removeunused', 400, 520)
self.events_box = self.top.get_object('events_box')
self.sources_box = self.top.get_object('sources_box')

View File

@ -157,8 +157,8 @@ fname = 'finddupes.py',
authors = ["Donald N. Allingham"],
authors_email = ["don@gramps-project.org"],
category = TOOL_DBPROC,
toolclass = 'Merge',
optionclass = 'MergeOptions',
toolclass = 'DuplicatePeopleTool',
optionclass = 'DuplicatePeopleToolOptions',
tool_modes = [TOOL_MODE_GUI]
)