Skip to content

Commit

Permalink
git-gui: fix size and position of window panes on startup
Browse files Browse the repository at this point in the history
The themed panedwindow needs to have the sash position set after the
widget has been mapped therefore apply this setting in the Map event
binding. To avoid visible redraws as the application is constructed
the main window should be withdrawn until all the widgets have been added

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  • Loading branch information
Pat Thoyts committed Aug 2, 2010
1 parent 9cb268c commit 2810a58
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ proc _trace_exec {cmd} {
puts stderr $d
}

#'" fix poor old emacs font-lock mode

proc _git_cmd {name} {
global _git_cmd_path

Expand Down Expand Up @@ -648,6 +650,7 @@ proc rmsel_tag {text} {
return $text
}
wm withdraw .
set root_exists 0
bind . <Visibility> {
bind . <Visibility> {}
Expand Down Expand Up @@ -2919,6 +2922,7 @@ blame {
set current_branch $head
}
wm deiconify .
switch -- $subcommand {
browser {
if {$jump_spec ne {}} usage
Expand Down Expand Up @@ -3492,29 +3496,44 @@ $main_status show [mc "Initializing..."]
# -- Load geometry
#
catch {
set gm $repo_config(gui.geometry)
wm geometry . [lindex $gm 0]
if {$use_ttk} {
.vpane sashpos 0 [lindex $gm 1]
.vpane.files sashpos 0 [lindex $gm 2]
} else {
.vpane sash place 0 \
[lindex $gm 1] \
[lindex [.vpane sash coord 0] 1]
.vpane.files sash place 0 \
[lindex [.vpane.files sash coord 0] 0] \
[lindex $gm 2]
proc on_ttk_pane_mapped {w pane pos} {
bind $w <Map> {}
after 0 [list after idle [list $w sashpos $pane $pos]]
}
proc on_tk_pane_mapped {w pane x y} {
bind $w <Map> {}
after 0 [list after idle [list $w sash place $pane $x $y]]
}
proc on_application_mapped {} {
global repo_config use_ttk
bind . <Map> {}
set gm $repo_config(gui.geometry)
if {$use_ttk} {
bind .vpane <Map> \
[list on_ttk_pane_mapped %W 0 [lindex $gm 1]]
bind .vpane.files <Map> \
[list on_ttk_pane_mapped %W 0 [lindex $gm 2]]
} else {
bind .vpane <Map> \
[list on_tk_pane_mapped %W 0 \
[lindex $gm 1] \
[lindex [.vpane sash coord 0] 1]]
bind .vpane.files <Map> \
[list on_tk_pane_mapped %W 0 \
[lindex [.vpane.files sash coord 0] 0] \
[lindex $gm 2]]
}
wm geometry . [lindex $gm 0]
}
unset gm
if {[info exists repo_config(gui.geometry)]} {
bind . <Map> [list on_application_mapped]
wm geometry . [lindex $repo_config(gui.geometry) 0]
}
# -- Load window state
#
catch {
set gws $repo_config(gui.wmstate)
wm state . $gws
unset gws
if {[info exists repo_config(gui.wmstate)]} {
catch {wm state . $repo_config(gui.wmstate)}
}
# -- Key Bindings
Expand Down

0 comments on commit 2810a58

Please sign in to comment.