# [PATCH resend] gitk: font and theme use

6 messages from 2010-01-13 to 2010-01-13. Participants: Mark Hills.
Thread: https://gitlist.dev/t/22208

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH resend] gitk: font and theme use
Message-ID: <alpine.NEB.2.01.1001132030010.15349@jrf.vwaro.pbz>
URL: https://gitlist.dev/e/alpine.NEB.2.01.1001132030010.15349%40jrf.vwaro.pbz

```
Hi Paul,

I'm following up this email with a re-send of some earlier patches for 
your review (previously sent to the list). They make some fixes to the 
font and theme use, mainly for consistency.

Since last time and have based them on gitk.git master (instead of 
git.git); no other changes.

Thanks

-- 
Mark

```

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH 1/5] gitk: Remove forced use of sans-serif font
Message-ID: <1263415222-5911-1-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1263415222-5911-1-git-send-email-mark%40pogo.org.uk
In-Reply-To: <alpine.NEB.2.01.1001132030010.15349@jrf.vwaro.pbz>

```
The X resources set using uifont cover this case.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/gitk b/gitk
index 48cfce3..0e430bd 100755
--- a/gitk
+++ b/gitk
@@ -10528,7 +10528,6 @@ proc mkfontdisp {font top which} {
     set fontpref($font) [set $font]
     ${NS}::button $top.${font}but -text $which \
 	-command [list choosefont $font $which]
-    if {!$use_ttk} {$top.${font}but configure  -font optionfont}
     ${NS}::label $top.$font -relief flat -font $font \
 	-text $fontattr($font,family) -justify left
     grid x $top.${font}but $top.$font -sticky w
@@ -10791,15 +10790,6 @@ proc doprefs {} {
     mkfontdisp textfont $top [mc "Diff display font"]
     mkfontdisp uifont $top [mc "User interface font"]
 
-    if {!$use_ttk} {
-	foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag
-	    ldiff lattr extdifff.l extdifff.b bgbut fgbut
-	    diffoldbut diffnewbut hunksepbut markbgbut selbgbut
-	    want_ttk ttk_note} {
-	    $top.$w configure -font optionfont
-	}
-    }
-
     ${NS}::frame $top.buts
     ${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active
     ${NS}::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
@@ -11411,8 +11401,6 @@ namespace import ::msgcat::mc
 
 catch {source ~/.gitk}
 
-font create optionfont -family sans-serif -size -12
-
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
 eval font create mainfontbold [fontflags mainfont 1]
-- 
1.6.6.5.ge408

```

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH 2/5] gitk: Set the font for all spinbox widgets
Message-ID: <1263415222-5911-2-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1263415222-5911-2-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1263415222-5911-1-git-send-email-mark@pogo.org.uk>

```
Use the X resources to set the font, removing the need to set the font
for specific widgets.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index 0e430bd..e010010 100755
--- a/gitk
+++ b/gitk
@@ -1879,6 +1879,7 @@ proc setoptions {} {
     option add *Message.font uifont startupFile
     option add *Entry.font uifont startupFile
     option add *Labelframe.font uifont startupFile
+    option add *Spinbox.font textfont startupFile
 }
 
 # Make a menu and submenus.
@@ -2229,7 +2230,7 @@ proc makewindow {} {
 	-command changediffdisp -variable diffelide -value {1 0}
     ${NS}::label .bleft.mid.labeldiffcontext -text "      [mc "Lines of context"]: "
     pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
-    spinbox .bleft.mid.diffcontext -width 5 -font textfont \
+    spinbox .bleft.mid.diffcontext -width 5 \
 	-from 0 -increment 1 -to 10000000 \
 	-validate all -validatecommand "diffcontextvalidate %P" \
 	-textvariable diffcontextstring
-- 
1.6.6.5.ge408

```

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH 3/5] gitk: Set the font for all listbox widgets
Message-ID: <1263415222-5911-3-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1263415222-5911-3-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1263415222-5911-2-git-send-email-mark@pogo.org.uk>

