Work on configure.
[ir-tcl-moved-to-github.git] / client.tcl
index 9da25e0..0418f81 100644 (file)
@@ -4,7 +4,20 @@
 # Sebastian Hammer, Adam Dickmeiss
 #
 # $Log: client.tcl,v $
-# Revision 1.49  1995-06-20 14:16:42  adam
+# Revision 1.52  1995-06-22 13:14:59  adam
+# Feature: SUTRS. Setting getSutrs implemented.
+# Work on display formats.
+# Preferred record syntax can be set by the user.
+#
+# Revision 1.51  1995/06/21  11:11:00  adam
+# Bug fix: libdir undefined in about-origin.
+#
+# Revision 1.50  1995/06/21  11:04:48  adam
+# Uses GNU autoconf 2.3.
+# Install procedure implemented.
+# boook bitmaps moved to sub directory bitmaps.
+#
+# Revision 1.49  1995/06/20  14:16:42  adam
 # More work on cancel mechanism.
 #
 # Revision 1.48  1995/06/20  08:07:23  adam
 # First presentRequest attempts. Hot-target list.
 #
 #
+
+set libdir LIBDIR
+if {[file readable clientrc.tcl]} {
+       set libdir .
+}
 set hotTargets {}
 set hotInfo {}
 set busy 0
 
-set libDir ""
-
 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39}
 set hostid Default
 set settingsChanged 0
@@ -188,6 +204,7 @@ set fullMarcSeq 0
 set displayFormat 1
 set popupMarcdf 0
 set textWrap word
+set recordSyntax USMARC
 set delayRequest {}
 
 set queryTypes {Simple}
