gitk: offer "Copy commit ID to X11 selection" only on X11

This option is only useful where a selection clipboard is available, which is only the case on X11. Do not clutter the UI in other environments. Signed-off-by: Johannes Sixt <j6t@kdbg.org>

Johannes Sixt committed Dec 14, 2024 at 15:53 UTC 36625a6974156fbc56bbb97c983b09ae303a06ff
1 file changed +10 -4
gitk
+10 -4
@@ -1969,6 +1969,10 @@ proc confirm_popup {msg {owner .}} {
1969 return $confirm_ok
1970 }
1971
1972 +proc haveselectionclipboard {} {
1973 + return [expr {[tk windowingsystem] eq "x11"}]
1974 +}
1975 +
1976 proc setoptions {} {
1977 global use_ttk
1978
@@ -7410,7 +7414,7 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
7414
7415 $sha1entry delete 0 end
7416 $sha1entry insert 0 $id
7413 - if {$autoselect} {
7417 + if {$autoselect && [haveselectionclipboard]} {
7418 $sha1entry selection range 0 $autosellen
7419 }
7420 if {$autocopy} {
@@ -11605,9 +11609,11 @@ proc prefspage_general {notebook} {
11609 ${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
11610 -variable autocopy
11611 grid x $page.autocopy -sticky w
11608 - ${NS}::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
11609 - -variable autoselect
11610 - grid x $page.autoselect -sticky w
11612 + if {[haveselectionclipboard]} {
11613 + ${NS}::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
11614 + -variable autoselect
11615 + grid x $page.autoselect -sticky w
11616 + }
11617 spinbox $page.autosellen -from 1 -to 40 -width 4 -textvariable autosellen
11618 ${NS}::label $page.autosellenl -text [mc "Length of commit ID to copy"]
11619 grid x $page.autosellenl $page.autosellen -sticky w