Movie list view: if not in edit mode, use SelectionMode.NONE, not SINGLE
[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                 "Game-Show",
77                 "News",
78                 "Film-Noir"
79         };
80
81         public int field;
82
83         public string to_string () {
84                 string s = null;
85
86                 for (int i = 0; i < 28; i++) {
87                         if ((1 << i) in field) {
88                                 if (s == null) {
89                                         s = _genre_string[i];
90                                 } else {
91                                         s += ", " + _genre_string[i];
92                                 }
93                         }
94                 }
95
96                 return s;
97         }
98
99         public void set_bit (GenreType genre, bool enable) {
100                 if (enable)
101                         field |= (1 << genre);
102                 else
103                         field &= ~(1 << genre);
104         }
105
106         public bool get_bit (GenreType genre) {
107                 return (genre in field);
108         }
109
110         public static unowned string genre_string (GenreType genre) {
111                 return _genre_string[genre];
112         }
113
114 /*
115         public static int genre_bit (string genre) {
116                 int i = 0;
117
118                 do {
119                         if (_genres[i] == genre) {
120                                 return (1 << i);
121                         }
122                 } while (++i < 28);
123
124                 return 0;
125         }
126 */
127 }
128