~ricmm/+junk/unity-lens_music-sc

« back to all changes in this revision

Viewing changes to src/rhythmbox-scope.c

  • Committer: Ricardo Mendoza
  • Date: 2012-09-05 14:20:15 UTC
  • Revision ID: ricardo.mendoza@canonical.com-20120905142015-prem6hiyfshwgm8q
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* rhythmbox-scope.c generated by valac 0.16.1, the Vala compiler
 
2
 * generated from rhythmbox-scope.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2011 Canonical Ltd
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License version 3 as
 
9
 * published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 * Authored by Alex Launi <alex.launi@canonical.com>
 
20
 *
 
21
 */
 
22
 
 
23
#include <glib.h>
 
24
#include <glib-object.h>
 
25
#include <gio/gio.h>
 
26
#include <unity.h>
 
27
#include <stdlib.h>
 
28
#include <string.h>
 
29
#include <glib/gi18n-lib.h>
 
30
#include <float.h>
 
31
#include <math.h>
 
32
 
 
33
 
 
34
#define UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE (unity_music_lens_simple_scope_get_type ())
 
35
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScope))
 
36
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScopeClass))
 
37
#define UNITY_MUSIC_LENS_IS_SIMPLE_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE))
 
38
#define UNITY_MUSIC_LENS_IS_SIMPLE_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE))
 
39
#define UNITY_MUSIC_LENS_SIMPLE_SCOPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, UnityMusicLensSimpleScopeClass))
 
40
 
 
41
typedef struct _UnityMusicLensSimpleScope UnityMusicLensSimpleScope;
 
42
typedef struct _UnityMusicLensSimpleScopeClass UnityMusicLensSimpleScopeClass;
 
43
typedef struct _UnityMusicLensSimpleScopePrivate UnityMusicLensSimpleScopePrivate;
 
44
 
 
45
#define UNITY_MUSIC_LENS_TYPE_FILTER_PARSER (unity_music_lens_filter_parser_get_type ())
 
46
#define UNITY_MUSIC_LENS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParser))
 
47
#define UNITY_MUSIC_LENS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
48
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
49
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
50
#define UNITY_MUSIC_LENS_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
51
 
 
52
typedef struct _UnityMusicLensFilterParser UnityMusicLensFilterParser;
 
53
typedef struct _UnityMusicLensFilterParserClass UnityMusicLensFilterParserClass;
 
54
 
 
55
#define UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE (unity_music_lens_rhythmbox_scope_get_type ())
 
56
#define UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE, UnityMusicLensRhythmboxScope))
 
57
#define UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE, UnityMusicLensRhythmboxScopeClass))
 
58
#define UNITY_MUSIC_LENS_IS_RHYTHMBOX_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE))
 
59
#define UNITY_MUSIC_LENS_IS_RHYTHMBOX_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE))
 
60
#define UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE, UnityMusicLensRhythmboxScopeClass))
 
61
 
 
62
typedef struct _UnityMusicLensRhythmboxScope UnityMusicLensRhythmboxScope;
 
63
typedef struct _UnityMusicLensRhythmboxScopeClass UnityMusicLensRhythmboxScopeClass;
 
64
typedef struct _UnityMusicLensRhythmboxScopePrivate UnityMusicLensRhythmboxScopePrivate;
 
65
 
 
66
#define UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION (unity_music_lens_rhythmbox_collection_get_type ())
 
67
#define UNITY_MUSIC_LENS_RHYTHMBOX_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION, UnityMusicLensRhythmboxCollection))
 
68
#define UNITY_MUSIC_LENS_RHYTHMBOX_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION, UnityMusicLensRhythmboxCollectionClass))
 
69
#define UNITY_MUSIC_LENS_IS_RHYTHMBOX_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION))
 
70
#define UNITY_MUSIC_LENS_IS_RHYTHMBOX_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION))
 
71
#define UNITY_MUSIC_LENS_RHYTHMBOX_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_COLLECTION, UnityMusicLensRhythmboxCollectionClass))
 
72
 
 
73
typedef struct _UnityMusicLensRhythmboxCollection UnityMusicLensRhythmboxCollection;
 
74
typedef struct _UnityMusicLensRhythmboxCollectionClass UnityMusicLensRhythmboxCollectionClass;
 
75
 
 
76
#define UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER (unity_music_lens_preview_player_get_type ())
 
77
#define UNITY_MUSIC_LENS_PREVIEW_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER, UnityMusicLensPreviewPlayer))
 
78
#define UNITY_MUSIC_LENS_PREVIEW_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER, UnityMusicLensPreviewPlayerClass))
 
79
#define UNITY_MUSIC_LENS_IS_PREVIEW_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER))
 
80
#define UNITY_MUSIC_LENS_IS_PREVIEW_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER))
 
81
#define UNITY_MUSIC_LENS_PREVIEW_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_PREVIEW_PLAYER, UnityMusicLensPreviewPlayerClass))
 
82
 
 
83
typedef struct _UnityMusicLensPreviewPlayer UnityMusicLensPreviewPlayer;
 
84
typedef struct _UnityMusicLensPreviewPlayerClass UnityMusicLensPreviewPlayerClass;
 
85
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
86
typedef struct _Block1Data Block1Data;
 
87
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
88
typedef struct _UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData;
 
89
#define _g_free0(var) (var = (g_free (var), NULL))
 
90
 
 
91
#define UNITY_MUSIC_LENS_TYPE_TRACK (unity_music_lens_track_get_type ())
 
92
#define UNITY_MUSIC_LENS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrack))
 
93
#define UNITY_MUSIC_LENS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrackClass))
 
94
#define UNITY_MUSIC_LENS_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_TRACK))
 
95
#define UNITY_MUSIC_LENS_IS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_TRACK))
 
96
#define UNITY_MUSIC_LENS_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_TRACK, UnityMusicLensTrackClass))
 
97
 
 
98
typedef struct _UnityMusicLensTrack UnityMusicLensTrack;
 
99
typedef struct _UnityMusicLensTrackClass UnityMusicLensTrackClass;
 
100
#define __g_slist_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_object_unref0_ (var), NULL)))
 
101
#define _g_slist_free0(var) ((var == NULL) ? NULL : (var = (g_slist_free (var), NULL)))
 
102
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
 
103
 
 
104
#define UNITY_MUSIC_LENS_TYPE_CATEGORY (unity_music_lens_category_get_type ())
 
105
typedef struct _UnityMusicLensRhythmboxScopePerformSearchData UnityMusicLensRhythmboxScopePerformSearchData;
 
106
 
 
107
struct _UnityMusicLensSimpleScope {
 
108
        GObject parent_instance;
 
109
        UnityMusicLensSimpleScopePrivate * priv;
 
110
};
 
111
 
 
112
struct _UnityMusicLensSimpleScopeClass {
 
113
        GObjectClass parent_class;
 
114
        void (*perform_search) (UnityMusicLensSimpleScope* self, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
115
        void (*perform_search_finish) (UnityMusicLensSimpleScope* self, GAsyncResult* _res_);
 
116
        gint (*get_num_results_without_search) (UnityMusicLensSimpleScope* self);
 
117
        gint (*get_num_results_global_search) (UnityMusicLensSimpleScope* self);
 
118
        gint (*get_num_results_lens_search) (UnityMusicLensSimpleScope* self);
 
119
};
 
120
 
 
121
struct _UnityMusicLensRhythmboxScope {
 
122
        UnityMusicLensSimpleScope parent_instance;
 
123
        UnityMusicLensRhythmboxScopePrivate * priv;
 
124
};
 
125
 
 
126
struct _UnityMusicLensRhythmboxScopeClass {
 
127
        UnityMusicLensSimpleScopeClass parent_class;
 
128
};
 
129
 
 
130
struct _UnityMusicLensRhythmboxScopePrivate {
 
131
        UnityMusicLensRhythmboxCollection* collection;
 
132
        gboolean db_ready;
 
133
        GFileMonitor* rb_xml_monitor;
 
134
        UnityMusicLensPreviewPlayer* preview_player;
 
135
        UnityMusicPreview* music_preview;
 
136
};
 
137
 
 
138
struct _Block1Data {
 
139
        int _ref_count_;
 
140
        UnityMusicLensRhythmboxScope * self;
 
141
        gchar** main_exec;
 
142
        gint main_exec_length1;
 
143
        gint _main_exec_size_;
 
144
        gpointer _async_data_;
 
145
};
 
146
 
 
147
struct _UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData {
 
148
        int _state_;
 
149
        GObject* _source_object_;
 
150
        GAsyncResult* _res_;
 
151
        GSimpleAsyncResult* _async_result;
 
152
        UnityMusicLensRhythmboxScope* self;
 
153
        gchar** exec_args;
 
154
        gint exec_args_length1;
 
155
        Block1Data* _data1_;
 
156
        gchar** _tmp0_;
 
157
        gint _tmp0__length1;
 
158
        gchar** _tmp1_;
 
159
        gint _tmp1__length1;
 
160
        GError * _inner_error_;
 
161
};
 
162
 
 
163
typedef enum  {
 
164
        UNITY_MUSIC_LENS_CATEGORY_SONGS,
 
165
        UNITY_MUSIC_LENS_CATEGORY_ALBUMS,
 
166
        UNITY_MUSIC_LENS_CATEGORY_PURCHASE,
 
167
        UNITY_MUSIC_LENS_CATEGORY_MUSIC,
 
168
        UNITY_MUSIC_LENS_CATEGORY_RADIOS
 
169
} UnityMusicLensCategory;
 
170
 
 
171
struct _UnityMusicLensRhythmboxScopePerformSearchData {
 
172
        int _state_;
 
173
        GObject* _source_object_;
 
174
        GAsyncResult* _res_;
 
175
        GSimpleAsyncResult* _async_result;
 
176
        UnityMusicLensRhythmboxScope* self;
 
177
        UnityLensSearch* search;
 
178
        UnitySearchType search_type;
 
179
        GList* filters;
 
180
        gint max_results;
 
181
        GCancellable* cancellable;
 
182
        gint category_override;
 
183
        UnitySearchType _tmp0_;
 
184
        UnityLensSearch* _tmp1_;
 
185
        gboolean _tmp2_;
 
186
        gboolean _tmp3_;
 
187
        const gchar* _tmp4_;
 
188
        gchar* _tmp5_;
 
189
        gchar* tdb_path;
 
190
        UnityMusicLensRhythmboxCollection* _tmp6_;
 
191
        const gchar* _tmp7_;
 
192
        const gchar* _tmp8_;
 
193
        gchar* _tmp9_;
 
194
        gchar* xml_path;
 
195
        UnityMusicLensRhythmboxCollection* _tmp10_;
 
196
        const gchar* _tmp11_;
 
197
        GFileMonitor* _tmp12_;
 
198
        const gchar* _tmp13_;
 
199
        GFile* _tmp14_;
 
200
        GFile* xml_file;
 
201
        GFile* _tmp15_;
 
202
        GFileMonitor* _tmp16_;
 
203
        GFileMonitor* _tmp17_;
 
204
        GFileMonitor* _tmp18_;
 
205
        GError* err;
 
206
        GError* _tmp19_;
 
207
        const gchar* _tmp20_;
 
208
        UnityMusicLensRhythmboxCollection* _tmp21_;
 
209
        UnityLensSearch* _tmp22_;
 
210
        UnitySearchType _tmp23_;
 
211
        GList* _tmp24_;
 
212
        gint _tmp25_;
 
213
        gint _tmp26_;
 
214
        GError * _inner_error_;
 
215
};
 
216
 
 
217
 
 
218
static gpointer unity_music_lens_rhythmbox_scope_parent_class = NULL;
 
219
 
 
220
GType unity_music_lens_simple_scope_get_type (void) G_GNUC_CONST;
 
221
GType unity_music_lens_filter_parser_get_type (void) G_GNUC_CONST;
 
222
GType unity_music_lens_rhythmbox_scope_get_type (void) G_GNUC_CONST;
 
223
GType unity_music_lens_rhythmbox_collection_get_type (void) G_GNUC_CONST;
 
224
GType unity_music_lens_preview_player_get_type (void) G_GNUC_CONST;
 
225
#define UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE, UnityMusicLensRhythmboxScopePrivate))
 
226
enum  {
 
227
        UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_DUMMY_PROPERTY,
 
228
        UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_WITHOUT_SEARCH,
 
229
        UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_GLOBAL_SEARCH,
 
230
        UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_LENS_SEARCH
 
231
};
 
232
UnityMusicLensRhythmboxScope* unity_music_lens_rhythmbox_scope_new (void);
 
233
UnityMusicLensRhythmboxScope* unity_music_lens_rhythmbox_scope_construct (GType object_type);
 
234
UnityMusicLensSimpleScope* unity_music_lens_simple_scope_construct (GType object_type);
 
235
void unity_music_lens_simple_scope_set_scope (UnityMusicLensSimpleScope* self, UnityScope* value);
 
236
UnityScope* unity_music_lens_simple_scope_get_scope (UnityMusicLensSimpleScope* self);
 
237
UnityActivationResponse* unity_music_lens_rhythmbox_scope_activate (UnityMusicLensRhythmboxScope* self, const gchar* uri);
 
238
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_activate_unity_scope_activate_uri (UnityScope* _sender, const gchar* uri, gpointer self);
 
239
UnityPreview* unity_music_lens_rhythmbox_scope_preview (UnityMusicLensRhythmboxScope* self, const gchar* uri);
 
240
static UnityPreview* _unity_music_lens_rhythmbox_scope_preview_unity_scope_preview_uri (UnityScope* _sender, const gchar* uri, gpointer self);
 
241
void unity_music_lens_simple_scope_initialize (UnityMusicLensSimpleScope* self);
 
242
UnityMusicLensRhythmboxCollection* unity_music_lens_rhythmbox_collection_new (void);
 
243
UnityMusicLensRhythmboxCollection* unity_music_lens_rhythmbox_collection_construct (GType object_type);
 
244
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_data_free (gpointer _data);
 
245
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue (UnityMusicLensRhythmboxScope* self, gchar** exec_args, int exec_args_length1, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
246
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_finish (UnityMusicLensRhythmboxScope* self, GAsyncResult* _res_);
 
247
static gboolean unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co (UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData* _data_);
 
248
static Block1Data* block1_data_ref (Block1Data* _data1_);
 
249
static void block1_data_unref (void * _userdata_);
 
250
static gchar** _vala_array_dup1 (gchar** self, int length);
 
251
static void __lambda13_ (Block1Data* _data1_);
 
252
static gboolean _unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co_gsource_func (gpointer self);
 
253
static gpointer ___lambda13__gthread_func (gpointer self);
 
254
GType unity_music_lens_track_get_type (void) G_GNUC_CONST;
 
255
GSList* unity_music_lens_rhythmbox_collection_get_album_tracks_detailed (UnityMusicLensRhythmboxCollection* self, const gchar* album_key);
 
256
const gchar* unity_music_lens_track_get_artwork_path (UnityMusicLensTrack* self);
 
257
const gchar* unity_music_lens_track_get_album (UnityMusicLensTrack* self);
 
258
const gchar* unity_music_lens_track_get_album_artist (UnityMusicLensTrack* self);
 
259
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_play_album_preview (UnityMusicLensRhythmboxScope* self, const gchar* uri);
 
260
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_play_album_preview_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self);
 
261
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_show_in_folder (UnityMusicLensRhythmboxScope* self, const gchar* uri);
 
262
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_show_in_folder_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self);
 
263
const gchar* unity_music_lens_track_get_uri (UnityMusicLensTrack* self);
 
264
gint unity_music_lens_track_get_track_number (UnityMusicLensTrack* self);
 
265
const gchar* unity_music_lens_track_get_title (UnityMusicLensTrack* self);
 
266
gint unity_music_lens_track_get_duration (UnityMusicLensTrack* self);
 
267
static void _g_object_unref0_ (gpointer var);
 
268
static void _g_slist_free__g_object_unref0_ (GSList* self);
 
269
UnityMusicLensTrack* unity_music_lens_rhythmbox_collection_get_album_track (UnityMusicLensRhythmboxCollection* self, const gchar* uri);
 
270
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox (UnityMusicLensRhythmboxScope* self, const gchar* uri);
 
271
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self);
 
272
void unity_music_lens_rhythmbox_scope_play (UnityMusicLensRhythmboxScope* self, UnityPreview* preview, const gchar* uri);
 
273
static void _unity_music_lens_rhythmbox_scope_play_unity_music_preview_play (UnityMusicPreview* _sender, const gchar* uri, gpointer self);
 
274
void unity_music_lens_rhythmbox_scope_pause (UnityMusicLensRhythmboxScope* self, UnityPreview* preview, const gchar* uri);
 
275
static void _unity_music_lens_rhythmbox_scope_pause_unity_music_preview_pause (UnityMusicPreview* _sender, const gchar* uri, gpointer self);
 
276
void unity_music_lens_rhythmbox_scope_closed (UnityMusicLensRhythmboxScope* self, UnityPreview* preview);
 
277
static void _unity_music_lens_rhythmbox_scope_closed_unity_preview_closed (UnityPreview* _sender, gpointer self);
 
278
GSList* unity_music_lens_rhythmbox_collection_get_album_tracks (UnityMusicLensRhythmboxCollection* self, const gchar* album_key);
 
279
void unity_music_lens_preview_player_close (UnityMusicLensPreviewPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
280
void unity_music_lens_preview_player_close_finish (UnityMusicLensPreviewPlayer* self, GAsyncResult* _res_, GError** error);
 
281
UnityMusicLensPreviewPlayer* unity_music_lens_preview_player_new (void);
 
282
UnityMusicLensPreviewPlayer* unity_music_lens_preview_player_construct (GType object_type);
 
283
static void unity_music_lens_rhythmbox_scope_on_progress_changed (UnityMusicLensRhythmboxScope* self, const gchar* uri, UnityMusicPreviewTrackState state, gdouble progress);
 
284
static void _unity_music_lens_rhythmbox_scope_on_progress_changed_unity_music_lens_preview_player_progress (UnityMusicLensPreviewPlayer* _sender, const gchar* uri, UnityMusicPreviewTrackState state, gdouble progress, gpointer self);
 
285
void unity_music_lens_preview_player_connect_to (UnityMusicLensPreviewPlayer* self, GError** error);
 
286
void unity_music_lens_preview_player_play (UnityMusicLensPreviewPlayer* self, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
287
void unity_music_lens_preview_player_play_finish (UnityMusicLensPreviewPlayer* self, GAsyncResult* _res_);
 
288
void unity_music_lens_preview_player_pause (UnityMusicLensPreviewPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
289
void unity_music_lens_preview_player_pause_finish (UnityMusicLensPreviewPlayer* self, GAsyncResult* _res_);
 
290
static void _vala_array_add4 (gchar*** array, int* length, int* size, gchar* value);
 
291
static void _vala_array_add5 (gchar*** array, int* length, int* size, gchar* value);
 
292
static void _vala_array_add6 (gchar*** array, int* length, int* size, gchar* value);
 
293
static void _vala_array_add7 (gchar*** array, int* length, int* size, gchar* value);
 
294
static void _vala_array_add8 (gchar*** array, int* length, int* size, gchar* value);
 
295
static void _vala_array_add9 (gchar*** array, int* length, int* size, gchar* value);
 
296
static void _g_list_free__g_object_unref0_ (GList* self);
 
297
static void unity_music_lens_rhythmbox_scope_real_perform_search_data_free (gpointer _data);
 
298
static void unity_music_lens_rhythmbox_scope_real_perform_search (UnityMusicLensSimpleScope* base, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
 
299
static gboolean unity_music_lens_rhythmbox_scope_real_perform_search_co (UnityMusicLensRhythmboxScopePerformSearchData* _data_);
 
300
GType unity_music_lens_category_get_type (void) G_GNUC_CONST;
 
301
gboolean unity_music_lens_simple_scope_is_search_empty (UnityMusicLensSimpleScope* self, UnityLensSearch* search);
 
302
void unity_music_lens_rhythmbox_collection_parse_metadata_file (UnityMusicLensRhythmboxCollection* self, const gchar* path);
 
303
void unity_music_lens_rhythmbox_collection_parse_file (UnityMusicLensRhythmboxCollection* self, const gchar* path);
 
304
static void _____lambda14_ (UnityMusicLensRhythmboxScope* self);
 
305
static void ______lambda14__g_file_monitor_changed (GFileMonitor* _sender, GFile* file, GFile* other_file, GFileMonitorEvent event_type, gpointer self);
 
306
void unity_music_lens_rhythmbox_collection_search (UnityMusicLensRhythmboxCollection* self, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, gint category_override);
 
307
static void unity_music_lens_rhythmbox_scope_finalize (GObject* obj);
 
308
gint unity_music_lens_simple_scope_get_num_results_without_search (UnityMusicLensSimpleScope* self);
 
309
gint unity_music_lens_simple_scope_get_num_results_global_search (UnityMusicLensSimpleScope* self);
 
310
gint unity_music_lens_simple_scope_get_num_results_lens_search (UnityMusicLensSimpleScope* self);
 
311
static void _vala_unity_music_lens_rhythmbox_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
 
312
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
313
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
314
 
 
315
 
 
316
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_activate_unity_scope_activate_uri (UnityScope* _sender, const gchar* uri, gpointer self) {
 
317
        UnityActivationResponse* result;
 
318
        result = unity_music_lens_rhythmbox_scope_activate (self, uri);
 
319
        return result;
 
320
}
 
321
 
 
322
 
 
323
static UnityPreview* _unity_music_lens_rhythmbox_scope_preview_unity_scope_preview_uri (UnityScope* _sender, const gchar* uri, gpointer self) {
 
324
        UnityPreview* result;
 
325
        result = unity_music_lens_rhythmbox_scope_preview (self, uri);
 
326
        return result;
 
327
}
 
328
 
 
329
 
 
330
UnityMusicLensRhythmboxScope* unity_music_lens_rhythmbox_scope_construct (GType object_type) {
 
331
        UnityMusicLensRhythmboxScope * self = NULL;
 
332
        UnityScope* _tmp0_;
 
333
        UnityScope* _tmp1_;
 
334
        UnityScope* _tmp2_;
 
335
        UnityScope* _tmp3_;
 
336
        UnityScope* _tmp4_;
 
337
        UnityScope* _tmp5_;
 
338
        UnityScope* _tmp6_;
 
339
        UnityScope* _tmp7_;
 
340
        UnityScope* _tmp8_;
 
341
        UnityScope* _tmp9_;
 
342
        UnityOptionsFilter* _tmp10_;
 
343
        UnityOptionsFilter* _tmp11_;
 
344
        const gchar* _tmp12_ = NULL;
 
345
        UnityFilterOption* _tmp13_ = NULL;
 
346
        UnityFilterOption* _tmp14_;
 
347
        UnityMusicLensRhythmboxCollection* _tmp15_;
 
348
        self = (UnityMusicLensRhythmboxScope*) unity_music_lens_simple_scope_construct (object_type);
 
349
        _tmp0_ = unity_scope_new ("/com/canonical/unity/scope/rhythmbox");
 
350
        _tmp1_ = _tmp0_;
 
351
        unity_music_lens_simple_scope_set_scope ((UnityMusicLensSimpleScope*) self, _tmp1_);
 
352
        _g_object_unref0 (_tmp1_);
 
353
        _tmp2_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
354
        _tmp3_ = _tmp2_;
 
355
        unity_scope_set_search_in_global (_tmp3_, TRUE);
 
356
        _tmp4_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
357
        _tmp5_ = _tmp4_;
 
358
        g_signal_connect_object (_tmp5_, "activate-uri", (GCallback) _unity_music_lens_rhythmbox_scope_activate_unity_scope_activate_uri, self, 0);
 
359
        _tmp6_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
360
        _tmp7_ = _tmp6_;
 
361
        g_signal_connect_object (_tmp7_, "preview-uri", (GCallback) _unity_music_lens_rhythmbox_scope_preview_unity_scope_preview_uri, self, 0);
 
362
        _tmp8_ = unity_music_lens_simple_scope_get_scope ((UnityMusicLensSimpleScope*) self);
 
363
        _tmp9_ = _tmp8_;
 
364
        _tmp10_ = unity_scope_get_sources (_tmp9_);
 
365
        _tmp11_ = _tmp10_;
 
366
        _tmp12_ = _ ("Rhythmbox");
 
367
        _tmp13_ = unity_options_filter_add_option (_tmp11_, "rhythmbox", _tmp12_, NULL);
 
368
        _tmp14_ = _tmp13_;
 
369
        _g_object_unref0 (_tmp14_);
 
370
        unity_music_lens_simple_scope_initialize (UNITY_MUSIC_LENS_SIMPLE_SCOPE (self));
 
371
        _tmp15_ = unity_music_lens_rhythmbox_collection_new ();
 
372
        _g_object_unref0 (self->priv->collection);
 
373
        self->priv->collection = _tmp15_;
 
374
        self->priv->db_ready = FALSE;
 
375
        return self;
 
376
}
 
377
 
 
378
 
 
379
UnityMusicLensRhythmboxScope* unity_music_lens_rhythmbox_scope_new (void) {
 
380
        return unity_music_lens_rhythmbox_scope_construct (UNITY_MUSIC_LENS_TYPE_RHYTHMBOX_SCOPE);
 
381
}
 
382
 
 
383
 
 
384
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_data_free (gpointer _data) {
 
385
        UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData* _data_;
 
386
        _data_ = _data;
 
387
        _g_object_unref0 (_data_->self);
 
388
        g_slice_free (UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData, _data_);
 
389
}
 
390
 
 
391
 
 
392
static gpointer _g_object_ref0 (gpointer self) {
 
393
        return self ? g_object_ref (self) : NULL;
 
394
}
 
395
 
 
396
 
 
397
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue (UnityMusicLensRhythmboxScope* self, gchar** exec_args, int exec_args_length1, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
398
        UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData* _data_;
 
399
        UnityMusicLensRhythmboxScope* _tmp0_;
 
400
        gchar** _tmp1_;
 
401
        gint _tmp1__length1;
 
402
        _data_ = g_slice_new0 (UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData);
 
403
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue);
 
404
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_data_free);
 
405
        _tmp0_ = _g_object_ref0 (self);
 
406
        _data_->self = _tmp0_;
 
407
        _tmp1_ = exec_args;
 
408
        _tmp1__length1 = exec_args_length1;
 
409
        _data_->exec_args = _tmp1_;
 
410
        _data_->exec_args_length1 = _tmp1__length1;
 
411
        unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co (_data_);
 
412
}
 
413
 
 
414
 
 
415
static void unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_finish (UnityMusicLensRhythmboxScope* self, GAsyncResult* _res_) {
 
416
        UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData* _data_;
 
417
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
418
}
 
419
 
 
420
 
 
421
static Block1Data* block1_data_ref (Block1Data* _data1_) {
 
422
        g_atomic_int_inc (&_data1_->_ref_count_);
 
423
        return _data1_;
 
424
}
 
425
 
 
426
 
 
427
static void block1_data_unref (void * _userdata_) {
 
428
        Block1Data* _data1_;
 
429
        _data1_ = (Block1Data*) _userdata_;
 
430
        if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
 
431
                UnityMusicLensRhythmboxScope * self;
 
432
                self = _data1_->self;
 
433
                _data1_->main_exec = (_vala_array_free (_data1_->main_exec, _data1_->main_exec_length1, (GDestroyNotify) g_free), NULL);
 
434
                _g_object_unref0 (self);
 
435
                g_slice_free (Block1Data, _data1_);
 
436
        }
 
437
}
 
438
 
 
439
 
 
440
static gchar** _vala_array_dup1 (gchar** self, int length) {
 
441
        gchar** result;
 
442
        int i;
 
443
        result = g_new0 (gchar*, length + 1);
 
444
        for (i = 0; i < length; i++) {
 
445
                gchar* _tmp0_;
 
446
                _tmp0_ = g_strdup (self[i]);
 
447
                result[i] = _tmp0_;
 
448
        }
 
449
        return result;
 
450
}
 
451
 
 
452
 
 
453
static gboolean _unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co_gsource_func (gpointer self) {
 
454
        gboolean result;
 
455
        result = unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co (self);
 
456
        return result;
 
457
}
 
458
 
 
459
 
 
460
static void __lambda13_ (Block1Data* _data1_) {
 
461
        UnityMusicLensRhythmboxScope * self;
 
462
        GError * _inner_error_ = NULL;
 
463
        self = _data1_->self;
 
464
        {
 
465
                g_spawn_command_line_sync ("rhythmbox-client --pause", NULL, NULL, NULL, &_inner_error_);
 
466
                if (_inner_error_ != NULL) {
 
467
                        goto __catch5_g_error;
 
468
                }
 
469
                g_spawn_command_line_sync ("rhythmbox-client --clear-queue", NULL, NULL, NULL, &_inner_error_);
 
470
                if (_inner_error_ != NULL) {
 
471
                        goto __catch5_g_error;
 
472
                }
 
473
                g_spawn_sync (NULL, _data1_->main_exec, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, NULL, &_inner_error_);
 
474
                if (_inner_error_ != NULL) {
 
475
                        goto __catch5_g_error;
 
476
                }
 
477
                g_spawn_command_line_sync ("rhythmbox-client --next", NULL, NULL, NULL, &_inner_error_);
 
478
                if (_inner_error_ != NULL) {
 
479
                        goto __catch5_g_error;
 
480
                }
 
481
                g_spawn_command_line_sync ("rhythmbox-client --play", NULL, NULL, NULL, &_inner_error_);
 
482
                if (_inner_error_ != NULL) {
 
483
                        goto __catch5_g_error;
 
484
                }
 
485
        }
 
486
        goto __finally5;
 
487
        __catch5_g_error:
 
488
        {
 
489
                GError* err = NULL;
 
490
                GError* _tmp0_;
 
491
                const gchar* _tmp1_;
 
492
                err = _inner_error_;
 
493
                _inner_error_ = NULL;
 
494
                _tmp0_ = err;
 
495
                _tmp1_ = _tmp0_->message;
 
496
                g_warning ("rhythmbox-scope.vala:68: %s", _tmp1_);
 
497
                _g_error_free0 (err);
 
498
        }
 
499
        __finally5:
 
500
        if (_inner_error_ != NULL) {
 
501
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
502
                g_clear_error (&_inner_error_);
 
503
                return;
 
504
        }
 
505
        g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co_gsource_func, _data1_->_async_data_, NULL);
 
506
}
 
507
 
 
508
 
 
509
static gpointer ___lambda13__gthread_func (gpointer self) {
 
510
        __lambda13_ (self);
 
511
}
 
512
 
 
513
 
 
514
static gboolean unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue_co (UnityMusicLensRhythmboxScopePrepareRhythmboxPlayQueueData* _data_) {
 
515
        switch (_data_->_state_) {
 
516
                case 0:
 
517
                goto _state_0;
 
518
                case 1:
 
519
                goto _state_1;
 
520
                default:
 
521
                g_assert_not_reached ();
 
522
        }
 
523
        _state_0:
 
524
        _data_->_data1_ = g_slice_new0 (Block1Data);
 
525
        _data_->_data1_->_ref_count_ = 1;
 
526
        _data_->_data1_->self = g_object_ref (_data_->self);
 
527
        _data_->_data1_->_async_data_ = _data_;
 
528
        _data_->_tmp0_ = _data_->exec_args;
 
529
        _data_->_tmp0__length1 = _data_->exec_args_length1;
 
530
        _data_->_tmp1_ = (_data_->_tmp0_ != NULL) ? _vala_array_dup1 (_data_->_tmp0_, _data_->_tmp0__length1) : ((gpointer) _data_->_tmp0_);
 
531
        _data_->_tmp1__length1 = _data_->_tmp0__length1;
 
532
        _data_->_data1_->main_exec = _data_->_tmp1_;
 
533
        _data_->_data1_->main_exec_length1 = _data_->_tmp1__length1;
 
534
        _data_->_data1_->_main_exec_size_ = _data_->_data1_->main_exec_length1;
 
535
        g_thread_create (___lambda13__gthread_func, _data_->_data1_, FALSE, &_data_->_inner_error_);
 
536
        if (_data_->_inner_error_ != NULL) {
 
537
                block1_data_unref (_data_->_data1_);
 
538
                _data_->_data1_ = NULL;
 
539
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
 
540
                g_clear_error (&_data_->_inner_error_);
 
541
                return FALSE;
 
542
        }
 
543
        _data_->_state_ = 1;
 
544
        return FALSE;
 
545
        _state_1:
 
546
        ;
 
547
        block1_data_unref (_data_->_data1_);
 
548
        _data_->_data1_ = NULL;
 
549
        if (_data_->_state_ == 0) {
 
550
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
551
        } else {
 
552
                g_simple_async_result_complete (_data_->_async_result);
 
553
        }
 
554
        g_object_unref (_data_->_async_result);
 
555
        return FALSE;
 
556
}
 
557
 
 
558
 
 
559
static glong string_strnlen (gchar* str, glong maxlen) {
 
560
        glong result = 0L;
 
561
        gchar* _tmp0_;
 
562
        glong _tmp1_;
 
563
        gchar* _tmp2_ = NULL;
 
564
        gchar* end;
 
565
        gchar* _tmp3_;
 
566
        _tmp0_ = str;
 
567
        _tmp1_ = maxlen;
 
568
        _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
 
569
        end = _tmp2_;
 
570
        _tmp3_ = end;
 
571
        if (_tmp3_ == NULL) {
 
572
                glong _tmp4_;
 
573
                _tmp4_ = maxlen;
 
574
                result = _tmp4_;
 
575
                return result;
 
576
        } else {
 
577
                gchar* _tmp5_;
 
578
                gchar* _tmp6_;
 
579
                _tmp5_ = end;
 
580
                _tmp6_ = str;
 
581
                result = (glong) (_tmp5_ - _tmp6_);
 
582
                return result;
 
583
        }
 
584
}
 
585
 
 
586
 
 
587
static gchar* string_substring (const gchar* self, glong offset, glong len) {
 
588
        gchar* result = NULL;
 
589
        glong string_length = 0L;
 
590
        gboolean _tmp0_ = FALSE;
 
591
        glong _tmp1_;
 
592
        gboolean _tmp3_;
 
593
        glong _tmp9_;
 
594
        glong _tmp15_;
 
595
        glong _tmp18_;
 
596
        glong _tmp19_;
 
597
        glong _tmp20_;
 
598
        glong _tmp21_;
 
599
        glong _tmp22_;
 
600
        gchar* _tmp23_ = NULL;
 
601
        g_return_val_if_fail (self != NULL, NULL);
 
602
        _tmp1_ = offset;
 
603
        if (_tmp1_ >= ((glong) 0)) {
 
604
                glong _tmp2_;
 
605
                _tmp2_ = len;
 
606
                _tmp0_ = _tmp2_ >= ((glong) 0);
 
607
        } else {
 
608
                _tmp0_ = FALSE;
 
609
        }
 
610
        _tmp3_ = _tmp0_;
 
611
        if (_tmp3_) {
 
612
                glong _tmp4_;
 
613
                glong _tmp5_;
 
614
                glong _tmp6_ = 0L;
 
615
                _tmp4_ = offset;
 
616
                _tmp5_ = len;
 
617
                _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
 
618
                string_length = _tmp6_;
 
619
        } else {
 
620
                gint _tmp7_;
 
621
                gint _tmp8_;
 
622
                _tmp7_ = strlen (self);
 
623
                _tmp8_ = _tmp7_;
 
624
                string_length = (glong) _tmp8_;
 
625
        }
 
626
        _tmp9_ = offset;
 
627
        if (_tmp9_ < ((glong) 0)) {
 
628
                glong _tmp10_;
 
629
                glong _tmp11_;
 
630
                glong _tmp12_;
 
631
                _tmp10_ = string_length;
 
632
                _tmp11_ = offset;
 
633
                offset = _tmp10_ + _tmp11_;
 
634
                _tmp12_ = offset;
 
635
                g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
 
636
        } else {
 
637
                glong _tmp13_;
 
638
                glong _tmp14_;
 
639
                _tmp13_ = offset;
 
640
                _tmp14_ = string_length;
 
641
                g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
 
642
        }
 
643
        _tmp15_ = len;
 
644
        if (_tmp15_ < ((glong) 0)) {
 
645
                glong _tmp16_;
 
646
                glong _tmp17_;
 
647
                _tmp16_ = string_length;
 
648
                _tmp17_ = offset;
 
649
                len = _tmp16_ - _tmp17_;
 
650
        }
 
651
        _tmp18_ = offset;
 
652
        _tmp19_ = len;
 
653
        _tmp20_ = string_length;
 
654
        g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
 
655
        _tmp21_ = offset;
 
656
        _tmp22_ = len;
 
657
        _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
 
658
        result = _tmp23_;
 
659
        return result;
 
660
}
 
661
 
 
662
 
 
663
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_play_album_preview_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self) {
 
664
        UnityActivationResponse* result;
 
665
        result = unity_music_lens_rhythmbox_scope_play_album_preview (self, uri);
 
666
        return result;
 
667
}
 
668
 
 
669
 
 
670
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_show_in_folder_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self) {
 
671
        UnityActivationResponse* result;
 
672
        result = unity_music_lens_rhythmbox_scope_show_in_folder (self, uri);
 
673
        return result;
 
674
}
 
675
 
 
676
 
 
677
static void _g_object_unref0_ (gpointer var) {
 
678
        (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
 
679
}
 
680
 
 
681
 
 
682
static void _g_slist_free__g_object_unref0_ (GSList* self) {
 
683
        g_slist_foreach (self, (GFunc) _g_object_unref0_, NULL);
 
684
        g_slist_free (self);
 
685
}
 
686
 
 
687
 
 
688
static UnityActivationResponse* _unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox_unity_preview_action_activated (UnityPreviewAction* _sender, const gchar* uri, gpointer self) {
 
689
        UnityActivationResponse* result;
 
690
        result = unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox (self, uri);
 
691
        return result;
 
692
}
 
693
 
 
694
 
 
695
static void _unity_music_lens_rhythmbox_scope_play_unity_music_preview_play (UnityMusicPreview* _sender, const gchar* uri, gpointer self) {
 
696
        unity_music_lens_rhythmbox_scope_play (self, _sender, uri);
 
697
}
 
698
 
 
699
 
 
700
static void _unity_music_lens_rhythmbox_scope_pause_unity_music_preview_pause (UnityMusicPreview* _sender, const gchar* uri, gpointer self) {
 
701
        unity_music_lens_rhythmbox_scope_pause (self, _sender, uri);
 
702
}
 
703
 
 
704
 
 
705
static void _unity_music_lens_rhythmbox_scope_closed_unity_preview_closed (UnityPreview* _sender, gpointer self) {
 
706
        unity_music_lens_rhythmbox_scope_closed (self, _sender);
 
707
}
 
708
 
 
709
 
 
710
UnityPreview* unity_music_lens_rhythmbox_scope_preview (UnityMusicLensRhythmboxScope* self, const gchar* uri) {
 
711
        UnityPreview* result = NULL;
 
712
        GThemedIcon* icon_file;
 
713
        const gchar* _tmp0_;
 
714
        gchar* _tmp1_ = NULL;
 
715
        gchar* _tmp2_;
 
716
        gboolean _tmp3_;
 
717
        UnityMusicPreview* _tmp109_;
 
718
        UnityPreview* _tmp110_;
 
719
        g_return_val_if_fail (self != NULL, NULL);
 
720
        g_return_val_if_fail (uri != NULL, NULL);
 
721
        _g_object_unref0 (self->priv->music_preview);
 
722
        self->priv->music_preview = NULL;
 
723
        icon_file = NULL;
 
724
        _tmp0_ = uri;
 
725
        _tmp1_ = g_uri_parse_scheme (_tmp0_);
 
726
        _tmp2_ = _tmp1_;
 
727
        _tmp3_ = g_strcmp0 (_tmp2_, "album") == 0;
 
728
        _g_free0 (_tmp2_);
 
729
        if (_tmp3_) {
 
730
                const gchar* _tmp4_;
 
731
                gchar* _tmp5_ = NULL;
 
732
                gchar* album_key;
 
733
                UnityMusicLensRhythmboxCollection* _tmp6_;
 
734
                const gchar* _tmp7_;
 
735
                GSList* _tmp8_ = NULL;
 
736
                _tmp4_ = uri;
 
737
                _tmp5_ = string_substring (_tmp4_, (glong) 8, (glong) (-1));
 
738
                album_key = _tmp5_;
 
739
                _tmp6_ = self->priv->collection;
 
740
                _tmp7_ = album_key;
 
741
                _tmp8_ = unity_music_lens_rhythmbox_collection_get_album_tracks_detailed (_tmp6_, _tmp7_);
 
742
                {
 
743
                        GSList* track_collection = NULL;
 
744
                        GSList* track_it = NULL;
 
745
                        track_collection = _tmp8_;
 
746
                        for (track_it = track_collection; track_it != NULL; track_it = track_it->next) {
 
747
                                UnityMusicLensTrack* track = NULL;
 
748
                                track = (UnityMusicLensTrack*) track_it->data;
 
749
                                {
 
750
                                        UnityMusicPreview* _tmp9_;
 
751
                                        UnityTrackMetadata* _tmp35_;
 
752
                                        UnityTrackMetadata* tm;
 
753
                                        UnityTrackMetadata* _tmp36_;
 
754
                                        UnityMusicLensTrack* _tmp37_;
 
755
                                        const gchar* _tmp38_;
 
756
                                        const gchar* _tmp39_;
 
757
                                        UnityTrackMetadata* _tmp40_;
 
758
                                        UnityMusicLensTrack* _tmp41_;
 
759
                                        gint _tmp42_;
 
760
                                        gint _tmp43_;
 
761
                                        UnityTrackMetadata* _tmp44_;
 
762
                                        UnityMusicLensTrack* _tmp45_;
 
763
                                        const gchar* _tmp46_;
 
764
                                        const gchar* _tmp47_;
 
765
                                        UnityTrackMetadata* _tmp48_;
 
766
                                        UnityMusicLensTrack* _tmp49_;
 
767
                                        gint _tmp50_;
 
768
                                        gint _tmp51_;
 
769
                                        UnityMusicPreview* _tmp52_;
 
770
                                        UnityTrackMetadata* _tmp53_;
 
771
                                        _tmp9_ = self->priv->music_preview;
 
772
                                        if (_tmp9_ == NULL) {
 
773
                                                UnityMusicLensTrack* _tmp10_;
 
774
                                                const gchar* _tmp11_;
 
775
                                                const gchar* _tmp12_;
 
776
                                                UnityMusicLensTrack* _tmp17_;
 
777
                                                const gchar* _tmp18_;
 
778
                                                const gchar* _tmp19_;
 
779
                                                UnityMusicLensTrack* _tmp20_;
 
780
                                                const gchar* _tmp21_;
 
781
                                                const gchar* _tmp22_;
 
782
                                                GThemedIcon* _tmp23_;
 
783
                                                UnityMusicPreview* _tmp24_;
 
784
                                                const gchar* _tmp25_ = NULL;
 
785
                                                UnityPreviewAction* _tmp26_;
 
786
                                                UnityPreviewAction* play_action;
 
787
                                                UnityPreviewAction* _tmp27_;
 
788
                                                UnityMusicPreview* _tmp28_;
 
789
                                                UnityPreviewAction* _tmp29_;
 
790
                                                const gchar* _tmp30_ = NULL;
 
791
                                                UnityPreviewAction* _tmp31_;
 
792
                                                UnityPreviewAction* show_folder_action;
 
793
                                                UnityPreviewAction* _tmp32_;
 
794
                                                UnityMusicPreview* _tmp33_;
 
795
                                                UnityPreviewAction* _tmp34_;
 
796
                                                _tmp10_ = track;
 
797
                                                _tmp11_ = unity_music_lens_track_get_artwork_path (_tmp10_);
 
798
                                                _tmp12_ = _tmp11_;
 
799
                                                if (_tmp12_ != NULL) {
 
800
                                                        UnityMusicLensTrack* _tmp13_;
 
801
                                                        const gchar* _tmp14_;
 
802
                                                        const gchar* _tmp15_;
 
803
                                                        GThemedIcon* _tmp16_;
 
804
                                                        _tmp13_ = track;
 
805
                                                        _tmp14_ = unity_music_lens_track_get_artwork_path (_tmp13_);
 
806
                                                        _tmp15_ = _tmp14_;
 
807
                                                        _tmp16_ = (GThemedIcon*) g_themed_icon_new (_tmp15_);
 
808
                                                        _g_object_unref0 (icon_file);
 
809
                                                        icon_file = _tmp16_;
 
810
                                                }
 
811
                                                _tmp17_ = track;
 
812
                                                _tmp18_ = unity_music_lens_track_get_album (_tmp17_);
 
813
                                                _tmp19_ = _tmp18_;
 
814
                                                _tmp20_ = track;
 
815
                                                _tmp21_ = unity_music_lens_track_get_album_artist (_tmp20_);
 
816
                                                _tmp22_ = _tmp21_;
 
817
                                                _tmp23_ = icon_file;
 
818
                                                _tmp24_ = unity_music_preview_new (_tmp19_, _tmp22_, (GIcon*) _tmp23_);
 
819
                                                _g_object_unref0 (self->priv->music_preview);
 
820
                                                self->priv->music_preview = _tmp24_;
 
821
                                                _tmp25_ = _ ("Play");
 
822
                                                _tmp26_ = unity_preview_action_new ("play_album", _tmp25_, NULL);
 
823
                                                play_action = _tmp26_;
 
824
                                                _tmp27_ = play_action;
 
825
                                                g_signal_connect_object (_tmp27_, "activated", (GCallback) _unity_music_lens_rhythmbox_scope_play_album_preview_unity_preview_action_activated, self, 0);
 
826
                                                _tmp28_ = self->priv->music_preview;
 
827
                                                _tmp29_ = play_action;
 
828
                                                unity_preview_add_action ((UnityPreview*) _tmp28_, _tmp29_);
 
829
                                                _tmp30_ = _ ("Show in Folder");
 
830
                                                _tmp31_ = unity_preview_action_new ("show_in_folder", _tmp30_, NULL);
 
831
                                                show_folder_action = _tmp31_;
 
832
                                                _tmp32_ = show_folder_action;
 
833
                                                g_signal_connect_object (_tmp32_, "activated", (GCallback) _unity_music_lens_rhythmbox_scope_show_in_folder_unity_preview_action_activated, self, 0);
 
834
                                                _tmp33_ = self->priv->music_preview;
 
835
                                                _tmp34_ = show_folder_action;
 
836
                                                unity_preview_add_action ((UnityPreview*) _tmp33_, _tmp34_);
 
837
                                                _g_object_unref0 (show_folder_action);
 
838
                                                _g_object_unref0 (play_action);
 
839
                                        }
 
840
                                        _tmp35_ = unity_track_metadata_new ();
 
841
                                        tm = _tmp35_;
 
842
                                        _tmp36_ = tm;
 
843
                                        _tmp37_ = track;
 
844
                                        _tmp38_ = unity_music_lens_track_get_uri (_tmp37_);
 
845
                                        _tmp39_ = _tmp38_;
 
846
                                        unity_track_metadata_set_uri (_tmp36_, _tmp39_);
 
847
                                        _tmp40_ = tm;
 
848
                                        _tmp41_ = track;
 
849
                                        _tmp42_ = unity_music_lens_track_get_track_number (_tmp41_);
 
850
                                        _tmp43_ = _tmp42_;
 
851
                                        unity_track_metadata_set_track_no (_tmp40_, _tmp43_);
 
852
                                        _tmp44_ = tm;
 
853
                                        _tmp45_ = track;
 
854
                                        _tmp46_ = unity_music_lens_track_get_title (_tmp45_);
 
855
                                        _tmp47_ = _tmp46_;
 
856
                                        unity_track_metadata_set_title (_tmp44_, _tmp47_);
 
857
                                        _tmp48_ = tm;
 
858
                                        _tmp49_ = track;
 
859
                                        _tmp50_ = unity_music_lens_track_get_duration (_tmp49_);
 
860
                                        _tmp51_ = _tmp50_;
 
861
                                        unity_track_metadata_set_length (_tmp48_, (guint) _tmp51_);
 
862
                                        _tmp52_ = self->priv->music_preview;
 
863
                                        _tmp53_ = tm;
 
864
                                        unity_music_preview_add_track (_tmp52_, _tmp53_);
 
865
                                        _g_object_unref0 (tm);
 
866
                                }
 
867
                        }
 
868
                        __g_slist_free__g_object_unref0_0 (track_collection);
 
869
                }
 
870
                _g_free0 (album_key);
 
871
        } else {
 
872
                const gchar* _tmp54_;
 
873
                gchar* _tmp55_ = NULL;
 
874
                gchar* _tmp56_;
 
875
                gboolean _tmp57_;
 
876
                _tmp54_ = uri;
 
877
                _tmp55_ = g_uri_parse_scheme (_tmp54_);
 
878
                _tmp56_ = _tmp55_;
 
879
                _tmp57_ = g_strcmp0 (_tmp56_, "file") == 0;
 
880
                _g_free0 (_tmp56_);
 
881
                if (_tmp57_) {
 
882
                        UnityMusicLensRhythmboxCollection* _tmp58_;
 
883
                        const gchar* _tmp59_;
 
884
                        UnityMusicLensTrack* _tmp60_ = NULL;
 
885
                        UnityMusicLensTrack* track;
 
886
                        UnityMusicLensTrack* _tmp61_;
 
887
                        _tmp58_ = self->priv->collection;
 
888
                        _tmp59_ = uri;
 
889
                        _tmp60_ = unity_music_lens_rhythmbox_collection_get_album_track (_tmp58_, _tmp59_);
 
890
                        track = _tmp60_;
 
891
                        _tmp61_ = track;
 
892
                        if (_tmp61_ != NULL) {
 
893
                                UnityMusicLensTrack* _tmp62_;
 
894
                                const gchar* _tmp63_;
 
895
                                const gchar* _tmp64_;
 
896
                                UnityMusicLensTrack* _tmp69_;
 
897
                                const gchar* _tmp70_;
 
898
                                const gchar* _tmp71_;
 
899
                                UnityMusicLensTrack* _tmp72_;
 
900
                                const gchar* _tmp73_;
 
901
                                const gchar* _tmp74_;
 
902
                                GThemedIcon* _tmp75_;
 
903
                                UnityMusicPreview* _tmp76_;
 
904
                                const gchar* _tmp77_ = NULL;
 
905
                                UnityPreviewAction* _tmp78_;
 
906
                                UnityPreviewAction* play_action;
 
907
                                UnityPreviewAction* _tmp79_;
 
908
                                UnityMusicPreview* _tmp80_;
 
909
                                UnityPreviewAction* _tmp81_;
 
910
                                const gchar* _tmp82_ = NULL;
 
911
                                UnityPreviewAction* _tmp83_;
 
912
                                UnityPreviewAction* show_folder_action;
 
913
                                UnityPreviewAction* _tmp84_;
 
914
                                UnityMusicPreview* _tmp85_;
 
915
                                UnityPreviewAction* _tmp86_;
 
916
                                UnityTrackMetadata* _tmp87_;
 
917
                                UnityTrackMetadata* tm;
 
918
                                UnityTrackMetadata* _tmp88_;
 
919
                                UnityMusicLensTrack* _tmp89_;
 
920
                                const gchar* _tmp90_;
 
921
                                const gchar* _tmp91_;
 
922
                                UnityTrackMetadata* _tmp92_;
 
923
                                UnityMusicLensTrack* _tmp93_;
 
924
                                gint _tmp94_;
 
925
                                gint _tmp95_;
 
926
                                UnityTrackMetadata* _tmp96_;
 
927
                                UnityMusicLensTrack* _tmp97_;
 
928
                                const gchar* _tmp98_;
 
929
                                const gchar* _tmp99_;
 
930
                                UnityTrackMetadata* _tmp100_;
 
931
                                UnityMusicLensTrack* _tmp101_;
 
932
                                gint _tmp102_;
 
933
                                gint _tmp103_;
 
934
                                UnityMusicPreview* _tmp104_;
 
935
                                UnityTrackMetadata* _tmp105_;
 
936
                                _tmp62_ = track;
 
937
                                _tmp63_ = unity_music_lens_track_get_artwork_path (_tmp62_);
 
938
                                _tmp64_ = _tmp63_;
 
939
                                if (_tmp64_ != NULL) {
 
940
                                        UnityMusicLensTrack* _tmp65_;
 
941
                                        const gchar* _tmp66_;
 
942
                                        const gchar* _tmp67_;
 
943
                                        GThemedIcon* _tmp68_;
 
944
                                        _tmp65_ = track;
 
945
                                        _tmp66_ = unity_music_lens_track_get_artwork_path (_tmp65_);
 
946
                                        _tmp67_ = _tmp66_;
 
947
                                        _tmp68_ = (GThemedIcon*) g_themed_icon_new (_tmp67_);
 
948
                                        _g_object_unref0 (icon_file);
 
949
                                        icon_file = _tmp68_;
 
950
                                }
 
951
                                _tmp69_ = track;
 
952
                                _tmp70_ = unity_music_lens_track_get_title (_tmp69_);
 
953
                                _tmp71_ = _tmp70_;
 
954
                                _tmp72_ = track;
 
955
                                _tmp73_ = unity_music_lens_track_get_album_artist (_tmp72_);
 
956
                                _tmp74_ = _tmp73_;
 
957
                                _tmp75_ = icon_file;
 
958
                                _tmp76_ = unity_music_preview_new (_tmp71_, _tmp74_, (GIcon*) _tmp75_);
 
959
                                _g_object_unref0 (self->priv->music_preview);
 
960
                                self->priv->music_preview = _tmp76_;
 
961
                                _tmp77_ = _ ("Play");
 
962
                                _tmp78_ = unity_preview_action_new ("play_track", _tmp77_, NULL);
 
963
                                play_action = _tmp78_;
 
964
                                _tmp79_ = play_action;
 
965
                                g_signal_connect_object (_tmp79_, "activated", (GCallback) _unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox_unity_preview_action_activated, self, 0);
 
966
                                _tmp80_ = self->priv->music_preview;
 
967
                                _tmp81_ = play_action;
 
968
                                unity_preview_add_action ((UnityPreview*) _tmp80_, _tmp81_);
 
969
                                _tmp82_ = _ ("Show in Folder");
 
970
                                _tmp83_ = unity_preview_action_new ("show_in_folder", _tmp82_, NULL);
 
971
                                show_folder_action = _tmp83_;
 
972
                                _tmp84_ = show_folder_action;
 
973
                                g_signal_connect_object (_tmp84_, "activated", (GCallback) _unity_music_lens_rhythmbox_scope_show_in_folder_unity_preview_action_activated, self, 0);
 
974
                                _tmp85_ = self->priv->music_preview;
 
975
                                _tmp86_ = show_folder_action;
 
976
                                unity_preview_add_action ((UnityPreview*) _tmp85_, _tmp86_);
 
977
                                _tmp87_ = unity_track_metadata_new ();
 
978
                                tm = _tmp87_;
 
979
                                _tmp88_ = tm;
 
980
                                _tmp89_ = track;
 
981
                                _tmp90_ = unity_music_lens_track_get_uri (_tmp89_);
 
982
                                _tmp91_ = _tmp90_;
 
983
                                unity_track_metadata_set_uri (_tmp88_, _tmp91_);
 
984
                                _tmp92_ = tm;
 
985
                                _tmp93_ = track;
 
986
                                _tmp94_ = unity_music_lens_track_get_track_number (_tmp93_);
 
987
                                _tmp95_ = _tmp94_;
 
988
                                unity_track_metadata_set_track_no (_tmp92_, _tmp95_);
 
989
                                _tmp96_ = tm;
 
990
                                _tmp97_ = track;
 
991
                                _tmp98_ = unity_music_lens_track_get_title (_tmp97_);
 
992
                                _tmp99_ = _tmp98_;
 
993
                                unity_track_metadata_set_title (_tmp96_, _tmp99_);
 
994
                                _tmp100_ = tm;
 
995
                                _tmp101_ = track;
 
996
                                _tmp102_ = unity_music_lens_track_get_duration (_tmp101_);
 
997
                                _tmp103_ = _tmp102_;
 
998
                                unity_track_metadata_set_length (_tmp100_, (guint) _tmp103_);
 
999
                                _tmp104_ = self->priv->music_preview;
 
1000
                                _tmp105_ = tm;
 
1001
                                unity_music_preview_add_track (_tmp104_, _tmp105_);
 
1002
                                _g_object_unref0 (tm);
 
1003
                                _g_object_unref0 (show_folder_action);
 
1004
                                _g_object_unref0 (play_action);
 
1005
                        }
 
1006
                        _g_object_unref0 (track);
 
1007
                }
 
1008
        }
 
1009
        if (unity_music_lens_rhythmbox_scope_preview != NULL) {
 
1010
                UnityMusicPreview* _tmp106_;
 
1011
                UnityMusicPreview* _tmp107_;
 
1012
                UnityMusicPreview* _tmp108_;
 
1013
                _tmp106_ = self->priv->music_preview;
 
1014
                g_signal_connect_object (_tmp106_, "play", (GCallback) _unity_music_lens_rhythmbox_scope_play_unity_music_preview_play, self, 0);
 
1015
                _tmp107_ = self->priv->music_preview;
 
1016
                g_signal_connect_object (_tmp107_, "pause", (GCallback) _unity_music_lens_rhythmbox_scope_pause_unity_music_preview_pause, self, 0);
 
1017
                _tmp108_ = self->priv->music_preview;
 
1018
                g_signal_connect_object ((UnityPreview*) _tmp108_, "closed", (GCallback) _unity_music_lens_rhythmbox_scope_closed_unity_preview_closed, self, 0);
 
1019
        }
 
1020
        _tmp109_ = self->priv->music_preview;
 
1021
        _tmp110_ = _g_object_ref0 ((UnityPreview*) _tmp109_);
 
1022
        result = _tmp110_;
 
1023
        _g_object_unref0 (icon_file);
 
1024
        return result;
 
1025
}
 
1026
 
 
1027
 
 
1028
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_show_in_folder (UnityMusicLensRhythmboxScope* self, const gchar* uri) {
 
1029
        UnityActivationResponse* result = NULL;
 
1030
        GFile* track_file;
 
1031
        const gchar* _tmp0_;
 
1032
        gchar* _tmp1_ = NULL;
 
1033
        gchar* _tmp2_;
 
1034
        gboolean _tmp3_;
 
1035
        GFile* _tmp16_;
 
1036
        GFile* _tmp17_ = NULL;
 
1037
        GFile* parent_dir;
 
1038
        GFile* _tmp18_;
 
1039
        UnityActivationResponse* _tmp30_;
 
1040
        UnityActivationResponse* _tmp31_;
 
1041
        GError * _inner_error_ = NULL;
 
1042
        g_return_val_if_fail (self != NULL, NULL);
 
1043
        g_return_val_if_fail (uri != NULL, NULL);
 
1044
        track_file = NULL;
 
1045
        _tmp0_ = uri;
 
1046
        _tmp1_ = g_uri_parse_scheme (_tmp0_);
 
1047
        _tmp2_ = _tmp1_;
 
1048
        _tmp3_ = g_strcmp0 (_tmp2_, "album") == 0;
 
1049
        _g_free0 (_tmp2_);
 
1050
        if (_tmp3_) {
 
1051
                const gchar* _tmp4_;
 
1052
                gchar* _tmp5_ = NULL;
 
1053
                gchar* album_key;
 
1054
                UnityMusicLensRhythmboxCollection* _tmp6_;
 
1055
                const gchar* _tmp7_;
 
1056
                GSList* _tmp8_ = NULL;
 
1057
                GSList* tracks;
 
1058
                GSList* _tmp9_;
 
1059
                guint _tmp10_ = 0U;
 
1060
                _tmp4_ = uri;
 
1061
                _tmp5_ = string_substring (_tmp4_, (glong) 8, (glong) (-1));
 
1062
                album_key = _tmp5_;
 
1063
                _tmp6_ = self->priv->collection;
 
1064
                _tmp7_ = album_key;
 
1065
                _tmp8_ = unity_music_lens_rhythmbox_collection_get_album_tracks (_tmp6_, _tmp7_);
 
1066
                tracks = _tmp8_;
 
1067
                _tmp9_ = tracks;
 
1068
                _tmp10_ = g_slist_length (_tmp9_);
 
1069
                if (_tmp10_ > ((guint) 0)) {
 
1070
                        GSList* _tmp11_;
 
1071
                        gconstpointer _tmp12_ = NULL;
 
1072
                        GFile* _tmp13_ = NULL;
 
1073
                        _tmp11_ = tracks;
 
1074
                        _tmp12_ = g_slist_nth_data (_tmp11_, (guint) 0);
 
1075
                        _tmp13_ = g_file_new_for_uri ((const gchar*) _tmp12_);
 
1076
                        _g_object_unref0 (track_file);
 
1077
                        track_file = _tmp13_;
 
1078
                }
 
1079
                _g_slist_free0 (tracks);
 
1080
                _g_free0 (album_key);
 
1081
        } else {
 
1082
                const gchar* _tmp14_;
 
1083
                GFile* _tmp15_ = NULL;
 
1084
                _tmp14_ = uri;
 
1085
                _tmp15_ = g_file_new_for_uri (_tmp14_);
 
1086
                _g_object_unref0 (track_file);
 
1087
                track_file = _tmp15_;
 
1088
        }
 
1089
        _tmp16_ = track_file;
 
1090
        _tmp17_ = g_file_get_parent (_tmp16_);
 
1091
        parent_dir = _tmp17_;
 
1092
        _tmp18_ = parent_dir;
 
1093
        if (_tmp18_ != NULL) {
 
1094
                {
 
1095
                        GFile* _tmp19_;
 
1096
                        gchar* _tmp20_ = NULL;
 
1097
                        gchar* _tmp21_;
 
1098
                        UnityActivationResponse* _tmp22_;
 
1099
                        UnityActivationResponse* _tmp23_;
 
1100
                        _tmp19_ = parent_dir;
 
1101
                        _tmp20_ = g_file_get_uri (_tmp19_);
 
1102
                        _tmp21_ = _tmp20_;
 
1103
                        g_app_info_launch_default_for_uri (_tmp21_, NULL, &_inner_error_);
 
1104
                        _g_free0 (_tmp21_);
 
1105
                        if (_inner_error_ != NULL) {
 
1106
                                goto __catch6_g_error;
 
1107
                        }
 
1108
                        _tmp22_ = unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, "");
 
1109
                        _tmp23_ = g_object_ref_sink (_tmp22_);
 
1110
                        result = _tmp23_;
 
1111
                        _g_object_unref0 (parent_dir);
 
1112
                        _g_object_unref0 (track_file);
 
1113
                        return result;
 
1114
                }
 
1115
                goto __finally6;
 
1116
                __catch6_g_error:
 
1117
                {
 
1118
                        GError* e = NULL;
 
1119
                        GFile* _tmp24_;
 
1120
                        gchar* _tmp25_ = NULL;
 
1121
                        gchar* _tmp26_;
 
1122
                        GError* _tmp27_;
 
1123
                        const gchar* _tmp28_;
 
1124
                        e = _inner_error_;
 
1125
                        _inner_error_ = NULL;
 
1126
                        _tmp24_ = parent_dir;
 
1127
                        _tmp25_ = g_file_get_uri (_tmp24_);
 
1128
                        _tmp26_ = _tmp25_;
 
1129
                        _tmp27_ = e;
 
1130
                        _tmp28_ = _tmp27_->message;
 
1131
                        g_warning ("rhythmbox-scope.vala:176: Failed to launch application for uri '%s': %" \
 
1132
"s", _tmp26_, _tmp28_);
 
1133
                        _g_free0 (_tmp26_);
 
1134
                        _g_error_free0 (e);
 
1135
                }
 
1136
                __finally6:
 
1137
                if (_inner_error_ != NULL) {
 
1138
                        _g_object_unref0 (parent_dir);
 
1139
                        _g_object_unref0 (track_file);
 
1140
                        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
1141
                        g_clear_error (&_inner_error_);
 
1142
                        return NULL;
 
1143
                }
 
1144
        } else {
 
1145
                const gchar* _tmp29_;
 
1146
                _tmp29_ = uri;
 
1147
                g_warning ("rhythmbox-scope.vala:181: Failed to get parent dir for uri: '%s'", _tmp29_);
 
1148
        }
 
1149
        _tmp30_ = unity_activation_response_new (UNITY_HANDLED_TYPE_NOT_HANDLED, "");
 
1150
        _tmp31_ = g_object_ref_sink (_tmp30_);
 
1151
        result = _tmp31_;
 
1152
        _g_object_unref0 (parent_dir);
 
1153
        _g_object_unref0 (track_file);
 
1154
        return result;
 
1155
}
 
1156
 
 
1157
 
 
1158
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_play_track_in_rhythmbox (UnityMusicLensRhythmboxScope* self, const gchar* uri) {
 
1159
        UnityActivationResponse* result = NULL;
 
1160
        const gchar* _tmp0_;
 
1161
        UnityActivationResponse* _tmp1_ = NULL;
 
1162
        g_return_val_if_fail (self != NULL, NULL);
 
1163
        g_return_val_if_fail (uri != NULL, NULL);
 
1164
        _tmp0_ = uri;
 
1165
        _tmp1_ = unity_music_lens_rhythmbox_scope_activate (self, _tmp0_);
 
1166
        result = _tmp1_;
 
1167
        return result;
 
1168
}
 
1169
 
 
1170
 
 
1171
static UnityActivationResponse* unity_music_lens_rhythmbox_scope_play_album_preview (UnityMusicLensRhythmboxScope* self, const gchar* uri) {
 
1172
        UnityActivationResponse* result = NULL;
 
1173
        const gchar* _tmp0_;
 
1174
        UnityActivationResponse* _tmp1_ = NULL;
 
1175
        g_return_val_if_fail (self != NULL, NULL);
 
1176
        g_return_val_if_fail (uri != NULL, NULL);
 
1177
        _tmp0_ = uri;
 
1178
        _tmp1_ = unity_music_lens_rhythmbox_scope_activate (self, _tmp0_);
 
1179
        result = _tmp1_;
 
1180
        return result;
 
1181
}
 
1182
 
 
1183
 
 
1184
void unity_music_lens_rhythmbox_scope_closed (UnityMusicLensRhythmboxScope* self, UnityPreview* preview) {
 
1185
        UnityMusicLensPreviewPlayer* _tmp0_;
 
1186
        GError * _inner_error_ = NULL;
 
1187
        g_return_if_fail (self != NULL);
 
1188
        g_return_if_fail (preview != NULL);
 
1189
        _tmp0_ = self->priv->preview_player;
 
1190
        if (_tmp0_ != NULL) {
 
1191
                {
 
1192
                        UnityMusicLensPreviewPlayer* _tmp1_;
 
1193
                        _tmp1_ = self->priv->preview_player;
 
1194
                        unity_music_lens_preview_player_close (_tmp1_, NULL, NULL);
 
1195
                }
 
1196
                goto __finally7;
 
1197
                __catch7_g_io_error:
 
1198
                {
 
1199
                        GError* e = NULL;
 
1200
                        GError* _tmp2_;
 
1201
                        const gchar* _tmp3_;
 
1202
                        e = _inner_error_;
 
1203
                        _inner_error_ = NULL;
 
1204
                        _tmp2_ = e;
 
1205
                        _tmp3_ = _tmp2_->message;
 
1206
                        g_warning ("rhythmbox-scope.vala:206: Failed to close preview player: %s", _tmp3_);
 
1207
                        _g_error_free0 (e);
 
1208
                }
 
1209
                __finally7:
 
1210
                if (_inner_error_ != NULL) {
 
1211
                        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
1212
                        g_clear_error (&_inner_error_);
 
1213
                        return;
 
1214
                }
 
1215
        }
 
1216
}
 
1217
 
 
1218
 
 
1219
static void _unity_music_lens_rhythmbox_scope_on_progress_changed_unity_music_lens_preview_player_progress (UnityMusicLensPreviewPlayer* _sender, const gchar* uri, UnityMusicPreviewTrackState state, gdouble progress, gpointer self) {
 
1220
        unity_music_lens_rhythmbox_scope_on_progress_changed (self, uri, state, progress);
 
1221
}
 
1222
 
 
1223
 
 
1224
void unity_music_lens_rhythmbox_scope_play (UnityMusicLensRhythmboxScope* self, UnityPreview* preview, const gchar* uri) {
 
1225
        const gchar* _tmp0_;
 
1226
        UnityMusicLensPreviewPlayer* _tmp1_;
 
1227
        UnityMusicPreview* _tmp5_;
 
1228
        const gchar* _tmp6_;
 
1229
        UnityMusicPreview* _tmp7_;
 
1230
        UnityMusicPreview* _tmp8_;
 
1231
        UnityMusicLensPreviewPlayer* _tmp9_;
 
1232
        const gchar* _tmp10_;
 
1233
        GError * _inner_error_ = NULL;
 
1234
        g_return_if_fail (self != NULL);
 
1235
        g_return_if_fail (preview != NULL);
 
1236
        g_return_if_fail (uri != NULL);
 
1237
        _tmp0_ = uri;
 
1238
        g_debug ("rhythmbox-scope.vala:213: play request: '%s'", _tmp0_);
 
1239
        _tmp1_ = self->priv->preview_player;
 
1240
        if (_tmp1_ == NULL) {
 
1241
                UnityMusicLensPreviewPlayer* _tmp2_;
 
1242
                UnityMusicLensPreviewPlayer* _tmp3_;
 
1243
                UnityMusicLensPreviewPlayer* _tmp4_;
 
1244
                _tmp2_ = unity_music_lens_preview_player_new ();
 
1245
                _g_object_unref0 (self->priv->preview_player);
 
1246
                self->priv->preview_player = _tmp2_;
 
1247
                _tmp3_ = self->priv->preview_player;
 
1248
                g_signal_connect_object (_tmp3_, "progress", (GCallback) _unity_music_lens_rhythmbox_scope_on_progress_changed_unity_music_lens_preview_player_progress, self, 0);
 
1249
                _tmp4_ = self->priv->preview_player;
 
1250
                unity_music_lens_preview_player_connect_to (_tmp4_, &_inner_error_);
 
1251
                if (_inner_error_ != NULL) {
 
1252
                        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
1253
                        g_clear_error (&_inner_error_);
 
1254
                        return;
 
1255
                }
 
1256
        }
 
1257
        _tmp5_ = self->priv->music_preview;
 
1258
        _tmp6_ = uri;
 
1259
        unity_music_preview_set_current_track_uri (_tmp5_, _tmp6_);
 
1260
        _tmp7_ = self->priv->music_preview;
 
1261
        unity_music_preview_set_current_progress (_tmp7_, 0.0f);
 
1262
        _tmp8_ = self->priv->music_preview;
 
1263
        unity_music_preview_set_current_track_state (_tmp8_, UNITY_MUSIC_PREVIEW_TRACK_STATE_PLAYING);
 
1264
        _tmp9_ = self->priv->preview_player;
 
1265
        _tmp10_ = uri;
 
1266
        unity_music_lens_preview_player_play (_tmp9_, _tmp10_, NULL, NULL);
 
1267
}
 
1268
 
 
1269
 
 
1270
void unity_music_lens_rhythmbox_scope_pause (UnityMusicLensRhythmboxScope* self, UnityPreview* preview, const gchar* uri) {
 
1271
        const gchar* _tmp0_;
 
1272
        UnityMusicLensPreviewPlayer* _tmp1_;
 
1273
        g_return_if_fail (self != NULL);
 
1274
        g_return_if_fail (preview != NULL);
 
1275
        g_return_if_fail (uri != NULL);
 
1276
        _tmp0_ = uri;
 
1277
        g_debug ("rhythmbox-scope.vala:232: pause request: '%s'", _tmp0_);
 
1278
        _tmp1_ = self->priv->preview_player;
 
1279
        if (_tmp1_ != NULL) {
 
1280
                UnityMusicPreview* _tmp2_;
 
1281
                const gchar* _tmp3_;
 
1282
                UnityMusicPreview* _tmp4_;
 
1283
                UnityMusicLensPreviewPlayer* _tmp5_;
 
1284
                _tmp2_ = self->priv->music_preview;
 
1285
                _tmp3_ = uri;
 
1286
                unity_music_preview_set_current_track_uri (_tmp2_, _tmp3_);
 
1287
                _tmp4_ = self->priv->music_preview;
 
1288
                unity_music_preview_set_current_track_state (_tmp4_, UNITY_MUSIC_PREVIEW_TRACK_STATE_PAUSED);
 
1289
                _tmp5_ = self->priv->preview_player;
 
1290
                unity_music_lens_preview_player_pause (_tmp5_, NULL, NULL);
 
1291
        }
 
1292
}
 
1293
 
 
1294
 
 
1295
static void unity_music_lens_rhythmbox_scope_on_progress_changed (UnityMusicLensRhythmboxScope* self, const gchar* uri, UnityMusicPreviewTrackState state, gdouble progress) {
 
1296
        g_return_if_fail (self != NULL);
 
1297
        g_return_if_fail (uri != NULL);
 
1298
        if (unity_music_lens_rhythmbox_scope_preview != NULL) {
 
1299
                UnityMusicPreview* _tmp0_;
 
1300
                const gchar* _tmp1_;
 
1301
                UnityMusicPreview* _tmp2_;
 
1302
                UnityMusicPreviewTrackState _tmp3_;
 
1303
                UnityMusicPreview* _tmp4_;
 
1304
                gdouble _tmp5_;
 
1305
                _tmp0_ = self->priv->music_preview;
 
1306
                _tmp1_ = uri;
 
1307
                unity_music_preview_set_current_track_uri (_tmp0_, _tmp1_);
 
1308
                _tmp2_ = self->priv->music_preview;
 
1309
                _tmp3_ = state;
 
1310
                unity_music_preview_set_current_track_state (_tmp2_, _tmp3_);
 
1311
                _tmp4_ = self->priv->music_preview;
 
1312
                _tmp5_ = progress;
 
1313
                unity_music_preview_set_current_progress (_tmp4_, (gfloat) _tmp5_);
 
1314
        }
 
1315
}
 
1316
 
 
1317
 
 
1318
/**
 
1319
     * Tells rhythmbox to play the selected uri(s)
 
1320
     */
 
1321
static void _vala_array_add4 (gchar*** array, int* length, int* size, gchar* value) {
 
1322
        if ((*length) == (*size)) {
 
1323
                *size = (*size) ? (2 * (*size)) : 4;
 
1324
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1325
        }
 
1326
        (*array)[(*length)++] = value;
 
1327
        (*array)[*length] = NULL;
 
1328
}
 
1329
 
 
1330
 
 
1331
static void _vala_array_add5 (gchar*** array, int* length, int* size, gchar* value) {
 
1332
        if ((*length) == (*size)) {
 
1333
                *size = (*size) ? (2 * (*size)) : 4;
 
1334
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1335
        }
 
1336
        (*array)[(*length)++] = value;
 
1337
        (*array)[*length] = NULL;
 
1338
}
 
1339
 
 
1340
 
 
1341
static void _vala_array_add6 (gchar*** array, int* length, int* size, gchar* value) {
 
1342
        if ((*length) == (*size)) {
 
1343
                *size = (*size) ? (2 * (*size)) : 4;
 
1344
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1345
        }
 
1346
        (*array)[(*length)++] = value;
 
1347
        (*array)[*length] = NULL;
 
1348
}
 
1349
 
 
1350
 
 
1351
static void _vala_array_add7 (gchar*** array, int* length, int* size, gchar* value) {
 
1352
        if ((*length) == (*size)) {
 
1353
                *size = (*size) ? (2 * (*size)) : 4;
 
1354
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1355
        }
 
1356
        (*array)[(*length)++] = value;
 
1357
        (*array)[*length] = NULL;
 
1358
}
 
1359
 
 
1360
 
 
1361
static void _vala_array_add8 (gchar*** array, int* length, int* size, gchar* value) {
 
1362
        if ((*length) == (*size)) {
 
1363
                *size = (*size) ? (2 * (*size)) : 4;
 
1364
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1365
        }
 
1366
        (*array)[(*length)++] = value;
 
1367
        (*array)[*length] = NULL;
 
1368
}
 
1369
 
 
1370
 
 
1371
static void _vala_array_add9 (gchar*** array, int* length, int* size, gchar* value) {
 
1372
        if ((*length) == (*size)) {
 
1373
                *size = (*size) ? (2 * (*size)) : 4;
 
1374
                *array = g_renew (gchar*, *array, (*size) + 1);
 
1375
        }
 
1376
        (*array)[(*length)++] = value;
 
1377
        (*array)[*length] = NULL;
 
1378
}
 
1379
 
 
1380
 
 
1381
UnityActivationResponse* unity_music_lens_rhythmbox_scope_activate (UnityMusicLensRhythmboxScope* self, const gchar* uri) {
 
1382
        UnityActivationResponse* result = NULL;
 
1383
        gchar* _tmp0_;
 
1384
        gchar** _tmp1_ = NULL;
 
1385
        gchar** exec;
 
1386
        gint exec_length1;
 
1387
        gint _exec_size_;
 
1388
        GError * _inner_error_ = NULL;
 
1389
        g_return_val_if_fail (self != NULL, NULL);
 
1390
        g_return_val_if_fail (uri != NULL, NULL);
 
1391
        _tmp0_ = g_strdup ("rhythmbox-client");
 
1392
        _tmp1_ = g_new0 (gchar*, 1 + 1);
 
1393
        _tmp1_[0] = _tmp0_;
 
1394
        exec = _tmp1_;
 
1395
        exec_length1 = 1;
 
1396
        _exec_size_ = exec_length1;
 
1397
        {
 
1398
                const gchar* _tmp2_;
 
1399
                gchar* _tmp3_ = NULL;
 
1400
                gchar* _tmp4_;
 
1401
                gboolean _tmp5_;
 
1402
                gchar** _tmp25_;
 
1403
                gint _tmp25__length1;
 
1404
                gchar** _tmp26_;
 
1405
                gint _tmp26__length1;
 
1406
                gchar* _tmp27_ = NULL;
 
1407
                gchar* _tmp28_;
 
1408
                gchar** _tmp29_;
 
1409
                gint _tmp29__length1;
 
1410
                UnityActivationResponse* _tmp30_;
 
1411
                UnityActivationResponse* _tmp31_;
 
1412
                _tmp2_ = uri;
 
1413
                _tmp3_ = g_uri_parse_scheme (_tmp2_);
 
1414
                _tmp4_ = _tmp3_;
 
1415
                _tmp5_ = g_strcmp0 (_tmp4_, "album") == 0;
 
1416
                _g_free0 (_tmp4_);
 
1417
                if (_tmp5_) {
 
1418
                        gchar** _tmp6_;
 
1419
                        gint _tmp6__length1;
 
1420
                        gchar* _tmp7_;
 
1421
                        const gchar* _tmp8_;
 
1422
                        gchar* _tmp9_ = NULL;
 
1423
                        gchar* album_key;
 
1424
                        UnityMusicLensRhythmboxCollection* _tmp10_;
 
1425
                        const gchar* _tmp11_;
 
1426
                        GSList* _tmp12_ = NULL;
 
1427
                        gchar** _tmp16_;
 
1428
                        gint _tmp16__length1;
 
1429
                        gchar** _tmp17_;
 
1430
                        gint _tmp17__length1;
 
1431
                        UnityActivationResponse* _tmp18_;
 
1432
                        UnityActivationResponse* _tmp19_;
 
1433
                        _tmp6_ = exec;
 
1434
                        _tmp6__length1 = exec_length1;
 
1435
                        _tmp7_ = g_strdup ("--enqueue");
 
1436
                        _vala_array_add4 (&exec, &exec_length1, &_exec_size_, _tmp7_);
 
1437
                        _tmp8_ = uri;
 
1438
                        _tmp9_ = string_substring (_tmp8_, (glong) 8, (glong) (-1));
 
1439
                        album_key = _tmp9_;
 
1440
                        _tmp10_ = self->priv->collection;
 
1441
                        _tmp11_ = album_key;
 
1442
                        _tmp12_ = unity_music_lens_rhythmbox_collection_get_album_tracks (_tmp10_, _tmp11_);
 
1443
                        {
 
1444
                                GSList* track_uri_collection = NULL;
 
1445
                                GSList* track_uri_it = NULL;
 
1446
                                track_uri_collection = _tmp12_;
 
1447
                                for (track_uri_it = track_uri_collection; track_uri_it != NULL; track_uri_it = track_uri_it->next) {
 
1448
                                        const gchar* track_uri = NULL;
 
1449
                                        track_uri = (const gchar*) track_uri_it->data;
 
1450
                                        {
 
1451
                                                gchar** _tmp13_;
 
1452
                                                gint _tmp13__length1;
 
1453
                                                const gchar* _tmp14_;
 
1454
                                                gchar* _tmp15_;
 
1455
                                                _tmp13_ = exec;
 
1456
                                                _tmp13__length1 = exec_length1;
 
1457
                                                _tmp14_ = track_uri;
 
1458
                                                _tmp15_ = g_strdup (_tmp14_);
 
1459
                                                _vala_array_add5 (&exec, &exec_length1, &_exec_size_, _tmp15_);
 
1460
                                        }
 
1461
                                }
 
1462
                                _g_slist_free0 (track_uri_collection);
 
1463
                        }
 
1464
                        _tmp16_ = exec;
 
1465
                        _tmp16__length1 = exec_length1;
 
1466
                        _vala_array_add6 (&exec, &exec_length1, &_exec_size_, NULL);
 
1467
                        _tmp17_ = exec;
 
1468
                        _tmp17__length1 = exec_length1;
 
1469
                        unity_music_lens_rhythmbox_scope_prepare_rhythmbox_play_queue (self, _tmp17_, _tmp17__length1, NULL, NULL);
 
1470
                        _tmp18_ = unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, "");
 
1471
                        _tmp19_ = g_object_ref_sink (_tmp18_);
 
1472
                        result = _tmp19_;
 
1473
                        _g_free0 (album_key);
 
1474
                        exec = (_vala_array_free (exec, exec_length1, (GDestroyNotify) g_free), NULL);
 
1475
                        return result;
 
1476
                } else {
 
1477
                        gchar** _tmp20_;
 
1478
                        gint _tmp20__length1;
 
1479
                        gchar* _tmp21_;
 
1480
                        gchar** _tmp22_;
 
1481
                        gint _tmp22__length1;
 
1482
                        const gchar* _tmp23_;
 
1483
                        gchar* _tmp24_;
 
1484
                        _tmp20_ = exec;
 
1485
                        _tmp20__length1 = exec_length1;
 
1486
                        _tmp21_ = g_strdup ("--play-uri");
 
1487
                        _vala_array_add7 (&exec, &exec_length1, &_exec_size_, _tmp21_);
 
1488
                        _tmp22_ = exec;
 
1489
                        _tmp22__length1 = exec_length1;
 
1490
                        _tmp23_ = uri;
 
1491
                        _tmp24_ = g_strdup (_tmp23_);
 
1492
                        _vala_array_add8 (&exec, &exec_length1, &_exec_size_, _tmp24_);
 
1493
                }
 
1494
                _tmp25_ = exec;
 
1495
                _tmp25__length1 = exec_length1;
 
1496
                _vala_array_add9 (&exec, &exec_length1, &_exec_size_, NULL);
 
1497
                _tmp26_ = exec;
 
1498
                _tmp26__length1 = exec_length1;
 
1499
                _tmp27_ = g_strjoinv (" ", _tmp26_);
 
1500
                _tmp28_ = _tmp27_;
 
1501
                g_debug ("rhythmbox-scope.vala:283: Spawning rb '%s'", _tmp28_);
 
1502
                _g_free0 (_tmp28_);
 
1503
                _tmp29_ = exec;
 
1504
                _tmp29__length1 = exec_length1;
 
1505
                g_spawn_async (NULL, _tmp29_, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &_inner_error_);
 
1506
                if (_inner_error_ != NULL) {
 
1507
                        if (_inner_error_->domain == G_SPAWN_ERROR) {
 
1508
                                goto __catch8_g_spawn_error;
 
1509
                        }
 
1510
                        exec = (_vala_array_free (exec, exec_length1, (GDestroyNotify) g_free), NULL);
 
1511
                        g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
1512
                        g_clear_error (&_inner_error_);
 
1513
                        return NULL;
 
1514
                }
 
1515
                _tmp30_ = unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, "");
 
1516
                _tmp31_ = g_object_ref_sink (_tmp30_);
 
1517
                result = _tmp31_;
 
1518
                exec = (_vala_array_free (exec, exec_length1, (GDestroyNotify) g_free), NULL);
 
1519
                return result;
 
1520
        }
 
1521
        goto __finally8;
 
1522
        __catch8_g_spawn_error:
 
1523
        {
 
1524
                GError* _error_ = NULL;
 
1525
                const gchar* _tmp32_;
 
1526
                UnityActivationResponse* _tmp33_;
 
1527
                UnityActivationResponse* _tmp34_;
 
1528
                _error_ = _inner_error_;
 
1529
                _inner_error_ = NULL;
 
1530
                _tmp32_ = uri;
 
1531
                g_warning ("rhythmbox-scope.vala:293: Failed to launch URI %s", _tmp32_);
 
1532
                _tmp33_ = unity_activation_response_new (UNITY_HANDLED_TYPE_NOT_HANDLED, "");
 
1533
                _tmp34_ = g_object_ref_sink (_tmp33_);
 
1534
                result = _tmp34_;
 
1535
                _g_error_free0 (_error_);
 
1536
                exec = (_vala_array_free (exec, exec_length1, (GDestroyNotify) g_free), NULL);
 
1537
                return result;
 
1538
        }
 
1539
        __finally8:
 
1540
        exec = (_vala_array_free (exec, exec_length1, (GDestroyNotify) g_free), NULL);
 
1541
        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
1542
        g_clear_error (&_inner_error_);
 
1543
        return NULL;
 
1544
}
 
1545
 
 
1546
 
 
1547
static void _g_list_free__g_object_unref0_ (GList* self) {
 
1548
        g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
 
1549
        g_list_free (self);
 
1550
}
 
1551
 
 
1552
 
 
1553
static void unity_music_lens_rhythmbox_scope_real_perform_search_data_free (gpointer _data) {
 
1554
        UnityMusicLensRhythmboxScopePerformSearchData* _data_;
 
1555
        _data_ = _data;
 
1556
        _g_object_unref0 (_data_->search);
 
1557
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
1558
        _g_object_unref0 (_data_->cancellable);
 
1559
        _g_object_unref0 (_data_->self);
 
1560
        g_slice_free (UnityMusicLensRhythmboxScopePerformSearchData, _data_);
 
1561
}
 
1562
 
 
1563
 
 
1564
static void unity_music_lens_rhythmbox_scope_real_perform_search (UnityMusicLensSimpleScope* base, UnityLensSearch* search, UnitySearchType search_type, GList* filters, gint max_results, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
 
1565
        UnityMusicLensRhythmboxScope * self;
 
1566
        UnityMusicLensRhythmboxScopePerformSearchData* _data_;
 
1567
        UnityMusicLensRhythmboxScope* _tmp0_;
 
1568
        UnityLensSearch* _tmp1_;
 
1569
        UnityLensSearch* _tmp2_;
 
1570
        UnitySearchType _tmp3_;
 
1571
        GList* _tmp4_;
 
1572
        gint _tmp5_;
 
1573
        GCancellable* _tmp6_;
 
1574
        GCancellable* _tmp7_;
 
1575
        self = (UnityMusicLensRhythmboxScope*) base;
 
1576
        _data_ = g_slice_new0 (UnityMusicLensRhythmboxScopePerformSearchData);
 
1577
        _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, unity_music_lens_rhythmbox_scope_real_perform_search);
 
1578
        g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, unity_music_lens_rhythmbox_scope_real_perform_search_data_free);
 
1579
        _tmp0_ = _g_object_ref0 (self);
 
1580
        _data_->self = _tmp0_;
 
1581
        _tmp1_ = search;
 
1582
        _tmp2_ = _g_object_ref0 (_tmp1_);
 
1583
        _data_->search = _tmp2_;
 
1584
        _tmp3_ = search_type;
 
1585
        _data_->search_type = _tmp3_;
 
1586
        _tmp4_ = filters;
 
1587
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
1588
        _data_->filters = _tmp4_;
 
1589
        _tmp5_ = max_results;
 
1590
        _data_->max_results = _tmp5_;
 
1591
        _tmp6_ = cancellable;
 
1592
        _tmp7_ = _g_object_ref0 (_tmp6_);
 
1593
        _data_->cancellable = _tmp7_;
 
1594
        unity_music_lens_rhythmbox_scope_real_perform_search_co (_data_);
 
1595
}
 
1596
 
 
1597
 
 
1598
static void unity_music_lens_rhythmbox_scope_real_perform_search_finish (UnityMusicLensSimpleScope* base, GAsyncResult* _res_) {
 
1599
        UnityMusicLensRhythmboxScopePerformSearchData* _data_;
 
1600
        _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
 
1601
}
 
1602
 
 
1603
 
 
1604
static void _____lambda14_ (UnityMusicLensRhythmboxScope* self) {
 
1605
        self->priv->db_ready = FALSE;
 
1606
}
 
1607
 
 
1608
 
 
1609
static void ______lambda14__g_file_monitor_changed (GFileMonitor* _sender, GFile* file, GFile* other_file, GFileMonitorEvent event_type, gpointer self) {
 
1610
        _____lambda14_ (self);
 
1611
}
 
1612
 
 
1613
 
 
1614
static gboolean unity_music_lens_rhythmbox_scope_real_perform_search_co (UnityMusicLensRhythmboxScopePerformSearchData* _data_) {
 
1615
        switch (_data_->_state_) {
 
1616
                case 0:
 
1617
                goto _state_0;
 
1618
                default:
 
1619
                g_assert_not_reached ();
 
1620
        }
 
1621
        _state_0:
 
1622
        _data_->category_override = -1;
 
1623
        _data_->_tmp0_ = _data_->search_type;
 
1624
        if (_data_->_tmp0_ == UNITY_SEARCH_TYPE_GLOBAL) {
 
1625
                _data_->category_override = (gint) UNITY_MUSIC_LENS_CATEGORY_MUSIC;
 
1626
                _data_->_tmp1_ = _data_->search;
 
1627
                _data_->_tmp2_ = FALSE;
 
1628
                _data_->_tmp2_ = unity_music_lens_simple_scope_is_search_empty ((UnityMusicLensSimpleScope*) _data_->self, _data_->_tmp1_);
 
1629
                if (_data_->_tmp2_) {
 
1630
                        __g_list_free__g_object_unref0_0 (_data_->filters);
 
1631
                        if (_data_->_state_ == 0) {
 
1632
                                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
1633
                        } else {
 
1634
                                g_simple_async_result_complete (_data_->_async_result);
 
1635
                        }
 
1636
                        g_object_unref (_data_->_async_result);
 
1637
                        return FALSE;
 
1638
                }
 
1639
        }
 
1640
        _data_->_tmp3_ = _data_->self->priv->db_ready;
 
1641
        if (!_data_->_tmp3_) {
 
1642
                _data_->_tmp4_ = NULL;
 
1643
                _data_->_tmp4_ = g_get_user_cache_dir ();
 
1644
                _data_->_tmp5_ = NULL;
 
1645
                _data_->_tmp5_ = g_build_filename (_data_->_tmp4_, "rhythmbox", "album-art", "store.tdb", NULL);
 
1646
                _data_->tdb_path = _data_->_tmp5_;
 
1647
                _data_->_tmp6_ = _data_->self->priv->collection;
 
1648
                _data_->_tmp7_ = _data_->tdb_path;
 
1649
                unity_music_lens_rhythmbox_collection_parse_metadata_file (_data_->_tmp6_, _data_->_tmp7_);
 
1650
                _data_->_tmp8_ = NULL;
 
1651
                _data_->_tmp8_ = g_get_user_data_dir ();
 
1652
                _data_->_tmp9_ = NULL;
 
1653
                _data_->_tmp9_ = g_build_filename (_data_->_tmp8_, "rhythmbox", "rhythmdb.xml", NULL);
 
1654
                _data_->xml_path = _data_->_tmp9_;
 
1655
                _data_->_tmp10_ = _data_->self->priv->collection;
 
1656
                _data_->_tmp11_ = _data_->xml_path;
 
1657
                unity_music_lens_rhythmbox_collection_parse_file (_data_->_tmp10_, _data_->_tmp11_);
 
1658
                _data_->_tmp12_ = _data_->self->priv->rb_xml_monitor;
 
1659
                if (_data_->_tmp12_ == NULL) {
 
1660
                        _data_->_tmp13_ = _data_->xml_path;
 
1661
                        _data_->_tmp14_ = NULL;
 
1662
                        _data_->_tmp14_ = g_file_new_for_path (_data_->_tmp13_);
 
1663
                        _data_->xml_file = _data_->_tmp14_;
 
1664
                        {
 
1665
                                _data_->_tmp15_ = _data_->xml_file;
 
1666
                                _data_->_tmp16_ = NULL;
 
1667
                                _data_->_tmp16_ = g_file_monitor (_data_->_tmp15_, G_FILE_MONITOR_NONE, NULL, &_data_->_inner_error_);
 
1668
                                _data_->_tmp17_ = _data_->_tmp16_;
 
1669
                                if (_data_->_inner_error_ != NULL) {
 
1670
                                        goto __catch9_g_error;
 
1671
                                }
 
1672
                                _g_object_unref0 (_data_->self->priv->rb_xml_monitor);
 
1673
                                _data_->self->priv->rb_xml_monitor = _data_->_tmp17_;
 
1674
                                _data_->_tmp18_ = _data_->self->priv->rb_xml_monitor;
 
1675
                                g_signal_connect_object (_data_->_tmp18_, "changed", (GCallback) ______lambda14__g_file_monitor_changed, _data_->self, 0);
 
1676
                        }
 
1677
                        goto __finally9;
 
1678
                        __catch9_g_error:
 
1679
                        {
 
1680
                                _data_->err = _data_->_inner_error_;
 
1681
                                _data_->_inner_error_ = NULL;
 
1682
                                _data_->_tmp19_ = _data_->err;
 
1683
                                _data_->_tmp20_ = _data_->_tmp19_->message;
 
1684
                                g_warning ("rhythmbox-scope.vala:334: %s", _data_->_tmp20_);
 
1685
                                _g_error_free0 (_data_->err);
 
1686
                        }
 
1687
                        __finally9:
 
1688
                        if (_data_->_inner_error_ != NULL) {
 
1689
                                _g_object_unref0 (_data_->xml_file);
 
1690
                                _g_free0 (_data_->xml_path);
 
1691
                                _g_free0 (_data_->tdb_path);
 
1692
                                __g_list_free__g_object_unref0_0 (_data_->filters);
 
1693
                                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
 
1694
                                g_clear_error (&_data_->_inner_error_);
 
1695
                                return FALSE;
 
1696
                        }
 
1697
                        _g_object_unref0 (_data_->xml_file);
 
1698
                }
 
1699
                _data_->self->priv->db_ready = TRUE;
 
1700
                _g_free0 (_data_->xml_path);
 
1701
                _g_free0 (_data_->tdb_path);
 
1702
        }
 
1703
        _data_->_tmp21_ = _data_->self->priv->collection;
 
1704
        _data_->_tmp22_ = _data_->search;
 
1705
        _data_->_tmp23_ = _data_->search_type;
 
1706
        _data_->_tmp24_ = _data_->filters;
 
1707
        _data_->_tmp25_ = _data_->max_results;
 
1708
        _data_->_tmp26_ = _data_->category_override;
 
1709
        unity_music_lens_rhythmbox_collection_search (_data_->_tmp21_, _data_->_tmp22_, _data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_, _data_->_tmp26_);
 
1710
        __g_list_free__g_object_unref0_0 (_data_->filters);
 
1711
        if (_data_->_state_ == 0) {
 
1712
                g_simple_async_result_complete_in_idle (_data_->_async_result);
 
1713
        } else {
 
1714
                g_simple_async_result_complete (_data_->_async_result);
 
1715
        }
 
1716
        g_object_unref (_data_->_async_result);
 
1717
        return FALSE;
 
1718
}
 
1719
 
 
1720
 
 
1721
static gint unity_music_lens_rhythmbox_scope_real_get_num_results_without_search (UnityMusicLensSimpleScope* base) {
 
1722
        gint result;
 
1723
        UnityMusicLensRhythmboxScope* self;
 
1724
        self = (UnityMusicLensRhythmboxScope*) base;
 
1725
        result = 100;
 
1726
        return result;
 
1727
}
 
1728
 
 
1729
 
 
1730
static gint unity_music_lens_rhythmbox_scope_real_get_num_results_global_search (UnityMusicLensSimpleScope* base) {
 
1731
        gint result;
 
1732
        UnityMusicLensRhythmboxScope* self;
 
1733
        self = (UnityMusicLensRhythmboxScope*) base;
 
1734
        result = 20;
 
1735
        return result;
 
1736
}
 
1737
 
 
1738
 
 
1739
static gint unity_music_lens_rhythmbox_scope_real_get_num_results_lens_search (UnityMusicLensSimpleScope* base) {
 
1740
        gint result;
 
1741
        UnityMusicLensRhythmboxScope* self;
 
1742
        self = (UnityMusicLensRhythmboxScope*) base;
 
1743
        result = 50;
 
1744
        return result;
 
1745
}
 
1746
 
 
1747
 
 
1748
static void unity_music_lens_rhythmbox_scope_class_init (UnityMusicLensRhythmboxScopeClass * klass) {
 
1749
        unity_music_lens_rhythmbox_scope_parent_class = g_type_class_peek_parent (klass);
 
1750
        g_type_class_add_private (klass, sizeof (UnityMusicLensRhythmboxScopePrivate));
 
1751
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->perform_search = unity_music_lens_rhythmbox_scope_real_perform_search;
 
1752
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->perform_search_finish = unity_music_lens_rhythmbox_scope_real_perform_search_finish;
 
1753
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_without_search = unity_music_lens_rhythmbox_scope_real_get_num_results_without_search;
 
1754
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_global_search = unity_music_lens_rhythmbox_scope_real_get_num_results_global_search;
 
1755
        UNITY_MUSIC_LENS_SIMPLE_SCOPE_CLASS (klass)->get_num_results_lens_search = unity_music_lens_rhythmbox_scope_real_get_num_results_lens_search;
 
1756
        G_OBJECT_CLASS (klass)->get_property = _vala_unity_music_lens_rhythmbox_scope_get_property;
 
1757
        G_OBJECT_CLASS (klass)->finalize = unity_music_lens_rhythmbox_scope_finalize;
 
1758
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_WITHOUT_SEARCH, g_param_spec_int ("num-results-without-search", "num-results-without-search", "num-results-without-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
1759
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_GLOBAL_SEARCH, g_param_spec_int ("num-results-global-search", "num-results-global-search", "num-results-global-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
1760
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_LENS_SEARCH, g_param_spec_int ("num-results-lens-search", "num-results-lens-search", "num-results-lens-search", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
1761
}
 
1762
 
 
1763
 
 
1764
static void unity_music_lens_rhythmbox_scope_instance_init (UnityMusicLensRhythmboxScope * self) {
 
1765
        self->priv = UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_GET_PRIVATE (self);
 
1766
}
 
1767
 
 
1768
 
 
1769
static void unity_music_lens_rhythmbox_scope_finalize (GObject* obj) {
 
1770
        UnityMusicLensRhythmboxScope * self;
 
1771
        self = UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE (obj);
 
1772
        _g_object_unref0 (self->priv->collection);
 
1773
        _g_object_unref0 (self->priv->rb_xml_monitor);
 
1774
        _g_object_unref0 (self->priv->preview_player);
 
1775
        _g_object_unref0 (self->priv->music_preview);
 
1776
        G_OBJECT_CLASS (unity_music_lens_rhythmbox_scope_parent_class)->finalize (obj);
 
1777
}
 
1778
 
 
1779
 
 
1780
GType unity_music_lens_rhythmbox_scope_get_type (void) {
 
1781
        static volatile gsize unity_music_lens_rhythmbox_scope_type_id__volatile = 0;
 
1782
        if (g_once_init_enter (&unity_music_lens_rhythmbox_scope_type_id__volatile)) {
 
1783
                static const GTypeInfo g_define_type_info = { sizeof (UnityMusicLensRhythmboxScopeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_music_lens_rhythmbox_scope_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMusicLensRhythmboxScope), 0, (GInstanceInitFunc) unity_music_lens_rhythmbox_scope_instance_init, NULL };
 
1784
                GType unity_music_lens_rhythmbox_scope_type_id;
 
1785
                unity_music_lens_rhythmbox_scope_type_id = g_type_register_static (UNITY_MUSIC_LENS_TYPE_SIMPLE_SCOPE, "UnityMusicLensRhythmboxScope", &g_define_type_info, 0);
 
1786
                g_once_init_leave (&unity_music_lens_rhythmbox_scope_type_id__volatile, unity_music_lens_rhythmbox_scope_type_id);
 
1787
        }
 
1788
        return unity_music_lens_rhythmbox_scope_type_id__volatile;
 
1789
}
 
1790
 
 
1791
 
 
1792
static void _vala_unity_music_lens_rhythmbox_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
 
1793
        UnityMusicLensRhythmboxScope * self;
 
1794
        self = UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE (object);
 
1795
        switch (property_id) {
 
1796
                case UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_WITHOUT_SEARCH:
 
1797
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_without_search ((UnityMusicLensSimpleScope*) self));
 
1798
                break;
 
1799
                case UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_GLOBAL_SEARCH:
 
1800
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_global_search ((UnityMusicLensSimpleScope*) self));
 
1801
                break;
 
1802
                case UNITY_MUSIC_LENS_RHYTHMBOX_SCOPE_NUM_RESULTS_LENS_SEARCH:
 
1803
                g_value_set_int (value, unity_music_lens_simple_scope_get_num_results_lens_search ((UnityMusicLensSimpleScope*) self));
 
1804
                break;
 
1805
                default:
 
1806
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
1807
                break;
 
1808
        }
 
1809
}
 
1810
 
 
1811
 
 
1812
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
1813
        if ((array != NULL) && (destroy_func != NULL)) {
 
1814
                int i;
 
1815
                for (i = 0; i < array_length; i = i + 1) {
 
1816
                        if (((gpointer*) array)[i] != NULL) {
 
1817
                                destroy_func (((gpointer*) array)[i]);
 
1818
                        }
 
1819
                }
 
1820
        }
 
1821
}
 
1822
 
 
1823
 
 
1824
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
1825
        _vala_array_destroy (array, array_length, destroy_func);
 
1826
        g_free (array);
 
1827
}
 
1828
 
 
1829
 
 
1830