[GRASS-dev] Re: gis.m: font selection in module panels

Paul Kelly paul-grass at stjohnspoint.co.uk
Fri Jul 27 13:06:32 EDT 2007


On Fri, 27 Jul 2007, Michael Barton wrote:

> OK. I'll wait for your fix. I took a quick look and noted the following
> behavior.
>
> set default display font to A
> launch font setting dialog for the barscale panel
> the barscale font dialog shows A selected
> select font B for the barscale
> open the default display font dialog
> it shows A
> click OK without clicking on a font in the listbox
> reopen the default display font dialog
> it shows B
>
> This suggests to me that there is a variable that is either 1) not getting
> updated properly when OK is pressed or 2) the list selection is not moving
> properly to show the selected font.

The attached patch fixes things a little bit (apply to latest CVS, after 
my updates today), by presetting the dfont variable before calling the 
select box, so it is pointing at the right font at the start. But it 
doesn't work 100% yet and the whole thing is a bit complicated. I think 
binding some events to the OK button instead of the select box change 
event is part of the solution though.

Paul
-------------- next part --------------
Index: dtext.tcl
===================================================================
RCS file: /home/grass/grassrepository/grass6/gui/tcltk/gis.m/dtext.tcl,v
retrieving revision 1.15
diff -u -r1.15 dtext.tcl
--- dtext.tcl	27 Jul 2007 14:28:33 -0000	1.15
+++ dtext.tcl	27 Jul 2007 17:00:46 -0000
@@ -110,9 +110,11 @@
 	variable opt
 
 	
+	set Gm::dfont $GmDtext::opt($id,1,font)
 	Gm:DefaultFont dbarscale
 	tkwait variable Gm::dfont
 	set GmDtext::opt($id,1,font) $Gm::dfont
+	set Gm::dfont ""
 
 }
 
Index: gm.tcl
===================================================================
RCS file: /home/grass/grassrepository/grass6/gui/tcltk/gis.m/gm.tcl,v
retrieving revision 1.61
diff -u -r1.61 gm.tcl
--- gm.tcl	27 Jul 2007 14:28:33 -0000	1.61
+++ gm.tcl	27 Jul 2007 17:00:46 -0000
@@ -113,8 +113,6 @@
     variable prgtext
     variable mainwindow
     variable dfont 
-    variable fonttype
-    variable fontpath
     variable encoding
 	global array filename # mon
 
@@ -232,8 +230,6 @@
     variable gm_mainframe
     variable tree
 	variable moncount
-	variable fontpath
-	variable fonttype
 	variable dfont
 	variable ecoding
     global gmpath
@@ -246,9 +242,7 @@
     global env
     
     set env(GRASS_RENDER_IMMEDIATE) "TRUE"
-	set fontpath ""
-	set Gm::fonttype "grassfont"
-	set Gm::dfont "romans"
+	set Gm::dfont ""
 	set Gm::encoding "ISO-8859-1"
 
 	set moncount 1
@@ -502,9 +496,18 @@
     foreach item $fontlist {
     	$fontlb insert end $item
     }
-    
-    if {![catch {set env(GRASS_FONT)}] && $env(GRASS_FONT) != ""} {
-    	set fontindex [lsearch $fontlist $env(GRASS_FONT)]
+
+    # If $Gm::dfont is empty then it hasn't been set by a layer module
+    # before calling this procedure, so we should read the current
+    # default font from the GRASS_FONT environment variable
+    if {$Gm::dfont == ""} {    
+        if {![catch {set env(GRASS_FONT)}] && $env(GRASS_FONT) != ""} {
+	    set Gm::dfont $env(GRASS_FONT)
+	}
+    }
+   
+    if {$Gm::dfont != ""} {
+    	set fontindex [lsearch $fontlist $Gm::dfont]
     	if {$fontindex > -1} {
     		$fontlb selection set $fontindex
     		$fontlb see $fontindex
@@ -554,6 +557,7 @@
 
 	if { $source == "menu" && $dfont != "" } {
 		set env(GRASS_FONT) $dfont
+		set dfont ""
 	}
 
 };
Index: histogram.tcl
===================================================================
RCS file: /home/grass/grassrepository/grass6/gui/tcltk/gis.m/histogram.tcl,v
retrieving revision 1.21
diff -u -r1.21 histogram.tcl
--- histogram.tcl	27 Jul 2007 14:28:33 -0000	1.21
+++ histogram.tcl	27 Jul 2007 17:00:47 -0000
@@ -114,9 +114,11 @@
 	variable opt
 
 	
+	set Gm::dfont $GmHist::opt($id,1,font)
 	Gm:DefaultFont dhist
 	tkwait variable Gm::dfont
 	set GmHist::opt($id,1,font) $Gm::dfont
+	set Gm::dfont ""
 
 }
 


More information about the grass-dev mailing list