]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/deploy/deploy.factor
Cleaning up USING: lists for new strict semantics
[factor.git] / basis / ui / tools / deploy / deploy.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: colors kernel models tools.deploy.config
4 tools.deploy.config.editor tools.deploy vocabs namespaces
5 models.mapping sequences system accessors fry ui.gadgets ui.render
6 ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
7 ui.gadgets.editors ui.gadgets.borders ui.gestures ui.commands assocs
8 ui.gadgets.tracks ui ui.tools.listener ui.tools.browser ;
9 IN: ui.tools.deploy
10
11 TUPLE: deploy-gadget < pack vocab settings ;
12
13 : bundle-name ( parent -- parent )
14     deploy-name get <model-field>
15     "Executable name:" label-on-left add-gadget ;
16
17 : deploy-ui ( parent -- parent )
18     deploy-ui? get
19     "Include user interface framework" <checkbox> add-gadget ;
20
21 : io-settings ( parent -- parent )
22     "Input/output support:" <label> add-gadget
23     deploy-io get deploy-io-options <radio-buttons> add-gadget ;
24
25 : reflection-settings ( parent -- parent )
26     "Reflection support:" <label> add-gadget
27     deploy-reflection get deploy-reflection-options <radio-buttons> add-gadget ;
28
29 : advanced-settings ( parent -- parent )
30     "Advanced:" <label> add-gadget
31     deploy-math? get "Rational and complex number support" <checkbox> add-gadget
32     deploy-threads? get "Threading support" <checkbox> add-gadget
33     deploy-unicode? get "Unicode character literal support" <checkbox> add-gadget
34     deploy-word-props? get "Retain all word properties" <checkbox> add-gadget
35     deploy-word-defs? get "Retain all word definitions" <checkbox> add-gadget
36     deploy-c-types? get "Retain all C types" <checkbox> add-gadget ;
37
38 : deploy-settings-theme ( gadget -- gadget )
39     { 10 10 } >>gap
40     1 >>fill ;
41
42 : <deploy-settings> ( vocab -- control )
43     default-config [ <model> ] assoc-map
44         [
45             <pile>
46             bundle-name
47             deploy-ui
48             io-settings
49             reflection-settings
50             advanced-settings
51
52             deploy-settings-theme
53             namespace <mapping> >>model
54         ]
55     bind ;
56
57 : find-deploy-gadget ( gadget -- deploy-gadget )
58     [ deploy-gadget? ] find-parent ;
59
60 : find-deploy-vocab ( gadget -- vocab )
61     find-deploy-gadget vocab>> ;
62
63 : find-deploy-config ( gadget -- config )
64     find-deploy-vocab deploy-config ;
65
66 : find-deploy-settings ( gadget -- settings )
67     find-deploy-gadget settings>> ;
68
69 : com-revert ( gadget -- )
70     dup find-deploy-config
71     swap find-deploy-settings set-control-value ;
72
73 : com-save ( gadget -- )
74     dup find-deploy-settings control-value
75     swap find-deploy-vocab set-deploy-config ;
76
77 : com-deploy ( gadget -- )
78     [ com-save ]
79     [ find-deploy-vocab '[ _ deploy ] \ deploy call-listener ]
80     [ close-window ]
81     tri ;
82
83 : com-help ( -- )
84     "ui.tools.deploy" com-browse ;
85
86 \ com-help H{
87     { +nullary+ t }
88 } define-command
89
90 : com-close ( gadget -- )
91     close-window ;
92
93 deploy-gadget "misc" "Miscellaneous commands" {
94     { T{ key-down f f "ESC" } com-close }
95 } define-command-map
96
97 deploy-gadget "toolbar" f {
98     { T{ key-down f f "F1" } com-help }
99     { f com-revert }
100     { f com-save }
101     { T{ key-down f f "RET" } com-deploy }
102 } define-command-map
103
104 : <deploy-gadget> ( vocab -- gadget )
105     deploy-gadget new
106       over >>vocab
107       vertical >>orientation
108       swap <deploy-settings> >>settings
109       dup settings>> add-gadget
110       dup <toolbar> { 10 10 } >>gap add-gadget
111     deploy-settings-theme
112     dup com-revert ;
113     
114 : deploy-tool ( vocab -- )
115     vocab-name
116     [ <deploy-gadget> { 10 10 } <border> ]
117     [ "Deploying “" "”" surround ] bi
118     open-window ;