git-gui: theme the search and line-number entry fields on blame screen
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Pat Thoyts committed
Oct 19, 2011 at 12:44 UTC
35927672765f39a045a89d2ef1b392ab3ac61189
3 files changed
+100
-8
lib/line.tcl
+1
-1
@@ -15,7 +15,7 @@ constructor new {i_w i_text args} {
15
16
${NS}::frame $w
17
${NS}::label $w.l -text [mc "Goto Line:"]
18
- entry $w.ent \
18
+ tentry $w.ent \
19
-textvariable ${__this}::linenum \
20
-background lightgreen \
21
-validate key \
lib/search.tcl
+5
-3
@@ -35,7 +35,7 @@ constructor new {i_w i_text args} {
35
36
${NS}::frame $w
37
${NS}::label $w.l -text [mc Find:]
38
- entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
38
+ tentry $w.ent -textvariable ${__this}::searchstring -background lightgreen
39
${NS}::button $w.bn -text [mc Next] -command [cb find_next]
40
${NS}::button $w.bp -text [mc Prev] -command [cb find_prev]
41
${NS}::checkbutton $w.re -text [mc RegExp] \
@@ -162,10 +162,12 @@ method _incrsearch {} {
162
$ctext see $here
163
$ctext tag remove sel 1.0 end
164
$ctext tag add sel $here "$here + $mlen c"
165
- $w.ent configure -background lightgreen
165
+ #$w.ent configure -background lightgreen
166
+ $w.ent state !pressed
167
_set_marks $this 1
168
} else {
168
- $w.ent configure -background lightpink
169
+ #$w.ent configure -background lightpink
170
+ $w.ent state pressed
171
}
172
}
173
}
lib/themed.tcl
+94
-4
@@ -23,10 +23,59 @@ proc InitTheme {} {
23
ttk::style configure Gold.TFrame -background gold -relief flat
24
# listboxes should have a theme border so embed in ttk::frame
25
ttk::style layout SListbox.TFrame {
26
- SListbox.Frame.Entry.field -sticky news -border true -children {
27
- SListbox.Frame.padding -sticky news
28
- }
29
- }
26
+ SListbox.Frame.Entry.field -sticky news -border true -children {
27
+ SListbox.Frame.padding -sticky news
28
+ }
29
+ }
30
+
31
+ # Handle either current Tk or older versions of 8.5
32
+ if {[catch {set theme [ttk::style theme use]}]} {
33
+ set theme $::ttk::currentTheme
34
+ }
35
+
36
+ if {[lsearch -exact {default alt classic clam} $theme] != -1} {
37
+ # Simple override of standard ttk::entry to change the field
38
+ # packground according to a state flag. We should use 'user1'
39
+ # but not all versions of 8.5 support that so make use of 'pressed'
40
+ # which is not normally in use for entry widgets.
41
+ ttk::style layout Edged.Entry [ttk::style layout TEntry]
42
+ ttk::style map Edged.Entry {*}[ttk::style map TEntry]
43
+ ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \
44
+ -fieldbackground lightgreen
45
+ ttk::style map Edged.Entry -fieldbackground {
46
+ {pressed !disabled} lightpink
47
+ }
48
+ } else {
49
+ # For fancier themes, in particular the Windows ones, the field
50
+ # element may not support changing the background color. So instead
51
+ # override the fill using the default fill element. If we overrode
52
+ # the vista theme field element we would loose the themed border
53
+ # of the widget.
54
+ catch {
55
+ ttk::style element create color.fill from default
56
+ }
57
+
58
+ ttk::style layout Edged.Entry {
59
+ Edged.Entry.field -sticky nswe -border 0 -children {
60
+ Edged.Entry.border -sticky nswe -border 1 -children {
61
+ Edged.Entry.padding -sticky nswe -children {
62
+ Edged.Entry.color.fill -sticky nswe -children {
63
+ Edged.Entry.textarea -sticky nswe
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \
71
+ -background lightgreen -padding 0 -borderwidth 0
72
+ ttk::style map Edged.Entry {*}[ttk::style map TEntry] \
73
+ -background {{pressed !disabled} lightpink}
74
+ }
75
+
76
+ if {[lsearch [bind . <<ThemeChanged>>] InitTheme] == -1} {
77
+ bind . <<ThemeChanged>> +[namespace code [list InitTheme]]
78
+ }
79
}
80
81
proc gold_frame {w args} {
@@ -143,6 +192,47 @@ proc tspinbox {w args} {
192
}
193
}
194
195
+proc tentry {w args} {
196
+ global use_ttk
197
+ if {$use_ttk} {
198
+ InitTheme
199
+ ttk::entry $w -style Edged.Entry
200
+ } else {
201
+ entry $w
202
+ }
203
+
204
+ rename $w _$w
205
+ interp alias {} $w {} tentry_widgetproc $w
206
+ eval [linsert $args 0 tentry_widgetproc $w configure]
207
+ return $w
208
+}
209
+proc tentry_widgetproc {w cmd args} {
210
+ global use_ttk
211
+ switch -- $cmd {
212
+ state {
213
+ if {$use_ttk} {
214
+ return [uplevel 1 [list _$w $cmd] $args]
215
+ } else {
216
+ if {[lsearch -exact $args pressed] != -1} {
217
+ _$w configure -background lightpink
218
+ } else {
219
+ _$w configure -background lightgreen
220
+ }
221
+ }
222
+ }
223
+ configure {
224
+ if {$use_ttk} {
225
+ if {[set n [lsearch -exact $args -background]] != -1} {
226
+ set args [lreplace $args $n [incr n]]
227
+ if {[llength $args] == 0} {return}
228
+ }
229
+ }
230
+ return [uplevel 1 [list _$w $cmd] $args]
231
+ }
232
+ default { return [uplevel 1 [list _$w $cmd] $args] }
233
+ }
234
+}
235
+
236
# Tk 8.6 provides a standard font selection dialog. This uses the native
237
# dialogs on Windows and MacOSX or a standard Tk dialog on X11.
238
proc tchoosefont {w title familyvar sizevar} {