Czech translation update (via transifex.net)
[cinaest] / src / genres.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 public enum GenreType {
20         ANIMATION = 0,
21         ADULT,
22         DRAMA,
23         SHORT,
24         ACTION,
25         FANTASY,
26         HORROR,
27         SCIFI,
28         THRILLER,
29         BIOGRAPHY,
30         COMEDY,
31         MUSICAL,
32         ADVENTURE,
33         DOCUMENTARY,
34         CRIME,
35         MUSIC,
36         SPORT,
37         ROMANCE,
38         HISTORY,
39         MYSTERY,
40         WAR,
41         WESTERN,
42         FAMILY,
43         TALKSHOW,
44         REALITYTV,
45         GAMESHOW,
46         NEWS,
47         FILMNOIR
48 }
49
50 public struct Genres {
51         private static const string[] _genre_string = {
52                 "Animation",
53                 "Adult",
54                 "Drama",
55                 "Short",
56                 "Action",
57                 "Fantasy",
58                 "Horror",
59                 "Sci-Fi",
60                 "Thriller",
61                 "Biography",
62                 "Comedy",
63                 "Musical",
64                 "Adventure",
65                 "Documentary",
66                 "Crime",
67                 "Music",
68                 "Sport",
69                 "Romance",
70                 "History",
71                 "Mystery",
72                 "War",
73                 "Western",
74                 "Family",
75                 "Talk-Show",
76                 "Reality-TV",
77                 "Game-Show",
78                 "News",
79                 "Film-Noir"
80         };
81
82         public int field;
83
84         public string to_string () {
85                 string s = null;
86
87                 for (int i = 0; i < 28; i++) {
88                         if ((1 << i) in field) {
89                                 if (s == null) {
90                                         s = _genre_string[i];
91                                 } else {
92                                         s += ", " + _genre_string[i];
93                                 }
94                         }
95                 }
96
97                 return s;
98         }
99
100         public void set_bit (GenreType genre, bool enable) {
101                 if (enable)
102                         field |= (1 << genre);
103                 else
104                         field &= ~(1 << genre);
105         }
106
107         public bool get_bit (GenreType genre) {
108                 return (genre in field);
109         }
110
111         public static unowned string genre_string (GenreType genre) {
112                 return _genre_string[genre];
113         }
114
115         public static int genre_bit (string genre) {
116                 int i = 0;
117
118                 do {
119                         if (_genre_string[i] == genre) {
120                                 return (1 << i);
121                         }
122                 } while (++i < 28);
123
124                 return 0;
125         }
126 }
127