1
1
use gtk:: prelude:: * ;
2
- use gtk:: { self , Widget , TreeView , ListStore , Button , ButtonBox , ButtonBoxStyle , Orientation , Builder , MenuItem , TreeSelection , TargetEntry , TargetFlags , Stack , ScrolledWindow } ;
2
+ use gtk:: { self , Widget , TreeView , ListStore , Builder , MenuItem , TreeSelection , TargetEntry , TargetFlags , Stack } ;
3
3
use gdk;
4
4
use uuid:: Uuid ;
5
5
use std:: collections:: HashMap ;
6
6
use std:: mem;
7
7
use sync:: UISender ;
8
- use widgets:: PropertyWindow ;
9
8
use sqa_backend:: codec:: { Command , Reply } ;
10
9
use sqa_backend:: mixer:: MixerConf ;
11
- use sqa_backend:: actions:: { ActionParameters , PlaybackState , OpaqueAction } ;
10
+ use sqa_backend:: actions:: { ActionParameters , OpaqueAction } ;
12
11
use sqa_backend:: actions:: audio:: AudioParams ;
13
12
use messages:: Message ;
14
13
15
14
pub mod audio;
16
15
pub mod fade;
16
+ pub mod template;
17
+ pub use self :: template:: UITemplate ;
17
18
use self :: audio:: AudioUI ;
18
19
use self :: fade:: FadeUI ;
19
20
pub enum ActionInternalMessage {
20
21
Create ( & ' static str ) ,
21
22
SelectionChanged ,
22
23
FilesDropped ( Vec < String > ) ,
23
24
BeginSelection ( Uuid ) ,
24
- CancelSelection
25
+ CancelSelection ,
26
+ ChangeCurPage ( Option < u32 > )
25
27
}
26
28
#[ derive( Clone ) ]
27
29
pub enum ActionMessageInner {
@@ -54,7 +56,8 @@ pub struct ActionController {
54
56
mload : MenuItem ,
55
57
mexec : MenuItem ,
56
58
mcreate_audio : MenuItem ,
57
- mcreate_fade : MenuItem
59
+ mcreate_fade : MenuItem ,
60
+ cur_page : Option < u32 >
58
61
}
59
62
pub trait ActionUI {
60
63
fn on_update ( & mut self , p : & OpaqueAction ) ;
@@ -66,65 +69,9 @@ pub trait ActionUI {
66
69
fn on_action_list ( & mut self , _l : & HashMap < Uuid , OpaqueAction > ) { }
67
70
fn on_selection_finished ( & mut self , _sel : Uuid ) { }
68
71
fn on_selection_cancelled ( & mut self ) { }
69
- }
70
- pub struct UITemplate {
71
- pub pwin : PropertyWindow ,
72
- pub close_btn : Button ,
73
- pub load_btn : Button ,
74
- pub execute_btn : Button ,
75
- pub tx : UISender ,
76
- pub popped_out : bool ,
77
- pub uu : Uuid
72
+ fn change_cur_page ( & mut self , Option < u32 > ) ;
78
73
}
79
74
80
- impl UITemplate {
81
- pub fn new ( uu : Uuid , tx : UISender ) -> Self {
82
- let mut pwin = PropertyWindow :: new ( ) ;
83
- let close_btn = Button :: new_with_mnemonic ( "_Close" ) ;
84
- let load_btn = Button :: new_with_mnemonic ( "_Load" ) ;
85
- let execute_btn = Button :: new_with_mnemonic ( "_Execute" ) ;
86
- let btn_box = ButtonBox :: new ( Orientation :: Horizontal ) ;
87
- let popped_out = false ;
88
- btn_box. set_layout ( ButtonBoxStyle :: Spread ) ;
89
- btn_box. pack_start ( & load_btn, false , false , 0 ) ;
90
- btn_box. pack_start ( & execute_btn, false , false , 0 ) ;
91
- pwin. append_button ( & close_btn) ;
92
- pwin. props_box . pack_start ( & btn_box, false , false , 0 ) ;
93
- UITemplate { pwin, close_btn, load_btn, execute_btn, popped_out, tx, uu }
94
- }
95
- pub fn get_container ( & mut self ) -> Option < Widget > {
96
- if self . pwin . window . is_visible ( ) {
97
- None
98
- }
99
- else {
100
- if !self . popped_out {
101
- self . pwin . props_box_box . remove ( & self . pwin . props_box ) ;
102
- self . popped_out = true ;
103
- }
104
- let swin = ScrolledWindow :: new ( None , None ) ;
105
- swin. add ( & self . pwin . props_box ) ;
106
- Some ( swin. upcast ( ) )
107
- }
108
- }
109
- pub fn edit_separately ( & mut self ) {
110
- if self . popped_out {
111
- self . popped_out = false ;
112
- self . pwin . props_box_box . pack_start ( & self . pwin . props_box , true , true , 0 ) ;
113
- }
114
- self . pwin . window . show_all ( ) ;
115
- }
116
- pub fn bind ( & mut self ) {
117
- let uu = self . uu ;
118
- let ref tx = self . tx ;
119
- use self :: ActionMessageInner :: * ;
120
- self . close_btn . connect_clicked ( clone ! ( tx; |_a| {
121
- tx. send_internal( ( uu, CloseButton ) ) ;
122
- } ) ) ;
123
- }
124
- pub fn on_update ( & mut self , p : & OpaqueAction ) {
125
- playback_state_update ( p, & mut self . pwin ) ;
126
- }
127
- }
128
75
#[ derive( Clone ) ]
129
76
struct TreeSelectGetter {
130
77
sel : TreeSelection ,
@@ -142,42 +89,6 @@ impl TreeSelectGetter {
142
89
None
143
90
}
144
91
}
145
- pub fn playback_state_update ( p : & OpaqueAction , pwin : & mut PropertyWindow ) {
146
- use self :: PlaybackState :: * ;
147
- match p. state {
148
- Inactive => pwin. update_header (
149
- "gtk-media-stop" ,
150
- "Inactive" ,
151
- & p. desc
152
- ) ,
153
- Unverified ( ref errs) => pwin. update_header (
154
- "gtk-dialog-error" ,
155
- "Incomplete" ,
156
- format ! ( "{} errors are present." , errs. len( ) )
157
- ) ,
158
- Loading => pwin. update_header (
159
- "gtk-refresh" ,
160
- "Loading" ,
161
- & p. desc
162
- ) ,
163
- Loaded => pwin. update_header (
164
- "gtk-home" ,
165
- "Loaded" ,
166
- & p. desc
167
- ) ,
168
- Paused => pwin. update_header (
169
- "gtk-media-pause" ,
170
- "Paused" ,
171
- & p. desc
172
- ) ,
173
- Active ( ref dur) => pwin. update_header (
174
- "gtk-media-play" ,
175
- format ! ( "Active ({}s)" , dur. as_secs( ) ) ,
176
- & p. desc
177
- ) ,
178
- _ => { }
179
- }
180
- }
181
92
macro_rules! bind_action_menu_items {
182
93
( $self: ident, $tx: ident, $tsg: ident, $( $name: ident => $res: ident) ,* ) => {
183
94
$(
@@ -206,11 +117,12 @@ impl ActionController {
206
117
let ctls = HashMap :: new ( ) ;
207
118
let opas = HashMap :: new ( ) ;
208
119
let tx = None ;
120
+ let cur_page = None ;
209
121
let cur_widget = None ;
210
122
let cur_sel = None ;
211
123
let mixer = Default :: default ( ) ;
212
124
build ! ( ActionController using b
213
- with ctls, opas, tx, mixer, cur_widget, cur_sel
125
+ with ctls, opas, tx, mixer, cur_widget, cur_sel, cur_page
214
126
get view, store, medit, mload, mexec, mdelete, mcreate_audio, mcreate_fade, sidebar)
215
127
}
216
128
pub fn bind ( & mut self , tx : & UISender ) {
@@ -356,6 +268,7 @@ impl ActionController {
356
268
self . sidebar . set_visible_child ( & w) ;
357
269
self . cur_widget = Some ( ( uu, w) ) ;
358
270
}
271
+ act. change_cur_page ( self . cur_page ) ;
359
272
}
360
273
}
361
274
else {
@@ -399,6 +312,9 @@ impl ActionController {
399
312
act. on_selection_cancelled ( ) ;
400
313
}
401
314
}
315
+ } ,
316
+ ChangeCurPage ( cp) => {
317
+ self . cur_page = cp;
402
318
}
403
319
}
404
320
}
0 commit comments