enable the main window to remember its position on the screen
The genealogy -- as it were -- of this patch started with https://gramps-project.org/bugs/view.php?id=5357 which was a feature request for the clipboard to remember its location on the screen, its placement, its position. The p.r. https://github.com/gramps-project/gramps/pull/58 was a prototype implementation, but it also had the main window remembering its location. Then p.r. 58 turned into https://github.com/gramps-project/gramps/pull/60/ -- but later both of those were closed, never committed. Since I really wanted the main window to be able to remember its position, I have extracted the relevant code. I also modified it along the way, e.g. renaming some variables. So all the credit should go to Sam Manzi, the originator of those two pull requests, and thus the code in this commit. However, any problems are due to me, my changes -- not Sam.
This commit is contained in:
parent
3e1a0187e3
commit
b03579428b
@ -224,6 +224,8 @@ register('interface.lds-width', 600)
|
||||
register('interface.location-height', 250)
|
||||
register('interface.location-width', 600)
|
||||
register('interface.main-window-height', 500)
|
||||
register('interface.main-window-horiz-position', 15)
|
||||
register('interface.main-window-vert-position', 10)
|
||||
register('interface.main-window-width', 775)
|
||||
register('interface.mapservice', 'OpenStreetMap')
|
||||
register('interface.media-height', 450)
|
||||
|
@ -527,6 +527,7 @@ class ManagedWindow:
|
||||
"""
|
||||
Set the dimensions of the window
|
||||
"""
|
||||
# self.width_key is set in the subclass, typically in its _local_init
|
||||
if self.width_key is not None:
|
||||
width = config.get(self.width_key)
|
||||
height = config.get(self.height_key)
|
||||
@ -536,6 +537,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
|
||||
if self.width_key is not None:
|
||||
(width, height) = self.window.get_size()
|
||||
config.set(self.width_key, width)
|
||||
|
@ -356,10 +356,13 @@ class ViewManager(CLIManager):
|
||||
"""
|
||||
width = config.get('interface.main-window-width')
|
||||
height = config.get('interface.main-window-height')
|
||||
horiz_position = config.get('interface.main-window-horiz-position')
|
||||
vert_position = config.get('interface.main-window-vert-position')
|
||||
|
||||
self.window = Gtk.Window()
|
||||
self.window.set_icon_from_file(ICON)
|
||||
self.window.set_default_size(width, height)
|
||||
self.window.move(horiz_position, vert_position)
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.window.add(vbox)
|
||||
@ -758,6 +761,10 @@ class ViewManager(CLIManager):
|
||||
(width, height) = self.window.get_size()
|
||||
config.set('interface.main-window-width', width)
|
||||
config.set('interface.main-window-height', height)
|
||||
# save the current window position
|
||||
(horiz_position, vert_position) = self.window.get_position()
|
||||
config.set('interface.main-window-horiz-position', horiz_position)
|
||||
config.set('interface.main-window-vert-position', vert_position)
|
||||
config.save()
|
||||
Gtk.main_quit()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user