gitk: Implement "permanent" views (stored in ~/.gitk)
With this the user can now mark a view as "permanent" and it will appear in the list every time gitk is started (until it is deleted). Also tidied up the view definition window, and changed the view menu to use radiobuttons for the view selections so there is some feedback as to which is the current view. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Apr 25, 2006 at 17:12 UTC
a90a6d249bc4fe29c11ce3291f9ec90d8e5e67f4
1 file changed
+48
-13
gitk
+48
-13
@@ -362,7 +362,8 @@ proc makewindow {} {
362
.bar.view add command -label "New view..." -command newview
363
.bar.view add command -label "Delete view" -command delview -state disabled
364
.bar.view add separator
365
- .bar.view add command -label "All files" -command {showview 0}
365
+ .bar.view add radiobutton -label "All files" -command {showview 0} \
366
+ -variable selectedview -value 0
367
menu .bar.help
368
.bar add cascade -label "Help" -menu .bar.help
369
.bar.help add command -label "About gitk" -command about
@@ -632,6 +633,7 @@ proc savestuff {w} {
633
global canv canv2 canv3 ctext cflist mainfont textfont uifont
634
global stuffsaved findmergefiles maxgraphpct
635
global maxwidth
636
+ global viewname viewfiles viewperm nextviewnum
637
638
if {$stuffsaved} return
639
if {![winfo viewable .]} return
@@ -655,6 +657,13 @@ proc savestuff {w} {
657
set wid [expr {([winfo width $cflist] - 11) \
658
/ [font measure [$cflist cget -font] "0"]}]
659
puts $f "set geometry(cflistw) $wid"
660
+ puts -nonewline $f "set permviews {"
661
+ for {set v 0} {$v < $nextviewnum} {incr v} {
662
+ if {$viewperm($v)} {
663
+ puts $f "{[list $viewname($v) $viewfiles($v)]}"
664
+ }
665
+ }
666
+ puts $f "}"
667
close $f
668
file rename -force "~/.gitk-new" "~/.gitk"
669
}
@@ -797,7 +806,7 @@ f Scroll diff view to next file
806
}
807
808
proc newview {} {
800
- global newviewname nextviewnum newviewtop
809
+ global newviewname nextviewnum newviewtop newviewperm uifont
810
811
set top .gitkview
812
if {[winfo exists $top]} {
@@ -807,14 +816,18 @@ proc newview {} {
816
set newviewtop $top
817
toplevel $top
818
wm title $top "Gitk view definition"
810
- label $top.nl -text "Name"
819
+ label $top.nl -text "Name" -font $uifont
820
entry $top.name -width 20 -textvariable newviewname
821
set newviewname "View $nextviewnum"
813
- grid $top.nl $top.name -sticky w
814
- label $top.l -text "Files and directories to include:"
815
- grid $top.l - -sticky w -pady 10
816
- text $top.t -width 30 -height 10
817
- grid $top.t - -sticky w
822
+ grid $top.nl $top.name -sticky w -pady 5
823
+ set newviewperm 0
824
+ checkbutton $top.perm -text "Remember this view" -variable newviewperm
825
+ grid $top.perm - -pady 5 -sticky w
826
+ message $top.l -aspect 500 -font $uifont \
827
+ -text "Enter files and directories to include, one per line:"
828
+ grid $top.l - -sticky w
829
+ text $top.t -width 40 -height 10 -background white
830
+ grid $top.t - -sticky w -padx 5
831
frame $top.buts
832
button $top.buts.ok -text "OK" -command newviewok
833
button $top.buts.can -text "Cancel" -command newviewcan
@@ -826,12 +839,13 @@ proc newview {} {
839
}
840
841
proc newviewok {} {
829
- global newviewtop nextviewnum
830
- global viewname viewfiles
842
+ global newviewtop nextviewnum newviewperm
843
+ global viewname viewfiles viewperm selectedview
844
845
set n $nextviewnum
846
incr nextviewnum
847
set viewname($n) [$newviewtop.name get]
848
+ set viewperm($n) $newviewperm
849
set files {}
850
foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
851
set ft [string trim $f]
@@ -842,7 +856,8 @@ proc newviewok {} {
856
set viewfiles($n) $files
857
catch {destroy $newviewtop}
858
unset newviewtop
845
- .bar.view add command -label $viewname($n) -command [list showview $n]
859
+ .bar.view add radiobutton -label $viewname($n) \
860
+ -command [list showview $n] -variable selectedview -value $n
861
after idle showview $n
862
}
863
@@ -854,7 +869,7 @@ proc newviewcan {} {
869
}
870
871
proc delview {} {
857
- global curview viewdata
872
+ global curview viewdata viewperm
873
874
if {$curview == 0} return
875
set nmenu [.bar.view index end]
@@ -866,6 +881,7 @@ proc delview {} {
881
}
882
}
883
set viewdata($curview) {}
884
+ set viewperm($curview) 0
885
showview 0
886
}
887
@@ -898,6 +914,7 @@ proc showview {n} {
914
global pending_select phase
915
global commitidx rowlaidout rowoptim linesegends leftover
916
global commfd nextupdate
917
+ global selectedview
918
919
if {$n == $curview} return
920
set selid {}
@@ -939,6 +956,7 @@ proc showview {n} {
956
clear_display
957
958
set curview $n
959
+ set selectedview $n
960
.bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
961
962
if {![info exists viewdata($n)]} {
@@ -4209,7 +4227,9 @@ set optim_delay 16
4227
4228
set nextviewnum 1
4229
set curview 0
4230
+set selectedview 0
4231
set viewfiles(0) {}
4232
+set viewperm(0) 0
4233
4234
set stopped 0
4235
set stuffsaved 0
@@ -4232,10 +4252,25 @@ if {[lindex $revtreeargs end] eq "--"} {
4252
if {$cmdline_files ne {}} {
4253
# create a view for the files/dirs specified on the command line
4254
set curview 1
4255
+ set selectedview 1
4256
set nextviewnum 2
4257
set viewname(1) "Command line"
4258
set viewfiles(1) $cmdline_files
4238
- .bar.view add command -label $viewname(1) -command {showview 1}
4259
+ set viewperm(1) 0
4260
+ .bar.view add radiobutton -label $viewname(1) -command {showview 1} \
4261
+ -variable selectedview -value 1
4262
.bar.view entryconf 2 -state normal
4263
}
4264
+
4265
+if {[info exists permviews]} {
4266
+ foreach v $permviews {
4267
+ set n $nextviewnum
4268
+ incr nextviewnum
4269
+ set viewname($n) [lindex $v 0]
4270
+ set viewfiles($n) [lindex $v 1]
4271
+ set viewperm($n) 1
4272
+ .bar.view add radiobutton -label $viewname($n) \
4273
+ -command [list showview $n] -variable selectedview -value $n
4274
+ }
4275
+}
4276
getcommits