All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT GUI/PATCH/RFC] git gui: get current theme in 8.5-backwards-compatible way
@ 2016-12-20 19:20 Pete Harlan
  0 siblings, 0 replies; only message in thread
From: Pete Harlan @ 2016-12-20 19:20 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git

Later Tcl 8.5 versions learned to return the current theme by omitting
the final argument to "[ttk::style theme use]", but this throws an
error on earlier 8.5 versions (e.g., 8.5.7).

InitTheme works around this by catching the error and reading
::ttk::currentTheme instead.

A call to "[ttk::style theme use]" was added to ttext in 30508bc
("Amend tab ordering and text widget border and highlighting.",
2016-10-02).  Break out InitTheme's workaround into its own
get_current_theme proc and use it in both places.

Signed-off-by: Pete Harlan <pgit@tento.net>
---

Note: Applies to the upstream git-gui repo, http://repo.or.cz/git-gui .
To apply to Git itself, apply in the git-gui directory.

Issue entered Git in v2.10.1-537-g3eae30870.

 lib/themed.tcl | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/themed.tcl b/lib/themed.tcl
index 351a712..85c157b 100644
--- a/lib/themed.tcl
+++ b/lib/themed.tcl
@@ -28,10 +28,7 @@ proc InitTheme {} {
                }
        }

-       # Handle either current Tk or older versions of 8.5
-       if {[catch {set theme [ttk::style theme use]}]} {
-               set theme  $::ttk::currentTheme
-       }
+       set theme [get_current_theme]

        if {[lsearch -exact {default alt classic clam} $theme] != -1} {
                # Simple override of standard ttk::entry to change the field
@@ -248,7 +245,7 @@ proc tspinbox {w args} {
 proc ttext {w args} {
        global use_ttk
        if {$use_ttk} {
-               switch -- [ttk::style theme use] {
+               switch -- [get_current_theme] {
                        "vista" - "xpnative" {
                                lappend args -highlightthickness 0
-borderwidth 0
                        }
@@ -343,6 +340,16 @@ proc on_choosefont {familyvar sizevar font} {
        set size [dict get $font -size]
 }

+# Get current theme in a backwards-compatible way.
+proc get_current_theme {} {
+       # Handle either current Tk or older versions of 8.5
+       if {[catch {set theme [ttk::style theme use]}]} {
+               set theme $::ttk::currentTheme
+       }
+
+       return $theme
+}
+
 # Local variables:
 # mode: tcl
 # indent-tabs-mode: t

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-20 19:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 19:20 [GIT GUI/PATCH/RFC] git gui: get current theme in 8.5-backwards-compatible way Pete Harlan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.