gitk: make configuration dialog resizing useful

gitk's configuration dialog can be resized, but this does not expand the space allocated to any widgets. Some items may have long lines of text that would be visible if the widgets expanded, but this does not happen. The top-level container uses a two column grid and allocates any space change equally to both columns. However, the configuration pages are contained in one cell so half the additional space is wasted if expanding. Also, the individual configuration pages do not mark any column or widgets to expand, so any additional space given is just used as padding. Collapse the top-level page to have one column, placing the "OK" and "Cancel" buttons in a non-resizing frame in column 1 (this keeps the buttons in constant geometry as the dialog is expanded). This makes all additional space go to the configuration page. Mark column 3 of the individual pages to get all additional space, and mark the text widgets in that column so they will expand to use the space. While we're at it, eliminate or simplify use of frames to contain column 2 content, and harmonize the indents of that content. prefspage_general adds a special "spacer" label in row 2, column 1, that causes all of the subsequent rows with no column 1 content to indent, and this carries over to the next notebook tab (prefspage_color) through some undocumented feature. The fonts page has a different indent, again for unknown reason. The documented approach would be to use -padx explicitly on all the rows to set the indents. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

Mark Levedahl committed Sep 30, 2025 at 19:35 UTC b9f6b8237db9ebe999064e029c1b4784a7f4cfcd
1 file changed +24 -21
gitk
+24 -21
@@ -11567,9 +11567,10 @@ proc mkfontdisp {font top which} {
11567 set fontpref($font) [set $font]
11568 ttk::button $top.${font}but -text $which \
11569 -command [list choosefont $font $which]
11570 - ttk::label $top.$font -relief flat -font $font \
11571 - -text $fontattr($font,family) -justify left
11570 + ttk::label $top.$font -font $font \
11571 + -text $fontattr($font,family)
11572 grid x $top.${font}but $top.$font -sticky w
11573 + grid configure $top.$font -sticky ew
11574 }
11575
11576 proc centertext {w} {
@@ -11665,11 +11666,9 @@ proc prefspage_general {notebook} {
11666 grid x $page.hideremotes -sticky w
11667
11668 ttk::entry $page.refstohide -textvariable refstohide
11668 - ttk::frame $page.refstohidef
11669 - ttk::label $page.refstohidef.l -text [mc "Refs to hide (space-separated globs)" ]
11670 - pack $page.refstohidef.l -side left
11671 - pack configure $page.refstohidef.l -padx 10
11672 - grid x $page.refstohidef $page.refstohide -sticky ew
11669 + ttk::label $page.refstohidel -text [mc "Refs to hide (space-separated globs)"]
11670 + grid x $page.refstohidel $page.refstohide -sticky ew
11671 + grid configure $page.refstohide -padx {0 5}
11672
11673 ttk::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
11674 -variable autocopy
@@ -11718,16 +11717,17 @@ proc prefspage_general {notebook} {
11717 ttk::frame $page.extdifff
11718 ttk::label $page.extdifff.l -text [mc "External diff tool" ]
11719 ttk::button $page.extdifff.b -text [mc "Choose..."] -command choose_extdiff
11721 - pack $page.extdifff.l $page.extdifff.b -side left
11722 - pack configure $page.extdifff.l -padx 10
11720 + pack $page.extdifff.l -side left
11721 + pack $page.extdifff.b -side right -padx {0 5}
11722 grid x $page.extdifff $page.extdifft -sticky ew
11723 + grid configure $page.extdifft -padx {0 5}
11724
11725 ttk::entry $page.webbrowser -textvariable web_browser
11726 - ttk::frame $page.webbrowserf
11727 - ttk::label $page.webbrowserf.l -text [mc "Web browser" ]
11728 - pack $page.webbrowserf.l -side left
11729 - pack configure $page.webbrowserf.l -padx 10
11730 - grid x $page.webbrowserf $page.webbrowser -sticky ew
11726 + ttk::label $page.webbrowserl -text [mc "Web browser" ]
11727 + grid x $page.webbrowserl $page.webbrowser -sticky ew
11728 + grid configure $page.webbrowser -padx {0 5}
11729 +
11730 + grid columnconfigure $page 2 -weight 1
11731
11732 return $page
11733 }
@@ -11751,9 +11751,11 @@ proc prefspage_colors {notebook} {
11751 ttk::label $page.tloadframe.l -text [mc "Theme definition file"]
11752 ttk::button $page.tloadframe.b -text [mc "Choose..."] \
11753 -command [list choose_themeloader $page]
11754 - pack $page.tloadframe.l $page.tloadframe.b -side left -padx 2
11754 + pack $page.tloadframe.l -side left
11755 + pack $page.tloadframe.b -side right -padx {0 5}
11756 pack configure $page.tloadframe.l -padx 0
11757 grid x $page.tloadframe $page.tloadvar -sticky ew
11758 + grid configure $page.tloadvar -padx {0 5}
11759
11760 ttk::label $page.themelabel2 -text \
11761 [mc "The theme definition file may affect all themes."]
@@ -11799,6 +11801,9 @@ proc prefspage_colors {notebook} {
11801 ttk::button $page.selbgbut -text [mc "Select bg"] \
11802 -command [list choosecolor selectbgcolor {} $page [mc "background"]]
11803 grid x $page.selbgbut $page.selbgsep -sticky w
11804 +
11805 + grid columnconfigure $page 2 -weight 1
11806 +
11807 return $page
11808 }
11809
@@ -11824,6 +11829,7 @@ proc prefspage_fonts {notebook} {
11829 mkfontdisp mainfont $page [mc "Main font"]
11830 mkfontdisp textfont $page [mc "Diff display font"]
11831 mkfontdisp uifont $page [mc "User interface font"]
11832 + grid columnconfigure $page 2 -weight 1
11833 return $page
11834 }
11835
@@ -11858,7 +11864,7 @@ proc doprefs {} {
11864 grid rowconfigure $notebook 1 -weight 1
11865 raise [lindex $pages 0]
11866
11861 - grid $notebook -sticky news -padx 2 -pady 2
11867 + grid $notebook -sticky news -padx 3 -pady 3
11868 grid rowconfigure $top 0 -weight 1
11869 grid columnconfigure $top 0 -weight 1
11870
@@ -11867,11 +11873,8 @@ proc doprefs {} {
11873 ttk::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
11874 bind $top <Key-Return> prefsok
11875 bind $top <Key-Escape> prefscan
11870 - grid $top.buts.ok $top.buts.can
11871 - grid columnconfigure $top.buts 0 -weight 1 -uniform a
11872 - grid columnconfigure $top.buts 1 -weight 1 -uniform a
11873 - grid $top.buts - - -pady 10 -sticky ew
11874 - grid columnconfigure $top 2 -weight 1
11876 + grid $top.buts.ok $top.buts.can -padx 20
11877 + grid $top.buts -sticky w -pady 10
11878 bind $top <Visibility> [list focus $top.buts.ok]
11879 }
11880