Czech translation update (via transifex.net)
[cinaest] / src / source-dialog.vala
1 /* This file is part of Cinaest.
2  *
3  * Copyright (C) 2009 Philipp Zabel
4  *
5  * Cinaest is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Cinaest is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 using Hildon;
20 using Gtk;
21
22 class SourceDialog : Gtk.Dialog {
23         List<MovieSource> sources;
24
25         public SourceDialog (Gtk.Window window) {
26                 set_transient_for (window);
27                 set_title (_("Select movie source"));
28
29                 var content = (VBox) get_content_area ();
30                 content.set_size_request (-1, 5*70);
31
32                 sources = new List<MovieSource> ();
33                 foreach (Plugin plugin in CinaestProgram.plugins) {
34                         foreach (MovieSource source in plugin.get_sources ()) {
35                                 sources.append (source);
36                         }
37                 }
38
39                 var source_list = new SourceListView (sources, true, window);
40                 content.pack_start (source_list, true, true, 0);
41
42                 source_list.source_activated.connect (on_source_activated);
43         }
44
45         public void on_source_activated (MovieSource source) {
46                 int n = sources.index (source);
47
48                 response (n);
49         }
50
51         public new int run (ref MovieSource source) {
52                 int res = 0;
53
54                 show_all ();
55
56                 res = base.run ();
57                 destroy ();
58
59                 if (res >= 0) {
60                         source = sources.nth_data (res);
61                         return 0;
62                 }
63
64                 return res;
65         }
66 }
67