summaryrefslogtreecommitdiff
path: root/git-gui/lib
diff options
context:
space:
mode:
Diffstat (limited to 'git-gui/lib')
-rw-r--r--git-gui/lib/blame.tcl1
-rw-r--r--git-gui/lib/choose_repository.tcl27
-rw-r--r--git-gui/lib/commit.tcl1
-rw-r--r--git-gui/lib/index.tcl6
-rw-r--r--git-gui/lib/mergetool.tcl2
-rw-r--r--git-gui/lib/themed.tcl59
6 files changed, 66 insertions, 30 deletions
diff --git a/git-gui/lib/blame.tcl b/git-gui/lib/blame.tcl
index 62ec083667..8441e109be 100644
--- a/git-gui/lib/blame.tcl
+++ b/git-gui/lib/blame.tcl
@@ -328,6 +328,7 @@ constructor new {i_commit i_path i_jump} {
bind $i <Any-Motion> [cb _show_tooltip $i @%x,%y]
bind $i <Any-Enter> [cb _hide_tooltip]
bind $i <Any-Leave> [cb _hide_tooltip]
+ bind $i <Deactivate> [cb _hide_tooltip]
bind_button3 $i "
[cb _hide_tooltip]
set cursorX %x
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index e54f3e66d8..af1fee7c75 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -357,31 +357,10 @@ proc _is_git {path {outdir_var ""}} {
if {$outdir_var ne ""} {
upvar 1 $outdir_var outdir
}
- if {[file isfile $path]} {
- set fp [open $path r]
- gets $fp line
- close $fp
- if {[regexp "^gitdir: (.+)$" $line line link_target]} {
- set path [file join [file dirname $path] $link_target]
- set path [file normalize $path]
- }
- }
-
- if {[file exists [file join $path HEAD]]
- && [file exists [file join $path objects]]
- && [file exists [file join $path config]]} {
- set outdir $path
- return 1
- }
- if {[is_Cygwin]} {
- if {[file exists [file join $path HEAD]]
- && [file exists [file join $path objects.lnk]]
- && [file exists [file join $path config.lnk]]} {
- set outdir $path
- return 1
- }
+ if {[catch {set outdir [git rev-parse --resolve-git-dir $path]}]} {
+ return 0
}
- return 0
+ return 1
}
proc _objdir {path} {
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index b516aa2990..11379f8ad3 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -456,6 +456,7 @@ A rescan will be automatically started now.
}
$ui_comm delete 0.0 end
+ load_message [get_config commit.template]
$ui_comm edit reset
$ui_comm edit modified false
if {$::GITGUI_BCK_exists} {
diff --git a/git-gui/lib/index.tcl b/git-gui/lib/index.tcl
index 1fc5b42300..d2ec24bd80 100644
--- a/git-gui/lib/index.tcl
+++ b/git-gui/lib/index.tcl
@@ -60,7 +60,7 @@ proc rescan_on_error {err {after {}}} {
$::main_status stop_all
unlock_index
- rescan [concat $after [list ui_ready]] 0
+ rescan [concat $after {ui_ready;}] 0
}
proc update_indexinfo {msg path_list after} {
@@ -314,7 +314,7 @@ proc unstage_helper {txt paths} {
update_indexinfo \
$txt \
$path_list \
- [concat $after [list ui_ready]]
+ [concat $after {ui_ready;}]
}
}
@@ -366,7 +366,7 @@ proc add_helper {txt paths} {
update_index \
$txt \
$path_list \
- [concat $after {ui_status [mc "Ready to commit."]}]
+ [concat $after {ui_status [mc "Ready to commit."];}]
}
}
diff --git a/git-gui/lib/mergetool.tcl b/git-gui/lib/mergetool.tcl
index 120bc4064b..e688b016ef 100644
--- a/git-gui/lib/mergetool.tcl
+++ b/git-gui/lib/mergetool.tcl
@@ -59,7 +59,7 @@ proc merge_add_resolution {path} {
update_index \
[mc "Adding resolution for %s" [short_path $path]] \
[list $path] \
- [concat $after [list ui_ready]]
+ [concat $after {ui_ready;}]
}
proc merge_force_stage {stage} {
diff --git a/git-gui/lib/themed.tcl b/git-gui/lib/themed.tcl
index 88b3119a75..f43d84e54f 100644
--- a/git-gui/lib/themed.tcl
+++ b/git-gui/lib/themed.tcl
@@ -1,6 +1,61 @@
# 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
+ variable inactive_select_bg lightgray
+ variable inactive_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 inactive_select_bg [convert_rgb_to_gray $select_bg]
+ set inactive_select_fg $select_fg
+
+ set color::select_bg $select_bg
+ set color::select_fg $select_fg
+ set color::inactive_select_bg $inactive_select_bg
+ set color::inactive_select_fg $inactive_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.selectBackground $select_bg
+ add_option *Text.selectForeground $select_fg
+ add_option *Text.inactiveSelectBackground $inactive_select_bg
+ add_option *Text.inactiveSelectForeground $inactive_select_fg
+ }
+}
+
+proc convert_rgb_to_gray {rgb} {
+ # Simply take the average of red, green and blue. This wouldn't be good
+ # enough for, say, converting a photo to grayscale, but for this simple
+ # purpose of approximating the brightness of a color it's good enough.
+ lassign [winfo rgb . $rgb] r g b
+ set gray [expr {($r / 256 + $g / 256 + $b / 256) / 3}]
+ return [format "#%2.2X%2.2X%2.2X" $gray $gray $gray]
+}
+
proc ttk_get_current_theme {} {
# Handle either current Tk or older versions of 8.5
if {[catch {set theme [ttk::style theme use]}]} {
@@ -136,7 +191,7 @@ proc InitEntryFrame {} {
proc gold_frame {w args} {
global use_ttk
- if {$use_ttk} {
+ if {$use_ttk && ![is_MacOSX]} {
eval [linsert $args 0 ttk::frame $w -style Gold.TFrame]
} else {
eval [linsert $args 0 frame $w -background gold]
@@ -145,7 +200,7 @@ proc gold_frame {w args} {
proc tlabel {w args} {
global use_ttk
- if {$use_ttk} {
+ if {$use_ttk && ![is_MacOSX]} {
set cmd [list ttk::label $w -style Color.TLabel]
foreach {k v} $args {
switch -glob -- $k {