finally figured out how to access defaults

This commit is contained in:
Seb Shader 2022-11-22 18:29:21 -08:00
parent c844e4aaf2
commit 3825fa37c1

View file

@ -91,22 +91,26 @@ proc ::color-themes::set_theme {name} {
pdsend "$wind map 0" pdsend "$wind map 0"
pdsend "$wind map 1" pdsend "$wind map 1"
set tmpcol [::pdtk_canvas::get_color txt_highlight $wind] set tmpcol [::pdtk_canvas::get_color txt_highlight $wind]
if {$tmpcol ne ""} { # idk about an easier way to set stuff to default
if {$tmpcol eq ""} {
set tmpcol [lindex [${wind}.c configure -selectbackground] 3]
}
${wind}.c configure -selectbackground $tmpcol ${wind}.c configure -selectbackground $tmpcol
}
set tmpcol [::pdtk_canvas::get_color canvas_fill $wind] set tmpcol [::pdtk_canvas::get_color canvas_fill $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
set tmpcol [lindex [${wind}.c configure -background] 3]
}
${wind}.c configure -background $tmpcol ${wind}.c configure -background $tmpcol
}
set tmpcol [::pdtk_canvas::get_color canvas_text_cursor $wind] set tmpcol [::pdtk_canvas::get_color canvas_text_cursor $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
set tmpcol [lindex [${wind}.c configure -insertbackground] 3]
}
${wind}.c configure -insertbackground $tmpcol ${wind}.c configure -insertbackground $tmpcol
}
#in Tk 8.6 the selectforeground is set by the os theme?
set tmpcol [::pdtk_canvas::get_color txt_highlight_front $wind] set tmpcol [::pdtk_canvas::get_color txt_highlight_front $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
${wind}.c configure -selectforeground $tmpcol set tmpcol [lindex [${wind}.c configure -selectforeground] 3]
} }
${wind}.c configure -selectforeground $tmpcol
} elseif {[winfo class $wind] eq "HelpBrowser"} { } elseif {[winfo class $wind] eq "HelpBrowser"} {
foreach child [winfo children .helpbrowser.c.f] { foreach child [winfo children .helpbrowser.c.f] {
if {[winfo class $child] eq "Listbox"} { if {[winfo class $child] eq "Listbox"} {
@ -117,25 +121,30 @@ proc ::color-themes::set_theme {name} {
# assume text window if text widget # assume text window if text widget
if {[winfo exists $wind.text]} { if {[winfo exists $wind.text]} {
set tmpcol [::pdtk_canvas::get_color text_window_text $wind] set tmpcol [::pdtk_canvas::get_color text_window_text $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
$wind.text configure -foreground $tmpcol set tmpcol [lindex [${wind}.text configure -foreground] 3]
} }
${wind}.text configure -foreground $tmpcol
set tmpcol [::pdtk_canvas::get_color text_window_cursor $wind] set tmpcol [::pdtk_canvas::get_color text_window_cursor $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
$wind.text configure -insertbackground $tmpcol set tmpcol [lindex [${wind}.text configure -insertbackground] 3]
} }
${wind}.text configure -insertbackground $tmpcol
set tmpcol [::pdtk_canvas::get_color text_window_fill $wind] set tmpcol [::pdtk_canvas::get_color text_window_fill $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
$wind.text configure -background $tmpcol set tmpcol [lindex [${wind}.text configure -background] 3]
} }
${wind}.text configure -background $tmpcol
set tmpcol [::pdtk_canvas::get_color text_window_highlight $wind] set tmpcol [::pdtk_canvas::get_color text_window_highlight $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
$wind.text configure -selectbackground $tmpcol set tmpcol [lindex [${wind}.text configure -selectbackground] 3]
} }
${wind}.text configure -selectbackground $tmpcol
set tmpcol [::pdtk_canvas::get_color text_window_hl_text $wind] set tmpcol [::pdtk_canvas::get_color text_window_hl_text $wind]
if {$tmpcol ne ""} { if {$tmpcol eq ""} {
$wind.text configure -selectforeground $tmpcol set tmpcol [lindex [${wind}.text configure -selectforeground] 3]
} }
${wind}.text configure -selectforeground $tmpcol
} }
} }
} }
@ -530,6 +539,11 @@ proc ::color-themes::opendialog {} {
bind .colortheme_dialog.theme_list.c <Shift-Button-5> \ bind .colortheme_dialog.theme_list.c <Shift-Button-5> \
{break} {break}
} }
# on xfwm and openbox <Enter> and <Leave> events are generated when the scroll wheel is used
# or the mouse is clicked, so <Leave> and <Enter> can't be used directly and I have to
# calculate the geometry for which canvas is hovered manually
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929090
# https://linux.debian.user.narkive.com/dXxiVBcM/strange-event-handling-problem-with-xfce-lxde-which-pkg-responsible
bind .colortheme_dialog <Motion><Leave> { bind .colortheme_dialog <Motion><Leave> {
#::pdwindow::post "leave\n" #::pdwindow::post "leave\n"
if {${::color-themes::hover_theme} ne "" && \ if {${::color-themes::hover_theme} ne "" && \