1/* This file is part of Gradio.
2 *
3 * Gradio is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * Gradio is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with Gradio.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17using Gtk;
18
19namespace Gradio{
20
21	public class MainBox : Gd.MainBox{
22
23		public signal void collection_clicked(Collection collection);
24
25		public MainBox(){
26			Object(box_type: Gd.MainBoxType.ICON);
27
28			this.set_show_primary_text(true);
29			this.set_show_secondary_text(true);
30			this.set_vexpand(true);
31			this.show_all();
32
33			(((Frame)this.get_child()).get_child()).margin_top = 12;
34			(((Frame)this.get_child()).get_child()).margin_bottom = 12;
35			Frame frame = (Frame)this.get_child();
36			frame.set_shadow_type(ShadowType.NONE);
37
38			connect_signals();
39		}
40
41		private void connect_signals(){
42			this.selection_mode_request.connect(() => {
43				this.set_selection_mode(true);
44			});
45
46			this.item_activated.connect((t,a) => {
47				Gd.MainBoxItem item = (Gd.MainBoxItem)a;
48				if(!Util.is_collection_item(int.parse(item.id))){
49					App.window.details_box.set_station((RadioStation)item);
50					if(App.player.station == (RadioStation)item)
51						App.player.toggle_play_stop();
52					else
53						App.player.station = (RadioStation)item;
54				}else{
55					App.window.details_box.set_collection((Collection)item);
56					collection_clicked((Collection)item);
57				}
58			});
59		}
60	}
61}
62