Sync GTK4/libadwaita/Qt/Tk gtkTtk themes, add Tcl/Tk, and fix lid-close input leak

- Extend geminux-sync-gtk-theme and geminux-apply-theme to synchronize GTK4/libadwaita (dconf + ADW_DISABLE_PORTAL=1), qt6ct (QT_QPA_PLATFORMTHEME=qt6ct:gtk3), Kvantum, and live classic/ttk Tk apps
- Preinstall dconf, gtk+2.0, tcl, tcl-lib, tcl-tls, tk, and custom zero-glycin geminux-gtkttk (GtkTtk 0.9 with XImage blitting, RESOURCE_MANAGER live reload, and *TkTheme: gtkTtk)
- Add kernel patch 0011 to open gemini-lid keyboard/touchscreen handles for synchronous raw Hall GPIO66 input filtering, inhibit SSD2092 touch while closed, and set 1 ms hall-switch / 10 ms keyboard-matrix debounce in DT
This commit is contained in:
Luxferre committed 2026-11-25 20:09:34 +02:00
1 parent 16fcaaaba6
commit 983d529ec3
87 files changed
+10943 -45

No files matched your search

+536
View File
@@ -0,0 +1,536 @@
##
## Function to return the containing lib of a symbol
##
proc symbol2lib {s} {
switch -glob $s {
gdk_pixbuf_get_from_drawable {return gdk}
gtk_* {return gtk}
g_object_* {return gobject}
g_* {return glib}
xlib_rgb_init -
gdk_pixbuf_xlib_* {return gdk_pixbuf_xlib}
gdk_pixbuf_* {return gdk_pixbuf}
gdk_* {return gdk}
xlib_* {return xlib}
default {
puts $s
}
}
return unknown
};# symbol2lib
##
## Function name to return type/arguments map.
##
proc get_function_spec {f} {
set t {}; set a {}
switch -glob $f {
g_free {
set a {gpointer mem}
}
g_hash_table_get_keys {
set t {GList*}
set a {GHashTable *hash_table}
}
g_malloc {
set t {gpointer}
set a {gsize n_bytes}
}
g_malloc0 {
set t {gpointer}
set a {gsize n_bytes}
}
g_new0 {
set t {}
set a {}
puts "FIXME: $f"
}
g_object_get {
set a {gpointer object, const gchar *first_property_name, ...}
}
g_object_ref {
set a {gpointer object}
}
g_object_unref {
set a {gpointer object}
}
g_option_context_add_main_entries {
set a {GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain}
}
g_option_context_new {
set t {GOptionContext*}
set a {const gchar *parameter_string}
}
g_strfreev {
set a {gchar **str_array}
}
gdk_color_to_string {
set t {gchar*}
set a {const GdkColor *color}
}
gdk_display_get_default {
set t {GdkDisplay*}
}
gdk_display_get_screen {
set t {GdkScreen*}
set a {GdkDisplay*, gint}
}
gdk_drawable_unref {
set a {GdkDrawable *drawable}
}
gdk_drawable_get_colormap {
set t {GdkColormap*}
set a {GdkDrawable *drawable}
}
gdk_drawable_set_colormap {
set a {GdkColormap*}
}
gdk_pixmap_foreign_new {
set t {GdkPixmap*}
set a {GdkNativeWindow anid}
}
gdk_pixmap_foreign_new_for_screen {
set t {GdkPixmap*}
set a {GdkScreen *screen, GdkNativeWindow anid, gint width, gint height, gint depth}
}
gdk_gc_new {
set t {GdkGC*}
set a {GdkDrawable *drawable}
}
gdk_pixbuf_get_from_drawable {
set t {GdkPixbuf*}
set a {GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height}
}
gdk_pixbuf_new {
set t {GdkPixbuf*}
set a {GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height}
}
gdk_pixbuf_unref {
set a {GdkPixbuf *pixbuf}
}
gdk_pixbuf_xlib_render_to_drawable {
set a {GdkPixbuf *pixbuf, Drawable drawable, GC gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, XlibRgbDither dither, int x_dither, int y_dither}
}
gdk_pixmap_new {
set t {GdkPixmap*}
set a {GdkDrawable *drawable, gint width, gint height, gint depth}
}
gdk_pixmap_foreign_new_for_display {
set t {GdkPixmap*}
set a {GdkDisplay *display, GdkNativeWindow anid}
}
gdk_win32_hdc_get {
set t {HDC}
set a {GdkDrawable *drawable, GdkGC *gc, GdkGCValuesMask usage}
}
gdk_win32_hdc_release {
set a {GdkDrawable *drawable, GdkGC *gc, GdkGCValuesMask usage}
}
gdk_x11_colormap_foreign_new {
set t {GdkColormap*}
set a {GdkVisual *visual, Colormap xcolormap}
}
gdk_x11_lookup_xdisplay {
set t {GdkDisplay*}
set a {Display *xdisplay}
}
gdk_x11_screen_lookup_visual {
set t {GdkVisual*}
set a {GdkScreen *screen, VisualID xvisualid}
}
xlib_rgb_init {
set a {Display *display, Screen *screen}
}
gtk_adjustment_new {
set t {GtkObject*}
set a {double, double, double, double, double, double}
}
gtk_adjustment_set_value {
set a {GtkAdjustment *adjustment, gdouble value}
}
gtk_arrow_new {
set a {GtkArrowType at, GtkShadowType st}
set t {GtkWidget*}
}
gtk_tool_button_new {
set t {GtkToolItem*}
set a {GtkWidget *icon_widget, const gchar *label}
}
gtk_vpaned_new -
gtk_toolbar_new -
gtk_statusbar_new -
gtk_progress_bar_new -
gtk_notebook_new -
gtk_hpaned_new -
gtk_fixed_new -
gtk_entry_new -
gtk_combo_box_new -
gtk_combo_box_entry_new -
gtk_check_button_new -
gtk_button_new {
set t {GtkWidget*}
}
gtk_button_get_relief {
set t {GtkReliefStyle}
set a {GtkButton *button}
}
gtk_button_set_relief {
set t {}
set a {GtkButton *button, GtkReliefStyle newstyle}
}
gtk_border_free {
set a {GtkBorder*}
}
gtk_container_add {
set a {GtkContainer *container, GtkWidget *widget}
}
gtk_disable_setlocale {
}
gtk_frame_new {
set t {GtkWidget*}
set a {const gchar *label}
}
gtk_hscale_new_with_range {
set t {GtkWidget*}
set a {gdouble min, gdouble max, gdouble step}
}
gtk_hscrollbar_new {
set t {GtkWidget*}
set a {GtkAdjustment *}
}
gtk_init_check {
set t {gboolean}
set a {int *argc, char ***argv}
}
gtk_object_get {
set a {GtkObject *object, const gchar *first_property_name, ...}
}
gtk_paint_arrow {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint}
}
gtk_paint_box {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint}
}
gtk_paint_box_gap {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint gap_x, gint gap_width}
}
gtk_paint_check {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint}
}
gtk_paint_extension {
set a {GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType}
}
gtk_paint_flat_box {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint}
}
gtk_paint_focus {
set a {GtkStyle *style, GdkWindow *window, GtkStateType state_type, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height}
}
gtk_paint_handle {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation}
}
gtk_paint_option {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint}
}
gtk_paint_resize_grip {
set a {GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint}
}
gtk_paint_shadow {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint}
}
gtk_paint_slider {
set a {GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation}
}
gtk_progress_bar_set_bar_style {
set a {GtkProgressBar *pbar, GtkProgressBarStyle style}
}
gtk_progress_bar_set_fraction {
set a {GtkProgressBar *pbar, gdouble fraction}
}
gtk_progress_bar_set_orientation {
set a {GtkProgressBar *pbar, GtkProgressBarOrientation orientation}
}
gtk_range_get_adjustment {
set t {GtkAdjustment *}
set a {GtkRange *range}
}
gtk_rc_get_default_files {
set t {gchar**}
}
gtk_rc_get_style {
set t {GtkStyle *}
set a {GtkWidget*}
}
gtk_rc_get_theme_dir {
set t {gchar*}
}
gtk_rc_reparse_all_for_settings {
set t {gboolean}
set a {GtkSettings *settings, gboolean force_load}
}
gtk_rc_reset_styles {
set a {GtkSettings *settings}
}
gtk_rc_set_default_files {
set a {gchar **filenames}
}
gtk_set_locale {
set t {gchar*}
}
gtk_settings_get_default {
set t {GtkSettings *}
}
gtk_style_apply_default_background {
set a {GtkStyle *style, GdkWindow *window, gboolean set_bg, GtkStateType state_type, GdkRectangle *area, gint x, gint y, gint width, gint height}
}
gtk_style_attach {
set t {GtkStyle*}
set a {GtkStyle *, GdkWindow *}
}
gtk_style_lookup_color {
set t {gboolean}
set a {GtkStyle *style, const gchar *color_name, GdkColor *color}
}
gtk_vscrollbar_new {
set t {GtkWidget*}
set a {GtkAdjustment *}
}
gtk_vscale_new_with_range {
set t {GtkWidget*}
set a {gdouble min, gdouble max, gdouble step}
}
gtk_widget_realize -
gtk_widget_destroy {
set a {GtkWidget *}
}
gtk_widget_set_size_request {
set a {GtkWidget *widget, gint width, gint height}
}
gtk_widget_size_request {
set a {GtkWidget *widget, GtkRequisition *requisition}
}
gtk_widget_style_get {
set a {GtkWidget *, const gchar *first_property_name, ...}
}
gdk_window_destroy {
set a {(GdkWindow *}
}
gdk_window_foreign_new {
set t {GdkWindow*}
set a {GdkNativeWindow}
}
gtk_window_new {
set t {GtkWidget*}
set a {GtkWindowType}
}
default {
puts " $f \{\n set t {}\n set a {}\n \}"
}
}
if {![string length $t]} {set t void}
if {![string length $a]} {set a void}
return [list $t $a]
};# get_function_spec
set HomeDir [file dirname [file normalize [info script]]]
set sources [file dirname $HomeDir]/generic
##
## Force the following symbols to exist!
##
foreach s {g_malloc0 g_malloc} {
set Symbols(GtkTtk_$s) 1
}
proc process {data} {
global Symbols
set skip {[^)(\",=]+}
foreach lib {gtk gdk xlib g} {
foreach s [regexp -inline -all "GtkTtk_${lib}_${skip}\\\s*\\\(" $data] {
set Symbols([string trim $s { ()}]) 1
}
}
}
foreach file [lsort [glob -directory $sources -type f *]] {
if {[string match *gtkTtk_Symbols* $file ]} continue
set fd [open $file]
fconfigure $fd -encoding utf-8
set data [read $fd]
close $fd
process $data
}
## Remove definitions...
foreach s {g_new0} {
unset -nocomplain Symbols(GtkTtk_$s)
}
switch $::tcl_platform(platform) {
windows {
set not_native {gdk_pixbuf_xlib_render_to_drawable xlib_rgb_init
gdk_x11_lookup_xdisplay}
}
unix {
set not_native {gdk_win32_hdc_get gdk_win32_hdc_release}
}
default {
}
}
foreach s $not_native {
unset -nocomplain Symbols(GtkTtk_$s)
}
##
## Generate file gtkTtk_Symbols.cpp
##
set fc [open $sources/gtkTtk_Symbols.cpp w]
fconfigure $fc -encoding iso8859-1
puts $fc \
{/*
* gtkTtk_Symbols.cpp
* ------------------------
*
* This file is part of the GtkTtk package, a ttk based theme that uses
* Gtk/GNOME for drawing.
*
* Copyright (C) 2004-2012 by:
* Georgios Petasis, petasis@iit.demokritos.gr,
* Software and Knowledge Engineering Laboratory,
* Institute of Informatics and Telecommunications,
* National Centre for Scientific Research (NCSR) "Demokritos",
* Aghia Paraskevi, 153 10, Athens, Greece.
*/
/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT! */
#include "gtkTtk_Symbols.h"
#ifdef GTKTTK_LOAD_GTK_DYNAMICALLY
#if (TCL_MAJOR_VERSION >= 8) && (TCL_MINOR_VERSION >= 6)
#define LOAD_SYMBOLS_WITH_TCL
#endif
#ifndef LOAD_SYMBOLS_WITH_TCL
#include <gmodule.h>
#endif
}
##
## Generate file gtkTtk_Symbols.h
##
set fd [open $sources/gtkTtk_Symbols.h w]
fconfigure $fd -encoding iso8859-1
puts $fd \
{/*
* gtkTtk_Symbols.h
* --------------------
*
* This file is part of the GtkTtk package, a ttk based theme that uses
* Gtk/GNOME for drawing.
*
* Copyright (C) 2004-2012 by:
* Georgios Petasis, petasis@iit.demokritos.gr,
* Software and Knowledge Engineering Laboratory,
* Institute of Informatics and Telecommunications,
* National Centre for Scientific Research (NCSR) "Demokritos",
* Aghia Paraskevi, 153 10, Athens, Greece.
*/
/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT! */
#ifndef _GTKTTK_SYMBOLS
#define _GTKTTK_SYMBOLS
#include "tcl.h"
#ifdef LOAD_SYMBOLS_WITH_TCL
#else
#include <glib.h>
#endif
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#ifndef __WIN32__
#include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
#include <gdk/gdkx.h>
#else
#include <gdk/gdkwin32.h>
#endif
#ifdef GTKTTK_LOAD_GTK_DYNAMICALLY}
puts $fd "extern \"C\" \{"
if {1} {
foreach symbol [lsort -dictionary [array names Symbols]] {
set gtk_s [string range $symbol 7 end]
set lib [symbol2lib $gtk_s]
foreach {t a} [get_function_spec $gtk_s] {break}
puts $fd " typedef $t (*Ptr_$gtk_s)($a);"
puts $fd " extern Ptr_$gtk_s $symbol;"
puts $fc "Ptr_$gtk_s $symbol = 0;"
lappend GTKSymbols($lib) $gtk_s;
#puts $fd "/*\n * $symbol: Stub for [string range $symbol 7 end]\n */"
#puts $fd "${symbol}() {\n GTKTTK_ENSURE\n}; /* $symbol */\n"
}
}
puts $fd "\}\n"
proc initialise_lib {lib} {
global fc fd GTKSymbols
puts $fd "extern int\
GtkTtk_InitialiseSymbols_${lib}(Tcl_Interp *interp, Tcl_Obj *file_name);"
puts $fc "\nint\
GtkTtk_InitialiseSymbols_${lib}(Tcl_Interp *interp, Tcl_Obj *file_name) \{"
puts $fc "#ifdef LOAD_SYMBOLS_WITH_TCL"
puts $fc " Tcl_LoadHandle loadHandle;"
puts $fc " int status;"
puts $fc " status = Tcl_LoadFile(interp, file_name, NULL, 0, NULL, &loadHandle);"
puts $fc " if (status != TCL_OK) return status;"
foreach s $GTKSymbols($lib) {
puts $fc " GtkTtk_$s = (Ptr_$s) Tcl_FindSymbol(interp, loadHandle, \"$s\");"
puts $fc " if (GtkTtk_$s == NULL) return TCL_ERROR;"
}
puts $fc "#else"
puts $fc " const char *fname = Tcl_GetString(file_name);"
puts $fc " GModule *m = g_module_open(fname, G_MODULE_BIND_LAZY);"
puts $fc " if (!m) {"
puts $fc " Tcl_SetResult(interp, (char *) \"cannot open module: \", TCL_STATIC);"
puts $fc " Tcl_AppendResult(interp, fname, (char *) NULL);"
puts $fc " return TCL_ERROR;"
puts $fc " }"
foreach s $GTKSymbols($lib) {
puts $fc " if (!g_module_symbol(m, \"$s\", (gpointer *) &GtkTtk_$s)) {"
puts $fc " Tcl_SetResult(interp, (char *) \"cannot find symbol: \", TCL_STATIC);"
puts $fc " Tcl_AppendResult(interp, (char *) \"$s\", (char *) NULL);"
puts $fc " return TCL_ERROR;"
puts $fc " }"
}
puts $fc "#endif"
puts $fc " return TCL_OK;\n\}; /* GtkTtk_InitialiseSymbols_${lib} */\n"
puts $fd "#define GTKTTK_LAST_SYMBOL_$lib GtkTtk_$s"
};# initialise_lib
foreach lib [lsort [array names GTKSymbols]] {
initialise_lib $lib
}
puts $fd {
#else /* GTKTTK_LOAD_GTK_DYNAMICALLY */
}
##
## Definitions for linking with GTK...
##
if {1} {
foreach symbol [lsort -dictionary [array names Symbols]] {
puts $fd "#define $symbol \\\n \
[string range $symbol 7 end]"
}
}
puts $fd \
{#endif /* GTKTTK_LOAD_GTK_DYNAMICALLY */
#endif /* _GTKTTK_SYMBOLS */}
close $fd
puts $fc \
{#endif /* GTKTTK_LOAD_GTK_DYNAMICALLY */}
close $fc
+906
View File
@@ -0,0 +1,906 @@
namespace eval ttk::theme::gtkTtk {
variable PreviewInterp {}
variable System
variable StyleToRc
proc loadLibraries {args} {
if {![initialiseLibrary required]} {return}
package require platform
set libs {gdk gdk_pixbuf glib gobject gtk}
switch -glob [::platform::generic] {
*_64 {
set paths {
/usr/lib64 /usr/lib /opt/gnome/lib /usr/openwin/lib /usr/lib/x86_64-linux-gnu
}
}
default {
set paths {
/usr/lib /opt/gnome/lib /usr/openwin/lib
}
}
}
set ext [info sharedlibextension]
switch $::tcl_platform(platform) {
windows {
set sep \;
set prefixes {{} lib}
set names {-win32-2.0* -2.0* 20* -win32* * {}}
}
unix {
set sep :
set prefixes {lib}
set names {-x11-2.0 -2.0 20 -x11 {}}
lappend libs gdk_pixbuf_xlib
}
default {}
}
if {[info exists ::env(LD_LIBRARY_PATH)]} {
foreach path [split $::env(LD_LIBRARY_PATH) $sep] {
set path [string trim $path]
if {[string length $path] && [file isdirectory $path]} {
lappend paths $path
}
}
}
if {[info exists ::env(ProgramFiles)]} {
foreach path [glob -nocomplain -dir $::env(ProgramFiles) *gtk*] {
set path $path/bin
if {[file isdirectory $path]} {
lappend paths [file normalize $path]
}
}
}
set loaded 0
foreach lib $libs {
set found 0
foreach name $names {
foreach prefix $prefixes {
foreach path $paths {
if {$found} {break}
if {![file isdirectory $path]} {continue}
foreach file [glob -nocomplain -dir $path -type f \
${prefix}${lib}${name}$ext] {
if {$found} {break}
if {[file exists $file]} {
if {[catch {initialiseLibrary $lib $file} symbol]} {
puts " => ERROR while initialising library $lib from $file : $symbol"
} else {
incr loaded; set found 1
break
}
};# if {[file exists $file]}
};# foreach file ...
};# foreach prefix $prefixes
};# foreach name $names
}
}
if {$loaded != [llength $libs]} {
error "Not all symbols loaded!"
}
};# loadLibraries
proc getSystemInfo {} {
global env
variable System
set System(HOME) {}
foreach var {HOME} {
if {[info exists env($var)]} {
set System($var) [file normalize $env($var)]
break
}
}
set System(GTK_RC_FILES) {}
if {[info exists env(GTK_RC_FILES)]} {
set System(GTK_RC_FILES) [file normalize $env(GTK_RC_FILES)]
} elseif {[info exists env(HOME)]} {
foreach rc [glob -nocomplain -dir $System(HOME) -type f .gtkrc*] {
lappend System(GTK_RC_FILES) $rc
}
set System(GTK_RC_FILES) [lsort -dictionary $System(GTK_RC_FILES)]
}
set System(TEMP) {}
foreach var {TEMP TMP temp tmp} {
if {[info exists env($var)]} {
set System(TEMP) [file normalize $env($var)]
break
}
}
if {![string length $System(TEMP)]} {
foreach dir {/tmp} {
if {[file isdirectory $dir] && [file writable $dir]} {
set System(TEMP) $dir; break
}
}
}
set System(DEFAULT_FILES) [gtkDirectory default_files]
};# getSystemInfo
## availableStyles_AsReturned:
# Returns the available styles...
proc availableStyles_AsReturned {} {
variable StyleToRc
variable System
set styles {}
foreach dir [list $System(HOME)/.themes [gtkDirectory theme]] {
foreach theme [glob -nocomplain -type d -directory $dir *] {
if {[file exists $theme/gtk-2.0/gtkrc]} {
set style [file tail $theme]
lappend styles $style
set StyleToRc($style) [file normalize $theme/gtk-2.0/gtkrc]
}
}
}
return $styles
};# availableStyles_AsReturned
proc updateLayouts {} {
## Variable "theme" should be defined by the C part of the extension.
variable theme
variable GtkHScrollbar
variable GtkVScrollbar
if {![info exists theme]} {return}
ttk::style theme use gtkTtk
# puts "============================================================"
# puts "Current Gtk Theme: [currentThemeName] ($theme)"
# puts "Tab alignment: [getStyleHint -SH_TabBar_Alignment]"
# puts "Tab base overlap: [getPixelMetric -PM_TabBarBaseOverlap]"
# puts "Tab overlap: [getPixelMetric -PM_TabBarTabOverlap]"
# foreach sc {SC_ScrollBarAddLine SC_ScrollBarSubLine
# SC_ScrollBarAddPage SC_ScrollBarSubPage
# SC_ScrollBarFirst SC_ScrollBarLast
# SC_ScrollBarSlider SC_ScrollBarGroove} {
# foreach {x y w h} [getSubControlMetrics -$sc] {break}
# puts "$sc: x=$x, y=$y, w=$w, h=$h"
# }
##
## Update the scrollbars layouts, according to information retrieved from
## the GTK style in use...
##
## has-backward-stepper: Display the standard backward arrow
## button.
## has-forward-stepper: Display the standard forward arrow
## button.
## has-secondary-backward-stepper: Display a second backward arrow button
## on the opposite end of the scrollbar.
## has-secondary-forward-stepper: Display a second forward arrow button
## on the opposite end of the scrollbar.
foreach widget {GtkHScrollbar GtkVScrollbar} {
foreach p {has-backward-stepper has-forward-stepper
has-secondary-backward-stepper has-secondary-forward-stepper
trough-under-steppers trough-side-details} {
set ${widget}($p) [widgetStyleProperty $widget $p boolean]
}
foreach p {arrow-displacement-x arrow-displacement-y
slider-width stepper-size stepper-spacing trough-border} {
set ${widget}($p) [widgetStyleProperty $widget $p integer]
}
}
# parray GtkHScrollbar
# puts "============================================================"
##
## Dynamically create the scrollbars layouts...
##
set Horizontal.Scrollbar.trough [list]
if {$GtkHScrollbar(has-backward-stepper)} {
lappend Horizontal.Scrollbar.trough \
Horizontal.Scrollbar.leftarrow -side left
}
if {$GtkHScrollbar(has-forward-stepper)} {
lappend Horizontal.Scrollbar.trough \
Horizontal.Scrollbar.rightarrow -side right
}
if {$GtkHScrollbar(has-secondary-backward-stepper)} {
lappend Horizontal.Scrollbar.trough \
Horizontal.Scrollbar.leftarrow -side right
}
if {$GtkHScrollbar(has-secondary-forward-stepper)} {
lappend Horizontal.Scrollbar.trough \
Horizontal.Scrollbar.rightarrow -side left
}
lappend Horizontal.Scrollbar.trough \
Horizontal.Scrollbar.thumb -side left -expand true -sticky we
ttk::style layout Horizontal.TScrollbar [list \
Horizontal.Scrollbar.trough -children ${Horizontal.Scrollbar.trough}]
set Vertical.Scrollbar.trough [list]
if {$GtkVScrollbar(has-backward-stepper)} {
lappend Vertical.Scrollbar.trough \
Vertical.Scrollbar.uparrow -side top
}
if {$GtkVScrollbar(has-forward-stepper)} {
lappend Vertical.Scrollbar.trough \
Vertical.Scrollbar.downarrow -side bottom
}
if {$GtkVScrollbar(has-secondary-backward-stepper)} {
lappend Vertical.Scrollbar.trough \
Vertical.Scrollbar.uparrow -side bottom
}
if {$GtkVScrollbar(has-secondary-forward-stepper)} {
lappend Vertical.Scrollbar.trough \
Vertical.Scrollbar.downarrow -side top
}
lappend Vertical.Scrollbar.trough \
Vertical.Scrollbar.thumb -side top -expand true -sticky ns
ttk::style layout Vertical.TScrollbar \
[list Vertical.Scrollbar.trough -children ${Vertical.Scrollbar.trough}]
}; # updateLayouts
proc updateStyles {} {
# puts [currentThemeColourKeys]
ttk::style theme settings gtkTtk {
ttk::style configure . \
-background [currentThemeColour bg(NORMAL)] \
-foreground [currentThemeColour fg(NORMAL)] \
-selectforeground [currentThemeColour fg(SELECTED)] \
-selectbackground [currentThemeColour bg(SELECTED)] \
;
# Configuration of the ttk::Treeview
ttk::style map Treeview -foreground [list \
active [currentThemeColour fg(ACTIVE)] \
disabled [currentThemeColour fg(INSENSITIVE)] \
focus [currentThemeColour fg(PRELIGHT)] \
pressed [currentThemeColour fg(ACTIVE)] \
selected [currentThemeColour fg(SELECTED)] \
] -background [list \
active [currentThemeColour bg(ACTIVE)] \
disabled [currentThemeColour bg(INSENSITIVE)] \
pressed [currentThemeColour bg(ACTIVE)] \
selected [currentThemeColour bg(SELECTED)] \
]
ttk::style map Treeview.Heading -foreground [list \
pressed [currentThemeColour bg(PRELIGHT)] \
] -background [list \
pressed [currentThemeColour fg(PRELIGHT)] \
]
ttk::style configure Treeview.Heading -relief raised \
-background [currentThemeColour bg(ACTIVE)]
ttk::style configure Treeview.Item -indicatormargins {1 2 1 1} -indicatorsize 5
ttk::style configure Treeview -fieldbackground [currentThemeColour bg(INSENSITIVE)]
set base_bg [ttk::style lookup . -background]
set base_fg [ttk::style lookup . -foreground]
set text_fg [ttk::style lookup Treeview -foreground]
set select_bg [ttk::style lookup . -selectbackground]
set select_fg [ttk::style lookup . -selectforeground]
option add *Menu.Background $base_bg
option add *Menu.Foreground $base_fg
option add *Menu.activeBackground $select_bg
option add *Menu.activeForeground $select_fg
option add *Menu.selectColor $text_fg
# ttk::style map TButton -foreground [list \
# ] -background [list \
# ]
ttk::style configure TButton -anchor center -width -11 -padding {2}
# ttk::style map TCheckbutton -foreground [list \
# ] -background [list \
# ]
ttk::style configure TCheckbutton -padding {0 1 0 1}
# ttk::style map TCombobox -foreground [list \
# ] -background [list \
# ]
ttk::style configure TCombobox -padding {1 2 1 1}
# ttk::style map TEntry -foreground [list \
# ] -background [list \
# ] -selectforeground [list \
# ] -selectbackground [list \
# ]
# ttk::style configure TEntry -padding {3 4 3 3}
ttk::style configure TLabelframe -background [currentThemeColour \
bg(NORMAL)] -labeloutside false -padding 0
# ttk::style map TMenubutton -foreground [list \
# ] -background [list \
# ] -selectforeground [list \
# ] -selectbackground [list \
# ]
ttk::style configure TMenubutton -width -11 -padding {3 2 3 2}
##
## Notebook widget properties:
## tab-pos: Which side of the notebook holds the tabs
## tab-border: Width of the border around the tab labels
## tab-hborder: Width of the horizontal border of tab labels
## tab-vborder: Width of the vertical border of tab labels
## homogeneous: Whether tabs should have homogeneous sizes
## tab-overlap: Size of tab overlap area
## tab-curvature: Size of tab curvature
## arrow-spacing: Scroll arrow spacing
##
set tab_overlap [widgetStyleProperty GtkNotebook tab-overlap integer]
set tab_curvature [widgetStyleProperty GtkNotebook tab-curvature integer]
set homogeneous [widgetProperty GtkNotebook homogeneous boolean]
set tab_pos [gtkEnum GtkPositionType \
[widgetProperty GtkNotebook tab-pos integer]]
set tab_base_overlap 0
# incr tab_overlap $tab_curvature
# puts "tab_overlap -> $tab_overlap"
# puts "tab_curvature -> $tab_curvature"
# puts "homogeneous -> $homogeneous"
# puts "tab_pos -> $tab_pos"
# # puts "tab_overlap=$tab_overlap, tab_base_overlap=$tab_base_overlap"
switch -exact $tab_pos {
GTK_POS_TOP {set tabposition nw}
GTK_POS_BOTTOM {set tabposition sw}
GTK_POS_LEFT {set tabposition nw}
GTK_POS_RIGHT {set tabposition ne}
default {set tabposition nw}
}
# tabmargins {left top right bottom}
ttk::style configure TNotebook -tabmargins \
[list $tab_overlap 0 $tab_overlap $tab_base_overlap] \
-tabposition $tabposition
ttk::style map TNotebook.Tab -expand [list selected \
[list $tab_overlap 0 $tab_overlap $tab_base_overlap]]
# ttk::style map TRadiobutton -foreground [list \
# ] -background [list \
# ]
ttk::style configure TRadiobutton -padding {0 1 0 1}
# ttk::style map Toolbutton -foreground [list \
# ] -background [list \
# ]
ttk::style configure Toolbutton -anchor center -padding {2 2 2 2}
ttk::style configure TPaned -background [currentThemeColour bg(NORMAL)]
ttk::style configure Horizontal.Sash -background [currentThemeColour \
bg(NORMAL)]
ttk::style configure Vertical.Sash -background [currentThemeColour \
bg(NORMAL)]
};# ttk::style theme settings gtkTtk
syncTkClassicPaletteAndFonts
# puts "\nPixel Metric Information:"
# foreach pm {PM_TabBarTabOverlap PM_TabBarTabHSpace
# PM_TabBarTabVSpace PM_TabBarBaseHeight
# PM_TabBarBaseOverlap PM_TabBarTabShiftHorizontal
# PM_TabBarTabShiftVertical PM_TabBarScrollButtonWidth
# PM_DefaultFrameWidth} {
# puts "$pm: [getPixelMetric -$pm]"
# }
};# updateStyles
## updateColourPalette:
# This procedure will be called from gtkTtk core each time a message is
# received from KDE to change the palette used.
proc updateColourPalette {} {
return
# puts >>updateColourPalette
foreach filename [kdeLocate_kdeglobals] {
if {[file exists $filename]} {
set file [open $filename]
while {[gets $file line] != -1} {
set line [string trim $line]
switch -glob $line {
contrast=* {
if {![info exists options(-contrast)]} {
set options(-contrast) [string range $line 9 end]
}
}
background=* {
if {![info exists options(-background)]} {
set options(-background) [kdeGetColourHex $line]
}
}
foreground=* {
if {![info exists options(-foreground)]} {
set options(-foreground) [kdeGetColourHex $line]
}
}
buttonBackground=* {
if {![info exists options(-buttonBackground)]} {
set options(-buttonBackground) [kdeGetColourHex $line]
}
}
buttonForeground=* {
if {![info exists options(-buttonForeground)]} {
set options(-buttonForeground) [kdeGetColourHex $line]
}
}
selectBackground=* {
if {![info exists options(-selectBackground)]} {
set options(-selectBackground) [kdeGetColourHex $line]
}
}
selectForeground=* {
if {![info exists options(-selectForeground)]} {
set options(-selectForeground) [kdeGetColourHex $line]
}
}
windowBackground=* {
if {![info exists options(-windowBackground)]} {
set options(-windowBackground) [kdeGetColourHex $line]
}
}
windowForeground=* {
if {![info exists options(-windowForeground)]} {
set options(-windowForeground) [kdeGetColourHex $line]
}
}
linkColor=* {
if {![info exists options(-linkColor)]} {
set options(-linkColor) [kdeGetColourHex $line]
}
}
visitedLinkColor=* {
if {![info exists options(-visitedLinkColor)]} {
set options(-visitedLinkColor) [kdeGetColourHex $line]
}
}
}
}
close $file
}
}
if {[info exists options]} {
eval setPalette [array get options]
}
};# updateColourPalette
## kdeStyleChangeNotification:
# This procedure will be called from gtkTtk core each time a message is
# received from KDE to change the style used.
proc kdeStyleChangeNotification {} {
return
# puts >>kdeStyleChangeNotification
## This method will be called each time a ClientMessage is received from
## KDE KIPC...
## Our Job is:
## a) To get the current style from KDE, and
## b) Apply it.
foreach filename [kdeLocate_kdeglobals] {
if {[file exists $filename]} {
set file [open $filename]
while {[gets $file line] != -1} {
set line [string trim $line]
if {[string match widgetStyle*=* $line]} {
# We have found the style!
set index [string first = $line]; incr index
set style [string range $line $index end]
if {[string length $style]} {
close $file
applyStyle $style
return
}
}
}
close $file
}
}
};# kdeStyleChangeNotification
## applyStyle:
# This procedure can be used to apply any available GTK+ style.
# Ths "style" parameter must be a string from the style names returned by
# ttk::theme::gtkTtk::availableStyles.
proc applyStyle {style} {
variable StyleToRc
variable System
if {![info exists StyleToRc($style)]} {
error "unknown GTK style: \"$style\""
}
##
## In order to force a style update, we need to create an rc file, and force
## GTK to load it...
##
set rc [file normalize $System(TEMP)/gtkrc.gtkTtk-[pid]]
set fd [open $rc w]
puts $fd {# -- THEME AUTO-WRITTEN DO NOT EDIT}
puts $fd "include \"$StyleToRc($style)\""
puts $fd "include \"$System(HOME)/.gtkrc.mine\""
puts $fd {# -- THEME AUTO-WRITTEN DO NOT EDIT}
close $fd
##
## Set it as the default file...
##
set default_files [gtkDirectory default_files]
gtkDirectory default_files [list $rc]
gtk_method gtk_rc_reparse_all_for_settings
gtk_method gtk_rc_reset_styles
#gtkDirectory default_files $default_files
puts $StyleToRc($style)
updateColourPalette
updateStyles
updateLayouts
event generate {} <<ThemeChanged>>
file delete -force $rc
};# applyStyle
## kdePaletteChangeNotification:
# This procedure will be called from gtkTtk core each time a message is
# received from KDE to change the palette used.
proc kdePaletteChangeNotification {} {
return
# puts >>kdePaletteChangeNotification
kdeStyleChangeNotification
};# kdePaletteChangeNotification
proc kdeGetColourHex {line} {
set index [string first = $line]; incr index
set value [string range $line $index end]
foreach {r g b} [split $value ,] {break}
return [format #%02X%02X%02X $r $g $b]
};# kdeGetColourHex
## createThemeConfigurationPanel:
# This method will create a configuration panel for the gtkTtk theme in the
# provided frame widget.
proc createThemeConfigurationPanel {dlgFrame} {
## The first element in our panel, is a combobox, with all the available
## GTK+ styles.
ttk::labelframe $dlgFrame.style_selection -text "GTK+ Style:"
ttk::combobox $dlgFrame.style_selection.style -state readonly
$dlgFrame.style_selection.style set [currentThemeName]
bind $dlgFrame.style_selection.style <<ThemeChanged>> \
{%W set [ttk::theme::gtkTtk::currentThemeName]}
bind $dlgFrame.style_selection.style <Enter> \
{%W configure -values [ttk::theme::gtkTtk::availableStyles]}
ttk::button $dlgFrame.style_selection.apply -text Apply -command \
"ttk::theme::gtkTtk::applyStyle \[$dlgFrame.style_selection.style get\]"
grid $dlgFrame.style_selection.style $dlgFrame.style_selection.apply \
-padx 2 -sticky snew
grid columnconfigure $dlgFrame.style_selection 0 -weight 1
pack $dlgFrame.style_selection -fill x -expand 0 -padx 2 -pady 2
## The second element of our panel, is a preview area. Since tile does not
## allow us to use a different theme for some widgets, we start a new wish
## session through a pipe, and we embed its window in our dialog. Then, we
## instrument this second wish through the pipe...
ttk::labelframe $dlgFrame.preview -text "Preview:"
variable PreviewInterp
if {[string length $PreviewInterp]} {
frame $dlgFrame.preview.container
pack [label $dlgFrame.preview.container.lbl \
-text {Preview Unavailable!}] -fill both -expand 1
} else {
frame $dlgFrame.preview.container -container 1 -height 250 -width 400
## Create a slave interpreter, and load gtkTtk. Widgets in this interp
## may be of a different widget style!
set PreviewInterp [interp create]
interp eval $PreviewInterp {package require Tk}
interp eval $PreviewInterp "
wm withdraw .
set auto_path \{$::auto_path\}
if {[catch {package require Ttk}]} {
package require tile
}
ttk::setTheme gtkTtk
# package require ttk::theme::gtkTtk
ttk::theme::gtkTtk::applyStyle \{[currentThemeName]\}
toplevel .widgets -height 250 -width 400 \
-use [winfo id $dlgFrame.preview.container]
ttk::theme::gtkTtk::selectStyleDlg_previewWidgets .widgets
"
bind $dlgFrame.preview.container <Destroy> \
"ttk::theme::gtkTtk::destroyThemeConfigurationPanel"
bind $dlgFrame.style_selection.style <<ComboboxSelected>> \
{ttk::theme::gtkTtk::updateThemeConfigurationPanel [%W get]}
}
pack $dlgFrame.preview.container -padx 0 -pady 0 -fill both -expand 1
pack $dlgFrame.preview -fill both -expand 1 -padx 2 -pady 2
};# createThemeConfigurationPanel
proc destroyThemeConfigurationPanel {} {
variable PreviewInterp
interp delete $PreviewInterp
set PreviewInterp {}
};# destroyThemeConfigurationPanel
proc updateThemeConfigurationPanel {style} {
variable PreviewInterp
interp eval $PreviewInterp "ttk::theme::gtkTtk::applyStyle \{$style\}"
};# updateThemeConfigurationPanel
proc selectStyleDlg_previewWidgets {{win {}}} {
## Create a notebook widget...
ttk::notebook $win.nb -padding 6
set tab1 [ttk::frame $win.nb.tab1]
$win.nb add $tab1 -text "Tab 1" -underline 4 -sticky news
set tab2 [ttk::frame $win.nb.tab2]
$win.nb add $tab2 -text "Tab 2" -underline 4 -sticky news
set tab3 [ttk::frame $win.nb.tab3]
$win.nb add $tab3 -text "Tab 3" -underline 4 -sticky news
set tab4 [ttk::frame $win.nb.tab4]
$win.nb add $tab4 -text "Tab 4" -underline 4 -sticky news
## Fill tab1...
#####################
ttk::panedwindow $tab1.panedwindow -orient horizontal
## Add a set of radiobuttons to the left...
ttk::labelframe $tab1.panedwindow.buttons -text " Button Group "
ttk::radiobutton $tab1.panedwindow.buttons.b1 -text "Radio button" \
-variable ttk::theme::gtkTtk::temp(selectionVariable) -value 1
ttk::radiobutton $tab1.panedwindow.buttons.b2 -text "Radio button" \
-variable ttk::theme::gtkTtk::temp(selectionVariable) -value 2
ttk::radiobutton $tab1.panedwindow.buttons.b3 -text "Radio button" \
-variable ttk::theme::gtkTtk::temp(selectionVariable) -value 3
ttk::separator $tab1.panedwindow.buttons.sep -orient horizontal
ttk::checkbutton $tab1.panedwindow.buttons.b4 -text "Checkbox"
$tab1.panedwindow.buttons.b4 state selected
set ttk::theme::gtkTtk::temp(selectionVariable) 1
grid $tab1.panedwindow.buttons.b1 -sticky snew -padx 2 -pady 2
grid $tab1.panedwindow.buttons.b2 -sticky snew -padx 2 -pady 2
grid $tab1.panedwindow.buttons.b3 -sticky snew -padx 2 -pady 2
grid $tab1.panedwindow.buttons.sep -sticky snew -padx 2 -pady 2
grid $tab1.panedwindow.buttons.b4 -sticky snew -padx 2 -pady 2
grid columnconfigure $tab1.panedwindow.buttons 0 -weight 1
$tab1.panedwindow add $tab1.panedwindow.buttons
## Add a set of other widgets (like progress, combo, scale, etc).
ttk::frame $tab1.panedwindow.widgets
ttk::progressbar $tab1.panedwindow.widgets.progress -orient horizontal \
-maximum 100 -variable ttk::theme::gtkTtk::temp(progress)
grid $tab1.panedwindow.widgets.progress -sticky snew -padx 2 -pady 2
ttk::scale $tab1.panedwindow.widgets.scale -orient horizontal -from 0 \
-to 100 -variable ttk::theme::gtkTtk::temp(progress)
set ttk::theme::gtkTtk::temp(progress) 70
grid $tab1.panedwindow.widgets.scale -sticky snew -padx 2 -pady 2
ttk::entry $tab1.panedwindow.widgets.entry -textvariable \
ttk::theme::gtkTtk::temp(entry)
set ttk::theme::gtkTtk::temp(entry) {Entry Widget}
grid $tab1.panedwindow.widgets.entry -sticky snew -padx 2 -pady 2
ttk::button $tab1.panedwindow.widgets.button -text Button
grid $tab1.panedwindow.widgets.button -sticky snew -padx 2 -pady 2
ttk::combobox $tab1.panedwindow.widgets.combo -values \
{{Selection 1} {Selection 2} {Selection 3} {Selection 4}}
$tab1.panedwindow.widgets.combo set {Selection 1}
grid $tab1.panedwindow.widgets.combo -sticky snew -padx 2 -pady 2
grid columnconfigure $tab1.panedwindow.widgets 0 -weight 1
$tab1.panedwindow add $tab1.panedwindow.widgets
grid $tab1.panedwindow -padx 2 -pady 2 -sticky snew
ttk::sizegrip $tab1.sg
ttk::scrollbar $tab1.hsb -orient horizontal
grid $tab1.hsb $tab1.sg -padx 2 -pady 2 -sticky snew
ttk::scrollbar $tab1.vsb -orient vertical
grid $tab1.vsb -row 0 -column 1 -padx 2 -pady 2 -sticky snew
grid columnconfigure $tab1 0 -weight 1
grid rowconfigure $tab1 0 -weight 1
## Fill tab2...
#####################
ttk::panedwindow $tab2.panedwindow -orient vertical
ttk::label $tab2.panedwindow.label -text {Label Widget}
$tab2.panedwindow add $tab2.panedwindow.label
ttk::treeview $tab2.panedwindow.tree -height 4
$tab2.panedwindow add $tab2.panedwindow.tree
grid $tab2.panedwindow -padx 2 -pady 2 -sticky snew
grid columnconfigure $tab2 0 -weight 1
grid rowconfigure $tab2 0 -weight 1
pack $win.nb -fill both -expand 1
};# selectStyleDlg_previewWidgets
proc availableStyles {} {
return [lsort -dictionary [availableStyles_AsReturned]]
};# availableStyles
## Test the theme configuration panel...
if {0 && ![info exists ::testConfigurationPanel]} {
toplevel .themeConfPanel
wm withdraw .themeConfPanel
wm title .themeConfPanel "GtkTtk Configuration Panel..."
frame .themeConfPanel.page
createThemeConfigurationPanel .themeConfPanel.page
update
pack .themeConfPanel.page -fill both -expand 1
wm deiconify .themeConfPanel
}
proc getStyleColourInformation {} {
foreach colour {fg_color bg_color base_color text_color
selected_bg_color selected_fg_color
tooltip_bg_color tooltip_fg_color} {
catch {set C($colour) [currentThemeColour $colour]} e
}
foreach prefix {fg bg base text} {
foreach state {NORMAL PRELIGHT ACTIVE SELECTED INSENSITIVE} {
set colour ${prefix}($state)
catch {set C($colour) [currentThemeColour $colour]} e
}
}
return [array get C]
};# getStyleColourInformation
variable prevClassicPalette
if {![info exists prevClassicPalette]} {
array set prevClassicPalette {}
}
proc syncTkClassicPaletteAndFonts {} {
variable prevClassicPalette
array set nextPal [list \
base_bg [currentThemeColour bg(NORMAL)] \
base_fg [currentThemeColour fg(NORMAL)] \
active_bg [currentThemeColour bg(PRELIGHT)] \
active_fg [currentThemeColour fg(PRELIGHT)] \
select_bg [currentThemeColour bg(SELECTED)] \
select_fg [currentThemeColour fg(SELECTED)] \
entry_bg [currentThemeColour base(NORMAL)] \
entry_fg [currentThemeColour text(NORMAL)] \
dis_fg [currentThemeColour fg(INSENSITIVE)] \
]
set base_bg $nextPal(base_bg)
set base_fg $nextPal(base_fg)
set active_bg $nextPal(active_bg)
set active_fg $nextPal(active_fg)
set select_bg $nextPal(select_bg)
set select_fg $nextPal(select_fg)
set entry_bg $nextPal(entry_bg)
set entry_fg $nextPal(entry_fg)
set dis_fg $nextPal(dis_fg)
set queue [list .]
while {[llength $queue] > 0} {
set w [lindex $queue 0]
set queue [lrange $queue 1 end]
if {![winfo exists $w]} {
continue
}
foreach child [winfo children $w] {
lappend queue $child
}
if {![catch {$w cget -style}]} {
continue
}
set cls [winfo class $w]
if {$cls in {Entry Text Listbox Canvas Spinbox}} {
set w_bg_role entry_bg
set w_fg_role entry_fg
} else {
set w_bg_role base_bg
set w_fg_role base_fg
}
foreach {opt role} [list \
-background $w_bg_role \
-foreground $w_fg_role \
-activebackground active_bg \
-activeforeground active_fg \
-selectbackground select_bg \
-selectforeground select_fg \
-disabledforeground dis_fg \
-highlightbackground base_bg \
-highlightcolor select_bg \
-insertbackground $w_fg_role \
-troughcolor active_bg] {
if {![info exists nextPal($role)] || $nextPal($role) eq ""} {
continue
}
if {[catch {$w configure $opt} cfg] == 0 && [llength $cfg] == 5} {
set def_val [lindex $cfg 3]
set cur_val [lindex $cfg 4]
set matched 0
if {$cur_val eq $def_val} {
set matched 1
} elseif {[catch {winfo rgb . $cur_val} cur_rgb] == 0 && \
[catch {winfo rgb . $def_val} def_rgb] == 0 && \
$cur_rgb eq $def_rgb} {
set matched 1
} elseif {[info exists prevClassicPalette($role)] && $prevClassicPalette($role) ne ""} {
set prev_val $prevClassicPalette($role)
if {$cur_val eq $prev_val} {
set matched 1
} elseif {[catch {winfo rgb . $cur_val} cur_rgb] == 0 && \
[catch {winfo rgb . $prev_val} prev_rgb] == 0 && \
$cur_rgb eq $prev_rgb} {
set matched 1
}
}
if {$matched} {
catch {$w configure $opt $nextPal($role)}
}
}
}
}
array set prevClassicPalette [array get nextPal]
foreach {pat val} [list \
*background $base_bg \
*foreground $base_fg \
*activeBackground $active_bg \
*activeForeground $active_fg \
*selectBackground $select_bg \
*selectForeground $select_fg \
*disabledForeground $dis_fg \
*highlightBackground $base_bg \
*highlightColor $select_bg \
*troughColor $active_bg \
*insertBackground $entry_fg \
*Entry.background $entry_bg \
*Entry.foreground $entry_fg \
*Text.background $entry_bg \
*Text.foreground $entry_fg \
*Listbox.background $entry_bg \
*Listbox.foreground $entry_fg \
*Canvas.background $entry_bg \
*Menu.background $base_bg \
*Menu.foreground $base_fg \
*Menu.activeBackground $select_bg \
*Menu.activeForeground $select_fg \
*Menu.selectColor $entry_fg] {
catch {option add $pat $val widgetDefault}
}
if {![catch {set font_spec [settingsProperty gtk-font-name string]}] && $font_spec ne ""} {
set parts [split [string trim $font_spec]]
if {[llength $parts] >= 2 && [string is integer -strict [lindex $parts end]]} {
set sz [lindex $parts end]
set fam [join [lrange $parts 0 end-1] " "]
foreach tkfont {TkDefaultFont TkTextFont TkFixedFont TkMenuFont TkHeadingFont} {
catch {font configure $tkfont -family $fam -size $sz}
}
}
}
};# syncTkClassicPaletteAndFonts
proc syncGtkRcSettings {} {
set home [expr {[info exists ::env(HOME)] ? $::env(HOME) : "/home/user"}]
set rcfile [file join $home .gtkrc-2.0]
if {![file readable $rcfile] && [file readable /etc/skel/.gtkrc-2.0]} {
set rcfile /etc/skel/.gtkrc-2.0
}
if {[file readable $rcfile]} {
set fd [open $rcfile r]
set data [read $fd]
close $fd
set tname ""
set fname ""
foreach line [split $data "\n"] {
set line [string trim $line]
if {[regexp {^gtk-theme-name\s*=\s*"?([^"]+)"?} $line -> m]} {
set tname [string trim $m]
} elseif {[regexp {^gtk-font-name\s*=\s*"?([^"]+)"?} $line -> m]} {
set fname [string trim $m]
}
}
gtkDirectory default_files [list $rcfile]
if {$tname ne ""} {
set themeRc [file join $home .themes $tname gtk-2.0 gtkrc]
if {![file readable $themeRc] && [file readable [file join /etc/skel .themes $tname gtk-2.0 gtkrc]]} {
set themeRc [file join /etc/skel .themes $tname gtk-2.0 gtkrc]
}
if {[file readable $themeRc]} {
gtkDirectory default_files [list $themeRc $rcfile]
}
catch {setSettingsString gtk-theme-name $tname}
variable theme $tname
}
if {$fname ne ""} {
catch {setSettingsString gtk-font-name $fname}
}
catch {gtk_method gtk_rc_reparse_all_for_settings}
catch {gtk_method gtk_rc_reset_styles}
}
};# syncGtkRcSettings
proc reloadCurrentGtkTheme {} {
getSystemInfo
availableStyles_AsReturned
syncGtkRcSettings
if {[ttk::style theme use] eq "gtkTtk"} {
updateLayouts
updateStyles
event generate . <<ThemeChanged>>
}
};# reloadCurrentGtkTheme
## Update layouts on load...
proc init {} {
getSystemInfo
availableStyles_AsReturned
syncGtkRcSettings
updateLayouts
updateStyles
};# init
}
+3
View File
@@ -0,0 +1,3 @@
package ifneeded ttk::theme::gtkTtk 0.9 [list load [file join $dir libgtkTtk0.9[info sharedlibextension]] gtkTtk]
package ifneeded ttk::theme::gtk 0.9 [list load [file join $dir libgtkTtk0.9[info sharedlibextension]] gtkTtk]
package ifneeded gtkTtk 0.9 [list load [file join $dir libgtkTtk0.9[info sharedlibextension]] gtkTtk]