~alecu/unity-lens-music/rework-credentials-check

« back to all changes in this revision

Viewing changes to src/daemon.vala

  • Committer: James Henstridge
  • Date: 2013-03-13 12:14:27 UTC
  • Revision ID: james@jamesh.id.au-20130313121427-u7ecqgphes3kev3r
Start moving music scopes over to libunity7 API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  
27
27
  public class Daemon : GLib.Object
28
28
  {
29
 
    private Unity.Lens lens;
30
29
    private BansheeScopeProxy banshee;
31
30
    private RhythmboxScope rb;
32
31
     
33
32
    construct
34
33
    {
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");
39
 
      lens.visible = true;
40
 
      
41
 
      populate_categories ();
42
 
      populate_filters();
43
 
 
44
34
      var app_check = new DesktopAppInfo ("banshee.desktop");
45
35
      if (app_check != null)
46
36
      {
47
37
        banshee = new BansheeScopeProxy ();
48
 
        lens.add_local_scope (banshee.scope);
 
38
        try {
 
39
          banshee.scope.export ();
 
40
        } catch (GLib.IOError e) {
 
41
          stdout.printf ("error %s\n", e.message);
 
42
        }
49
43
      }
50
44
 
51
45
      app_check = new DesktopAppInfo ("rhythmbox.desktop");
52
46
      if (app_check != null)
53
47
      {
54
48
        rb = new RhythmboxScope ();
55
 
        lens.add_local_scope (rb.scope);
56
 
      }
57
 
 
58
 
      try {
59
 
        lens.export ();
60
 
      } catch (GLib.IOError e) {
61
 
        stdout.printf ("error %s\n", e.message);
62
 
      }
63
 
    }
64
 
 
65
 
    private void populate_filters ()
66
 
    {
67
 
      var filters = new GLib.List<Unity.Filter> ();
68
 
 
69
 
      /* Decade filter */
70
 
      {
71
 
        var filter = new MultiRangeFilter ("decade", _("Decade"));
72
 
 
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"));
80
 
 
81
 
        filters.append (filter);
82
 
      }
83
 
 
84
 
      /* Genre filter */
85
 
      {
86
 
        var filter = new CheckOptionFilterCompact ("genre", _("Genre"));
87
 
        filter.sort_type = OptionsFilter.SortType.DISPLAY_NAME;
88
 
 
89
 
        filter.add_option (Genre.BLUES_ID, _("Blues"));
90
 
        filter.add_option (Genre.CLASSICAL_ID, _("Classical"));
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"));
107
 
 
108
 
        filters.append (filter);
109
 
      }
110
 
 
111
 
      lens.filters = filters;
112
 
    }
113
 
 
114
 
    // FIXME icons
115
 
    private void populate_categories ()
116
 
    {
117
 
      /* Offsets of categories must match up with the Category enum */
118
 
      
119
 
      var categories = new GLib.List<Unity.Category> ();
120
 
      var icon_dir = File.new_for_path (ICON_PATH);
121
 
 
122
 
      var cat = new Unity.Category (_("Songs"),
123
 
                                    new FileIcon (icon_dir.get_child ("group-songs.svg")));
124
 
      categories.append (cat);
125
 
 
126
 
      cat =  new Unity.Category (_("Albums"),
127
 
                                 new FileIcon (icon_dir.get_child ("group-albums.svg")));
128
 
      categories.append (cat);
129
 
 
130
 
      cat = new Unity.Category (_("More suggestions"),
131
 
                                new FileIcon (icon_dir.get_child ("group-treat-yourself.svg")),
132
 
                                Unity.CategoryRenderer.FLOW);
133
 
      categories.append (cat);
134
 
      
135
 
      cat = new Unity.Category (_("Music"),
136
 
                                new FileIcon (icon_dir.get_child ("group-songs.svg")));
137
 
      categories.append (cat);
138
 
 
139
 
      cat = new Unity.Category (_("Radio"),
140
 
                                new FileIcon (icon_dir.get_child ("group-songs.svg")));
141
 
      categories.append (cat);
142
 
 
143
 
      lens.categories = categories;
 
49
        try {
 
50
          rb.scope.export ();
 
51
        } catch (GLib.IOError e) {
 
52
          stdout.printf ("error %s\n", e.message);
 
53
        }
 
54
      }
144
55
    }
145
56
  }
146
57
} /* namespace */