@matheusbsbs / matheus-bagliano / commits / d89a494fca
Fork 0

git-gui: Cleanup blame::new widget initialization

A lot of this code was pre-class, which meant that I just sort of copied and pasted my way through it, rather than being really smart and using a variable for each widget's path name. Since we have a field for each path, we can use those throughout the constructor and make things a lot neater. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jun 1, 2007 at 00:05 UTC d89a494fcae246b696a2fe234ccf166669a3a45e
1 file changed +38 -39
lib/blame.tcl
+38 -39
@@ -48,25 +48,28 @@ constructor new {i_commit i_path} {
48 pack $w.path -side top -fill x
49
50 frame $w.out
51 - text $w.out.loaded_t \
51 + set w_load $w.out.loaded_t
52 + text $w_load \
53 -background white -borderwidth 0 \
54 -state disabled \
55 -wrap none \
56 -height 40 \
57 -width 1 \
58 -font font_diff
58 - $w.out.loaded_t tag conf annotated -background grey
59 + $w_load tag conf annotated -background grey
60
60 - text $w.out.linenumber_t \
61 + set w_line $w.out.linenumber_t
62 + text $w_line \
63 -background white -borderwidth 0 \
64 -state disabled \
65 -wrap none \
66 -height 40 \
67 -width 5 \
68 -font font_diff
67 - $w.out.linenumber_t tag conf linenumber -justify right
69 + $w_line tag conf linenumber -justify right
70
69 - text $w.out.commit_t \
71 + set w_cgrp $w.out.commit_t
72 + text $w_cgrp \
73 -background white -borderwidth 0 \
74 -state disabled \
75 -wrap none \
@@ -74,7 +77,8 @@ constructor new {i_commit i_path} {
77 -width 4 \
78 -font font_diff
79
77 - text $w.out.file_t \
80 + set w_file $w.out.file_t
81 + text $w_file \
82 -background white -borderwidth 0 \
83 -state disabled \
84 -wrap none \
@@ -83,19 +87,19 @@ constructor new {i_commit i_path} {
87 -xscrollcommand [list $w.out.sbx set] \
88 -font font_diff
89
86 - scrollbar $w.out.sbx -orient h -command [list $w.out.file_t xview]
90 + scrollbar $w.out.sbx -orient h -command [list $w_file xview]
91 scrollbar $w.out.sby -orient v \
92 -command [list scrollbar2many [list \
89 - $w.out.loaded_t \
90 - $w.out.linenumber_t \
91 - $w.out.commit_t \
92 - $w.out.file_t \
93 + $w_load \
94 + $w_line \
95 + $w_cgrp \
96 + $w_file \
97 ] yview]
98 grid \
95 - $w.out.commit_t \
96 - $w.out.linenumber_t \
97 - $w.out.loaded_t \
98 - $w.out.file_t \
99 + $w_cgrp \
100 + $w_line \
101 + $w_load \
102 + $w_file \
103 $w.out.sby \
104 -sticky nsew
105 grid conf $w.out.sbx -column 3 -sticky we
@@ -112,7 +116,8 @@ constructor new {i_commit i_path} {
116 pack $w.status -side bottom -fill x
117
118 frame $w.cm
115 - text $w.cm.t \
119 + set w_cmit $w.cm.t
120 + text $w_cmit \
121 -background white -borderwidth 0 \
122 -state disabled \
123 -wrap none \
@@ -121,11 +126,11 @@ constructor new {i_commit i_path} {
126 -xscrollcommand [list $w.cm.sbx set] \
127 -yscrollcommand [list $w.cm.sby set] \
128 -font font_diff
124 - scrollbar $w.cm.sbx -orient h -command [list $w.cm.t xview]
125 - scrollbar $w.cm.sby -orient v -command [list $w.cm.t yview]
129 + scrollbar $w.cm.sbx -orient h -command [list $w_cmit xview]
130 + scrollbar $w.cm.sby -orient v -command [list $w_cmit yview]
131 pack $w.cm.sby -side right -fill y
132 pack $w.cm.sbx -side bottom -fill x
128 - pack $w.cm.t -expand 1 -fill both
133 + pack $w_cmit -expand 1 -fill both
134 pack $w.cm -side bottom -fill x
135
136 menu $w.ctxm -tearoff 0
@@ -133,26 +138,20 @@ constructor new {i_commit i_path} {
138 -label "Copy Commit" \
139 -command [cb _copycommit]
140
136 - set w_line $w.out.linenumber_t
137 - set w_cgrp $w.out.commit_t
138 - set w_load $w.out.loaded_t
139 - set w_file $w.out.file_t
140 - set w_cmit $w.cm.t
141 -
141 foreach i [list \
143 - $w.out.commit_t \
144 - $w.out.loaded_t \
145 - $w.out.linenumber_t \
146 - $w.out.file_t] {
142 + $w_cgrp \
143 + $w_load \
144 + $w_line \
145 + $w_file] {
146 $i tag conf in_sel \
147 -background [$i cget -foreground] \
148 -foreground [$i cget -background]
149 $i conf -yscrollcommand \
150 [list many2scrollbar [list \
152 - $w.out.commit_t \
153 - $w.out.loaded_t \
154 - $w.out.linenumber_t \
155 - $w.out.file_t \
151 + $w_cgrp \
152 + $w_load \
153 + $w_line \
154 + $w_file \
155 ] yview $w.out.sby]
156 bind $i <Button-1> "[cb _click $i @%x,%y]; focus $i"
157 bind_button3 $i "
@@ -164,11 +163,11 @@ constructor new {i_commit i_path} {
163 }
164
165 foreach i [list \
167 - $w.out.commit_t \
168 - $w.out.loaded_t \
169 - $w.out.linenumber_t \
170 - $w.out.file_t \
171 - $w.cm.t] {
166 + $w_cgrp \
167 + $w_load \
168 + $w_line \
169 + $w_file \
170 + $w_cmit] {
171 bind $i <Key-Up> {catch {%W yview scroll -1 units};break}
172 bind $i <Key-Down> {catch {%W yview scroll 1 units};break}
173 bind $i <Key-Left> {catch {%W xview scroll -1 units};break}
@@ -181,7 +180,7 @@ constructor new {i_commit i_path} {
180 bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
181 }
182
184 - bind $w.cm.t <Button-1> [list focus $w.cm.t]
183 + bind $w_cmit <Button-1> [list focus $w_cmit]
184 bind $top <Visibility> [list focus $top]
185 bind $top <Destroy> [list delete_this $this]
186