~tintou/appcenter/reduce-complexity

« back to all changes in this revision

Viewing changes to src/Core/AppCategories.vala

  • Committer: RabbitBot
  • Author(s): Daniel Foré, Corentin Noël
  • Date: 2016-05-05 01:49:06 UTC
  • mfrom: (174.1.9 category-cards)
  • Revision ID: rabbitbot-20160505014906-fgdqxod2c6dqhq17
Make categories into stylized cards

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
/*-
 
3
 * Copyright (c) 2014-2015 elementary LLC. (https://elementary.io)
 
4
 *
 
5
 * This program 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
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 *
 
18
 * Authored by: Corentin Noël <corentin@elementary.io>
 
19
 */
 
20
 
 
21
 
 
22
namespace AppCenter {
 
23
    public static Gee.TreeSet<Widgets.CategoryItem> get_app_categories () {
 
24
        var items = new Gee.TreeSet<Widgets.CategoryItem> ();
 
25
        items.add (get_audio_category ());
 
26
        items.add (get_development_category ());
 
27
        items.add (get_accessories_category ());
 
28
        items.add (get_office_category ());
 
29
        items.add (get_system_category ());
 
30
        items.add (get_video_category ());
 
31
        items.add (get_graphics_category ());
 
32
        items.add (get_games_category ());
 
33
        items.add (get_education_category ());
 
34
        items.add (get_internet_category ());
 
35
        items.add (get_science_category ());
 
36
        items.add (get_a11y_category ());
 
37
        return items;
 
38
    }
 
39
    
 
40
    public static Widgets.CategoryItem get_audio_category () {
 
41
        var category = new AppStream.Category ();
 
42
        category.set_name (_("Audio"));
 
43
        category.set_icon ("applications-audio-symbolic");
 
44
        category.get_included ().append ("Audio");
 
45
        var item = new Widgets.CategoryItem (category);
 
46
        item.add_category_class ("audio");
 
47
 
 
48
        return item;
 
49
    }
 
50
 
 
51
    public static Widgets.CategoryItem get_development_category () {
 
52
        var category = new AppStream.Category ();
 
53
        category.set_name (_("Development"));
 
54
        category.get_included ().append ("Development");
 
55
        category.get_included ().append ("IDE");
 
56
        var item = new Widgets.CategoryItem (category);
 
57
        item.add_category_class ("development");
 
58
 
 
59
        return item;
 
60
    }
 
61
 
 
62
    public static Widgets.CategoryItem get_accessories_category () {
 
63
        var category = new AppStream.Category ();
 
64
        category.set_name (_("Accessories"));
 
65
        category.set_icon ("applications-accessories");
 
66
        category.get_included ().append ("Utility");
 
67
        var item = new Widgets.CategoryItem (category);
 
68
        item.add_category_class ("accessories");
 
69
 
 
70
        return item;
 
71
    }
 
72
 
 
73
    public static Widgets.CategoryItem get_office_category () {
 
74
        var category = new AppStream.Category ();
 
75
        category.set_name (_("Office"));
 
76
        category.set_icon ("applications-office-symbolic");
 
77
        category.get_included ().append ("Office");
 
78
        var item = new Widgets.CategoryItem (category);
 
79
        item.add_category_class ("office");
 
80
 
 
81
        return item;
 
82
    }
 
83
 
 
84
    public static Widgets.CategoryItem get_system_category () {
 
85
        var category = new AppStream.Category ();
 
86
        category.set_name (_("System"));
 
87
        category.set_icon ("applications-system");
 
88
        category.get_included ().append ("System");
 
89
        var item = new Widgets.CategoryItem (category);
 
90
        item.add_category_class ("system");
 
91
 
 
92
        return item;
 
93
    }
 
94
 
 
95
    public static Widgets.CategoryItem get_video_category () {
 
96
        var category = new AppStream.Category ();
 
97
        category.set_name (_("Video"));
 
98
        category.set_icon ("applications-video-symbolic");
 
99
        category.get_included ().append ("Video");
 
100
        var item = new Widgets.CategoryItem (category);
 
101
        item.add_category_class ("video");
 
102
 
 
103
        return item;
 
104
    }
 
105
 
 
106
    public static Widgets.CategoryItem get_graphics_category () {
 
107
        var category = new AppStream.Category ();
 
108
        category.set_name (_("Graphics"));
 
109
        category.get_included ().append ("Graphics");
 
110
        var item = new Widgets.CategoryItem (category);
 
111
        item.add_category_class ("graphics");
 
112
 
 
113
        return item;
 
114
    }
 
115
 
 
116
    public static Widgets.CategoryItem get_games_category () {
 
117
        var category = new AppStream.Category ();
 
118
        category.set_name (_("GAMES"));
 
119
        category.get_included ().append ("Game");
 
120
        category.set_icon ("applications-games-symbolic");
 
121
        var item = new Widgets.CategoryItem (category);
 
122
        item.add_category_class ("games");
 
123
 
 
124
        return item;
 
125
    }
 
126
 
 
127
    public static Widgets.CategoryItem get_education_category () {
 
128
        var category = new AppStream.Category ();
 
129
        category.set_name (_("Education"));
 
130
        category.get_included ().append ("Education");
 
131
        var item = new Widgets.CategoryItem (category);
 
132
        item.add_category_class ("education");
 
133
 
 
134
        return item;
 
135
    }
 
136
 
 
137
    public static Widgets.CategoryItem get_internet_category () {
 
138
        var category = new AppStream.Category ();
 
139
        category.set_name (_("Internet"));
 
140
        category.set_icon ("applications-internet");
 
141
        category.get_included ().append ("Network");
 
142
        var item = new Widgets.CategoryItem (category);
 
143
        item.add_category_class ("internet");
 
144
 
 
145
        return item;
 
146
    }
 
147
 
 
148
    public static Widgets.CategoryItem get_science_category () {
 
149
        var category = new AppStream.Category ();
 
150
        // TRANSLATORS: We need to force the newline so that the buttons get a decent size
 
151
        category.set_name (_("Science &\nEngineering"));
 
152
        category.get_included ().append ("Science");
 
153
        var item = new Widgets.CategoryItem (category);
 
154
        item.add_category_class ("science");
 
155
 
 
156
        return item;
 
157
    }
 
158
 
 
159
    public static Widgets.CategoryItem get_a11y_category () {
 
160
        var category = new AppStream.Category ();
 
161
        // TRANSLATORS: We need to force the newline so that the buttons get a decent size
 
162
        category.set_name (_("UNIVERSAL\nACCESS"));
 
163
        category.set_icon ("applications-accessibility-symbolic");
 
164
        category.get_included ().append ("Accessibility");
 
165
        var item = new Widgets.CategoryItem (category);
 
166
        item.add_category_class ("accessibility");
 
167
 
 
168
        return item;
 
169
    }
 
170
}