{"thread":{"id":"44743","subject":"[GIT GUI/PATCH/RFC] git gui: get current theme in 8.5-backwards-compatible way","startedAt":"2016-12-20T19:20:37Z","lastAt":"2016-12-20T19:20:37Z","messageCount":1,"participants":["Pete Harlan"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"308162","messageId":"CAAB=nN=dVgg1BREfoZhOTcT5PQSbi+wE+Ng7fqjUSenkp9fcKg@mail.gmail.com","threadId":"44743","inReplyTo":null,"subject":"[GIT GUI/PATCH/RFC] git gui: get current theme in 8.5-backwards-compatible way","fromName":"Pete Harlan","fromEmail":"pgit@tento.net","sentAt":"2016-12-20T19:20:30Z","receivedAt":"2016-12-20T19:20:37Z","isPatch":true,"sender":{"key":"pgit@tento.net","avatar":null},"body":"Later Tcl 8.5 versions learned to return the current theme by omitting\nthe final argument to \"[ttk::style theme use]\", but this throws an\nerror on earlier 8.5 versions (e.g., 8.5.7).\n\nInitTheme works around this by catching the error and reading\n::ttk::currentTheme instead.\n\nA call to \"[ttk::style theme use]\" was added to ttext in 30508bc\n(\"Amend tab ordering and text widget border and highlighting.\",\n2016-10-02).  Break out InitTheme's workaround into its own\nget_current_theme proc and use it in both places.\n\nSigned-off-by: Pete Harlan <pgit@tento.net>\n---\n\nNote: Applies to the upstream git-gui repo, http://repo.or.cz/git-gui .\nTo apply to Git itself, apply in the git-gui directory.\n\nIssue entered Git in v2.10.1-537-g3eae30870.\n\n lib/themed.tcl | 17 ++++++++++++-----\n 1 file changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/lib/themed.tcl b/lib/themed.tcl\nindex 351a712..85c157b 100644\n--- a/lib/themed.tcl\n+++ b/lib/themed.tcl\n@@ -28,10 +28,7 @@ proc InitTheme {} {\n                }\n        }\n\n-       # Handle either current Tk or older versions of 8.5\n-       if {[catch {set theme [ttk::style theme use]}]} {\n-               set theme  $::ttk::currentTheme\n-       }\n+       set theme [get_current_theme]\n\n        if {[lsearch -exact {default alt classic clam} $theme] != -1} {\n                # Simple override of standard ttk::entry to change the field\n@@ -248,7 +245,7 @@ proc tspinbox {w args} {\n proc ttext {w args} {\n        global use_ttk\n        if {$use_ttk} {\n-               switch -- [ttk::style theme use] {\n+               switch -- [get_current_theme] {\n                        \"vista\" - \"xpnative\" {\n                                lappend args -highlightthickness 0\n-borderwidth 0\n                        }\n@@ -343,6 +340,16 @@ proc on_choosefont {familyvar sizevar font} {\n        set size [dict get $font -size]\n }\n\n+# Get current theme in a backwards-compatible way.\n+proc get_current_theme {} {\n+       # Handle either current Tk or older versions of 8.5\n+       if {[catch {set theme [ttk::style theme use]}]} {\n+               set theme $::ttk::currentTheme\n+       }\n+\n+       return $theme\n+}\n+\n # Local variables:\n # mode: tcl\n # indent-tabs-mode: t\n"}]}