diff options
author | csaba <csaba> | 2022-12-08 17:26:48 (GMT) |
---|---|---|
committer | csaba <csaba> | 2022-12-08 17:26:48 (GMT) |
commit | 33bd61da1b8f1cf06506b9c5cb54892de3ee558b (patch) | |
tree | 1e9d49e3401855db1ecfeaecda48d439d2f6b788 /library | |
parent | 95ac6a3201fa8b494b8f11d416dee777fcc008b6 (diff) | |
download | tk-33bd61da1b8f1cf06506b9c5cb54892de3ee558b.zip tk-33bd61da1b8f1cf06506b9c5cb54892de3ee558b.tar.gz tk-33bd61da1b8f1cf06506b9c5cb54892de3ee558b.tar.bz2 |
Replaced several pixmap icons with SVG images that are automatically scaled according to the display' scaling percentage
Diffstat (limited to 'library')
-rw-r--r-- | library/icons.tcl | 163 | ||||
-rw-r--r-- | library/scaling.tcl | 218 | ||||
-rw-r--r-- | library/tclIndex | 3 | ||||
-rw-r--r-- | library/tkfbox.tcl | 90 |
4 files changed, 310 insertions, 164 deletions
diff --git a/library/icons.tcl b/library/icons.tcl index 382efef..a88a362 100644 --- a/library/icons.tcl +++ b/library/icons.tcl @@ -1,132 +1,65 @@ # icons.tcl -- # # A set of stock icons for use in Tk dialogs. The icons used here -# were provided by the Tango Desktop project which provides a +# were provided by the Vimix Icon Theme project, which provides a # unified set of high quality icons licensed under the # Creative Commons Attribution Share-Alike license -# (https://creativecommons.org/licenses/by-sa/3.0/) +# (https://creativecommons.org/licenses/by-sa/4.0/) # -# See http://tango.freedesktop.org/Tango_Desktop_Project +# See https://github.com/vinceliuice/vimix-icon-theme # # Copyright © 2009 Pat Thoyts <patthoyts@users.sourceforge.net> +# Copyright © 2022 Harald Oehlmann <harald.oehlmann@elmicron.de> +# Copyright © 2022 Csaba Nemethi <csaba.nemethi@t-online.de> namespace eval ::tk::icons {} -image create photo ::tk::icons::warning -data { - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABSZJREFU - WIXll1toVEcYgL+Zc87u2Yu7MYmrWRuTJuvdi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uDPJEDwD4DVyKrv+UlZurxSorUWfMQC8oGOBc - CDHgC/Rdc4TD2BctIl5fT+bkyTahaXvOw8RPApiwd2Ju7hjZ2EhXSwvOkhKQcoADgIqKCioqKgYc - QW9LOnIEIxZDbWpiXCCABT9+FKAUxtm83pKMUEiLVVejLVqEtmTJB50LIdi2bRuFPbnRd7232efM - wbVuHR2PHjHR77dJXS8sg5mDAihweFJenmrevYvR1oazpGTQ6IQQaJqG7ClI/dd655IOHsSyLMSL - F6QFAib9nugEQClk2Xy+orTsbK3t1i3sa9ei5eQMGr0QgvLyci5evDiocyEEtsxMPNu30/nsGRO8 - XlVzu8NlkNvrV+0T/fHMZcusrtu3MeNx9PXrobUVq8cYQrw3TrRub1h9+v573Bs3Ej1zBvP5c/zp - 6dbLhoaTwPy+ANKCfF92thq7dg2A6JYt/fNlxGK8eUNSerryHEJHQT8K8V4A5ztojty8OeaLzZul - 1DSwLCzDANPEMozusWFgmWZ33288YK3/nGlixuM0v3xpWfDX0Z4i1VupXEWwIgRnJfhGPfQ+YsLr - +7DzNFwCuvqWyiRg7DSYoIBu9smPkYqEd4AwIN4ITUAL0A4Da7UC6ICdEfy2fUBMoAvo7GnWKNoe - mfwLcAuinuFNL7QAAAAASUVORK5CYII= +variable ::tk::svgFmt [list svg -scale [expr {[::tk::ScalingPct] / 100.0}]] + +image create photo ::tk::icons::error -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="32" height="32" version="1.1" viewBox="0 0 8.4669 8.4669" xmlns="http://www.w3.org/2000/svg"> + <g transform="matrix(1.4545 0 0 1.4545 5.0036 -423.15)"> + <rect transform="matrix(0,-1,-1,0,0,0)" x="-296.73" y="-2.381" width="5.821" height="5.821" rx="2.91" ry="2.91" fill="#d32f2f"/> + <path d="m-1.587 292.77 2.116 2.116m1e-3 -2.116-2.118 2.116" fill="none" stroke="#fff" stroke-linecap="square" stroke-width=".661"/> + </g> + </svg> } -image create photo ::tk::icons::error -format svg -data\ - {<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg width="32" height="32" viewBox="0 0 8.4666665 8.4666666" version="1.1" -id="svg5" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" -xmlns:svg="http://www.w3.org/2000/svg"><g id="layer1"><circle -style="fill:#d50c0c;stroke:#fc7572;stroke-width:0.25;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;fill-opacity:1;stroke-opacity:1" -id="path912" cy="4.2333331" cx="4.2333331" r="3.7041664" /><rect -style="fill:#efefef;fill-opacity:1;stroke:#efefef;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1" -id="rect4018" width="4.7624998" height="1.5875" x="1.8520833" y="3.4395833" -ry="3.7090308e-06" /></g></svg>} +image create photo ::tk::icons::warning -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <style id="current-color-scheme" type="text/css">.ColorScheme-NeutralText { + color:#f67400; + } + .ColorScheme-Text { + color:#232629; + }</style> + <g stroke-width="2"> + <circle transform="scale(1,-1)" cx="16" cy="-16" r="16" fill="#f67400"/> + <circle cx="16" cy="24" r="2" fill="#fff"/> + <path d="m14 20h4v-14h-4z" fill="#fff" fill-rule="evenodd"/> + </g> + </svg> +} -image create photo ::tk::icons::information -data { - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBI - WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gUdFDM4pWaDogAABwNJREFUWMPFlltsVNcVhv+199ln - bh7PjAdfMGNDcA04EKMkJlIsBVJVbRqlEVUrqyW0QAtFTVWpjVpFfamUF6K+tCTKQyXn0jaiShOr - bRqRoHJpEEoIEBucENuk2OViPB5f5j5zrvuc3YcMFQ8FPBFVj7S0paN91v+tf1/OAv7PD9UzeeCp - p0KRCrYyHtymoPrgySYAANdyBBr2Peu1agP+NrR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FYNdC1sIBYN1sCeq5Ca9bqtWcu9Fe3FDl - 9Uqvu3HLjfhvTUo85WzjhogAAAAASUVORK5CYII= +image create photo ::tk::icons::information -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <g stroke-width="2"> + <circle transform="scale(1,-1)" cx="16" cy="-16" r="16" fill="#2091df"/> + <circle transform="scale(1,-1)" cx="16" cy="-8" r="2" fill="#fff"/> + <path d="m14 12h4v14h-4z" fill="#fff" fill-rule="evenodd"/> + </g> + </svg> } -image create photo ::tk::icons::question -data { - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAACG5JREFU - WIXFl3twVdUVxn97n3Nubm7euZcghEdeBBICEQUFIgVECqIo1uJMp3WodqyjMzpjZ7TTh20cK31N - /2jL2FYdKXaqRcbnDKGpoBFaAY1BHgHMgyRKQkJy87yv3Nyzd/84594k1RlppzPumTXn3Dl3r/Wd - b31rrbPhS17iSv+4bl2t2ZFhrRGI7QKxRkMAyHEfjwgYEOgjNnpfcXjiSENDbeL/AqBoW22uGE/7 - MYL7yubN4MYVpVkrquaKqwJZ+LPTARgcjdIbHKOx+aI+9EH7WGvnZdA8q9PGf9b5eu3w/wygaPPO - h6Uhntxcsyj9/q+vtMrnBa6Is7ZPgzzzyvGJ/YfPRpWWj3fWff93/xWAonW1Xu3z/nVx6cxNTz74 - 1YzK4gIQjuN/nfyEEx9fIjgaYXAkhhAQyE3Hn5PBsvJZrF46l5I5+QB83NnP40+/FT7d1ltPOPrN - zoba2BcCWLy91hMOp72/bX1VxU/u3+BJ91i0fhrkuTcaaTzbjTQkhpQIIZBSIBApL1prtNYsryhk - xy1XUzonn1g8wVPPvh1/5dDpcz5f7LrmfbXxqfGM6eG1yCw+9uq2G6tW7nxoU5plGrzecJYnnnub - SwMhTNPAmmKmYWCaBoYpMQyJaRhIQ3IpGOKt4+1k+dK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YORoIX2OExVF26Px8NCZSN/5d0bb3mlK - JGIhHLpDwLAL4jPnxSs9nBqABXhddrw4XdRygSrABuKuxYBx9/6KDqlf2vo3PYe56vmkuwMAAAAA - SUVORK5CYII= +image create photo ::tk::icons::question -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="32" height="32" version="1" xmlns="http://www.w3.org/2000/svg"> + <g transform="matrix(.8 0 0 .8 -3.2 -3.2)"> + <circle cx="24" cy="24" r="20" fill="#78c367"/> + <path d="m26 38h-4v-4h4zm4.14-15.5-1.8 1.84c-1.44 1.46-2.34 2.66-2.34 5.66h-4v-1c0-2.2 0.9-4.2 2.34-5.66l2.48-2.52a3.91 3.91 0 0 0 1.18-2.82c0-2.2-1.8-4-4-4s-4 1.8-4 4h-4c0-4.42 3.58-8 8-8s8 3.58 8 8c0 1.76-0.72 3.36-1.86 4.5z" fill="#fff"/> + </g> + </svg> } diff --git a/library/scaling.tcl b/library/scaling.tcl new file mode 100644 index 0000000..5d6da4e --- /dev/null +++ b/library/scaling.tcl @@ -0,0 +1,218 @@ +# scaling.tcl -- +# +# Contains scaling-related utility procedures. +# +# Copyright © 2022 Csaba Nemethi <csaba.nemethi@t-online.de> + +# ::tk::ScalingPct -- +# +# Returns the display's current scaling percentage (100, 125, 150, 175, 200, or +# a greater integer value). + +namespace eval ::tk { + namespace export ScalingPct ScaleNum +} + +proc ::tk::ScalingPct {} { + variable scalingPct + if {[info exists scalingPct]} { + return $scalingPct + } + + set pct [expr {[tk scaling] * 75}] + set origPct $pct + + set onX11 [expr {[tk windowingsystem] eq "x11"}] + set usingSDL [expr {[info exists ::tk::sdltk] && $::tk::sdltk}] + + if {$onX11 && !$usingSDL} { + # + # Try to get the window scaling factor (1 or 2), partly + # based on https://wiki.archlinux.org/title/HiDPI + # + set factor 1 + if {[catch {exec ps -e | grep xfce4-session}] == 0} { ;# Xfce + if {[catch {exec xfconf-query -c xsettings \ + -p /Gdk/WindowScalingFactor} result] == 0} { + set factor $result + } + + # + # The DPI value can be set in the "Fonts" tab of the "Appearance" + # dialog or (on Linux Lite 5+) via the "HiDPI Settings" dialog. + # + } elseif {[catch {exec ps -e | grep mate-session}] == 0} { ;# MATE + if {[catch {exec gsettings get org.mate.interface \ + window-scaling-factor} result] == 0} { + if {$result == 0} { ;# means: "Auto-detect" + # + # Try to get the value of factor from the cursor size + # + if {[catch {exec xrdb -query | grep Xcursor.size} result] + == 0 && + [catch {exec gsettings get org.mate.peripherals-mouse \ + cursor-size} defCursorSize] == 0} { + set cursorSize [lindex $result 1] + set factor [expr {($cursorSize + $defCursorSize - 1) / + $defCursorSize}] + } + } else { + set factor $result + } + } + + # + # The DPI value can be set via the "Font Rendering Details" + # dialog, which can be opened using the "Details..." button + # in the "Fonts" tab of the "Appearance Preferences" dialog. + # + } elseif {[catch {exec gsettings get \ + org.gnome.settings-daemon.plugins.xsettings overrides} \ + result] == 0 && + [set idx \ + [string first "'Gdk/WindowScalingFactor'" $result]] >= 0} { + scan [string range $result $idx end] "%*s <%d>" factor + } + if {$factor > 2} { + set factor 2 + } + + # + # Save $factor because it is needed in the file ttk/fonts.tcl + # + variable windowScalingFactor $factor + + # + # Get the scaling percentage + # + if {$factor == 2} { + set pct 200 + } elseif {[catch {exec xrdb -query | grep Xft.dpi} result] == 0} { + # + # Derive the value of pct from that of the font DPI + # + set dpi [lindex $result 1] + set pct [expr {100 * $dpi / 96}] + } elseif {[catch {exec ps -e | grep gnome-session}] == 0 && + ![info exists ::env(WAYLAND_DISPLAY)] && + [catch {exec xrandr | grep " connected"} result] == 0 && + [catch {open $::env(HOME)/.config/monitors.xml} chan] == 0} { + # + # Update pct by scanning the file ~/.config/monitors.xml + # + ScanMonitorsFile $result $chan pct + } + } + + if {$pct < 100 + 12.5} { + set pct 100 + } elseif {$pct < 125 + 12.5} { + set pct 125 + } elseif {$pct < 150 + 12.5} { + set pct 150 + } elseif {$pct < 175 + 12.5} { + set pct 175 + } elseif {$pct < 200 + 12.5} { + set pct 200 + } else { + set pct [expr {int($pct + 0.5)}] + } + + if {$onX11 && $pct != 100 && $pct != $origPct} { + # + # Set Tk's scaling factor according to $pct + # + tk scaling [expr {$pct / 75.0}] + } + + set scalingPct $pct + return $pct +} + +# ::tk::ScaleNum -- +# +# Scales a nonnegative integer according to the display's current scaling +# percentage. +# +# Arguments: +# num - A nonnegative integer. + +proc ::tk::ScaleNum num { + set pct [::tk::ScalingPct] + set factor [expr {$num * $pct}] + set result [expr {$factor / 100}] + if {$factor % 100 >= 50} { + incr result + } + + return $result +} + +# ::tk::ScanMonitorsFile -- +# +# Updates the scaling percentage by scanning the file ~/.config/monitors.xml. +# +# Arguments: +# xrandrResult - The output of 'xrandr | grep " connected"'. +# chan - Returned from 'open ~/.config/monitors.xml'. +# pctName - The name of a variable containing the scaling percentage. + +proc ::tk::ScanMonitorsFile {xrandrResult chan pctName} { + upvar $pctName pct + + # + # Get the list of connected outputs reported by xrandr + # + set outputList {} + foreach line [split $xrandrResult "\n"] { + set idx [string first " " $line] + set output [string range $line 0 [incr idx -1]] + lappend outputList $output + } + set outputList [lsort $outputList] + + # + # Get the content of the file ~/.config/monitors.xml + # + set str [read $chan] + close $chan + + # + # Run over the file's "configuration" sections + # + set idx 0 + while {[set idx2 [string first "<configuration>" $str $idx]] >= 0} { + set idx2 [string first ">" $str $idx2] + set idx [string first "</configuration>" $str $idx2] + set config [string range $str [incr idx2] [incr idx -1]] + + # + # Get the list of connectors within this configuration + # + set connectorList {} + foreach {dummy connector} [regexp -all -inline \ + {<connector>([^<]+)</connector>} $config] { + lappend connectorList $connector + } + set connectorList [lsort $connectorList] + + # + # If $outputList and $connectorList are identical then set the + # variable pct to 100 or 200, depending on the max. scaling + # within this configuration, and exit the loop. (Due to the + # way fractional scaling is implemented in GNOME, we have to + # set the variable pct to 200 rather than 125, 150, or 175.) + # + if {[string compare $outputList $connectorList] == 0} { + set maxScaling 0.0 + foreach {dummy scaling} [regexp -all -inline \ + {<scale>([^<]+)</scale>} $config] { + if {$scaling > $maxScaling} { + set maxScaling $scaling + } + } + set pct [expr {$maxScaling > 1.0 ? 200 : 100}] + break + } + } +} diff --git a/library/tclIndex b/library/tclIndex index 06006cd..f064cea 100644 --- a/library/tclIndex +++ b/library/tclIndex @@ -144,6 +144,9 @@ set auto_index(::tk::ScaleEndDrag) [list source [file join $dir scale.tcl]] set auto_index(::tk::ScaleIncrement) [list source [file join $dir scale.tcl]] set auto_index(::tk::ScaleControlPress) [list source [file join $dir scale.tcl]] set auto_index(::tk::ScaleButton2Down) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScalingPct) [list source [file join $dir scaling.tcl]] +set auto_index(::tk::ScaleNum) [list source [file join $dir scaling.tcl]] +set auto_index(::tk::ScanMonitorsFile) [list source [file join $dir scaling.tcl]] set auto_index(::tk::ScrollButtonDown) [list source [file join $dir scrlbar.tcl]] set auto_index(::tk::ScrollButtonUp) [list source [file join $dir scrlbar.tcl]] set auto_index(::tk::ScrollSelect) [list source [file join $dir scrlbar.tcl]] diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index e1b42ed..a806397 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -24,61 +24,53 @@ namespace eval ::tk::dialog::file { # Create the images if they did not already exist. if {![info exists ::tk::Priv(updirImage)]} { - set ::tk::Priv(updirImage) [image create photo -data { - iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/gD+AP7rGN - SCAAAACXBIWXMAAA3WAAAN1gGQb3mcAAAACXZwQWcAAAAWAAAAFgDcxelYAAAENUlE - QVQ4y7WUbWiVZRjHf/f9POcc9+Kc5bC2aIq5sGG0XnTzNU13zAIlFMNc9CEhTCKwCC - JIgt7AglaR0RcrolAKg14+GBbiGL6xZiYyy63cmzvu7MVznnOe537rw7bDyvlBoT/c - n+6L3/3nf13XLZLJJP+HfICysjKvqqpq+rWKysvLR1tbW+11g+fPn/+bEGIe4KYqCs - Owu66u7oG2trah6wJrrRc0N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Pa9h0/RzwzMov2nGlG5TmW1YOzzlnSfL - mVnyGf19Q7lwZHBp+1fPtflAIgiC7389n9qkihP+lWyeqfUO15ZwQTqlw9H+o2cOvN - QJCAHEgEqgYnI0NyALjAJdyWQy7wMa6AEujUdzo3LjcAXwD/XCTKIRjWytAAAAJXRF - WHRjcmVhdGUtZGF0ZQAyMDA5LTA0LTA2VDIxOjI1OjQxLTAzOjAw8s+uCAAAACV0RV - h0bW9kaWZ5LWRhdGUAMjAwOC0wMS0wM1QxNTowODoyMS0wMjowMJEc/44AAAAZdEVY - dFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC + # Based on Vimix/22/actions/go-up.svg + # See https://github.com/vinceliuice/vimix-icon-theme + set ::tk::Priv(updirImage) [image create photo -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="22" height="22" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <defs> + <style id="current-color-scheme" type="text/css">.ColorScheme-Text { color:#565656; } .ColorScheme-Highlight { color:#5294e2; }</style> + </defs> + <g transform="translate(3 3)"> + <path class="ColorScheme-Text" d="m7 14v-8l-3.5 3.5-1.5-1.5 6-6 6 6-1.5 1.5-3.5-3.5v8z"/> + </g> + </svg> }] } if {![info exists ::tk::Priv(folderImage)]} { - set ::tk::Priv(folderImage) [image create photo -data { - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiA - AAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBl - Lm9yZ5vuPBoAAAHCSURBVDiNpZAxa5NRFIafc+9XLCni4BC6FBycMnbrLpkcgtDVX6 - C70D/g4lZX/4coxLlgxFkpiiSSUGm/JiXfveee45AmNlhawXc53HvPee55X+l2u/yP - qt3d3Tfu/viatwt3fzIYDI5uBJhZr9fr3TMzzAx3B+D09PR+v98/7HQ6z5fNOWdCCG - U4HH6s67oAVDlnV1UmkwmllBUkhMD29nYHeLuEAkyn06qU8qqu64MrgIyqYmZrkHa7 - 3drc3KTVahFjJITAaDRiPB4/XFlQVVMtHH5IzJo/P4EA4MyB+erWPQB7++zs7ccYvl - U5Z08pMW2cl88eIXLZeDUpXzsBkNQ5eP1+p0opmaoCTgzw6fjs6gLLsp58FB60t0Dc - K1Ul54yIEIMQ43Uj68pquDmCeJVztpwzuBNE2LgBoMVpslHMCUEAFgDVxQbzVAiA+a - K5uGPmmDtZF3VpoUm2ArhqQaRiUjcMf81p1G60UEVhcjZfAFTVUkrgkS+jc06mDX9n - vq4YhJ9nlxZExMwMEaHJRutOdWuIIsJFUoBSuTvHJ4YIfP46unV4qdlsjsBRZRtb/X - fHd5+C8+P7+J8BIoxFwovfRxYhnhxjpzEAAAAASUVORK5CYII= + # Based on Boston/16/places/folder.svg + # See https://github.com/thecheis/Boston-Icons + set ::tk::Priv(folderImage) [image create photo -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> + <title>Boston Icons</title> + <g> + <path d="m2 1a2 2 0 0 0-0.51758 0.068359 2 2 0 0 0-0.48242 0.19922 2 2 0 0 0-0.41406 0.31836 2 2 0 0 0-0.31836 0.41406 2 2 0 0 0-0.19922 0.48242 2 2 0 0 0-0.068359 0.51758v13h2 12 2v-11-0.96094a1 1 0 0 0 0-0.039062 1 1 0 0 0 0-0.0058594 1 1 0 0 0 0-0.0097656 1 1 0 0 0 0-0.0058594 1 1 0 0 0 0-0.0097656 1 1 0 0 0 0-0.0097656 1 1 0 0 0-0.001953-0.0097656 1 1 0 0 0 0-0.0058594 1 1 0 0 0 0-0.0097656 1 1 0 0 0 0-0.0097657 1 1 0 0 0-0.001953-0.0097656 1 1 0 0 0 0-0.0058594 1 1 0 0 0 0-0.0097656 1 1 0 0 0-0.001953-0.0097656 1 1 0 0 0 0-0.0058594 1 1 0 0 0-0.001953-0.0097656 1 1 0 0 0 0-0.0039063 1 1 0 0 0-0.025391-0.12891 1 1 0 0 0-0.042969-0.12305 1 1 0 0 0-0.058594-0.11719 1 1 0 0 0-0.072265-0.10938 1 1 0 0 0-0.085938-0.097656 1 1 0 0 0-0.097656-0.085938 1 1 0 0 0-0.10938-0.072266 1 1 0 0 0-0.11719-0.058594 1 1 0 0 0-0.12305-0.042969 1 1 0 0 0-0.12891-0.025391 1 1 0 0 0-0.13086-0.0078125h-6l-2-2h-5zm13.99 3.1367a1 1 0 0 1-0.001953 0.019531 1 1 0 0 0 0.001953-0.019531zm-0.019531 0.10547a1 1 0 0 1-0.005859 0.019531 1 1 0 0 0 0.005859-0.019531z" fill="#2d8cff"/> + <path d="m9.5996 4-2.5 3h-6.0996v8h14v-10.471a0.5 0.5 0 0 1-0.001953 0.011719 0.5 0.5 0 0 0 0.001953-0.011719 0.5 0.5 0 0 0 0-0.0019531 0.5 0.5 0 0 0 0-0.027344 0.5 0.5 0 0 0-0.007812-0.085938 0.5 0.5 0 0 0-0.021485-0.085938 0.5 0.5 0 0 0-0.037109-0.078125 0.5 0.5 0 0 0-0.050782-0.072266 0.5 0.5 0 0 0-0.060546-0.060547 0.5 0.5 0 0 0-0.072266-0.050781 0.5 0.5 0 0 0-0.078125-0.037109 0.5 0.5 0 0 0-0.085937-0.021484 0.5 0.5 0 0 0-0.085938-0.0078125h-4.9004z" fill="#6fb7ff"/> + <path d="m2 2a1 1 0 0 0-0.22266 0.025391 1 1 0 0 0-0.21094 0.074219 1 1 0 0 0-0.18945 0.11914 1 1 0 0 0-0.1582 0.1582 1 1 0 0 0-0.11914 0.18945 1 1 0 0 0-0.074219 0.21094 1 1 0 0 0-0.025391 0.22266v3h5.5l1.7734-2.127-1.873-1.873h-4.4004z" fill="#6fb7ff"/> + </g> + </svg> }] } if {![info exists ::tk::Priv(fileImage)]} { - set ::tk::Priv(fileImage) [image create photo -data { - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gva - eTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QQWFA84umAmQgAAANpJREFU - OMutkj1uhDAQhb8HSLtbISGfgZ+zbJkix0HmFhwhUdocBnMBGvqtTIqIFSReWKK8ai - x73nwzHrVt+zEMwwvH9FrX9TsA1trpqKy10+yUzME4jnjvAZB0LzXHkojjmDRNVyh3 - A+89zrlVwlKSqKrqVy/J8lAUxSZBSMny4ZLgp54iyPM8UPHGNJ2IomibAKDv+9VlWZ - bABbgB5/0WQgSSkC4PF2JF4JzbHN430c4vhAm0TyCJruuClefph4yCBCGT3T3Isoy/ - KDHGfDZNcz2SZIx547/0BVRRX7n8uT/sAAAAAElFTkSuQmCC + # Based on Boston/16/mimes/text-x-plain.svg + # See https://github.com/thecheis/Boston-Icons + set ::tk::Priv(fileImage) [image create photo -format $::tk::svgFmt -data { + <?xml version="1.0" encoding="UTF-8"?> + <svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> + <title>Boston Icons</title> + <path d="m2 0h9l3 3v13h-12z" fill="#556e81"/> + <path d="m3 1h7.5l2.5 2.5v11.5h-10z" fill="#fff"/> + <g fill="#556e81"> + <path d="m10 0v4h4v-1h-3v-3z"/> + <rect x="5" y="4" width="3" height="1"/> + <rect x="5" y="6" width="6" height="1"/> + <rect x="5" y="8" width="6" height="1"/> + <rect x="5" y="10" width="6" height="1"/> + <rect x="5" y="12" width="3" height="1"/> + </g> + </svg> }] } } |