#!/usr/local/bin/wish8.0 -f

#
# $Id: tkcvs.blank,v 1.22 1995/11/22 00:24:50 davide Exp $
#
# tkCVS Main program -- A Tk interface to CVS.
#
# Uses a structured modules file -- see the manpage for more details.
#
# Author:  Del (del@babel.dialix.oz.au)
#

#
# Constants for user configuration
#
# Change these two variables to point to your bitmaps directories.
set global_bitmapdir "/usr/X11R6/include/bitmaps"
set local_bitmapdir "/usr/local/libdata/tkcvs/bitmaps"
set cvscfg(editor) "xedit"
set cvscfg(editorargs) {}

set auto_path [linsert $auto_path 0 /usr/local/libdata/tkcvs]

set cvscfg(allfiles) 0
set cvscfg(tagmissing) 0
set cvscfg(checkrecursive) {}

set maxdirs 15
set dirlist {}
set totaldirs 0


# Read in defaults
if [file exists /usr/local/libdata/tkcvs/tkcvs_def.tcl] {
  # catch {source /usr/local/libdata/tkcvs/tkcvs_def.tcl}
  source /usr/local/libdata/tkcvs/tkcvs_def.tcl
}
if [file exists ~/.tkcvs] {
  # catch {source ~/.tkcvs}
}

if {$cvscfg(papersize) == "A4"} {
  set cvscfg(ystart) 770
  set cvscfg(yend) 60
  set cvscfg(xstart) 25
  set cvscfg(xend) 580
} else {
  set cvscfg(ystart) 700
  set cvscfg(yend) 60
  set cvscfg(xstart) 25
  set cvscfg(xend) 580
}

set cwd [pwd]
set incvs 0

frame .menubar -relief raised -border 2
pack .menubar -side top -fill x

#
# Setup any necessary toplevels
#

read_modules_setup
import_setup
commit_setup
tag_setup
search_setup
update_setup
merge_setup
venselect_setup
checkout_setup
workdir_setup
reports_setup

#
# Create the Menu bar
#
 
menubutton .menubar.file -text File -underline 0 -menu .menubar.file.m
menubutton .menubar.reports -text Reports -underline 0 -menu .menubar.reports.m
menubutton .menubar.search -text Search -underline 0 -menu .menubar.search.m
menubutton .menubar.options -text Options -underline 0 -menu .menubar.options.m
menubutton .menubar.help -text Help -underline 0 -menu .menubar.help.m
pack .menubar.file .menubar.reports .menubar.search .menubar.options -side left
if { [info exists cvsmenu] || [info exists usermenu] } {
  menubutton .menubar.user -text "User Defined" -underline 0 \
    -menu .menubar.user.m
  pack .menubar.user -side left
  # puts stderr "Adding user defined menu."
}
menubutton .menubar.goto -text "Go" -underline 0 -menu .menubar.goto.m
pack .menubar.goto -side left
pack .menubar.help -side right

#
# Create Menus
#

menu .menubar.file.m
.menubar.file.m add command -label "Open"    -underline 0 \
  -command { workdir_act_on_file [workdir_list_marked_files] }
.menubar.file.m add command -label "Delete"  -underline 0 \
  -command { workdir_delete_file [workdir_list_marked_files] }
.menubar.file.m add command -label "Cleanup" -underline 0 \
  -command { workdir_cleanup }
.menubar.file.m add separator
.menubar.file.m add command -label "Print"   -underline 0 \
  -command { workdir_print_file  [workdir_list_marked_files ] }
.menubar.file.m add separator 
.menubar.file.m add command -label "Import ..." -underline 0 \
  -command import_run
.menubar.file.m add command -label "Create Dir ..." -underline 7 \
  -command inewdir_run
.menubar.file.m add separator
.menubar.file.m add command -label "Tag Files ..." -underline 0 \
  -command tag_run
.menubar.file.m add separator
.menubar.file.m add command -label "Update" -underline 0 \
  -command {
    eval "cvs_update {} [workdir_list_marked_files]"
  }
.menubar.file.m add command -label "Update to Tag ..." \
  -command update_run
.menubar.file.m add separator
.menubar.file.m add command -label "Module Level Merge" \
  -command merge_run
.menubar.file.m add command -label "Module Level Difference" \
  -command notyet
.menubar.file.m add separator
.menubar.file.m add command -label "Add Files" \
  -command {
    eval "cvs_add [workdir_list_marked_files]"
  }
.menubar.file.m add command -label "Remove Files" \
  -command {
    eval "cvs_remove [workdir_list_marked_files]"
  }
.menubar.file.m add command -label "Log Browse ..." \
  -command {
    eval "cvs_logcanvas [workdir_list_marked_files]"
  }
.menubar.file.m add command -label "Check In ..." \
  -command commit_run
.menubar.file.m add command -label "Check Out ..." \
  -command checkout_run
.menubar.file.m add separator
.menubar.file.m add command -label Exit -underline 1 \
  -command exit

menu .menubar.reports.m
.menubar.reports.m add command -label "CVS check ..." \
  -underline 4 \
  -command cvs_check
.menubar.reports.m add command -label "CVS status ..." \
  -underline 4 \
  -command {
    eval "cvs_status [workdir_list_marked_files]"
  }
.menubar.reports.m add command -label "CVS diff ..." \
  -underline 4 \
  -command {
    eval "cvs_diff [workdir_list_marked_files]"
  }
.menubar.reports.m add command -label "CVS log ..." \
  -underline 4 \
  -command {
    eval "cvs_log [workdir_list_marked_files]"
  }
