aboutsummaryrefslogtreecommitdiff
path: root/src/metadata-menu-item.c
blob: 1d8cae24e9579056689968bca28025f6016630f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/* metadata-menu-item.c generated by valac 0.12.1, the Vala compiler
 * generated from metadata-menu-item.vala, do not modify */

/*
Copyright 2010 Canonical Ltd.

Authors:
    Conor Curran <conor.curran@canonical.com>

This program is free software: you can redistribute it and/or modify it 
under the terms of the GNU General Public License version 3, as published 
by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranties of 
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along 
with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <glib.h>
#include <glib-object.h>
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/dbusmenu-glib.h>
#include <libdbusmenu-glib/enum-types.h>
#include <libdbusmenu-glib/menuitem-proxy.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-glib/types.h>
#include <stdlib.h>
#include <string.h>
#include <common-defs.h>
#include <gio/gio.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <glib/gstdio.h>
#include <gee.h>


#define TYPE_PLAYER_ITEM (player_item_get_type ())
#define PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_ITEM, PlayerItem))
#define PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_ITEM, PlayerItemClass))
#define IS_PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_ITEM))
#define IS_PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_ITEM))
#define PLAYER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_ITEM, PlayerItemClass))

typedef struct _PlayerItem PlayerItem;
typedef struct _PlayerItemClass PlayerItemClass;
typedef struct _PlayerItemPrivate PlayerItemPrivate;

#define TYPE_METADATA_MENUITEM (metadata_menuitem_get_type ())
#define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem))
#define METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
#define IS_METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_METADATA_MENUITEM))
#define IS_METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_METADATA_MENUITEM))
#define METADATA_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))

typedef struct _MetadataMenuitem MetadataMenuitem;
typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
typedef struct _MetadataMenuitemPrivate MetadataMenuitemPrivate;

#define TYPE_FETCH_FILE (fetch_file_get_type ())
#define FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FETCH_FILE, FetchFile))
#define FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FETCH_FILE, FetchFileClass))
#define IS_FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FETCH_FILE))
#define IS_FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FETCH_FILE))
#define FETCH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FETCH_FILE, FetchFileClass))

typedef struct _FetchFile FetchFile;
typedef struct _FetchFileClass FetchFileClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_PLAYER_CONTROLLER (player_controller_get_type ())
#define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController))
#define PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_CONTROLLER, PlayerControllerClass))
#define IS_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_CONTROLLER))
#define IS_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_CONTROLLER))
#define PLAYER_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_CONTROLLER, PlayerControllerClass))

typedef struct _PlayerController PlayerController;
typedef struct _PlayerControllerClass PlayerControllerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;

#define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ())
#define MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2Controller))
#define MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass))
#define IS_MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS2_CONTROLLER))
#define IS_MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS2_CONTROLLER))
#define MPRIS2_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass))

typedef struct _Mpris2Controller Mpris2Controller;
typedef struct _Mpris2ControllerClass Mpris2ControllerClass;

#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ())

struct _PlayerItem {
	DbusmenuMenuitem parent_instance;
	PlayerItemPrivate * priv;
};

struct _PlayerItemClass {
	DbusmenuMenuitemClass parent_class;
};

struct _MetadataMenuitem {
	PlayerItem parent_instance;
	MetadataMenuitemPrivate * priv;
};

struct _MetadataMenuitemClass {
	PlayerItemClass parent_class;
};

struct _MetadataMenuitemPrivate {
	gchar* previous_temp_album_art_path;
};

struct _PlayerController {
	GObject parent_instance;
	PlayerControllerPrivate * priv;
	gint current_state;
	DbusmenuMenuitem* root_menu;
	GeeArrayList* custom_items;
	Mpris2Controller* mpris_bridge;
	gboolean* use_playlists;
};

struct _PlayerControllerClass {
	GObjectClass parent_class;
};

typedef enum  {
	PLAYER_CONTROLLER_STATE_OFFLINE,
	PLAYER_CONTROLLER_STATE_INSTANTIATING,
	PLAYER_CONTROLLER_STATE_READY,
	PLAYER_CONTROLLER_STATE_CONNECTED,
	PLAYER_CONTROLLER_STATE_DISCONNECTED
} PlayerControllerstate;


static gpointer metadata_menuitem_parent_class = NULL;
extern gchar* metadata_menuitem_album_art_cache_dir;
gchar* metadata_menuitem_album_art_cache_dir = NULL;
static FetchFile* metadata_menuitem_fetcher;
static FetchFile* metadata_menuitem_fetcher = NULL;

GType player_item_get_type (void) G_GNUC_CONST;
GType metadata_menuitem_get_type (void) G_GNUC_CONST;
#define METADATA_MENUITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_METADATA_MENUITEM, MetadataMenuitemPrivate))
enum  {
	METADATA_MENUITEM_DUMMY_PROPERTY
};
GType fetch_file_get_type (void) G_GNUC_CONST;
#define METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX "indicator/sound/album-art-cache"
GType player_controller_get_type (void) G_GNUC_CONST;
MetadataMenuitem* metadata_menuitem_new (PlayerController* parent);
MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent);
static void metadata_menuitem_clean_album_art_temp_dir (void);
static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir);
static gchar* metadata_menuitem_create_album_art_temp_dir (void);
void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, const gchar* prop);
#define PLAYER_ITEM_EMPTY (-1)
FetchFile* fetch_file_new (const gchar* uri, const gchar* prop);
FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop);
static void _lambda0_ (MetadataMenuitem* self);
static void metadata_menuitem_on_fetcher_failed (MetadataMenuitem* self);
static void __lambda0__fetch_file_failed (FetchFile* _sender, gpointer self);
static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByteArray* update, const gchar* property);
static void _metadata_menuitem_on_fetcher_completed_fetch_file_completed (FetchFile* _sender, GByteArray* data, const gchar* property, gpointer self);
void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_);
static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp);
PlayerController* player_item_get_owner (PlayerItem* self);
GType mpris2_controller_get_type (void) G_GNUC_CONST;
GType player_controller_state_get_type (void) G_GNUC_CONST;
void player_controller_instantiate (PlayerController* self);
void mpris2_controller_expose (Mpris2Controller* self);
void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title);
void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update);
void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse);
GeeHashSet* metadata_menuitem_attributes_format (void);
GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void);
static GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
GAppInfo* player_controller_get_app_info (PlayerController* self);
const gchar* player_controller_get_icon_name (PlayerController* self);
void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
static void metadata_menuitem_finalize (GObject* obj);


MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent) {
	MetadataMenuitem * self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (MetadataMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_METADATA_MENUITEM_TYPE, "owner", parent, NULL);
	return self;
}


MetadataMenuitem* metadata_menuitem_new (PlayerController* parent) {
	return metadata_menuitem_construct (TYPE_METADATA_MENUITEM, parent);
}


static void metadata_menuitem_clean_album_art_temp_dir (void) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* path;
	GFile* _tmp2_ = NULL;
	GFile* album_art_dir;
	gboolean _tmp3_;
	_tmp0_ = g_get_user_cache_dir ();
	_tmp1_ = g_build_filename (_tmp0_, METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX, NULL);
	path = _tmp1_;
	_tmp2_ = g_file_new_for_path (path);
	album_art_dir = _tmp2_;
	_tmp3_ = metadata_menuitem_delete_album_art_contents (album_art_dir);
	if (_tmp3_ == FALSE) {
		g_warning ("metadata-menu-item.vala:58: could not remove the temp album art files " \
"%s", path);
	}
	_g_object_unref0 (album_art_dir);
	_g_free0 (path);
}


static gchar* metadata_menuitem_create_album_art_temp_dir (void) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* path;
	gint _tmp2_;
	_tmp0_ = g_get_user_cache_dir ();
	_tmp1_ = g_build_filename (_tmp0_, METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX, NULL);
	path = _tmp1_;
	_tmp2_ = g_mkdir_with_parents (path, 0700);
	if (_tmp2_ == (-1)) {
		g_warning ("metadata-menu-item.vala:66: could not create temp dir %s for remote al" \
"bum art, it must have been created already", path);
	}
	result = path;
	return result;
}


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir) {
	gboolean result = FALSE;
	gboolean _result_;
	GFileEnumerator* _tmp0_ = NULL;
	GFileEnumerator* e;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (dir != NULL, FALSE);
	_result_ = TRUE;
	_tmp0_ = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error_);
	e = _tmp0_;
	if (_inner_error_ != NULL) {
		goto __catch2_g_error;
	}
	while (TRUE) {
		GFileInfo* _tmp1_ = NULL;
		GFileInfo* file;
		const gchar* _tmp2_ = NULL;
		const gchar* _tmp3_ = NULL;
		GFile* _tmp4_ = NULL;
		GFile* child;
		_tmp1_ = g_file_enumerator_next_file (e, NULL, &_inner_error_);
		file = _tmp1_;
		if (_inner_error_ != NULL) {
			_g_object_unref0 (e);
			goto __catch2_g_error;
		}
		if (file == NULL) {
			_g_object_unref0 (file);
			break;
		}
		_tmp2_ = g_file_info_get_name (file);
		g_debug ("metadata-menu-item.vala:85: file name = %s", _tmp2_);
		_tmp3_ = g_file_info_get_name (file);
		_tmp4_ = g_file_get_child (dir, _tmp3_);
		child = _tmp4_;
		g_file_delete (child, NULL, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch3_g_error;
		}
		goto __finally3;
		__catch3_g_error:
		{
			GError * error_;
			gchar* _tmp5_ = NULL;
			gchar* _tmp6_;
			const gchar* _tmp7_ = NULL;
			const gchar* _tmp8_ = NULL;
			gchar* _tmp9_ = NULL;
			gchar* _tmp10_;
			error_ = _inner_error_;
			_inner_error_ = NULL;
			_tmp5_ = g_file_get_basename (child);
			_tmp6_ = _tmp5_;
			_tmp7_ = string_to_string (_tmp6_);
			_tmp8_ = string_to_string (error_->message);
			_tmp9_ = g_strconcat ("Unable to delete file '", _tmp7_, ": ", _tmp8_, NULL);
			_tmp10_ = _tmp9_;
			g_warning ("metadata-menu-item.vala:92: %s", _tmp10_);
			_g_free0 (_tmp10_);
			_g_free0 (_tmp6_);
			_result_ = FALSE;
			_g_error_free0 (error_);
		}
		__finally3:
		if (_inner_error_ != NULL) {
			_g_object_unref0 (child);
			_g_object_unref0 (file);
			_g_object_unref0 (e);
			goto __catch2_g_error;
		}
		_g_object_unref0 (child);
		_g_object_unref0 (file);
	}
	_g_object_unref0 (e);
	goto __finally2;
	__catch2_g_error:
	{
		GError * _error_;
		gchar* _tmp11_ = NULL;
		gchar* _tmp12_;
		const gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp11_ = g_file_get_basename (dir);
		_tmp12_ = _tmp11_;
		_tmp13_ = string_to_string (_tmp12_);
		_tmp14_ = g_strconcat ("Unable to read files from directory '", _tmp13_, "': %s", NULL);
		_tmp15_ = _tmp14_;
		g_warning (_tmp15_, _error_->message);
		_g_free0 (_tmp15_);
		_g_free0 (_tmp12_);
		_result_ = FALSE;
		_g_error_free0 (_error_);
	}
	__finally2:
	if (_inner_error_ != NULL) {
		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);
		g_clear_error (&_inner_error_);
		return FALSE;
	}
	result = _result_;
	return result;
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _result_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}


static void _lambda0_ (MetadataMenuitem* self) {
	metadata_menuitem_on_fetcher_failed (self);
}


static void __lambda0__fetch_file_failed (FetchFile* _sender, gpointer self) {
	_lambda0_ (self);
}


static void _metadata_menuitem_on_fetcher_completed_fetch_file_completed (FetchFile* _sender, GByteArray* data, const gchar* property, gpointer self) {
	metadata_menuitem_on_fetcher_completed (self, data, property);
}


void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, const gchar* prop) {
	GFile* _tmp0_ = NULL;
	GFile* art_file;
	gboolean _tmp1_;
	FetchFile* _tmp10_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (prop != NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	art_file = _tmp0_;
	_tmp1_ = g_file_is_native (art_file);
	if (_tmp1_ == TRUE) {
		gboolean _tmp2_;
		gchar* path = NULL;
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_;
		_tmp2_ = g_file_query_exists (art_file, NULL);
		if (_tmp2_ == FALSE) {
			dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, prop, PLAYER_ITEM_EMPTY);
			_g_object_unref0 (art_file);
			return;
		}
		_tmp3_ = string_strip (uri);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_filename_from_uri (_tmp4_, NULL, &_inner_error_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		_tmp7_ = _tmp6_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_CONVERT_ERROR) {
				goto __catch4_g_convert_error;
			}
			_g_free0 (path);
			_g_object_unref0 (art_file);
			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);
			g_clear_error (&_inner_error_);
			return;
		}
		_g_free0 (path);
		path = _tmp7_;
		_tmp8_ = string_strip (uri);
		_tmp9_ = _tmp8_;
		g_debug ("metadata-menu-item.vala:116: Populating the artwork field with %s", _tmp9_);
		_g_free0 (_tmp9_);
		dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, prop, path);
		goto __finally4;
		__catch4_g_convert_error:
		{
			GError * e;
			e = _inner_error_;
			_inner_error_ = NULL;
			g_warning ("metadata-menu-item.vala:120: Problem converting URI %s to file path", uri);
			_g_error_free0 (e);
		}
		__finally4:
		if (_inner_error_ != NULL) {
			_g_free0 (path);
			_g_object_unref0 (art_file);
			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);
			g_clear_error (&_inner_error_);
			return;
		}
		_g_free0 (path);
		_g_object_unref0 (art_file);
		return;
	}
	g_debug ("metadata-menu-item.vala:126: fetch_art -remotely %s", metadata_menuitem_album_art_cache_dir);
	if (metadata_menuitem_album_art_cache_dir == NULL) {
		_g_object_unref0 (art_file);
		return;
	}
	_tmp10_ = fetch_file_new (uri, prop);
	_g_object_unref0 (metadata_menuitem_fetcher);
	metadata_menuitem_fetcher = _tmp10_;
	g_signal_connect_object (metadata_menuitem_fetcher, "failed", (GCallback) __lambda0__fetch_file_failed, self, 0);
	g_signal_connect_object (metadata_menuitem_fetcher, "completed", (GCallback) _metadata_menuitem_on_fetcher_completed_fetch_file_completed, self, 0);
	fetch_file_fetch_data (metadata_menuitem_fetcher, NULL, NULL);
	_g_object_unref0 (art_file);
}


static void metadata_menuitem_on_fetcher_failed (MetadataMenuitem* self) {
	g_return_if_fail (self != NULL);
	g_warning ("metadata-menu-item.vala:141: on_fetcher_failed -> could not fetch artw" \
"ork");
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByteArray* update, const gchar* property) {
	GdkPixbufLoader* _tmp0_ = NULL;
	GdkPixbufLoader* loader;
	GdkPixbuf* _tmp1_ = NULL;
	GdkPixbuf* _tmp2_;
	GdkPixbuf* icon;
	gchar* _tmp3_ = NULL;
	gchar* path;
	gint _tmp4_;
	gint r;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (update != NULL);
	g_return_if_fail (property != NULL);
	_tmp0_ = gdk_pixbuf_loader_new ();
	loader = _tmp0_;
	gdk_pixbuf_loader_write (loader, update->data, (gsize) ((gint) update->len), &_inner_error_);
	if (_inner_error_ != NULL) {
		_g_object_unref0 (loader);
		goto __catch5_g_error;
	}
	gdk_pixbuf_loader_close (loader, &_inner_error_);
	if (_inner_error_ != NULL) {
		_g_object_unref0 (loader);
		goto __catch5_g_error;
	}
	_tmp1_ = gdk_pixbuf_loader_get_pixbuf (loader);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	icon = _tmp2_;
	_tmp3_ = g_strconcat (metadata_menuitem_album_art_cache_dir, "/downloaded-coverart-XXXXXX", NULL);
	path = _tmp3_;
	_tmp4_ = g_mkstemp (path);
	r = _tmp4_;
	if (r != (-1)) {
		GdkPixbufFormat* _tmp5_ = NULL;
		const gchar* _tmp6_ = NULL;
		gchar* _tmp7_;
		_tmp5_ = gdk_pixbuf_loader_get_format (loader);
		_tmp6_ = gdk_pixbuf_format_get_name (_tmp5_);
		gdk_pixbuf_save (icon, path, _tmp6_, &_inner_error_, NULL);
		if (_inner_error_ != NULL) {
			_g_free0 (path);
			_g_object_unref0 (icon);
			_g_object_unref0 (loader);
			goto __catch5_g_error;
		}
		dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, path);
		if (self->priv->previous_temp_album_art_path != NULL) {
			g_remove (self->priv->previous_temp_album_art_path);
		}
		_tmp7_ = g_strdup (path);
		_g_free0 (self->priv->previous_temp_album_art_path);
		self->priv->previous_temp_album_art_path = _tmp7_;
	}
	_g_free0 (path);
	_g_object_unref0 (icon);
	_g_object_unref0 (loader);
	goto __finally5;
	__catch5_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_warning ("metadata-menu-item.vala:163: Problem creating file from bytearray fetc" \
"hed from the interweb - error: %s", e->message);
		_g_error_free0 (e);
	}
	__finally5:
	if (_inner_error_ != NULL) {
		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);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp) {
	MetadataMenuitem * self;
	PlayerController* _tmp0_ = NULL;
	self = (MetadataMenuitem*) base;
	g_return_if_fail (name != NULL);
	g_return_if_fail (input_value != NULL);
	_tmp0_ = player_item_get_owner ((PlayerItem*) self);
	if (_tmp0_->current_state == PLAYER_CONTROLLER_STATE_OFFLINE) {
		PlayerController* _tmp1_ = NULL;
		_tmp1_ = player_item_get_owner ((PlayerItem*) self);
		player_controller_instantiate (_tmp1_);
	} else {
		PlayerController* _tmp2_ = NULL;
		_tmp2_ = player_item_get_owner ((PlayerItem*) self);
		if (_tmp2_->current_state == PLAYER_CONTROLLER_STATE_CONNECTED) {
			PlayerController* _tmp3_ = NULL;
			_tmp3_ = player_item_get_owner ((PlayerItem*) self);
			mpris2_controller_expose (_tmp3_->mpris_bridge);
		}
	}
}


void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_title != NULL);
	if (new_title == NULL) {
		return;
	}
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, new_title);
}


void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update) {
	g_return_if_fail (self != NULL);
	g_debug ("metadata-menu-item.vala:189: toggle active triangle");
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING, update);
}


void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse) {
	g_return_if_fail (self != NULL);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, collapse);
}


GeeHashSet* metadata_menuitem_attributes_format (void) {
	GeeHashSet* result = NULL;
	GeeHashSet* _tmp0_ = NULL;
	GeeHashSet* attrs;
	_tmp0_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	attrs = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_TITLE);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTIST);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ALBUM);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTURL);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING);
	result = attrs;
	return result;
}


GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void) {
	GeeHashSet* result = NULL;
	GeeHashSet* _tmp0_ = NULL;
	GeeHashSet* attrs;
	_tmp0_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	attrs = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_TITLE);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTIST);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ALBUM);
	gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTURL);
	result = attrs;
	return result;
}


static GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	MetadataMenuitem * self;
	gchar* _tmp0_ = NULL;
	PlayerController* _tmp1_ = NULL;
	GAppInfo* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	PlayerController* _tmp4_ = NULL;
	GAppInfo* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	PlayerController* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	GeeHashSet* _tmp9_ = NULL;
	GeeHashSet* _tmp10_;
	parent_class = G_OBJECT_CLASS (metadata_menuitem_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = METADATA_MENUITEM (obj);
	metadata_menuitem_clean_album_art_temp_dir ();
	_g_free0 (self->priv->previous_temp_album_art_path);
	self->priv->previous_temp_album_art_path = NULL;
	_tmp0_ = metadata_menuitem_create_album_art_temp_dir ();
	_g_free0 (metadata_menuitem_album_art_cache_dir);
	metadata_menuitem_album_art_cache_dir = _tmp0_;
	_tmp1_ = player_item_get_owner ((PlayerItem*) self);
	_tmp2_ = player_controller_get_app_info (_tmp1_);
	_tmp3_ = g_app_info_get_name (_tmp2_);
	g_debug ("metadata-menu-item.vala:42: JUST ABOUT TO ATTEMPT PLAYER NAME SETTING " \
"%s", _tmp3_);
	_tmp4_ = player_item_get_owner ((PlayerItem*) self);
	_tmp5_ = player_controller_get_app_info (_tmp4_);
	_tmp6_ = g_app_info_get_name (_tmp5_);
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, _tmp6_);
	_tmp7_ = player_item_get_owner ((PlayerItem*) self);
	_tmp8_ = player_controller_get_icon_name (_tmp7_);
	dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON, _tmp8_);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING, FALSE);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, TRUE);
	_tmp9_ = metadata_menuitem_relevant_attributes_for_ui ();
	_tmp10_ = _tmp9_;
	player_item_reset ((PlayerItem*) self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	return obj;
}


static void metadata_menuitem_class_init (MetadataMenuitemClass * klass) {
	metadata_menuitem_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MetadataMenuitemPrivate));
	DBUSMENU_MENUITEM_CLASS (klass)->handle_event = metadata_menuitem_real_handle_event;
	G_OBJECT_CLASS (klass)->constructor = metadata_menuitem_constructor;
	G_OBJECT_CLASS (klass)->finalize = metadata_menuitem_finalize;
}


static void metadata_menuitem_instance_init (MetadataMenuitem * self) {
	self->priv = METADATA_MENUITEM_GET_PRIVATE (self);
}


static void metadata_menuitem_finalize (GObject* obj) {
	MetadataMenuitem * self;
	self = METADATA_MENUITEM (obj);
	_g_free0 (self->priv->previous_temp_album_art_path);
	G_OBJECT_CLASS (metadata_menuitem_parent_class)->finalize (obj);
}


GType metadata_menuitem_get_type (void) {
	static volatile gsize metadata_menuitem_type_id__volatile = 0;
	if (g_once_init_enter (&metadata_menuitem_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MetadataMenuitemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) metadata_menuitem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MetadataMenuitem), 0, (GInstanceInitFunc) metadata_menuitem_instance_init, NULL };
		GType metadata_menuitem_type_id;
		metadata_menuitem_type_id = g_type_register_static (TYPE_PLAYER_ITEM, "MetadataMenuitem", &g_define_type_info, 0);
		g_once_init_leave (&metadata_menuitem_type_id__volatile, metadata_menuitem_type_id);
	}
	return metadata_menuitem_type_id__volatile;
}