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>
This commit is contained in:
61
gitk
61
gitk
@ -362,7 +362,8 @@ proc makewindow {} {
|
|||||||
.bar.view add command -label "New view..." -command newview
|
.bar.view add command -label "New view..." -command newview
|
||||||
.bar.view add command -label "Delete view" -command delview -state disabled
|
.bar.view add command -label "Delete view" -command delview -state disabled
|
||||||
.bar.view add separator
|
.bar.view add separator
|
||||||
.bar.view add command -label "All files" -command {showview 0}
|
.bar.view add radiobutton -label "All files" -command {showview 0} \
|
||||||
|
-variable selectedview -value 0
|
||||||
menu .bar.help
|
menu .bar.help
|
||||||
.bar add cascade -label "Help" -menu .bar.help
|
.bar add cascade -label "Help" -menu .bar.help
|
||||||
.bar.help add command -label "About gitk" -command about
|
.bar.help add command -label "About gitk" -command about
|
||||||
@ -632,6 +633,7 @@ proc savestuff {w} {
|
|||||||
global canv canv2 canv3 ctext cflist mainfont textfont uifont
|
global canv canv2 canv3 ctext cflist mainfont textfont uifont
|
||||||
global stuffsaved findmergefiles maxgraphpct
|
global stuffsaved findmergefiles maxgraphpct
|
||||||
global maxwidth
|
global maxwidth
|
||||||
|
global viewname viewfiles viewperm nextviewnum
|
||||||
|
|
||||||
if {$stuffsaved} return
|
if {$stuffsaved} return
|
||||||
if {![winfo viewable .]} return
|
if {![winfo viewable .]} return
|
||||||
@ -655,6 +657,13 @@ proc savestuff {w} {
|
|||||||
set wid [expr {([winfo width $cflist] - 11) \
|
set wid [expr {([winfo width $cflist] - 11) \
|
||||||
/ [font measure [$cflist cget -font] "0"]}]
|
/ [font measure [$cflist cget -font] "0"]}]
|
||||||
puts $f "set geometry(cflistw) $wid"
|
puts $f "set geometry(cflistw) $wid"
|
||||||
|
puts -nonewline $f "set permviews {"
|
||||||
|
for {set v 0} {$v < $nextviewnum} {incr v} {
|
||||||
|
if {$viewperm($v)} {
|
||||||
|
puts $f "{[list $viewname($v) $viewfiles($v)]}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
puts $f "}"
|
||||||
close $f
|
close $f
|
||||||
file rename -force "~/.gitk-new" "~/.gitk"
|
file rename -force "~/.gitk-new" "~/.gitk"
|
||||||
}
|
}
|
||||||
@ -797,7 +806,7 @@ f Scroll diff view to next file
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc newview {} {
|
proc newview {} {
|
||||||
global newviewname nextviewnum newviewtop
|
global newviewname nextviewnum newviewtop newviewperm uifont
|
||||||
|
|
||||||
set top .gitkview
|
set top .gitkview
|
||||||
if {[winfo exists $top]} {
|
if {[winfo exists $top]} {
|
||||||
@ -807,14 +816,18 @@ proc newview {} {
|
|||||||
set newviewtop $top
|
set newviewtop $top
|
||||||
toplevel $top
|
toplevel $top
|
||||||
wm title $top "Gitk view definition"
|
wm title $top "Gitk view definition"
|
||||||
label $top.nl -text "Name"
|
label $top.nl -text "Name" -font $uifont
|
||||||
entry $top.name -width 20 -textvariable newviewname
|
entry $top.name -width 20 -textvariable newviewname
|
||||||
set newviewname "View $nextviewnum"
|
set newviewname "View $nextviewnum"
|
||||||
grid $top.nl $top.name -sticky w
|
grid $top.nl $top.name -sticky w -pady 5
|
||||||
label $top.l -text "Files and directories to include:"
|
set newviewperm 0
|
||||||
grid $top.l - -sticky w -pady 10
|
checkbutton $top.perm -text "Remember this view" -variable newviewperm
|
||||||
text $top.t -width 30 -height 10
|
grid $top.perm - -pady 5 -sticky w
|
||||||
grid $top.t - -sticky w
|
message $top.l -aspect 500 -font $uifont \
|
||||||
|
-text "Enter files and directories to include, one per line:"
|
||||||
|
grid $top.l - -sticky w
|
||||||
|
text $top.t -width 40 -height 10 -background white
|
||||||
|
grid $top.t - -sticky w -padx 5
|
||||||
frame $top.buts
|
frame $top.buts
|
||||||
button $top.buts.ok -text "OK" -command newviewok
|
button $top.buts.ok -text "OK" -command newviewok
|
||||||
button $top.buts.can -text "Cancel" -command newviewcan
|
button $top.buts.can -text "Cancel" -command newviewcan
|
||||||
@ -826,12 +839,13 @@ proc newview {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc newviewok {} {
|
proc newviewok {} {
|
||||||
global newviewtop nextviewnum
|
global newviewtop nextviewnum newviewperm
|
||||||
global viewname viewfiles
|
global viewname viewfiles viewperm selectedview
|
||||||
|
|
||||||
set n $nextviewnum
|
set n $nextviewnum
|
||||||
incr nextviewnum
|
incr nextviewnum
|
||||||
set viewname($n) [$newviewtop.name get]
|
set viewname($n) [$newviewtop.name get]
|
||||||
|
set viewperm($n) $newviewperm
|
||||||
set files {}
|
set files {}
|
||||||
foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
|
foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
|
||||||
set ft [string trim $f]
|
set ft [string trim $f]
|
||||||
@ -842,7 +856,8 @@ proc newviewok {} {
|
|||||||
set viewfiles($n) $files
|
set viewfiles($n) $files
|
||||||
catch {destroy $newviewtop}
|
catch {destroy $newviewtop}
|
||||||
unset newviewtop
|
unset newviewtop
|
||||||
.bar.view add command -label $viewname($n) -command [list showview $n]
|
.bar.view add radiobutton -label $viewname($n) \
|
||||||
|
-command [list showview $n] -variable selectedview -value $n
|
||||||
after idle showview $n
|
after idle showview $n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,7 +869,7 @@ proc newviewcan {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc delview {} {
|
proc delview {} {
|
||||||
global curview viewdata
|
global curview viewdata viewperm
|
||||||
|
|
||||||
if {$curview == 0} return
|
if {$curview == 0} return
|
||||||
set nmenu [.bar.view index end]
|
set nmenu [.bar.view index end]
|
||||||
@ -866,6 +881,7 @@ proc delview {} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set viewdata($curview) {}
|
set viewdata($curview) {}
|
||||||
|
set viewperm($curview) 0
|
||||||
showview 0
|
showview 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,6 +914,7 @@ proc showview {n} {
|
|||||||
global pending_select phase
|
global pending_select phase
|
||||||
global commitidx rowlaidout rowoptim linesegends leftover
|
global commitidx rowlaidout rowoptim linesegends leftover
|
||||||
global commfd nextupdate
|
global commfd nextupdate
|
||||||
|
global selectedview
|
||||||
|
|
||||||
if {$n == $curview} return
|
if {$n == $curview} return
|
||||||
set selid {}
|
set selid {}
|
||||||
@ -939,6 +956,7 @@ proc showview {n} {
|
|||||||
clear_display
|
clear_display
|
||||||
|
|
||||||
set curview $n
|
set curview $n
|
||||||
|
set selectedview $n
|
||||||
.bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
|
.bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
|
||||||
|
|
||||||
if {![info exists viewdata($n)]} {
|
if {![info exists viewdata($n)]} {
|
||||||
@ -4209,7 +4227,9 @@ set optim_delay 16
|
|||||||
|
|
||||||
set nextviewnum 1
|
set nextviewnum 1
|
||||||
set curview 0
|
set curview 0
|
||||||
|
set selectedview 0
|
||||||
set viewfiles(0) {}
|
set viewfiles(0) {}
|
||||||
|
set viewperm(0) 0
|
||||||
|
|
||||||
set stopped 0
|
set stopped 0
|
||||||
set stuffsaved 0
|
set stuffsaved 0
|
||||||
@ -4232,10 +4252,25 @@ if {[lindex $revtreeargs end] eq "--"} {
|
|||||||
if {$cmdline_files ne {}} {
|
if {$cmdline_files ne {}} {
|
||||||
# create a view for the files/dirs specified on the command line
|
# create a view for the files/dirs specified on the command line
|
||||||
set curview 1
|
set curview 1
|
||||||
|
set selectedview 1
|
||||||
set nextviewnum 2
|
set nextviewnum 2
|
||||||
set viewname(1) "Command line"
|
set viewname(1) "Command line"
|
||||||
set viewfiles(1) $cmdline_files
|
set viewfiles(1) $cmdline_files
|
||||||
.bar.view add command -label $viewname(1) -command {showview 1}
|
set viewperm(1) 0
|
||||||
|
.bar.view add radiobutton -label $viewname(1) -command {showview 1} \
|
||||||
|
-variable selectedview -value 1
|
||||||
.bar.view entryconf 2 -state normal
|
.bar.view entryconf 2 -state normal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if {[info exists permviews]} {
|
||||||
|
foreach v $permviews {
|
||||||
|
set n $nextviewnum
|
||||||
|
incr nextviewnum
|
||||||
|
set viewname($n) [lindex $v 0]
|
||||||
|
set viewfiles($n) [lindex $v 1]
|
||||||
|
set viewperm($n) 1
|
||||||
|
.bar.view add radiobutton -label $viewname($n) \
|
||||||
|
-command [list showview $n] -variable selectedview -value $n
|
||||||
|
}
|
||||||
|
}
|
||||||
getcommits
|
getcommits
|
||||||
|
Reference in New Issue
Block a user