Changeset - dc35587fbbb6
[Not reviewed]
default
0 1 0
Drew Perttula - 12 years ago 2013-06-05 00:11:22
drewp@bigasterisk.com
hack up the window-save-position code to try to ignore automatic size changes at start
Ignore-this: c563fa4e2f0a42444afd5ad223e84cb9
1 file changed with 22 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/uihelpers.py
Show inline comments
 
@@ -2,10 +2,14 @@
 

	
 
from __future__ import nested_scopes
 
#from Tkinter import Button
 
import logging, time
 
from rdflib import Literal
 
from Tix import Button, Toplevel, Tk, IntVar, Entry, DoubleVar
 
import Tkinter
 
from light9.namespaces import L9
 

	
 
log = logging.getLogger("toplevel")
 

	
 
windowlocations = {
 
    'sub' : '425x738+00+00',
 
    'console' : '168x24+848+000',
 
@@ -39,6 +43,7 @@ def toplevelat(name, existingtoplevel=No
 

	
 
    lastSaved = [None]
 
    setOnce = [False]
 
    graphSetTime = [0]
 
    def setPosFromGraphOnce():
 
        """
 
        the graph is probably initially empty, but as soon as it gives
 
@@ -47,22 +52,31 @@ def toplevelat(name, existingtoplevel=No
 
        if setOnce[0]:
 
            return
 
        geo = graph.value(session, L9.windowGeometry)
 
        log.debug("setPosFromGraphOnce %s", geo)
 

	
 
        if geo is not None and geo != lastSaved[0]:
 
            setOnce[0] = True
 
            tl.geometry(geo)
 
            lastSaved[0] = geo
 

	
 
    def savePos():
 
        geo = tl.geometry()
 
            graphSetTime[0] = time.time()
 

	
 
        # todo: need a way to filter out the startup window sizes that
 
        # weren't set by the user
 
        if geo.startswith("1x1") or geo.startswith(("378x85", "378x86")):
 
    def savePos(ev):
 
        geo = tl.geometry()
 
        if not isinstance(ev.widget, Tkinter.Tk):
 
            # I think these are due to internal widget size changes,
 
            # not the toplevel changing
 
            return
 
        # this is trying to not save all the startup automatic window
 
        # sizes. I don't have a better plan for this yet.
 
        if graphSetTime[0] == 0 or time.time() < graphSetTime[0] + 3:
 
            return
 

	
 
        if geo == lastSaved[0]:
 
            return
 
        if not setOnce[0]:
 
            return
 
        lastSaved[0] = geo
 
        log.debug("saving position %s", geo)
 
        graph.patchObject(session, session, L9.windowGeometry, Literal(geo))
 

	
 
    if graph is not None and session is not None:
 
@@ -72,7 +86,8 @@ def toplevelat(name, existingtoplevel=No
 
        tl.geometry(positionOnCurrentDesktop(windowlocations[name]))
 

	
 
    if graph is not None:
 
        tl._toplevelat_funcid = tl.bind("<Configure>",lambda ev,tl=tl,name=name: savePos())
 
        tl._toplevelat_funcid = tl.bind("<Configure>",
 
                                        lambda ev,tl=tl,name=name: savePos(ev))
 

	
 
    return tl
 

	
0 comments (0 inline, 0 general)