1 ! Copyright (C) 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
7 USING: gadgets gadgets-books gadgets-workspace
8 generic kernel models scratchpad sequences syntax
11 DEFER: workspace-window
13 GENERIC: call-tool* ( arg tool -- )
15 GENERIC: tool-scroller ( tool -- scroller )
17 M: gadget tool-scroller drop f ;
19 GENERIC: tool-help ( tool -- topic )
21 M: gadget tool-help drop f ;
23 TUPLE: workspace book popup error-hook ;
25 : find-workspace [ workspace? ] find-parent ;
29 : find-tool ( class workspace -- index tool )
30 workspace-book gadget-children
31 [ tool-gadget class eq? ] find-with ;
33 : show-tool ( class workspace -- tool )
34 [ find-tool swap ] keep workspace-book control-model
37 : select-tool ( workspace class -- ) swap show-tool drop ;
39 : get-workspace* ( quot -- workspace )
40 [ dup workspace? [ over call ] [ drop f ] if ] find-window
41 [ nip dup raise-window world-gadget ]
42 [ workspace-window drop get-workspace* ] if* ; inline
44 : get-workspace ( -- workspace ) [ drop t ] get-workspace* ;
46 : call-tool ( arg class -- )
47 get-workspace show-tool call-tool* ;
49 : get-tool ( class -- gadget )
50 get-workspace find-tool nip tool-gadget ;
52 : find-messages ( -- gadget ) messages get-tool ;