summaryrefslogtreecommitdiff
path: root/git-gui/lib/themed.tcl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-20 16:33:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-10-20 16:33:17 (GMT)
commit3eae3087008f7f2b2a9f7f357d069e9384007c8f (patch)
tree1a8960141dfb944e3b69563accea61bc2a871880 /git-gui/lib/themed.tcl
parent659889482ac63411daea38b2c3d127842ea04e4d (diff)
parentccc985126f23ff5d9ac610cb820bca48405ff5ef (diff)
downloadgit-3eae3087008f7f2b2a9f7f357d069e9384007c8f.zip
git-3eae3087008f7f2b2a9f7f357d069e9384007c8f.tar.gz
git-3eae3087008f7f2b2a9f7f357d069e9384007c8f.tar.bz2
Merge tag 'gitgui-0.21.0' of git://repo.or.cz/git-gui
git-gui 0.21.0 * tag 'gitgui-0.21.0' of git://repo.or.cz/git-gui: (22 commits) git-gui: set version 0.21 git-gui: Mark 'All' in remote.tcl for translation git-gui i18n: Updated Bulgarian translation (565,0f,0u) git-gui: avoid persisting modified author identity git-gui: handle the encoding of Git's output correctly git-gui: unicode file name support on windows git-gui: Update Russian translation git-gui: maintain backwards compatibility for merge syntax git-gui i18n: mark string in lib/error.tcl for translation git-gui: fix incorrect use of Tcl append command git-gui i18n: mark "usage:" strings for translation git-gui i18n: internationalize use of colon punctuation git-gui: ensure the file in the diff pane is in the list of selected files git-gui: support for $FILENAMES in tool definitions git-gui: fix initial git gui message encoding git-gui/po/glossary/txt-to-pot.sh: use the $( ... ) construct for command substitution git-gui (Windows): use git-gui.exe in `Create Desktop Shortcut` git-gui: fix detection of Cygwin Amend tab ordering and text widget border and highlighting. Allow keyboard control to work in the staging widgets. ...
Diffstat (limited to 'git-gui/lib/themed.tcl')
-rw-r--r--git-gui/lib/themed.tcl87
1 files changed, 86 insertions, 1 deletions
diff --git a/git-gui/lib/themed.tcl b/git-gui/lib/themed.tcl
index 8b88d36..351a712 100644
--- a/git-gui/lib/themed.tcl
+++ b/git-gui/lib/themed.tcl
@@ -78,6 +78,57 @@ proc InitTheme {} {
}
}
+# Define a style used for the surround of text widgets.
+proc InitEntryFrame {} {
+ ttk::style theme settings default {
+ ttk::style layout EntryFrame {
+ EntryFrame.field -sticky nswe -border 0 -children {
+ EntryFrame.fill -sticky nswe -children {
+ EntryFrame.padding -sticky nswe
+ }
+ }
+ }
+ ttk::style configure EntryFrame -padding 1 -relief sunken
+ ttk::style map EntryFrame -background {}
+ }
+ ttk::style theme settings classic {
+ ttk::style configure EntryFrame -padding 2 -relief sunken
+ ttk::style map EntryFrame -background {}
+ }
+ ttk::style theme settings alt {
+ ttk::style configure EntryFrame -padding 2
+ ttk::style map EntryFrame -background {}
+ }
+ ttk::style theme settings clam {
+ ttk::style configure EntryFrame -padding 2
+ ttk::style map EntryFrame -background {}
+ }
+
+ # Ignore errors for missing native themes
+ catch {
+ ttk::style theme settings winnative {
+ ttk::style configure EntryFrame -padding 2
+ }
+ ttk::style theme settings xpnative {
+ ttk::style configure EntryFrame -padding 1
+ ttk::style element create EntryFrame.field vsapi \
+ EDIT 1 {disabled 4 focus 3 active 2 {} 1} -padding 1
+ }
+ ttk::style theme settings vista {
+ ttk::style configure EntryFrame -padding 2
+ ttk::style element create EntryFrame.field vsapi \
+ EDIT 6 {disabled 4 focus 3 active 2 {} 1} -padding 2
+ }
+ }
+
+ bind EntryFrame <Enter> {%W instate !disabled {%W state active}}
+ bind EntryFrame <Leave> {%W state !active}
+ bind EntryFrame <<ThemeChanged>> {
+ set pad [ttk::style lookup EntryFrame -padding]
+ %W configure -padding [expr {$pad eq {} ? 1 : $pad}]
+ }
+}
+
proc gold_frame {w args} {
global use_ttk
if {$use_ttk} {
@@ -123,7 +174,7 @@ proc paddedlabel {w args} {
# place a themed frame over the surface.
proc Dialog {w args} {
eval [linsert $args 0 toplevel $w -class Dialog]
- catch {wm attributes $w -type dialog}
+ catch {wm attributes $w -type dialog}
pave_toplevel $w
return $w
}
@@ -193,6 +244,40 @@ proc tspinbox {w args} {
}
}
+# Create a text widget with any theme specific properties.
+proc ttext {w args} {
+ global use_ttk
+ if {$use_ttk} {
+ switch -- [ttk::style theme use] {
+ "vista" - "xpnative" {
+ lappend args -highlightthickness 0 -borderwidth 0
+ }
+ }
+ }
+ set w [eval [linsert $args 0 text $w]]
+ if {$use_ttk} {
+ if {[winfo class [winfo parent $w]] eq "EntryFrame"} {
+ bind $w <FocusIn> {[winfo parent %W] state focus}
+ bind $w <FocusOut> {[winfo parent %W] state !focus}
+ }
+ }
+ return $w
+}
+
+# themed frame suitable for surrounding a text field.
+proc textframe {w args} {
+ global use_ttk
+ if {$use_ttk} {
+ if {[catch {ttk::style layout EntryFrame}]} {
+ InitEntryFrame
+ }
+ eval [linsert $args 0 ttk::frame $w -class EntryFrame -style EntryFrame]
+ } else {
+ eval [linsert $args 0 frame $w]
+ }
+ return $w
+}
+
proc tentry {w args} {
global use_ttk
if {$use_ttk} {