Patchwork [5,of,9] hgk: update backgroud colour when Ttk is available

login
register
mail settings
Submitter Andrew Shadura
Date March 10, 2013, 4:24 p.m.
Message ID <49ad2ddd4a8f5f776dbd.1362932686@localhost.localdomain>
Download mbox | patch
Permalink /patch/1102/
State Accepted
Commit 6a0578d07024bbcba57e110f5b5db90287743e70
Headers show

Comments

Andrew Shadura - March 10, 2013, 4:24 p.m.
# HG changeset patch
# User Andrew Shadura <bugzilla@tut.by>
# Date 1362930136 -3600
# Node ID 49ad2ddd4a8f5f776dbd0e97bfb8b6c4d8e7ee29
# Parent  c9806449456004b3f3e0e395dc8d98881bee6fe7
hgk: update backgroud colour when Ttk is available

Ttk doesn't automatically set up Tk colour palette.
Because of that, Ttk controls look differently when used
together with old Tk controls. When we use Ttk controls,
we first query if we have any setting for the client
background, and if we do, we update Tk palette as well.

Patch

diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -30,6 +30,8 @@  if {[catch {package require Ttk}]} {
     interp alias {} ttk::label {} label
     interp alias {} ttk::scrollbar {} scrollbar
     interp alias {} ttk::optionMenu {} tk_optionMenu
+
+    proc updatepalette {} {}
 } else {
     proc ::ttk::optionMenu {w varName firstValue args} {
         upvar #0 $varName var
@@ -46,6 +48,11 @@  if {[catch {package require Ttk}]} {
         }
         return $w.menu
     }
+    proc updatepalette {} {
+        catch {
+            tk_setPalette background [ttk::style lookup client -background]
+        }
+    }
 }
 
 if {[tk windowingsystem] eq "win32"} {
@@ -120,6 +127,7 @@  if {$theme eq "default"} {
 
 }
 
+updatepalette
 
 # Unify right mouse button handling.
 # See "mouse buttons on macintosh" thread on comp.lang.tcl