Implemented configuration tab in tiix
This commit is contained in:
+6
-6
@@ -1,8 +1,8 @@
|
|||||||
useragent "curl/7.54.1"
|
useragent "curl/7.54.2"
|
||||||
proxyhost ""
|
proxyhost ""
|
||||||
proxyport 0
|
proxyport "0"
|
||||||
tiix_font "Fira Code"
|
tiix_font "Fira Code"
|
||||||
tiix_fontsize 12
|
tiix_fontsize "12"
|
||||||
tiix_fgcolor #eee
|
tiix_fgcolor "#eee"
|
||||||
tiix_bgcolor #111
|
tiix_bgcolor "#111"
|
||||||
tiix_linkcolor cyan
|
tiix_linkcolor "cyan"
|
||||||
|
|||||||
@@ -20,28 +20,34 @@ source [file join $appdir "tiipost.tcl"]
|
|||||||
|
|
||||||
# populate general configuration
|
# populate general configuration
|
||||||
set cfg {}
|
set cfg {}
|
||||||
set textfont TkFixedFont
|
set tiix_font TkFixedFont
|
||||||
set textfontsize 10
|
set tiix_fontsize 10
|
||||||
set tiix_fgcolor black
|
set tiix_fgcolor black
|
||||||
set tiix_bgcolor white
|
set tiix_bgcolor white
|
||||||
set tiix_linkcolor blue
|
set tiix_linkcolor blue
|
||||||
|
set useragent ""
|
||||||
|
set proxyhost ""
|
||||||
|
set proxyport 0
|
||||||
set cfgfile [file join $appdir "config.txt"]
|
set cfgfile [file join $appdir "config.txt"]
|
||||||
if {[file exists $cfgfile]} {
|
if {[file exists $cfgfile]} {
|
||||||
set cfg [readfile $cfgfile]
|
set cfg [readfile $cfgfile]
|
||||||
if {[dict exists $cfg useragent]} {
|
if {[dict exists $cfg useragent]} {
|
||||||
::http::config -useragent [dict get $cfg useragent]
|
set useragent [dict get $cfg useragent]
|
||||||
|
::http::config -useragent $useragent
|
||||||
}
|
}
|
||||||
if {[dict exists $cfg proxyhost]} {
|
if {[dict exists $cfg proxyhost]} {
|
||||||
::http::config -proxyhost [dict get $cfg proxyhost]
|
set proxyhost [dict get $cfg proxyhost]
|
||||||
|
::http::config -proxyhost $proxyhost
|
||||||
}
|
}
|
||||||
if {[dict exists $cfg proxyport]} {
|
if {[dict exists $cfg proxyport]} {
|
||||||
::http::config -proxyport [dict get $cfg proxyport]
|
set proxyport [dict get $cfg proxyport]
|
||||||
|
::http::config -proxyport $proxyport
|
||||||
}
|
}
|
||||||
if {[dict exists $cfg tiix_font]} {
|
if {[dict exists $cfg tiix_font]} {
|
||||||
set textfont [dict get $cfg tiix_font]
|
set tiix_font [dict get $cfg tiix_font]
|
||||||
}
|
}
|
||||||
if {[dict exists $cfg tiix_fontsize]} {
|
if {[dict exists $cfg tiix_fontsize]} {
|
||||||
set textfontsize [dict get $cfg tiix_fontsize]
|
set tiix_fontsize [dict get $cfg tiix_fontsize]
|
||||||
}
|
}
|
||||||
if {[dict exists $cfg tiix_fgcolor]} {
|
if {[dict exists $cfg tiix_fgcolor]} {
|
||||||
set tiix_fgcolor [dict get $cfg tiix_fgcolor]
|
set tiix_fgcolor [dict get $cfg tiix_fgcolor]
|
||||||
@@ -55,7 +61,7 @@ if {[file exists $cfgfile]} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# create the font
|
# create the font
|
||||||
font create tiix_font -family "$textfont" -size $textfontsize -weight normal
|
font create tiix_font -family "$tiix_font" -size $tiix_fontsize -weight normal
|
||||||
|
|
||||||
# create the widget font
|
# create the widget font
|
||||||
font create tiix_widget_font -family "sans-serif" -size 11
|
font create tiix_widget_font -family "sans-serif" -size 11
|
||||||
@@ -240,6 +246,7 @@ pack .infoframe.author -side right
|
|||||||
grid .infoframe -row 1 -column 0 -sticky we
|
grid .infoframe -row 1 -column 0 -sticky we
|
||||||
|
|
||||||
# Viewer widgets
|
# Viewer widgets
|
||||||
|
|
||||||
ttk::frame .tabbar.r.addrframe
|
ttk::frame .tabbar.r.addrframe
|
||||||
ttk::frame .tabbar.r.addrframe.f
|
ttk::frame .tabbar.r.addrframe.f
|
||||||
ttk::frame .tabbar.r.addrframe.c
|
ttk::frame .tabbar.r.addrframe.c
|
||||||
@@ -289,6 +296,7 @@ grid rowconfigure .tabbar.r 0 -weight 0
|
|||||||
grid rowconfigure .tabbar.r 1 -weight 1
|
grid rowconfigure .tabbar.r 1 -weight 1
|
||||||
|
|
||||||
# Poster widgets
|
# Poster widgets
|
||||||
|
|
||||||
ttk::frame .tabbar.p.addrframe
|
ttk::frame .tabbar.p.addrframe
|
||||||
ttk::label .tabbar.p.addrframe.el -text "Echo name"
|
ttk::label .tabbar.p.addrframe.el -text "Echo name"
|
||||||
ttk::combobox .tabbar.p.addrframe.echo -width 25 -textvariable tiix_post_echoname -postcommand {
|
ttk::combobox .tabbar.p.addrframe.echo -width 25 -textvariable tiix_post_echoname -postcommand {
|
||||||
@@ -371,6 +379,33 @@ grid columnconfigure .tabbar.p 0 -weight 1
|
|||||||
grid rowconfigure .tabbar.p 0 -weight 0
|
grid rowconfigure .tabbar.p 0 -weight 0
|
||||||
grid rowconfigure .tabbar.p 1 -weight 1
|
grid rowconfigure .tabbar.p 1 -weight 1
|
||||||
|
|
||||||
|
# Configuration widgets
|
||||||
|
|
||||||
|
set rownum 0
|
||||||
|
dict for {cname cval} $cfg {
|
||||||
|
ttk::label .tabbar.c.cfglbl_$cname -text $cname
|
||||||
|
if {[string match *color $cname]} {
|
||||||
|
ttk::button .tabbar.c.cfgtxt_$cname -textvariable $cname -command "set $cname \[tk_chooseColor -initialcolor $cval -title {Choose color}\]"
|
||||||
|
} else {
|
||||||
|
ttk::entry .tabbar.c.cfgtxt_$cname -textvariable $cname
|
||||||
|
}
|
||||||
|
grid .tabbar.c.cfglbl_$cname -row $rownum -column 0 -sticky nsw -padx 5 -pady 5
|
||||||
|
grid .tabbar.c.cfgtxt_$cname -row $rownum -column 1 -sticky nswe -pady 5
|
||||||
|
incr rownum
|
||||||
|
}
|
||||||
|
ttk::button .tabbar.c.cfgsave -text "Save configuration" -command {
|
||||||
|
set answer [tk_messageBox -title "tiix config" -message "Save the config file?" -icon question -type yesno]
|
||||||
|
if {$answer eq "yes"} {
|
||||||
|
set cfgtext ""
|
||||||
|
dict for {cname cval} $cfg {
|
||||||
|
append cfgtext "$cname \"[set $cname]\"\n"
|
||||||
|
}
|
||||||
|
writefileln $cfgfile [string trim $cfgtext]
|
||||||
|
tk_messageBox -title "tiix config" -type ok -icon info -message "Configuration saved!" -detail "Restart tiix to see the changes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grid .tabbar.c.cfgsave -row $rownum -column 0 -sticky nsw -padx 5
|
||||||
|
grid columnconfigure .tabbar.c 1 -weight 1
|
||||||
|
|
||||||
# Custom keybindings
|
# Custom keybindings
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user