aboutsummaryrefslogtreecommitdiff
path: root/src/player-controller.c
blob: 2872736789a05dc5deba41a156b18ea92d4f0d5e (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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
/* player-controller.c generated by valac 0.11.2, the Vala compiler
 * generated from player-controller.vala, do not modify */

/*
This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
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 <gee.h>
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/menuitem-proxy.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#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;
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;

#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;

#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_WIDGET_ORDER (player_controller_widget_order_get_type ())

#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_TITLE_MENUITEM (title_menuitem_get_type ())
#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem))
#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass))
#define IS_TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TITLE_MENUITEM))
#define IS_TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TITLE_MENUITEM))
#define TITLE_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TITLE_MENUITEM, TitleMenuitemClass))

typedef struct _TitleMenuitem TitleMenuitem;
typedef struct _TitleMenuitemClass TitleMenuitemClass;

#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;

#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ())
#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem))
#define TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))
#define IS_TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPORT_MENUITEM))
#define IS_TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPORT_MENUITEM))
#define TRANSPORT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))

typedef struct _TransportMenuitem TransportMenuitem;
typedef struct _TransportMenuitemClass TransportMenuitemClass;

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

struct _PlayerControllerClass {
	GObjectClass parent_class;
};

struct _PlayerControllerPrivate {
	DbusmenuMenuitem* root_menu;
	gchar* _name;
	gchar* _dbus_name;
	GAppInfo* _app_info;
	gint _menu_offset;
	gchar* _icon_name;
};

typedef enum  {
	PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR,
	PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
	PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
	PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
} PlayerControllerwidget_order;

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 player_controller_parent_class = NULL;

GType player_controller_get_type (void) G_GNUC_CONST;
GType player_item_get_type (void) G_GNUC_CONST;
GType mpris2_controller_get_type (void) G_GNUC_CONST;
#define PLAYER_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYER_CONTROLLER, PlayerControllerPrivate))
enum  {
	PLAYER_CONTROLLER_DUMMY_PROPERTY,
	PLAYER_CONTROLLER_NAME,
	PLAYER_CONTROLLER_DBUS_NAME,
	PLAYER_CONTROLLER_APP_INFO,
	PLAYER_CONTROLLER_MENU_OFFSET,
	PLAYER_CONTROLLER_ICON_NAME
};
GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
GType player_controller_state_get_type (void) G_GNUC_CONST;
#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4
PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state);
PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state);
void player_controller_set_app_info (PlayerController* self, GAppInfo* value);
void player_controller_set_dbus_name (PlayerController* self, const gchar* value);
static gchar* player_controller_format_player_name (gchar* app_info_name);
GAppInfo* player_controller_get_app_info (PlayerController* self);
void player_controller_set_name (PlayerController* self, const gchar* value);
void player_controller_set_icon_name (PlayerController* self, const gchar* value);
void player_controller_set_menu_offset (PlayerController* self, gint value);
static void player_controller_construct_widgets (PlayerController* self);
static void player_controller_establish_mpris_connection (PlayerController* self);
void player_controller_update_layout (PlayerController* self);
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
const gchar* player_controller_get_name (PlayerController* self);
void player_controller_activate (PlayerController* self, const gchar* dbus_name);
void player_controller_instantiate (PlayerController* self);
const gchar* player_controller_get_dbus_name (PlayerController* self);
Mpris2Controller* mpris2_controller_new (PlayerController* ctrl);
Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl);
static void player_controller_determine_state (PlayerController* self);
void player_controller_vanish (PlayerController* self);
void player_controller_hibernate (PlayerController* self);
void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
GeeHashSet* transport_menuitem_attributes_format (void);
GeeHashSet* metadata_menuitem_attributes_format (void);
GType title_menuitem_get_type (void) G_GNUC_CONST;
void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update);
gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
PlayerItem* player_item_new (const gchar* type);
PlayerItem* player_item_construct (GType object_type, const gchar* type);
TitleMenuitem* title_menuitem_new (PlayerController* parent);
TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
GType metadata_menuitem_get_type (void) G_GNUC_CONST;
TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
GType transport_menuitem_get_type (void) G_GNUC_CONST;
gint player_controller_get_menu_offset (PlayerController* self);
gboolean mpris2_controller_connected (Mpris2Controller* self);
void mpris2_controller_initial_update (Mpris2Controller* self);
const gchar* player_controller_get_icon_name (PlayerController* self);
static void player_controller_finalize (GObject* obj);
static void _vala_player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


GType player_controller_widget_order_get_type (void) {
	static volatile gsize player_controller_widget_order_type_id__volatile = 0;
	if (g_once_init_enter (&player_controller_widget_order_type_id__volatile)) {
		static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, "PLAYER_CONTROLLER_WIDGET_ORDER_TITLE", "title"}, {PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, "PLAYER_CONTROLLER_WIDGET_ORDER_METADATA", "metadata"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, "PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT", "transport"}, {0, NULL, NULL}};
		GType player_controller_widget_order_type_id;
		player_controller_widget_order_type_id = g_enum_register_static ("PlayerControllerwidget_order", values);
		g_once_init_leave (&player_controller_widget_order_type_id__volatile, player_controller_widget_order_type_id);
	}
	return player_controller_widget_order_type_id__volatile;
}


GType player_controller_state_get_type (void) {
	static volatile gsize player_controller_state_type_id__volatile = 0;
	if (g_once_init_enter (&player_controller_state_type_id__volatile)) {
		static const GEnumValue values[] = {{PLAYER_CONTROLLER_STATE_OFFLINE, "PLAYER_CONTROLLER_STATE_OFFLINE", "offline"}, {PLAYER_CONTROLLER_STATE_INSTANTIATING, "PLAYER_CONTROLLER_STATE_INSTANTIATING", "instantiating"}, {PLAYER_CONTROLLER_STATE_READY, "PLAYER_CONTROLLER_STATE_READY", "ready"}, {PLAYER_CONTROLLER_STATE_CONNECTED, "PLAYER_CONTROLLER_STATE_CONNECTED", "connected"}, {PLAYER_CONTROLLER_STATE_DISCONNECTED, "PLAYER_CONTROLLER_STATE_DISCONNECTED", "disconnected"}, {0, NULL, NULL}};
		GType player_controller_state_type_id;
		player_controller_state_type_id = g_enum_register_static ("PlayerControllerstate", values);
		g_once_init_leave (&player_controller_state_type_id__volatile, player_controller_state_type_id);
	}
	return player_controller_state_type_id__volatile;
}


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


PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state) {
	PlayerController * self = NULL;
	DbusmenuMenuitem* _tmp0_;
	DbusmenuMenuitem* _tmp1_;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	GeeArrayList* _tmp6_ = NULL;
	GeeArrayList* _tmp7_;
	g_return_val_if_fail (root != NULL, NULL);
	g_return_val_if_fail (app != NULL, NULL);
	g_return_val_if_fail (icon_name != NULL, NULL);
	self = (PlayerController*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (root);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (self->priv->root_menu);
	self->priv->root_menu = _tmp1_;
	player_controller_set_app_info (self, app);
	player_controller_set_dbus_name (self, dbus_name);
	_tmp2_ = g_app_info_get_name (self->priv->_app_info);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = player_controller_format_player_name (_tmp3_);
	_tmp5_ = _tmp4_;
	player_controller_set_name (self, _tmp5_);
	_g_free0 (_tmp5_);
	player_controller_set_icon_name (self, icon_name);
	_tmp6_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (self->custom_items);
	self->custom_items = _tmp7_;
	self->current_state = (gint) initial_state;
	player_controller_set_menu_offset (self, offset);
	player_controller_construct_widgets (self);
	player_controller_establish_mpris_connection (self);
	player_controller_update_layout (self);
	return self;
}


PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state) {
	return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, app, dbus_name, icon_name, offset, initial_state);
}


void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) {
	g_return_if_fail (self != NULL);
	g_debug ("player-controller.vala:76: update_state - player controller %s : new s" \
"tate %i", self->priv->_name, (gint) new_state);
	self->current_state = (gint) new_state;
	player_controller_update_layout (self);
}


void player_controller_activate (PlayerController* self, const gchar* dbus_name) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (dbus_name != NULL);
	player_controller_set_dbus_name (self, dbus_name);
	player_controller_establish_mpris_connection (self);
}


void player_controller_instantiate (PlayerController* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_debug ("player-controller.vala:95: instantiate in player controller for %s", self->priv->_name);
	g_app_info_launch (self->priv->_app_info, NULL, NULL, &_inner_error_);
	if (_inner_error_ != NULL) {
		goto __catch6_g_error;
	}
	player_controller_update_state (self, PLAYER_CONTROLLER_STATE_INSTANTIATING);
	goto __finally6;
	__catch6_g_error:
	{
		GError * _error_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		g_warning ("player-controller.vala:101: Failed to launch app %s with error message" \
": %s", self->priv->_name, _error_->message);
		_g_error_free0 (_error_);
	}
	__finally6:
	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 player_controller_establish_mpris_connection (PlayerController* self) {
	gboolean _tmp0_ = FALSE;
	Mpris2Controller* _tmp1_ = NULL;
	Mpris2Controller* _tmp2_;
	g_return_if_fail (self != NULL);
	if (self->current_state != PLAYER_CONTROLLER_STATE_READY) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = self->priv->_dbus_name == NULL;
	}
	if (_tmp0_) {
		g_debug ("player-controller.vala:108: establish_mpris_connection - Not ready to " \
"connect");
		return;
	}
	_tmp1_ = mpris2_controller_new (self);
	_tmp2_ = _tmp1_;
	_g_object_unref0 (self->mpris_bridge);
	self->mpris_bridge = _tmp2_;
	player_controller_determine_state (self);
}


void player_controller_vanish (PlayerController* self) {
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _tmp0_;
		GeeArrayList* _item_list;
		gint _tmp1_;
		gint _item_size;
		gint _item_index;
		_tmp0_ = _g_object_ref0 (self->custom_items);
		_item_list = _tmp0_;
		_tmp1_ = gee_collection_get_size ((GeeCollection*) _item_list);
		_item_size = _tmp1_;
		_item_index = -1;
		while (TRUE) {
			gpointer _tmp2_ = NULL;
			DbusmenuMenuitem* item;
			_item_index = _item_index + 1;
			if (!(_item_index < _item_size)) {
				break;
			}
			_tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index);
			item = (DbusmenuMenuitem*) ((PlayerItem*) _tmp2_);
			dbusmenu_menuitem_child_delete (self->priv->root_menu, item);
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_list);
	}
}


void player_controller_hibernate (PlayerController* self) {
	gpointer _tmp0_ = NULL;
	PlayerItem* _tmp1_;
	GeeHashSet* _tmp2_ = NULL;
	GeeHashSet* _tmp3_;
	gpointer _tmp4_ = NULL;
	PlayerItem* _tmp5_;
	GeeHashSet* _tmp6_ = NULL;
	GeeHashSet* _tmp7_;
	gpointer _tmp8_ = NULL;
	PlayerItem* _tmp9_;
	TitleMenuitem* title;
	g_return_if_fail (self != NULL);
	player_controller_update_state (self, PLAYER_CONTROLLER_STATE_OFFLINE);
	_tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT);
	_tmp1_ = (PlayerItem*) _tmp0_;
	_tmp2_ = transport_menuitem_attributes_format ();
	_tmp3_ = _tmp2_;
	player_item_reset (_tmp1_, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
	_tmp5_ = (PlayerItem*) _tmp4_;
	_tmp6_ = metadata_menuitem_attributes_format ();
	_tmp7_ = _tmp6_;
	player_item_reset (_tmp5_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE);
	title = (_tmp9_ = (PlayerItem*) _tmp8_, IS_TITLE_MENUITEM (_tmp9_) ? ((TitleMenuitem*) _tmp9_) : NULL);
	title_menuitem_toggle_active_triangle (title, FALSE);
	_g_object_unref0 (title);
}


void player_controller_update_layout (PlayerController* self) {
	gpointer _tmp4_ = NULL;
	PlayerItem* _tmp5_;
	gpointer _tmp6_ = NULL;
	PlayerItem* _tmp7_;
	GeeHashSet* _tmp8_ = NULL;
	GeeHashSet* _tmp9_;
	gboolean _tmp10_;
	gpointer _tmp11_ = NULL;
	PlayerItem* _tmp12_;
	g_return_if_fail (self != NULL);
	if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) {
		gpointer _tmp0_ = NULL;
		PlayerItem* _tmp1_;
		gpointer _tmp2_ = NULL;
		PlayerItem* _tmp3_;
		_tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT);
		_tmp1_ = (PlayerItem*) _tmp0_;
		dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp1_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
		_g_object_unref0 (_tmp1_);
		_tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
		_tmp3_ = (PlayerItem*) _tmp2_;
		dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp3_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
		_g_object_unref0 (_tmp3_);
		return;
	}
	_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
	_tmp5_ = (PlayerItem*) _tmp4_;
	_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
	_tmp7_ = (PlayerItem*) _tmp6_;
	_tmp8_ = metadata_menuitem_attributes_format ();
	_tmp9_ = _tmp8_;
	_tmp10_ = player_item_populated (_tmp7_, _tmp9_);
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp10_);
	_g_object_unref0 (_tmp9_);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_tmp11_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT);
	_tmp12_ = (PlayerItem*) _tmp11_;
	dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp12_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
	_g_object_unref0 (_tmp12_);
}


static void player_controller_construct_widgets (PlayerController* self) {
	PlayerItem* _tmp0_ = NULL;
	PlayerItem* _tmp1_;
	TitleMenuitem* _tmp2_ = NULL;
	TitleMenuitem* title_menu_item;
	MetadataMenuitem* _tmp3_ = NULL;
	MetadataMenuitem* metadata_item;
	TransportMenuitem* _tmp4_ = NULL;
	TransportMenuitem* transport_item;
	g_return_if_fail (self != NULL);
	_tmp0_ = player_item_new (DBUSMENU_CLIENT_TYPES_SEPARATOR);
	_tmp1_ = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = title_menuitem_new (self);
	title_menu_item = _tmp2_;
	gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) title_menu_item);
	_tmp3_ = metadata_menuitem_new ();
	metadata_item = _tmp3_;
	gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) metadata_item);
	_tmp4_ = transport_menuitem_new (self);
	transport_item = _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) transport_item);
	{
		GeeArrayList* _tmp5_;
		GeeArrayList* _item_list;
		gint _tmp6_;
		gint _item_size;
		gint _item_index;
		_tmp5_ = _g_object_ref0 (self->custom_items);
		_item_list = _tmp5_;
		_tmp6_ = gee_collection_get_size ((GeeCollection*) _item_list);
		_item_size = _tmp6_;
		_item_index = -1;
		while (TRUE) {
			gpointer _tmp7_ = NULL;
			PlayerItem* item;
			gint _tmp8_;
			_item_index = _item_index + 1;
			if (!(_item_index < _item_size)) {
				break;
			}
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index);
			item = (PlayerItem*) _tmp7_;
			_tmp8_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item);
			dbusmenu_menuitem_child_add_position (self->priv->root_menu, (DbusmenuMenuitem*) item, (guint) (self->priv->_menu_offset + _tmp8_));
			_g_object_unref0 (item);
		}
		_g_object_unref0 (_item_list);
	}
	_g_object_unref0 (transport_item);
	_g_object_unref0 (metadata_item);
	_g_object_unref0 (title_menu_item);
}


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 const gchar* string_offset (const gchar* self, glong offset) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = (const gchar*) (((gchar*) self) + offset);
	return result;
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong _tmp0_;
	glong string_length;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_ = NULL;
	const gchar* start_string;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	string_length = _tmp0_;
	if (start < 0) {
		start = string_length + start;
	}
	if (end < 0) {
		end = string_length + end;
	}
	if (start >= 0) {
		_tmp1_ = start <= string_length;
	} else {
		_tmp1_ = FALSE;
	}
	g_return_val_if_fail (_tmp1_, NULL);
	if (end >= 0) {
		_tmp2_ = end <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp3_ = string_offset (self, start);
	start_string = _tmp3_;
	_tmp4_ = string_offset (start_string, end - start);
	_tmp5_ = g_strndup (start_string, ((gchar*) _tmp4_) - ((gchar*) start_string));
	result = _tmp5_;
	return result;
}


static gchar* player_controller_format_player_name (gchar* app_info_name) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	gchar* _result_;
	gchar** _tmp4_;
	gchar** _tmp5_ = NULL;
	gint tokens_length1;
	gint _tokens_size_;
	gchar** _tmp6_;
	gchar** tokens;
	glong _tmp9_;
	g_return_val_if_fail (app_info_name != NULL, NULL);
	_tmp0_ = g_utf8_strdown (app_info_name, (gssize) (-1));
	_tmp1_ = _tmp0_;
	_tmp2_ = string_strip (_tmp1_);
	_result_ = (_tmp3_ = _tmp2_, _g_free0 (_tmp1_), _tmp3_);
	_tmp5_ = _tmp4_ = g_strsplit (_result_, " ", 0);
	_tmp6_ = _tmp5_;
	tokens_length1 = _vala_array_length (_tmp4_);
	_tokens_size_ = tokens_length1;
	tokens = _tmp6_;
	if (tokens_length1 > 1) {
		gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = g_strdup (tokens[0]);
		_tmp8_ = _tmp7_;
		_g_free0 (_result_);
		_result_ = _tmp8_;
	}
	_tmp9_ = strlen (_result_);
	if (_tmp9_ > 1) {
		gchar* _tmp10_ = NULL;
		gchar* _tmp11_;
		glong _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_;
		gchar* _tmp15_ = NULL;
		gchar* _tmp16_;
		_tmp10_ = g_utf8_strup (_result_, (gssize) 1);
		_tmp11_ = _tmp10_;
		_tmp12_ = strlen (_result_);
		_tmp13_ = string_slice (_result_, (glong) 1, _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_strconcat (_tmp11_, _tmp14_, NULL);
		_tmp16_ = _tmp15_;
		_g_free0 (_result_);
		_result_ = _tmp16_;
		_g_free0 (_tmp14_);
		_g_free0 (_tmp11_);
	}
	g_debug ("player-controller.vala:178: PlayerController->format_player_name - : %" \
"s", _result_);
	result = _result_;
	tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (app_info_name);
	return result;
}


static void player_controller_determine_state (PlayerController* self) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = mpris2_controller_connected (self->mpris_bridge);
	if (_tmp0_ == TRUE) {
		gpointer _tmp1_ = NULL;
		PlayerItem* _tmp2_;
		TitleMenuitem* title;
		player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
		_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE);
		title = (_tmp2_ = (PlayerItem*) _tmp1_, IS_TITLE_MENUITEM (_tmp2_) ? ((TitleMenuitem*) _tmp2_) : NULL);
		title_menuitem_toggle_active_triangle (title, TRUE);
		mpris2_controller_initial_update (self->mpris_bridge);
		_g_object_unref0 (title);
	} else {
		player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
	}
}


const gchar* player_controller_get_name (PlayerController* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_name;
	return result;
}


void player_controller_set_name (PlayerController* self, const gchar* value) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_tmp1_ = _tmp0_;
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp1_;
	g_object_notify ((GObject *) self, "name");
}


const gchar* player_controller_get_dbus_name (PlayerController* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_dbus_name;
	return result;
}


void player_controller_set_dbus_name (PlayerController* self, const gchar* value) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_tmp1_ = _tmp0_;
	_g_free0 (self->priv->_dbus_name);
	self->priv->_dbus_name = _tmp1_;
	g_object_notify ((GObject *) self, "dbus-name");
}


GAppInfo* player_controller_get_app_info (PlayerController* self) {
	GAppInfo* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_app_info;
	return result;
}


void player_controller_set_app_info (PlayerController* self, GAppInfo* value) {
	GAppInfo* _tmp0_;
	GAppInfo* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (self->priv->_app_info);
	self->priv->_app_info = _tmp1_;
	g_object_notify ((GObject *) self, "app-info");
}


gint player_controller_get_menu_offset (PlayerController* self) {
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_menu_offset;
	return result;
}


void player_controller_set_menu_offset (PlayerController* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->_menu_offset = value;
	g_object_notify ((GObject *) self, "menu-offset");
}


const gchar* player_controller_get_icon_name (PlayerController* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_icon_name;
	return result;
}


void player_controller_set_icon_name (PlayerController* self, const gchar* value) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_tmp1_ = _tmp0_;
	_g_free0 (self->priv->_icon_name);
	self->priv->_icon_name = _tmp1_;
	g_object_notify ((GObject *) self, "icon-name");
}


static void player_controller_class_init (PlayerControllerClass * klass) {
	player_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (PlayerControllerPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_player_controller_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_player_controller_set_property;
	G_OBJECT_CLASS (klass)->finalize = player_controller_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_DBUS_NAME, g_param_spec_string ("dbus-name", "dbus-name", "dbus-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_APP_INFO, g_param_spec_object ("app-info", "app-info", "app-info", G_TYPE_APP_INFO, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MENU_OFFSET, g_param_spec_int ("menu-offset", "menu-offset", "menu-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_ICON_NAME, g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void player_controller_instance_init (PlayerController * self) {
	self->priv = PLAYER_CONTROLLER_GET_PRIVATE (self);
	self->current_state = (gint) PLAYER_CONTROLLER_STATE_OFFLINE;
}


static void player_controller_finalize (GObject* obj) {
	PlayerController * self;
	self = PLAYER_CONTROLLER (obj);
	_g_object_unref0 (self->priv->root_menu);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_dbus_name);
	_g_object_unref0 (self->custom_items);
	_g_object_unref0 (self->mpris_bridge);
	_g_object_unref0 (self->priv->_app_info);
	_g_free0 (self->priv->_icon_name);
	G_OBJECT_CLASS (player_controller_parent_class)->finalize (obj);
}


GType player_controller_get_type (void) {
	static volatile gsize player_controller_type_id__volatile = 0;
	if (g_once_init_enter (&player_controller_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (PlayerControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) player_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PlayerController), 0, (GInstanceInitFunc) player_controller_instance_init, NULL };
		GType player_controller_type_id;
		player_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "PlayerController", &g_define_type_info, 0);
		g_once_init_leave (&player_controller_type_id__volatile, player_controller_type_id);
	}
	return player_controller_type_id__volatile;
}


static void _vala_player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	PlayerController * self;
	self = PLAYER_CONTROLLER (object);
	switch (property_id) {
		case PLAYER_CONTROLLER_NAME:
		g_value_set_string (value, player_controller_get_name (self));
		break;
		case PLAYER_CONTROLLER_DBUS_NAME:
		g_value_set_string (value, player_controller_get_dbus_name (self));
		break;
		case PLAYER_CONTROLLER_APP_INFO:
		g_value_set_object (value, player_controller_get_app_info (self));
		break;
		case PLAYER_CONTROLLER_MENU_OFFSET:
		g_value_set_int (value, player_controller_get_menu_offset (self));
		break;
		case PLAYER_CONTROLLER_ICON_NAME:
		g_value_set_string (value, player_controller_get_icon_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	PlayerController * self;
	self = PLAYER_CONTROLLER (object);
	switch (property_id) {
		case PLAYER_CONTROLLER_NAME:
		player_controller_set_name (self, g_value_get_string (value));
		break;
		case PLAYER_CONTROLLER_DBUS_NAME:
		player_controller_set_dbus_name (self, g_value_get_string (value));
		break;
		case PLAYER_CONTROLLER_APP_INFO:
		player_controller_set_app_info (self, g_value_get_object (value));
		break;
		case PLAYER_CONTROLLER_MENU_OFFSET:
		player_controller_set_menu_offset (self, g_value_get_int (value));
		break;
		case PLAYER_CONTROLLER_ICON_NAME:
		player_controller_set_icon_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}