1 # application-aswitch.tcl --
2 #
3 # Creates an AutoSwitch object and gives it a frame to display in
4 #
5 # Copyright (c) 2000-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 Import enable
32
33 import Application AutoSwitch
34
35 Class AutoSwitchApplication -superclass Application
36
37 AutoSwitchApplication instproc showUsage {} {
38 puts stdout "usage: aswitch \[-cf <config file>\]"
39 }
40
41 AutoSwitchApplication instproc getFlags {argv} {
42 $self instvar configFile_
43
44 set configFile_ ""
45
46 set state flag
47 foreach arg $argv {
48 switch -exact -- $state {
49 flag {
50 switch -exact -- $arg {
51 -cf {
52 set state "cf"
53 }
54 -help {
55 $self showUsage
56 exit
57 }
58 default {
59 $self showUsage
60 exit
61 }
62 }
63 }
64 cf {
65 set configFile_ $arg
66 set state "flag"
67 }
68 }
69 }
70 }
71
72 AutoSwitchApplication instproc init {argv} {
73 $self instvar as_ configFile_
74 $self next $argv
75
76 $self getFlags $argv
77
78 $self initUI
79
80 set as_ [new AutoSwitch .asFrame $configFile_]
81 }
82
83 AutoSwitchApplication instproc initUI {} {
84 wm title . "AutoSwitch"
85 wm minsize . 200 100
86
87 # make auto switch frame
88 frame .asFrame
89 pack .asFrame -side top
90
91 # FIXME - test buttons
92 button .enable -text "Enable" -command "$self enableAutoSwitch"
93 pack .enable
94 button .disable -text "Disable" -command "$self disableAutoSwitch"
95 pack .disable
96 button .test -text "Test" -command "$self testProc"
97 pack .test
98
99 # make exit button
100 button .exit -text "Exit" -command "$self exitApp"
101 pack .exit -side bottom
102 }
103
104 AutoSwitchApplication instproc exitApp {} {
105 $self instvar as_
106
107 exit
108 }
109
110 AutoSwitchApplication instproc enableAutoSwitch {} {
111 $self instvar as_
112
113 $as_ enable
114 }
115
116 AutoSwitchApplication instproc disableAutoSwitch {} {
117 $self instvar as_
118
119 $as_ disable
120 }
121
122 AutoSwitchApplication instproc testProc {} {
123 $self instvar as_
124
125 $as_ setOutput htsr2
126 }
127
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.