.menubar.reports.m add separator
.menubar.reports.m add command -label "Module Tree ..." \
  -underline 7 \
  -command {modlist_by_code "." 0 "head"}
.menubar.reports.m add command -label "Modules Sorted by Name ..." \
  -underline 18 \
  -command {modlist_by_name 0 "head"}
.menubar.reports.m add command -label "Version Tree ..." \
  -command {modlist_by_code "." 1 "head"}
.menubar.reports.m add command -label "Version Listing by Name ..." \
  -command {modlist_by_name 1 "head"}

menu .menubar.search.m
.menubar.search.m add command -label "Search Repository by Code ..." \
  -underline 21 \
  -command code_search
.menubar.search.m add command -label "Search Repository by Name ..." \
  -underline 21 \
  -command name_search
.menubar.search.m add command -label "Search Repository by Keyword ..." \
  -underline 21 \
  -command keyword_search

menu .menubar.options.m
.menubar.options.m add checkbutton -label "Show hidden files" \
  -variable cvscfg(allfiles) -onvalue 1 -offvalue 0 \
  -command setup_dir
.menubar.options.m add checkbutton -label "Check recursively" \
  -variable cvscfg(checkrecursive) -onvalue {} -offvalue -l 
.menubar.options.m add checkbutton -label "Show untagged files in tag reports" \
  -variable cfscfg(tagmissing) -onvalue 1 -offvalue 0
.menubar.options.m add checkbutton -label "Automatic directory status" \
  -variable cvscfg(auto_status) -onvalue "true" -offvalue "false" \
  -command setup_dir
.menubar.options.m add checkbutton -label "Apply Recursively" \
  -variable cvscfg(recurse) -onvalue "true" -offvalue "false" 
.menubar.options.m add separator
.menubar.options.m add cascade -label "CVS Status Detail" \
  -menu .menubar.options.m.report_detail
.menubar.options.m add cascade -label "CVS Log Detail" \
  -menu .menubar.options.m.logfile_detail

menu .menubar.options.m.report_detail
.menubar.options.m.report_detail add radiobutton -label "Verbose" \
  -variable cvscfg(rdetail) -value "verbose"
.menubar.options.m.report_detail add radiobutton -label "Summary" \
  -variable cvscfg(rdetail) -value "summary"
.menubar.options.m.report_detail add radiobutton -label "Terse" \
  -variable cvscfg(rdetail) -value "terse"

menu .menubar.options.m.logfile_detail
.menubar.options.m.logfile_detail add radiobutton -label "Verbose" \
  -variable cvscfg(ldetail)  -value "verbose"
.menubar.options.m.logfile_detail add radiobutton -label "Summary" \
  -variable cvscfg(ldetail) -value "summary"
.menubar.options.m.logfile_detail add radiobutton -label "Last Entry Only" \
  -variable cvscfg(ldetail) -value "last"

menu .menubar.goto.m
.menubar.goto.m add command -label "Home" \
   -command {change_dir ~}

menu .menubar.help.m
.menubar.help.m add command -label "About tkCVS ..." -underline 0 \
  -command aboutbox
.menubar.help.m add command -label "About CVS ..." -underline 6 \
  -command cvs_version
.menubar.help.m add separator
.menubar.help.m add command -label "Working with tkCVS ..." \
  -command working_with_tkcvs
.menubar.help.m add command -label "Checking out Modules ..." \
  -command checking_out_modules
.menubar.help.m add command -label "Exporting ..." \
  -command exporting
.menubar.help.m add command -label "Tagging and Branching ..." \
  -command tagging_and_branching
.menubar.help.m add command -label "Importing New Modules ..." \
  -command importing_new_modules
.menubar.help.m add separator
.menubar.help.m add command -label "Current Directory Display ..." \
  -command current_directory
.menubar.help.m add command -label "Buttons ..." \
  -command buttons_help
.menubar.help.m add separator
.menubar.help.m add command -label "Module Browser ..." \
  -command module_browser
.menubar.help.m add command -label "File Browser ..." \
  -command file_browser
.menubar.help.m add command -label "Log Browser ..." \
  -command log_browser
.menubar.help.m add separator
.menubar.help.m add command -label "Configuration Files ..." \
  -command configuration_files
.menubar.help.m add command -label "Environment Variables ..." \
  -command environment_variables
.menubar.help.m add command -label "User Defined Menu ..." \
  -command user_defined_menu
.menubar.help.m add command -label "CVS modules File ..." \
  -command cvs_modules_file

#
# Add user commands to the menu.
#
if { [info exists cvsmenu] || [info exists usermenu] } {
  menu .menubar.user.m
}
if [info exists cvsmenu] {
  foreach item [array names cvsmenu] {
    .menubar.user.m add command -label $item \
      -command "eval cvs_usercmd $cvsmenu($item) \[workdir_list_marked_files\]"
  }
}
if [info exists usermenu] {
  .menubar.user.m add separator
  foreach item [array names usermenu] {
    .menubar.user.m add command -label $item \
      -command "eval cvs_anycmd $usermenu($item) \[workdir_list_marked_files\]"
  }
}


# Window manager stuff.
wm title . "tkCVS"
wm iconname . "CVS"
wm iconbitmap . @$local_bitmapdir/tkcvs32.xbm
wm iconmask . @$local_bitmapdir/tkcvs32_mask.xbm

wm maxsize . 100 [expr $cvscfg(y_size) * 3]
wm minsize . 0  [expr $cvscfg(y_size) / 3]
