Menu

[r1160]: / branches / tcl9 / tkrev / filebrowse.tcl  Maximize  Restore  History

Download this file

198 lines (171 with data), 5.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# Tcl library for TkRev
#
#
# Sets up a dialog to browse the contents of a module.
#
proc browse_files {module} {
global filenames
global modval
global checkout_version
global cvsglb
global colorglb
gen_log:log T "ENTER ($module)"
set browser 0
if {$module == ""} {
cvsfail "Please select a module!" .modbrowse
return
}
gen_log:log D "[array names modval]"
if {$module ni [array names modval]} {
cvsfail "$module is not a CVS module" .modbrowse
return
}
# Find the list of file names.
find_filenames $module
if {! [info exists filenames($module)]} {
cvsfail "There are no files in this module!" .modbrowse
return
}
#
# Create the browser window.
#
incr browser
set filebrowse ".filebrowse$browser"
toplevel $filebrowse
frame $filebrowse.top ;#-relief raised -border 2
frame $filebrowse.buttons ;#-relief raised -border 2
frame $filebrowse.srch ;#-relief raised -border 2
pack $filebrowse.top -side top -fill x
pack $filebrowse.buttons -side bottom -fill x
pack $filebrowse.srch -side bottom -fill x
label $filebrowse.top.verlbl -text "Version / Tag " -anchor w
entry $filebrowse.top.verent -relief sunken -textvariable checkout_version
button $filebrowse.srch.srchbtn -text Search \
-command "search_listbox $filebrowse.list"
entry $filebrowse.srch.srchent -width 20 -textvariable cvsglb(searchstr)
bind $filebrowse.srch.srchent <Return> "search_listbox $filebrowse.list"
pack $filebrowse.top.verlbl -side left
pack $filebrowse.top.verent -side right -fill x -expand y
pack $filebrowse.srch.srchbtn -side left
pack $filebrowse.srch.srchent -side right -fill x -expand y
#
# Create buttons
#
button $filebrowse.view -image Fileview \
-command "module_fileview $filebrowse $module"
button $filebrowse.log -image Log \
-command "module_filelog $filebrowse $module 0"
button $filebrowse.branches -image Branches \
-command "module_filelog $filebrowse $module 1"
button $filebrowse.tag -image Tags \
-command "module_tagview $filebrowse $module"
button $filebrowse.quit -text "Close" \
-padx 0 -pady 0 \
-command "destroy $filebrowse; exit_cleanup 0"
pack $filebrowse.view \
$filebrowse.log \
$filebrowse.branches \
$filebrowse.tag \
-in $filebrowse.buttons -side left -ipadx 1 -ipady 1 -fill x -expand 1
pack $filebrowse.quit \
-in $filebrowse.buttons -side left -ipadx 0 -ipady 0 -fill both -expand 1
set_tooltips $filebrowse.view \
{"View the selected file"}
set_tooltips $filebrowse.log \
{"See the revision log of the selected file"}
set_tooltips $filebrowse.branches \
{"See the branch diagram of the selected file"}
set_tooltips $filebrowse.tag \
{"List the tags of the selected file"}
#
# Create a scroll bar and a list box.
#
ttk::scrollbar $filebrowse.scroll -command "$filebrowse.list yview"
listbox $filebrowse.list \
-yscroll "$filebrowse.scroll set" -relief sunken \
-font $colorglb(listboxfont) \
-width 40 -height 25 -setgrid yes
pack $filebrowse.scroll -side right -fill y
pack $filebrowse.list -side left -fill both -expand 1
#
# Window manager stuff.
#
wm title $filebrowse "Files in $module"
wm minsize $filebrowse 5 5
#
# Fill the list.
#
foreach file $filenames($module) {
if {[info exists modval($module)]} {
set module $modval($module)
}
regsub "^$module/" $file "" file
$filebrowse.list insert end $file
}
search_listbox_init
gen_log:log T "LEAVE"
}
proc filepath {module filename} {
# Prepend a path to the filename if needed
global modval
global module_dir
global cvscfg
global cvs
gen_log:log T "ENTER ($filename $module)"
regsub -all {\$} $filename {\$} file
# set global module variable - branch_diagram may need it
set commandline \
"$cvs -d $cvscfg(cvsroot) rdiff -s -D 01/01/1971 \"$file\""
gen_log:log C $commandline
set ret [catch {exec {*}$commandline} view_this]
gen_log:log D "\"$view_this\""
if {! $ret} {
gen_log:log T "LEAVE (fine the way we are) ($file)"
return $file
}
if {[info exists modval($module)]} {
gen_log:log D "modval $module \"$modval($module)\""
set module_dir $modval($module)
#set file "$module_dir/[file tail $file]"
set file "$module_dir/$file"
gen_log:log T "LEAVE (prepend modval) ($file)"
return $file
}
set file "$module/$file"
gen_log:log T "LEAVE (default) ($file)"
return $file
}
proc module_filelog {toplevelname module {graphic {0}} } {
# Open the logbrowser from the file list
gen_log:log T "ENTER ($toplevelname $module $graphic)"
set listname $toplevelname.list
foreach item [$listname curselection] {
set v [$listname get $item]
set f [filepath $module $v]
cvs_filelog "$f" $toplevelname $graphic
}
gen_log:log T "LEAVE"
}
proc module_fileview {toplevelname module} {
# View a file from the file list
gen_log:log T "ENTER ($toplevelname $module)"
set listname $toplevelname.list
foreach item [$listname curselection] {
set v [$listname get $item]
set f [filepath $module $v]
cvs_fileview_checkout [$toplevelname.top.verent get] "$f"
}
gen_log:log T "LEAVE"
}
proc module_tagview {toplevelname module} {
# List the tags of a file from the filelist
gen_log:log T "ENTER ($toplevelname $module)"
set listname $toplevelname.list
foreach item [$listname curselection] {
set v [$listname get $item]
set f [filepath $module $v]
view_output::new "$f Tags" [cvs_gettaglist "$f" $toplevelname]
}
gen_log:log T "LEAVE"
}