Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratyush Yadav <me@yadavpratyush.com>2020-10-08 16:04:54 +0300
committerPratyush Yadav <me@yadavpratyush.com>2020-10-08 16:04:54 +0300
commit01121d6132135e62d4bf7c2e67e749ae3037d0ba (patch)
tree996d932e826b3b929f9a1054fc629d3fbeccf653
parent95bfc6cdb697b971ffd7766f353d9bcf7bad9f6f (diff)
parentc02efc13638447f9af0be6cb158a6c1a8dd4c727 (diff)
Merge branch 'st/dark-mode' into master
Improve dark mode support. Do not hard-code widget colors and instead pull them from the current theme and update them in the options database. * st/dark-mode: git-gui: improve dark mode support
-rwxr-xr-xgit-gui.sh17
-rw-r--r--lib/themed.tcl38
2 files changed, 49 insertions, 6 deletions
diff --git a/git-gui.sh b/git-gui.sh
index d18b902189..867b8cea46 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -720,7 +720,9 @@ proc rmsel_tag {text} {
-background [$text cget -background] \
-foreground [$text cget -foreground] \
-borderwidth 0
- $text tag conf in_sel -background lightgray
+ $text tag conf in_sel\
+ -background $color::select_bg \
+ -foreground $color::select_fg
bind $text <Motion> break
return $text
}
@@ -863,6 +865,7 @@ proc apply_config {} {
set NS ttk
bind [winfo class .] <<ThemeChanged>> [list InitTheme]
pave_toplevel .
+ color::sync_with_theme
}
}
}
@@ -3272,7 +3275,7 @@ pack .vpane -anchor n -side top -fill both -expand 1
textframe .vpane.files.workdir -height 100 -width 200
tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
-background lightsalmon -foreground black
-ttext $ui_workdir -background white -foreground black \
+ttext $ui_workdir \
-borderwidth 0 \
-width 20 -height 10 \
-wrap none \
@@ -3294,7 +3297,7 @@ textframe .vpane.files.index -height 100 -width 200
tlabel .vpane.files.index.title \
-text [mc "Staged Changes (Will Commit)"] \
-background lightgreen -foreground black
-ttext $ui_index -background white -foreground black \
+ttext $ui_index \
-borderwidth 0 \
-width 20 -height 10 \
-wrap none \
@@ -3321,7 +3324,9 @@ if {!$use_ttk} {
foreach i [list $ui_index $ui_workdir] {
rmsel_tag $i
- $i tag conf in_diff -background [$i tag cget in_sel -background]
+ $i tag conf in_diff \
+ -background $color::select_bg \
+ -foreground $color::select_fg
}
unset i
@@ -3429,7 +3434,7 @@ if {![is_enabled nocommit]} {
}
textframe .vpane.lower.commarea.buffer.frame
-ttext $ui_comm -background white -foreground black \
+ttext $ui_comm \
-borderwidth 1 \
-undo true \
-maxundo 20 \
@@ -3558,7 +3563,7 @@ bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}
#
textframe .vpane.lower.diff.body
set ui_diff .vpane.lower.diff.body.t
-ttext $ui_diff -background white -foreground black \
+ttext $ui_diff \
-borderwidth 0 \
-width 80 -height 5 -wrap none \
-font font_diff \
diff --git a/lib/themed.tcl b/lib/themed.tcl
index 88b3119a75..83e3ac795f 100644
--- a/lib/themed.tcl
+++ b/lib/themed.tcl
@@ -1,6 +1,44 @@
# Functions for supporting the use of themed Tk widgets in git-gui.
# Copyright (C) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+namespace eval color {
+ # Variable colors
+ # Preffered way to set widget colors is using add_option.
+ # In some cases, like with tags in_diff/in_sel, we use these colors.
+ variable select_bg lightgray
+ variable select_fg black
+
+ proc sync_with_theme {} {
+ set base_bg [ttk::style lookup . -background]
+ set base_fg [ttk::style lookup . -foreground]
+ set text_bg [ttk::style lookup Treeview -background]
+ set text_fg [ttk::style lookup Treeview -foreground]
+ set select_bg [ttk::style lookup Default -selectbackground]
+ set select_fg [ttk::style lookup Default -selectforeground]
+
+ set color::select_bg $select_bg
+ set color::select_fg $select_fg
+
+ proc add_option {key val} {
+ option add $key $val widgetDefault
+ }
+ # Add options for plain Tk widgets
+ # Using `option add` instead of tk_setPalette to avoid unintended
+ # consequences.
+ if {![is_MacOSX]} {
+ add_option *Menu.Background $base_bg
+ add_option *Menu.Foreground $base_fg
+ add_option *Menu.activeBackground $select_bg
+ add_option *Menu.activeForeground $select_fg
+ }
+ add_option *Text.Background $text_bg
+ add_option *Text.Foreground $text_fg
+ add_option *Text.HighlightBackground $base_bg
+ add_option *Text.HighlightColor $select_bg
+ }
+}
+
proc ttk_get_current_theme {} {
# Handle either current Tk or older versions of 8.5
if {[catch {set theme [ttk::style theme use]}]} {