Skip to content

Commit 2810a58

Browse files
committed
git-gui: fix size and position of window panes on startup
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 <[email protected]>
1 parent 9cb268c commit 2810a58

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

git-gui.sh

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ proc _trace_exec {cmd} {
334334
puts stderr $d
335335
}
336336

337+
#'" fix poor old emacs font-lock mode
338+
337339
proc _git_cmd {name} {
338340
global _git_cmd_path
339341

@@ -648,6 +650,7 @@ proc rmsel_tag {text} {
648650
return $text
649651
}
650652
653+
wm withdraw .
651654
set root_exists 0
652655
bind . <Visibility> {
653656
bind . <Visibility> {}
@@ -2919,6 +2922,7 @@ blame {
29192922
set current_branch $head
29202923
}
29212924
2925+
wm deiconify .
29222926
switch -- $subcommand {
29232927
browser {
29242928
if {$jump_spec ne {}} usage
@@ -3492,29 +3496,44 @@ $main_status show [mc "Initializing..."]
34923496
34933497
# -- Load geometry
34943498
#
3495-
catch {
3496-
set gm $repo_config(gui.geometry)
3497-
wm geometry . [lindex $gm 0]
3498-
if {$use_ttk} {
3499-
.vpane sashpos 0 [lindex $gm 1]
3500-
.vpane.files sashpos 0 [lindex $gm 2]
3501-
} else {
3502-
.vpane sash place 0 \
3503-
[lindex $gm 1] \
3504-
[lindex [.vpane sash coord 0] 1]
3505-
.vpane.files sash place 0 \
3506-
[lindex [.vpane.files sash coord 0] 0] \
3507-
[lindex $gm 2]
3499+
proc on_ttk_pane_mapped {w pane pos} {
3500+
bind $w <Map> {}
3501+
after 0 [list after idle [list $w sashpos $pane $pos]]
3502+
}
3503+
proc on_tk_pane_mapped {w pane x y} {
3504+
bind $w <Map> {}
3505+
after 0 [list after idle [list $w sash place $pane $x $y]]
3506+
}
3507+
proc on_application_mapped {} {
3508+
global repo_config use_ttk
3509+
bind . <Map> {}
3510+
set gm $repo_config(gui.geometry)
3511+
if {$use_ttk} {
3512+
bind .vpane <Map> \
3513+
[list on_ttk_pane_mapped %W 0 [lindex $gm 1]]
3514+
bind .vpane.files <Map> \
3515+
[list on_ttk_pane_mapped %W 0 [lindex $gm 2]]
3516+
} else {
3517+
bind .vpane <Map> \
3518+
[list on_tk_pane_mapped %W 0 \
3519+
[lindex $gm 1] \
3520+
[lindex [.vpane sash coord 0] 1]]
3521+
bind .vpane.files <Map> \
3522+
[list on_tk_pane_mapped %W 0 \
3523+
[lindex [.vpane.files sash coord 0] 0] \
3524+
[lindex $gm 2]]
3525+
}
3526+
wm geometry . [lindex $gm 0]
35083527
}
3509-
unset gm
3528+
if {[info exists repo_config(gui.geometry)]} {
3529+
bind . <Map> [list on_application_mapped]
3530+
wm geometry . [lindex $repo_config(gui.geometry) 0]
35103531
}
35113532
35123533
# -- Load window state
35133534
#
3514-
catch {
3515-
set gws $repo_config(gui.wmstate)
3516-
wm state . $gws
3517-
unset gws
3535+
if {[info exists repo_config(gui.wmstate)]} {
3536+
catch {wm state . $repo_config(gui.wmstate)}
35183537
}
35193538
35203539
# -- Key Bindings

0 commit comments

Comments
 (0)