```
This affects the font chooser.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gitk b/gitk
index e010010..3cdc31e 100755
--- a/gitk
+++ b/gitk
@@ -1880,6 +1880,7 @@ proc setoptions {} {
     option add *Entry.font uifont startupFile
     option add *Labelframe.font uifont startupFile
     option add *Spinbox.font textfont startupFile
+    option add *Listbox.font mainfont startupFile
 }
 
 # Make a menu and submenus.
-- 
1.6.6.5.ge408

```

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH 4/5] gitk: Disable option when themed widgets are not available
Message-ID: <1263415222-5911-4-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1263415222-5911-4-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1263415222-5911-3-git-send-email-mark@pogo.org.uk>

```
Disable the widget instead of using the label to indicate that themed
widgets are not available.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gitk b/gitk
index 3cdc31e..54f4fb3 100755
--- a/gitk
+++ b/gitk
@@ -10736,14 +10736,14 @@ proc doprefs {} {
 
     ${NS}::label $top.lgen -text [mc "General options"]
     grid $top.lgen - -sticky w -pady 10
-    ${NS}::checkbutton $top.want_ttk -variable want_ttk \
-	-text [mc "Use themed widgets"]
     if {$have_ttk} {
-	${NS}::label $top.ttk_note -text [mc "(change requires restart)"]
+	${NS}::checkbutton $top.want_ttk -variable want_ttk \
+	    -text [mc "Use themed widgets (change requires restart)"]
     } else {
-	${NS}::label $top.ttk_note -text [mc "(currently unavailable)"]
+	${NS}::checkbutton $top.want_ttk \
+	    -text [mc "Use themed widgets"] -state disabled
     }
-    grid x $top.want_ttk $top.ttk_note -sticky w
+    grid x $top.want_ttk - -sticky w
 
     ${NS}::label $top.cdisp -text [mc "Colors: press to choose"]
     grid $top.cdisp - -sticky w -pady 10
-- 
1.6.6.5.ge408

```

## Mark Hills, 2010-01-13 20:40

Subject: [PATCH 5/5] gitk: Use consistent font for all text input fields
Message-ID: <1263415222-5911-5-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1263415222-5911-5-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1263415222-5911-4-git-send-email-mark@pogo.org.uk>

```
Instead of setting the font for specific widgets, set the font for the
widget type. If themed widgets are not available, this is via the X
resources. If themed widgets are available, the theme font is used.

The exception is the SHA1 ID which is forced to use the fixed-width
font, even where themed widgets are used.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gitk b/gitk
index 54f4fb3..1f5f456 100755
--- a/gitk
+++ b/gitk
@@ -1877,7 +1877,8 @@ proc setoptions {} {
     option add *Menubutton.font uifont startupFile
     option add *Label.font uifont startupFile
     option add *Message.font uifont startupFile
-    option add *Entry.font uifont startupFile
+    option add *Entry.font textfont startupFile
+    option add *Text.font textfont startupFile
     option add *Labelframe.font uifont startupFile
     option add *Spinbox.font textfont startupFile
     option add *Listbox.font mainfont startupFile
@@ -2176,7 +2177,7 @@ proc makewindow {} {
     set findstring {}
     set fstring .tf.lbar.findstring
     lappend entries $fstring
-    ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring
+    ${NS}::entry $fstring -width 30 -textvariable findstring
     trace add variable findstring write find_change
     set findtype [mc "Exact"]
     set findtypemenu [makedroplist .tf.lbar.findtype \
@@ -2219,7 +2220,7 @@ proc makewindow {} {
     pack .bleft.top.search -side left -padx 5
     set sstring .bleft.top.sstring
     set searchstring ""
-    ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring
+    ${NS}::entry $sstring -width 20 -textvariable searchstring
     lappend entries $sstring
     trace add variable searchstring write incrsearch
     pack $sstring -side left -expand 1 -fill x
@@ -4039,7 +4040,7 @@ proc vieweditor {top n title} {
 	} elseif {$type eq "path"} {
 	    ${NS}::label $top.l -text $title
 	    pack $top.l -in $top -side top -pady [list 3 0] -anchor w -padx 3
-	    text $top.t -width 40 -height 5 -background $bgcolor -font uifont
+	    text $top.t -width 40 -height 5 -background $bgcolor
 	    if {[info exists viewfiles($n)]} {
 		foreach f $viewfiles($n) {
 		    $top.t insert end $f
-- 
1.6.6.5.ge408

```
