1
# Functions for supporting the use of themed Tk widgets in git-gui.
2
# Copyright (C) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
3
4
+
5
+namespace eval color {
6
+ # Variable colors
7
+ # Preffered way to set widget colors is using add_option.
8
+ # In some cases, like with tags in_diff/in_sel, we use these colors.
9
+ variable select_bg lightgray
10
+ variable select_fg black
11
+
12
+ proc sync_with_theme {} {
13
+ set base_bg [ttk::style lookup . -background]
14
+ set base_fg [ttk::style lookup . -foreground]
15
+ set text_bg [ttk::style lookup Treeview -background]
16
+ set text_fg [ttk::style lookup Treeview -foreground]
17
+ set select_bg [ttk::style lookup Default -selectbackground]
18
+ set select_fg [ttk::style lookup Default -selectforeground]
19
+
20
+ set color::select_bg $select_bg
21
+ set color::select_fg $select_fg
22
+
23
+ proc add_option {key val} {
24
+ option add $key $val widgetDefault
25
+ }
26
+ # Add options for plain Tk widgets
27
+ # Using `option add` instead of tk_setPalette to avoid unintended
28
+ # consequences.
29
+ if {![is_MacOSX]} {
30
+ add_option *Menu.Background $base_bg
31
+ add_option *Menu.Foreground $base_fg
32
+ add_option *Menu.activeBackground $select_bg
33
+ add_option *Menu.activeForeground $select_fg
34
+ }
35
+ add_option *Text.Background $text_bg
36
+ add_option *Text.Foreground $text_fg
37
+ add_option *Text.HighlightBackground $base_bg
38
+ add_option *Text.HighlightColor $select_bg
39
+ }
40
+}
41
+
42
proc ttk_get_current_theme {} {
43
# Handle either current Tk or older versions of 8.5
44
if {[catch {set theme [ttk::style theme use]}]} {