1 #---------------------------------------------------------------------------
4 # xcircuit Tcl script for handling multiple-file writes
6 # Tim Edwards 12/5/05 for MultiGiG
7 #---------------------------------------------------------------------------
9 set XCOps
(module
,files
) 1
11 #---------------------------------------------------------------------------
13 #---------------------------------------------------------------------------
15 proc xcircuit
::forcewriteall {} {
16 set pages
[page links all
]
17 for {set i
1} {$i <= $pages} {incr i
} {
19 set techlist
[technology used
$i]
20 foreach tech
$techlist {
21 if {[technology writable
$tech]} {technology changed
$tech 1}
25 xcircuit
::promptwriteall
28 #---------------------------------------------------------------------------
29 # Write all pages. Determine which pages are enabled/disabled in the
30 # ".writeall" window, and save each one.
31 #---------------------------------------------------------------------------
33 proc xcircuit
::writeall {} {
36 if {![catch {raise .writeall
}]} {
37 set rows
[lindex [grid size .writeall.
list] 1]
39 for {set i
1} {$i <= $rows} {incr i
} {
40 if {$XCOps(cbox
${i
}) > 0} {
41 set pagelist
[pack slaves .writeall.
list.pframe
${i
}]
42 set firstpage
[lindex $pagelist 0]
43 set pageno
[${firstpage
} cget
-text]
44 if {$pageno == "-" ||
$pageno == "X"} {
45 set tname
[.writeall.
list.f
${i
} cget
-text]
46 set fname
[technology
filename $tname]
47 if {$fname == "(no associated file)"} {
48 # Fix me: this works only on one technology at a time!
49 xcircuit
::promptsavetech
51 technology save
$tname
64 #---------------------------------------------------------------------------
65 # Prompt for writing all pages
66 #---------------------------------------------------------------------------
68 proc xcircuit
::promptwriteall {} {
71 # Get list of unique filenames.
73 set pages
[page links all
]
75 for {set i
1} {$i <= $pages} {incr i
} {
76 set changes
[page
$i changes
]
78 if {[page
$i filename] == {}} {
79 page
$i filename [page
$i label]
81 lappend filelist
[page
$i filename]
84 set filelist
[lsort -unique -dictionary $filelist]
88 foreach tech
[technology
list] {
89 if {[technology changed
$tech] > 0} {
90 if {[technology writable
$tech] > 0} {
91 lappend techlist
$tech
93 lappend badtechslist
$tech
98 set filestowrite
[expr [llength $filelist] + [llength $techlist]]
100 # Set up the "writeall" window
102 catch {destroy .writeall
}
103 toplevel .writeall
-bg beige
104 frame .writeall.tbar
-bg beige
105 frame .writeall.
list -bg beige
106 frame .writeall.bbar
-bg beige
108 pack .writeall.tbar
-side top
-padx 5 -pady 5 -fill x
109 pack .writeall.
list -side top
-padx 5 -pady 5 -fill x
110 pack .writeall.bbar
-side top
-padx 5 -pady 5 -fill x
112 if {$filestowrite == 0} {
113 label .writeall.tbar.title
-text \
114 "(No modified pages or technologies to write)" -bg \
116 pack .writeall.tbar.title
-side left
118 label .writeall.tbar.title
-text "Write All Modified Pages and Technologies:" \
120 pack .writeall.tbar.title
-side left
122 label .writeall.
list.ftitle
-text "Filename" -bg beige
-fg brown
123 label .writeall.
list.ptitle
-text "Pages" -bg beige
-fg brown
124 label .writeall.
list.wtitle
-text "Write?" -bg beige
-fg brown
125 grid .writeall.
list.ftitle
-row 0 -column 0 -sticky news
126 grid .writeall.
list.ptitle
-row 0 -column 1 -sticky news
127 grid .writeall.
list.wtitle
-row 0 -column 2 -sticky news
131 foreach j
$filelist {
133 label .writeall.
list.f
${k
} -text "$j" -anchor w
-bg beige
134 frame .writeall.
list.pframe
${k
} -bg beige
135 set XCOps
(cbox
${k
}) 1
136 checkbutton .writeall.
list.cbox
${k
} -bg beige
-variable XCOps
(cbox
${k
})
139 for {set i
1} {$i <= $pages} {incr i
} {
140 if {[page
$i filename] == $j} {
141 set changes
[page
$i changes
]
144 button .writeall.
list.pframe
${k
}.b
${l
} -text "$i" -bg \
145 white
-command "page goto $i ; \
147 pack .writeall.
list.pframe
${k
}.b
${l
} -side left
-padx 5
151 grid .writeall.
list.f
${k
} -row $k -column 0 -sticky news
152 grid .writeall.
list.pframe
${k
} -row $k -column 1 -sticky news
153 grid .writeall.
list.cbox
${k
} -row $k -column 2 -sticky news
156 foreach j
$techlist {
158 label .writeall.
list.f
${k
} -text "$j" -anchor w
-bg beige
159 frame .writeall.
list.pframe
${k
} -bg beige
160 set XCOps
(cbox
${k
}) 1
161 checkbutton .writeall.
list.cbox
${k
} -bg beige
-variable XCOps
(cbox
${k
})
163 button .writeall.
list.pframe
${k
}.b1
-text "-" -bg white
\
164 -command "set XCOps(technology) $j ; \
165 xcircuit::promptsavetech"
166 pack .writeall.
list.pframe
${k
}.b1
-side left
-padx 5
167 grid .writeall.
list.f
${k
} -row $k -column 0 -sticky news
168 grid .writeall.
list.pframe
${k
} -row $k -column 1 -sticky news
169 grid .writeall.
list.cbox
${k
} -row $k -column 2 -sticky news
172 foreach j
$badtechslist {
174 label .writeall.
list.f
${k
} -text "$j" -anchor w
-bg beige
-fg gray60
175 frame .writeall.
list.pframe
${k
} -bg beige
176 set XCOps
(cbox
${k
}) 0
177 checkbutton .writeall.
list.cbox
${k
} -bg beige
-variable XCOps
(cbox
${k
})
179 button .writeall.
list.pframe
${k
}.b1
-text "X" -bg white
-fg gray60
\
180 -command "set XCOps(technology) $j ; \
181 xcircuit::promptsavetech"
182 pack .writeall.
list.pframe
${k
}.b1
-side left
-padx 5
183 grid .writeall.
list.f
${k
} -row $k -column 0 -sticky news
184 grid .writeall.
list.pframe
${k
} -row $k -column 1 -sticky news
185 grid .writeall.
list.cbox
${k
} -row $k -column 2 -sticky news
188 if {$filestowrite > 0} {
189 button .writeall.bbar.okay
-text Write
-bg beige
-command \
191 pack .writeall.bbar.okay
-side left
-ipadx 10 -padx 5
194 if {$filestowrite < $pages} {
195 button .writeall.bbar.force
-text Force
-bg beige
-command \
196 {xcircuit
::forcewriteall}
197 pack .writeall.bbar.force
-side left
-ipadx 10 -padx 5
200 button .writeall.bbar.cancel
-text Cancel
-bg beige
-command \
202 pack .writeall.bbar.cancel
-side right
-ipadx 10 -padx 5