677
## config defaults
678
679
set cursor_ptr arrow
680
-font create font_diff -family Courier -size 10
680
font create font_ui
682
-catch {
683
- label .dummy
684
- eval font configure font_ui [font actual [.dummy cget -font]]
685
- destroy .dummy
681
+if {[lsearch -exact [font names] TkDefaultFont] != -1} {
682
+ eval [linsert [font actual TkDefaultFont] 0 font configure font_ui]
683
+ eval [linsert [font actual TkFixedFont] 0 font create font_diff]
684
+} else {
685
+ font create font_diff -family Courier -size 10
686
+ catch {
687
+ label .dummy
688
+ eval font configure font_ui [font actual [.dummy cget -font]]
689
+ destroy .dummy
690
+ }
691
}
692
693
font create font_uiitalic
702
}
703
if {![is_MacOSX]} {
704
option add *Menu.font font_ui
705
+ option add *Entry.borderWidth 1 startupFile
706
+ option add *Entry.relief sunken startupFile
707
+ option add *RadioButton.anchor w startupFile
708
}
709
unset class
710
757
font configure ${font}bold -weight bold
758
font configure ${font}italic -slant italic
759
}
760
+
761
+ global use_ttk NS
762
+ set use_ttk 0
763
+ set NS {}
764
+ if {$repo_config(gui.usettk)} {
765
+ set use_ttk [package vsatisfies [package provide Tk] 8.5]
766
+ if {$use_ttk} {
767
+ set NS ttk
768
+ bind [winfo class .] <<ThemeChanged>> [list InitTheme]
769
+ pave_toplevel .
770
+ }
771
+ }
772
}
773
774
set default_config(branch.autosetupmerge) true
795
set default_config(gui.fontdiff) [font configure font_diff]
796
# TODO: this option should be added to the git-config documentation
797
set default_config(gui.maxfilesdisplayed) 5000
798
+set default_config(gui.usettk) 1
799
set font_descs {
800
{fontui font_ui {mc "Main Font"}}
801
{fontdiff font_diff {mc "Diff/Console Font"}}
2114
global ui_comm is_quitting repo_config commit_type
2115
global GITGUI_BCK_exists GITGUI_BCK_i
2116
global ui_comm_spell
2096
- global ret_code
2117
+ global ret_code use_ttk
2118
2119
if {$is_quitting} return
2120
set is_quitting 1
2172
}
2173
set cfg_geometry [list]
2174
lappend cfg_geometry [wm geometry .]
2154
- lappend cfg_geometry [lindex [.vpane sash coord 0] 0]
2155
- lappend cfg_geometry [lindex [.vpane.files sash coord 0] 1]
2175
+ if {$use_ttk} {
2176
+ lappend cfg_geometry [.vpane sashpos 0]
2177
+ lappend cfg_geometry [.vpane.files sashpos 0]
2178
+ } else {
2179
+ lappend cfg_geometry [lindex [.vpane sash coord 0] 0]
2180
+ lappend cfg_geometry [lindex [.vpane.files sash coord 0] 1]
2181
+ }
2182
if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
2183
set rc_geometry {}
2184
}
2945
2946
# -- Branch Control
2947
#
2922
-frame .branch \
2923
- -borderwidth 1 \
2924
- -relief sunken
2925
-label .branch.l1 \
2948
+${NS}::frame .branch
2949
+if {!$use_ttk} {.branch configure -borderwidth 1 -relief sunken}
2950
+${NS}::label .branch.l1 \
2951
-text [mc "Current Branch:"] \
2952
-anchor w \
2953
-justify left
2929
-label .branch.cb \
2954
+${NS}::label .branch.cb \
2955
-textvariable current_branch \
2956
-anchor w \
2957
-justify left
2961
2962
# -- Main Window Layout
2963
#
2939
-panedwindow .vpane -orient horizontal
2940
-panedwindow .vpane.files -orient vertical
2941
-.vpane add .vpane.files -sticky nsew -height 100 -width 200
2964
+${NS}::panedwindow .vpane -orient horizontal
2965
+${NS}::panedwindow .vpane.files -orient vertical
2966
+if {$use_ttk} {
2967
+ .vpane add .vpane.files
2968
+} else {
2969
+ .vpane add .vpane.files -sticky nsew -height 100 -width 200
2970
+}
2971
pack .vpane -anchor n -side top -fill both -expand 1
2972
2973
# -- Index File List
2974
#
2946
-frame .vpane.files.index -height 100 -width 200
2947
-label .vpane.files.index.title -text [mc "Staged Changes (Will Commit)"] \
2975
+${NS}::frame .vpane.files.index -height 100 -width 200
2976
+tlabel .vpane.files.index.title \
2977
+ -text [mc "Staged Changes (Will Commit)"] \
2978
-background lightgreen -foreground black
2979
text $ui_index -background white -foreground black \
2980
-borderwidth 0 \
2984
-xscrollcommand {.vpane.files.index.sx set} \
2985
-yscrollcommand {.vpane.files.index.sy set} \
2986
-state disabled
2957
-scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview]
2958
-scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview]
2987
+${NS}::scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview]
2988
+${NS}::scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview]
2989
pack .vpane.files.index.title -side top -fill x
2990
pack .vpane.files.index.sx -side bottom -fill x
2991
pack .vpane.files.index.sy -side right -fill y
2993
2994
# -- Working Directory File List
2995
#
2966
-frame .vpane.files.workdir -height 100 -width 200
2967
-label .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
2996
+${NS}::frame .vpane.files.workdir -height 100 -width 200
2997
+tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
2998
-background lightsalmon -foreground black
2999
text $ui_workdir -background white -foreground black \
3000
-borderwidth 0 \
3004
-xscrollcommand {.vpane.files.workdir.sx set} \
3005
-yscrollcommand {.vpane.files.workdir.sy set} \
3006
-state disabled
2977
-scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
2978
-scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3007
+${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3008
+${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3009
pack .vpane.files.workdir.title -side top -fill x
3010
pack .vpane.files.workdir.sx -side bottom -fill x
3011
pack .vpane.files.workdir.sy -side right -fill y
3012
pack $ui_workdir -side left -fill both -expand 1
3013
2984
-.vpane.files add .vpane.files.workdir -sticky nsew
2985
-.vpane.files add .vpane.files.index -sticky nsew
3014
+.vpane.files add .vpane.files.workdir
3015
+.vpane.files add .vpane.files.index
3016
+if {!$use_ttk} {
3017
+ .vpane.files paneconfigure .vpane.files.workdir -sticky news
3018
+ .vpane.files paneconfigure .vpane.files.index -sticky news
3019
+}
3020
3021
foreach i [list $ui_index $ui_workdir] {
3022
rmsel_tag $i
3026
3027
# -- Diff and Commit Area
3028
#
2995
-frame .vpane.lower -height 300 -width 400
2996
-frame .vpane.lower.commarea
2997
-frame .vpane.lower.diff -relief sunken -borderwidth 1
3029
+${NS}::frame .vpane.lower -height 300 -width 400
3030
+${NS}::frame .vpane.lower.commarea
3031
+${NS}::frame .vpane.lower.diff -relief sunken -borderwidth 1
3032
pack .vpane.lower.diff -fill both -expand 1
3033
pack .vpane.lower.commarea -side bottom -fill x
3000
-.vpane add .vpane.lower -sticky nsew
3034
+.vpane add .vpane.lower
3035
+if {!$use_ttk} {.vpane paneconfigure .vpane.lower -sticky nsew}
3036
3037
# -- Commit Area Buttons
3038
#
3004
-frame .vpane.lower.commarea.buttons
3005
-label .vpane.lower.commarea.buttons.l -text {} \
3039
+${NS}::frame .vpane.lower.commarea.buttons
3040
+${NS}::label .vpane.lower.commarea.buttons.l -text {} \
3041
-anchor w \
3042
-justify left
3043
pack .vpane.lower.commarea.buttons.l -side top -fill x
3044
pack .vpane.lower.commarea.buttons -side left -fill y
3045
3011
-button .vpane.lower.commarea.buttons.rescan -text [mc Rescan] \
3046
+${NS}::button .vpane.lower.commarea.buttons.rescan -text [mc Rescan] \
3047
-command ui_do_rescan
3048
pack .vpane.lower.commarea.buttons.rescan -side top -fill x
3049
lappend disable_on_lock \
3050
{.vpane.lower.commarea.buttons.rescan conf -state}
3051
3017
-button .vpane.lower.commarea.buttons.incall -text [mc "Stage Changed"] \
3052
+${NS}::button .vpane.lower.commarea.buttons.incall -text [mc "Stage Changed"] \
3053
-command do_add_all
3054
pack .vpane.lower.commarea.buttons.incall -side top -fill x
3055
lappend disable_on_lock \
3056
{.vpane.lower.commarea.buttons.incall conf -state}
3057
3058
if {![is_enabled nocommitmsg]} {
3024
- button .vpane.lower.commarea.buttons.signoff -text [mc "Sign Off"] \
3059
+ ${NS}::button .vpane.lower.commarea.buttons.signoff -text [mc "Sign Off"] \
3060
-command do_signoff
3061
pack .vpane.lower.commarea.buttons.signoff -side top -fill x
3062
}
3063
3029
-button .vpane.lower.commarea.buttons.commit -text [commit_btn_caption] \
3064
+${NS}::button .vpane.lower.commarea.buttons.commit -text [commit_btn_caption] \
3065
-command do_commit
3066
pack .vpane.lower.commarea.buttons.commit -side top -fill x
3067
lappend disable_on_lock \
3068
{.vpane.lower.commarea.buttons.commit conf -state}
3069
3070
if {![is_enabled nocommit]} {
3036
- button .vpane.lower.commarea.buttons.push -text [mc Push] \
3071
+ ${NS}::button .vpane.lower.commarea.buttons.push -text [mc Push] \
3072
-command do_push_anywhere
3073
pack .vpane.lower.commarea.buttons.push -side top -fill x
3074
}
3075
3076
# -- Commit Message Buffer
3077
#
3043
-frame .vpane.lower.commarea.buffer
3044
-frame .vpane.lower.commarea.buffer.header
3078
+${NS}::frame .vpane.lower.commarea.buffer
3079
+${NS}::frame .vpane.lower.commarea.buffer.header
3080
set ui_comm .vpane.lower.commarea.buffer.t
3081
set ui_coml .vpane.lower.commarea.buffer.header.l
3082
3083
if {![is_enabled nocommit]} {
3049
- radiobutton .vpane.lower.commarea.buffer.header.new \
3084
+ ${NS}::radiobutton .vpane.lower.commarea.buffer.header.new \
3085
-text [mc "New Commit"] \
3086
-command do_select_commit_type \
3087
-variable selected_commit_type \
3088
-value new
3089
lappend disable_on_lock \
3090
[list .vpane.lower.commarea.buffer.header.new conf -state]
3056
- radiobutton .vpane.lower.commarea.buffer.header.amend \
3091
+ ${NS}::radiobutton .vpane.lower.commarea.buffer.header.amend \
3092
-text [mc "Amend Last Commit"] \
3093
-command do_select_commit_type \
3094
-variable selected_commit_type \
3097
[list .vpane.lower.commarea.buffer.header.amend conf -state]
3098
}
3099
3065
-label $ui_coml \
3100
+${NS}::label $ui_coml \
3101
-anchor w \
3102
-justify left
3103
proc trace_commit_type {varname args} {
3129
-width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
3130
-font font_diff \
3131
-yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3097
-scrollbar .vpane.lower.commarea.buffer.sby \
3132
+${NS}::scrollbar .vpane.lower.commarea.buffer.sby \
3133
-command [list $ui_comm yview]
3134
pack .vpane.lower.commarea.buffer.header -side top -fill x
3135
pack .vpane.lower.commarea.buffer.sby -side right -fill y
3195
}
3196
trace add variable current_diff_path write trace_current_diff_path
3197
3163
-frame .vpane.lower.diff.header -background gold
3164
-label .vpane.lower.diff.header.status \
3198
+gold_frame .vpane.lower.diff.header
3199
+tlabel .vpane.lower.diff.header.status \
3200
-background gold \
3201
-foreground black \
3202
-width $max_status_desc \
3203
-anchor w \
3204
-justify left
3170
-label .vpane.lower.diff.header.file \
3205
+tlabel .vpane.lower.diff.header.file \
3206
-background gold \
3207
-foreground black \
3208
-anchor w \
3209
-justify left
3175
-label .vpane.lower.diff.header.path \
3210
+tlabel .vpane.lower.diff.header.path \
3211
-background gold \
3212
-foreground black \
3213
-anchor w \
3231
3232
# -- Diff Body
3233
#
3199
-frame .vpane.lower.diff.body
3234
+${NS}::frame .vpane.lower.diff.body
3235
set ui_diff .vpane.lower.diff.body.t
3236
text $ui_diff -background white -foreground black \
3237
-borderwidth 0 \
3240
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
3241
-yscrollcommand {.vpane.lower.diff.body.sby set} \
3242
-state disabled
3208
-scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
3243
+${NS}::scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
3244
-command [list $ui_diff xview]
3210
-scrollbar .vpane.lower.diff.body.sby -orient vertical \
3245
+${NS}::scrollbar .vpane.lower.diff.body.sby -orient vertical \
3246
-command [list $ui_diff yview]
3247
pack .vpane.lower.diff.body.sbx -side bottom -fill x
3248
pack .vpane.lower.diff.body.sby -side right -fill y
3463
catch {
3464
set gm $repo_config(gui.geometry)
3465
wm geometry . [lindex $gm 0]
3431
-.vpane sash place 0 \
3432
- [lindex $gm 1] \
3433
- [lindex [.vpane sash coord 0] 1]
3434
-.vpane.files sash place 0 \
3435
- [lindex [.vpane.files sash coord 0] 0] \
3436
- [lindex $gm 2]
3466
+if {$use_ttk} {
3467
+ .vpane sashpos 0 [lindex $gm 1]
3468
+ .vpane.files sashpos 0 [lindex $gm 2]
3469
+} else {
3470
+ .vpane sash place 0 \
3471
+ [lindex $gm 1] \
3472
+ [lindex [.vpane sash coord 0] 1]
3473
+ .vpane.files sash place 0 \
3474
+ [lindex [.vpane.files sash coord 0] 0] \
3475
+ [lindex $gm 2]
3476
+}
3477
unset gm
3478
}
3479
3741
if {$picked && [is_config_true gui.autoexplore]} {
3742
do_explore
3743
}
3744
+
3745
+# Local variables:
3746
+# mode: tcl
3747
+# indent-tabs-mode: t
3748
+# tab-width: 4
3749
+# End: