~ubuntu-branches/ubuntu/oneiric/unity-lens-music/oneiric

« back to all changes in this revision

Viewing changes to src/musicstore-scope.vala

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2011-09-27 18:30:39 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: package-import@ubuntu.com-20110927183039-7n1jezqbf5ulsut5
Tags: 0.2.4-0ubuntu1
* New upstream release.
  - Clicking song/album in music lens loads in Banshee but does not
    focus on play queue (LP: #834933)
  - [FFE] Add support for U1 in the music lens (LP: #851691)
* debian/control:
  - makes u-l-m now recommends u-s-m as we want it by default now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical Ltd
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by Alex Launi <alex.launi@canonical.com>
 
17
 *
 
18
 */
 
19
 
 
20
using GLib;
 
21
 
 
22
namespace Unity.MusicLens {
 
23
  
 
24
  public class MusicStoreScopeProxy : SimpleScope
 
25
  {
 
26
    private MusicStoreCollection collection;
 
27
 
 
28
    public MusicStoreScopeProxy ()
 
29
    {
 
30
      base ();
 
31
 
 
32
      scope = new Unity.Scope ("/com/canonical/unity/scope/musicstore");
 
33
      scope.search_in_global = false;
 
34
      scope.activate_uri.connect (activate);
 
35
 
 
36
      base.initialize ();
 
37
 
 
38
      collection = new MusicStoreCollection ();
 
39
 
 
40
      try {
 
41
        scope.export ();
 
42
      } catch (GLib.IOError e) {
 
43
        stdout.printf (e.message);
 
44
      }
 
45
    }
 
46
 
 
47
    protected override int num_results_without_search { get { return 100; } }
 
48
    protected override int num_results_global_search { get { return 20; } }
 
49
    protected override int num_results_lens_search { get { return 50; } }
 
50
 
 
51
    public Unity.ActivationResponse activate (string uri)
 
52
    {
 
53
      /* launch the music store streaming client  or the webstore or whatevz */
 
54
        try {
 
55
          AppInfo.launch_default_for_uri (uri, null);
 
56
        } catch (GLib.Error e) {
 
57
          warning ("Failed to open uri %s. %s", uri, e.message);
 
58
        }
 
59
        return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);  
 
60
    }
 
61
 
 
62
    public override void perform_search (LensSearch? search, Dee.Model results_model,
 
63
                                         List<FilterParser> filters, int max_results = -1)
 
64
    {
 
65
      if (search_is_invalid (search))
 
66
        return;
 
67
      
 
68
      try {
 
69
        debug ("model has %u rows before search", results_model.get_n_rows ());
 
70
        collection.search (search, results_model, filters, max_results);          
 
71
        debug ("model has %u rows after search", results_model.get_n_rows ());
 
72
      } catch (IOError e) {
 
73
        warning ("Failed to search for '%s': %s", search.search_string, e.message);
 
74
      }
 
75
    }
 
76
 
 
77
  }
 
78
}