@@ -201,11 +218,16 @@ set setMax 0
 
 proc read-formats {} {
     global displayFormats
-    set formats [glob -nocomplain formats/*.tcl]
+    global libdir
+    set formats [glob -nocomplain ${libdir}/formats/*.tcl]
     foreach f $formats {
-        source $f
-        set l [expr [string length $f] - 5]
-       lappend displayFormats [string range $f 8 $l]
+       if {[file readable $f]} {
+            source $f
+            set l [string length $f]
+            set f [string range $f [string length "${libdir}/formats/"] \
+                    [expr $l - 5]]
+            lappend displayFormats $f
+        }
     }
 }
 
@@ -217,7 +239,7 @@ proc set-wrap {m} {
 }
 
 proc dputs {m} {
-    puts $m
+#    puts $m
 }
 
 proc set-display-format {f} {
@@ -233,7 +255,7 @@ proc set-display-format {f} {
         .bot.a.status configure -text "Reformatting"
     }
     update idletasks
-    add-title-lines 0 10000 1
+    add-title-lines -1 10000 1
     if {!$busy} {
         .bot.a.status configure -text "Ready"
     }
@@ -289,12 +311,12 @@ proc toplevelG {w} {
     bind $w <Destroy> [list destroyGW $w]
 }
 
-if {[file readable "clientrc.tcl"]} {
-    source "clientrc.tcl"
+if {[file readable "${libdir}/clientrc.tcl"]} {
+    source "${libdir}/clientrc.tcl"
 }
 
-if {[file readable "clientg.tcl"]} {
-    source "clientg.tcl"
+if {[file readable "~/.clientrc.tcl"]} {
+    source "~/.clientrc.tcl"
 }
 
 set queryButtonsFind [lindex $queryButtons 0]
@@ -376,17 +398,19 @@ proc show-target {target base} {
 
 proc show-logo {v1} {
     global busy
+    global libdir
+
     if {$busy != 0} {
         incr v1
         if {$v1==10} {
             set v1 1
         }
-        .bot.logo configure -bitmap @book${v1}
+        .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
         after 140 [list show-logo $v1]
         return
     }
     while {1} {
-        .bot.logo configure -bitmap @book1
+        .bot.logo configure -bitmap @${libdir}/bitmaps/book1
         tkwait variable busy
         if {$busy} {
             show-logo 1
@@ -458,6 +482,7 @@ proc insertWithTags {w text args} {
 }
 
 proc popup-license {} {
+    global libdir
     set w .popup-licence
     toplevel $w
 
@@ -474,12 +499,14 @@ proc popup-license {} {
     pack $w.top.s -side right -fill y
     pack $w.top.t -expand yes -fill both
 
-    set f [open "LICENSE" r]
-    while {[gets $f buf] != -1} {
-        $w.top.t insert end $buf
-        $w.top.t insert end "\n"
-    } 
-    close $f
+    if {[file readable "${libdir}/LICENSE"]} {
+        set f [open "${libdir}/LICENSE" r]
+        while {[gets $f buf] != -1} {
+            $w.top.t insert end $buf
+            $w.top.t insert end "\n"
+        } 
+        close $f
+    }
     bottom-buttons $w [list {Close} [list destroy $w]] 1
 }
 
@@ -517,6 +544,7 @@ proc about-target {} {
 }
 
 proc about-origin-logo {n} {
+    global libdir
     set w .about-origin-w
     if {![winfo exists $w]} {
         return
@@ -525,12 +553,13 @@ proc about-origin-logo {n} {
     if {$n==10} {
         set n 1
     }
-    $w.top.a.logo configure -bitmap @book$n
+    $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
     after 140 [list about-origin-logo $n]
 }
 
 proc about-origin {} {
     set w .about-origin-w
+    global libdir
     
     if {[winfo exists $w]} {
         destroy $w
@@ -548,7 +577,7 @@ proc about-origin {} {
     
     label $w.top.a.irtcl -text "IrTcl" \
             -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
-    label $w.top.a.logo -bitmap @book1 
+    label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1 
     pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
 
     set i [z39 implementationName]
@@ -613,11 +642,6 @@ proc popup-marc {sno no b df} {
     set recordType [z39.$sno recordType $no]
     wm title $w "$recordType record #$no"
 
-    set ffunc [lindex $displayFormats $df]
-    set ffunc "display-$ffunc"
-
-    $ffunc $sno $no $w.top.record 0
-
     if {$new} {
         bind $w.top.record <Return> {destroy .full-marc}
         
@@ -651,6 +675,10 @@ proc popup-marc {sno no b df} {
             incr i
         }
     }
+    set ffunc [lindex $displayFormats $df]
+    set ffunc "display-$ffunc"
+
+    $ffunc $sno $no $w.top.record 0
 }
 
 proc update-target-hotlist {target base} {
@@ -765,7 +793,6 @@ proc open-target {target base} {
         show-status Ready 0 {}
         return
     }
-#    z39 options search present scan namedResultSets triggerResourceCtrl
     set hostid $target
     .top.target.m disable 0
     .top.target.m enable 1
@@ -880,6 +907,7 @@ proc search-request {bflag} {
     global busy
     global cancelFlag
     global delayRequest
+    global recordSyntax
 
     set target $hostid
 
@@ -917,6 +945,9 @@ proc search-request {bflag} {
     if {[lindex $profile($target) 9] == 1} {
         z39.$setNo queryType ccl
     }
+    dputs Setting
+    dputs $recordSyntax
+    z39.$setNo preferredRecordSyntax $recordSyntax
     z39 callback {search-response}
     z39.$setNo search $query
     show-status {Searching} 1 0
@@ -1302,7 +1333,7 @@ proc add-title-lines {setno no offset} {
     global displayFormat
     global lastSetNo
 
-    if {$setno == 0} {
+    if {$setno == -1} {
         set setno $lastSetNo
     } else {
         set lastSetNo $setno
@@ -1312,6 +1343,7 @@ proc add-title-lines {setno no offset} {
         .data.record delete 0.0 end
     }
     set ffunc [lindex $displayFormats $displayFormat]
+    dputs "ffunc=$ffunc"
     set ffunc "display-$ffunc"
     for {set i 0} {$i < $no} {incr i} {
         set o [expr $i + $offset]
@@ -1869,15 +1901,17 @@ proc save-geometry {} {
     global textWrap
     global displayFormat
     global popupMarcdf
+    global recordSyntax
     
     set windowGeometry(.) [wm geometry .]
 
-    set f [open "clientg.tcl" w]
+    set f [open "~/.clientrc.tcl" w]
 
     puts $f "set hotTargets \{ $hotTargets \}"
     puts $f "set textWrap $textWrap"
     puts $f "set displayFormat $displayFormat"
     puts $f "set popupMarcdf $popupMarcdf"
+    puts $f "set recordSyntax $recordSyntax"
     foreach n [array names windowGeometry] {
         puts -nonewline $f "set \{windowGeometry($n)\} \{"
         puts -nonewline $f $windowGeometry($n)
@@ -1888,12 +1922,16 @@ proc save-geometry {} {
 
 proc save-settings {} {
     global profile
+    global libdir
     global settingsChanged
     global queryTypes
     global queryButtons
     global queryInfo
-    
-    set f [open "clientrc.tcl" w]
+   
+    if {![file writable "${libdir}/clientrc.tcl"]} {
+       return
+    }
+    set f [open "${libdir}/clientrc.tcl" w]
     puts $f "# Setup file"
 
     foreach n [array names profile] {
@@ -2734,6 +2772,7 @@ menu .top.options.m
 .top.options.m add cascade -label "Query" -menu .top.options.m.query
 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
+.top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
 
 menu .top.options.m.query
 .top.options.m.query add cascade -label "Select" \
@@ -2766,6 +2805,25 @@ menu .top.options.m.wrap
 .top.options.m.wrap add radiobutton -label "None" \
         -value none -variable textWrap -command {set-wrap none}
 
+menu .top.options.m.syntax
+.top.options.m.syntax add radiobutton -label "USMARC" \
+        -value USMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "UNIMARC" \
+        -value UNIMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "UKMARC" \
+        -value UKMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "DANMARC" \
+        -value DANMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "FINMARC" \
+        -value FINMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "NORMARC" \
+        -value NORMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "PICAMARC" \
+        -value PICAMARC -variable recordSyntax
+.top.options.m.syntax add separator
+.top.options.m.syntax add radiobutton -label "SUTRS" \
+        -value SUTRS -variable recordSyntax
+
 menubutton .top.help -text "Help" -menu .top.help.m
 menu .top.help.m
 
@@ -2805,7 +2863,7 @@ if {[tk colormodel .] == "color"} {
 }
 .data.record tag configure marc-data -foreground black
 
-button .bot.logo  -bitmap @book1 -command cancel-operation
+button .bot.logo  -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
 frame .bot.a
 pack .bot.a -side left -fill x
 pack .bot.logo -side right -padx 2 -pady 2