2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program 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.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
23
namespace Unity.MusicLens {
25
const string ICON_PATH = "/usr/share/icons/unity-icon-theme/places/svg/";
27
public class Daemon : GLib.Object
29
private Unity.Lens lens;
30
private BansheeScopeProxy banshee;
31
private RhythmboxScope rb;
35
lens = new Unity.Lens("/com/canonical/unity/lens/music", "music");
36
lens.search_in_global = true;
37
lens.search_hint = _("Search Music Collection");
38
lens.sources_display_name = _("Sources");
41
populate_categories ();
44
var app_check = new DesktopAppInfo ("banshee.desktop");
45
if (app_check != null)
47
banshee = new BansheeScopeProxy ();
48
lens.add_local_scope (banshee.scope);
51
app_check = new DesktopAppInfo ("rhythmbox.desktop");
52
if (app_check != null)
54
rb = new RhythmboxScope ();
55
lens.add_local_scope (rb.scope);
60
} catch (GLib.IOError e) {
61
stdout.printf ("error %s\n", e.message);
65
private void populate_filters ()
67
var filters = new GLib.List<Unity.Filter> ();
71
var filter = new MultiRangeFilter ("decade", _("Decade"));
73
filter.add_option ("0", _("Old"));
74
filter.add_option ("1960", _("60s"));
75
filter.add_option ("1970", _("70s"));
76
filter.add_option ("1980", _("80s"));
77
filter.add_option ("1990", _("90s"));
78
filter.add_option ("2000", _("00s"));
79
filter.add_option ("2010", _("10s"));
81
filters.append (filter);
86
var filter = new CheckOptionFilterCompact ("genre", _("Genre"));
87
filter.sort_type = OptionsFilter.SortType.DISPLAY_NAME;
89
filter.add_option (Genre.BLUES_ID, _("Blues"));
90
filter.add_option (Genre.CLASSIC_ID, _("Classic"));
91
filter.add_option (Genre.COUNTRY_ID, _("Country"));
92
filter.add_option (Genre.DISCO_ID, _("Disco"));
93
filter.add_option (Genre.FUNK_ID, _("Funk"));
94
filter.add_option (Genre.ROCK_ID, _("Rock"));
95
filter.add_option (Genre.METAL_ID, _("Metal"));
96
filter.add_option (Genre.HIPHOP_ID, _("Hip-hop"));
97
filter.add_option (Genre.HOUSE_ID, _("House"));
98
filter.add_option (Genre.NEWWAVE_ID, _("New-wave"));
99
filter.add_option (Genre.RANDB_ID, _("R&B"));
100
filter.add_option (Genre.PUNK_ID, _("Punk"));
101
filter.add_option (Genre.JAZZ_ID, _("Jazz"));
102
filter.add_option (Genre.POP_ID, _("Pop"));
103
filter.add_option (Genre.REGGAE_ID, _("Reggae"));
104
filter.add_option (Genre.SOUL_ID, _("Soul"));
105
filter.add_option (Genre.TECHNO_ID, _("Techno"));
106
filter.add_option (Genre.OTHER_ID, _("Other"));
108
filters.append (filter);
111
lens.filters = filters;
115
private void populate_categories ()
117
/* Offsets of categories must match up with the Category enum */
119
var categories = new GLib.List<Unity.Category> ();
120
var icon_dir = File.new_for_path (ICON_PATH);
122
var cat = new Unity.Category (_("Songs"),
123
new FileIcon (icon_dir.get_child ("group-songs.svg")));
124
categories.append (cat);
126
cat = new Unity.Category (_("Albums"),
127
new FileIcon (icon_dir.get_child ("group-albums.svg")));
128
categories.append (cat);
130
cat = new Unity.Category (_("Available for Purchase"),
131
new FileIcon (icon_dir.get_child ("group-purchase.svg")),
132
Unity.CategoryRenderer.FLOW);
133
categories.append (cat);
135
cat = new Unity.Category (_("Music"),
136
new FileIcon (icon_dir.get_child ("group-songs.svg")));
137
categories.append (cat);
139
cat = new Unity.Category (_("Radio"),
140
new FileIcon (icon_dir.get_child ("group-songs.svg")));
141
categories.append (cat);
143
lens.categories = categories;