[Tkabber-dev] r1638 - in trunk/tkabber: . ifacetk plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Feb 4 13:36:14 MSK 2009


Author: sergei
Date: 2009-02-04 13:36:13 +0300 (Wed, 04 Feb 2009)
New Revision: 1638

Added:
   trunk/tkabber/plugins/general/geometry.tcl
Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/ifacetk/iface.tcl
Log:
	* plugins/general/geometry.tcl: Added new plugin which saves main
	  window geometry and restores it on Tkabber start.

	* ifacetk/iface.tcl: Moved saving main window state (normal or zoomed)
	  to the new geometry plugin.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-02-03 19:33:44 UTC (rev 1637)
+++ trunk/tkabber/ChangeLog	2009-02-04 10:36:13 UTC (rev 1638)
@@ -1,3 +1,11 @@
+2009-02-04  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/general/geometry.tcl: Added new plugin which saves main
+	  window geometry and restores it on Tkabber start.
+
+	* ifacetk/iface.tcl: Moved saving main window state (normal or zoomed)
+	  to the new geometry plugin.
+
 2009-02-03  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/si/ibb.tcl: Fixed typo.

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2009-02-03 19:33:44 UTC (rev 1637)
+++ trunk/tkabber/ifacetk/iface.tcl	2009-02-04 10:36:13 UTC (rev 1638)
@@ -92,10 +92,6 @@
 					     icon is enabled, otherwise do nothing)"] \
 		    ]
 
-    custom::defvar mainwindowstate normal \
-	[::msgcat::mc "Stored main window state (normal or zoomed)"] \
-	-type string -group Hidden
-
     custom::defvar status_history [list] \
 	    [::msgcat::mc "History of availability status messages"] \
 	    -type string \
@@ -173,19 +169,7 @@
     }
 }
 
-proc ifacetk::save_mainwindowstate {w} {
-    variable mainwindowstate
 
-    if {![string equal $w .]} return
-
-    set state [wm state .]
-    if {$state != $mainwindowstate} {
-	set mainwindowstate $state
-    }
-}
-
-hook::add map_window_hook [namespace current]::ifacetk::save_mainwindowstate
-
 option add *errorForeground red widgetDefault
 
 wm protocol . WM_SAVE_YOURSELF session_checkpoint
@@ -1600,15 +1584,6 @@
 }
 
 proc ifacetk::deiconify {} {
-    global tcl_platform
-    variable mainwindowstate
-
-    if {[string equal $tcl_platform(platform) windows]} {
-	if {[string equal $mainwindowstate zoomed]} {
-	    wm state . zoomed
-	}
-    }
-    update
     wm deiconify .
 }
 

Added: trunk/tkabber/plugins/general/geometry.tcl
===================================================================
--- trunk/tkabber/plugins/general/geometry.tcl	                        (rev 0)
+++ trunk/tkabber/plugins/general/geometry.tcl	2009-02-04 10:36:13 UTC (rev 1638)
@@ -0,0 +1,78 @@
+# $Id$
+#
+
+namespace eval geometry {
+    custom::defvar MainWindowState {} \
+	[::msgcat::mc "Stored main window state (normal or zoomed)"] \
+	-type string -group Hidden
+
+    custom::defvar MainWindowGeometry {} \
+	[::msgcat::mc "Stored main window geometry"] \
+	-type string -group Hidden
+
+    hook::add finload_hook [namespace current]::setupBindings 101
+    hook::add finload_hook [namespace current]::restoreMainWindowState 99.9
+}
+
+proc geometry::setupBindings {} {
+    bind . <Map> [namespace current]::saveMainWindowState
+    bind . <Configure> [namespace current]::saveMainWindowGeometry
+}
+
+proc geometry::saveMainWindowState {} {
+    variable MainWindowState
+
+    set screen [winfo screen .]
+    array set tmp $MainWindowState
+
+    set state [wm state .]
+    if {![info exists tmp($screen)] || ![string equal $state $tmp($screen)]} {
+	set tmp($screen) $state
+	set MainWindowState [array get tmp]
+    }
+}
+
+proc geometry::saveMainWindowGeometry {} {
+    after cancel [namespace current]::afterSaveMainWindowGeometry
+    after idle [namespace current]::afterSaveMainWindowGeometry
+}
+
+proc geometry::afterSaveMainWindowGeometry {} {
+    variable MainWindowGeometry
+
+    set state [wm state .]
+    if {![string equal $state normal]} {
+	return
+    }
+
+    set screen [winfo screen .]
+    array set tmp $MainWindowGeometry
+
+    set geometry [wm geometry .]
+    if {![info exists tmp($screen)] || ![string equal $geometry $tmp($screen)]} {
+	set tmp($screen) $geometry
+	set MainWindowGeometry [array get tmp]
+    }
+}
+
+proc geometry::restoreMainWindowState {} {
+    global tcl_platform
+    variable MainWindowState
+    variable MainWindowGeometry
+
+    set screen [winfo screen .]
+
+    array set tmp1 $MainWindowGeometry
+    if {[info exists tmp1($screen)]} {
+	wm geometry . $tmp1($screen)
+    }
+
+    if {[string equal $tcl_platform(platform) windows]} {
+	array set tmp2 $MainWindowState
+	if {[info exists tmp2($screen)] && [string equal $tmp2($screen) zoomed]} {
+	    wm state . zoomed
+	}
+    }
+    update
+}
+


Property changes on: trunk/tkabber/plugins/general/geometry.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native



More information about the Tkabber-dev mailing list