aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2011-03-01 09:52:15 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2011-03-01 09:52:15 +0000
commit423fa3283a0d252ff284e9c0cd1f5484e5f94379 (patch)
treee9fcfe2d5749a0b48fdfc172b37b5459460cabe7
parent096df61dab2e4194d3af94d40d0d775b3e258705 (diff)
made everything settable via configuration file
svn path=/trunk/scripts/guiplugins/kiosk-plugin/; revision=14984
-rw-r--r--kiosk-plugin.tcl86
-rw-r--r--kiosk.cfg7
2 files changed, 71 insertions, 22 deletions
diff --git a/kiosk-plugin.tcl b/kiosk-plugin.tcl
index fb00870..a47d7c6 100644
--- a/kiosk-plugin.tcl
+++ b/kiosk-plugin.tcl
@@ -11,58 +11,100 @@ package require Tk
package require pdwindow 0.1
namespace eval ::kiosk:: {
- variable showmenu False
- variable fullscreen True
- variable hidemain True
- variable windowtitle "Pd KIOSK"
- variable hidepopup True
- variable scrollbars False
+ variable ::kiosk::config
}
-## hide the Pd window
-if { $::kiosk::hidemain } {
- set ::stderr 1
- wm state .pdwindow withdraw
-}
+## default values
+set ::kiosk::config(KioskNewWindow) False
+set ::kiosk::config(ShowMenu) False
+set ::kiosk::config(FullScreen) False
+set ::kiosk::config(HideMain) True
+set ::kiosk::config(WindowTitle) "Pd KIOSK"
+set ::kiosk::config(HidePopup) True
+set ::kiosk::config(ScrollBars) False
-## don't show popup menu on right-click
-if { $::kiosk::hidepopup } {
- proc ::pdtk_canvas::pdtk_canvas_popup {mytoplevel xcanvas ycanvas hasproperties hasopen} { }
-}
-if { $::kiosk::scrollbars } { } {
- proc ::pdtk_canvas::pdtk_canvas_getscroll {tkcanvas} { }
+proc ::kiosk::readconfig {{fname kiosk.cfg}} {
+ if {[file exists $fname]} {
+ set fp [open $fname r]
+ } else {
+ return False
+ }
+ while {![eof $fp]} {
+ set data [gets $fp]
+ set ::kiosk::config([lindex $data 0]) [lindex $data 1]
+ }
+
+
+ return True
}
# this is just an empty menu
menu .kioskmenu
+
+## KIOSkify a window
proc ::kiosk::makekiosk {mywin} {
+## refuse to kioskify the main Pd window
if { $mywin == ".pdwindow" } { return; }
-puts "KIOSKing $mywin"
+ puts "KIOSKing $mywin"
#puts "makekiosk $mywin"
#remove menu
- if { $::kiosk::showmenu } { } {
+ if { $::kiosk::config(ShowMenu) } { } {
$mywin configure -menu .kioskmenu;
}
# make fullscreen
- if { $::kiosk::fullscreen } {
+ if { $::kiosk::config(FullScreen) } {
wm attributes $mywin -fullscreen 1
}
# set the title of the window
# (makes mostly sense in non-fullscren...)
- if { $::kiosk::windowtitle != "" } {
- wm title $mywin $::kiosk::windowtitle
+ if { $::kiosk::config(WindowTitle) != "" } {
+ wm title $mywin $::kiosk::config(WindowTitle)
}
}
+
+
+######################################
+
+## read the default configuration file "kiosk.cfg"
+::kiosk::readconfig
+
+
+###### do some global KIOSK-settings
+
+## hide the Pd window
+if { $::kiosk::config(HideMain) } {
+ set ::stderr 1
+ wm state .pdwindow withdraw
+}
+
+## don't show popup menu on right-click
+if { $::kiosk::config(HidePopup) } {
+ proc ::pdtk_canvas::pdtk_canvas_popup {mytoplevel xcanvas ycanvas hasproperties hasopen} { }
+}
+
+if { $::kiosk::config(ScrollBars) } { } {
+ proc ::pdtk_canvas::pdtk_canvas_getscroll {tkcanvas} { }
+}
+
+# do the KIOSK-setting per existing window (those windows loaded at startup)
foreach kioskwin [array names ::loaded] {
::kiosk::makekiosk $kioskwin
}
+# do the KIOSKification for newly created windows as well
+if { $::kiosk::config(KioskNewWindow) } {
+ ## not the most elegant way: KIOSKifying each window as it get's focus
+ bind PatchWindow <FocusIn> {
+ ::kiosk::makekiosk %W;
+ }
+
+}
diff --git a/kiosk.cfg b/kiosk.cfg
new file mode 100644
index 0000000..43618df
--- /dev/null
+++ b/kiosk.cfg
@@ -0,0 +1,7 @@
+KioskNewWindow False
+ShowMenu False
+FullScreen True
+HideMain True
+WindowTitle "Pd KIOSK"
+HidePopup True
+ScrollBars False