1 /* gmpc-song-links.c generated by valac 0.12.0, the Vala compiler
2 * generated from gmpc-song-links.vala, do not modify */
3
4 /* Gnome Music Player Client (GMPC)
5 * Copyright (C) 2004-2011 Qball Cow <qball@gmpclient.org>
6 * Project homepage: http://gmpclient.org/
7
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 #include <glib.h>
24 #include <glib-object.h>
25 #include <gtk/gtk.h>
26 #include <gtktransition.h>
27 #include "gmpc-extras.h"
28 #include <libmpd/libmpdclient.h>
29 #include <libmpd/libmpd.h>
30 #include <misc.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <config.h>
34 #include <glib/gi18n-lib.h>
35 #include <plugin.h>
36 #include <glib/gstdio.h>
37 #include <gmpc_easy_download.h>
38
39 #define _mpd_freeSong0(var) ((var == NULL) ? NULL : (var = (mpd_freeSong (var), NULL)))
40 #define _g_free0(var) (var = (g_free (var), NULL))
41 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
42 #define _g_key_file_free0(var) ((var == NULL) ? NULL : (var = (g_key_file_free (var), NULL)))
43 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
44 #define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
45
46 struct _GmpcMetaDataWidgetsSongLinksPrivate {
47 GmpcMetaDataWidgetsSongLinksType type;
48 mpd_Song* song;
49 };
50
51
52 extern gboolean initialized;
53 gboolean initialized = FALSE;
54 static gpointer gmpc_meta_data_widgets_song_links_parent_class = NULL;
55
56 #define use_transition_sl TRUE
57 #define GMPC_META_DATA_WIDGETS_SONG_LINKS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GMPC_META_DATA_WIDGETS_TYPE_SONG_LINKS, GmpcMetaDataWidgetsSongLinksPrivate))
58 enum {
59 GMPC_META_DATA_WIDGETS_SONG_LINKS_DUMMY_PROPERTY
60 };
61 #define GMPC_META_DATA_WIDGETS_SONG_LINKS_some_unique_name VERSION
62 static void gmpc_meta_data_widgets_song_links_open_uri_function (GtkLinkButton* but, const gchar* uri);
63 static void gmpc_meta_data_widgets_song_links_parse_uris (GmpcMetaDataWidgetsSongLinks* self);
64 static void _gmpc_meta_data_widgets_song_links_open_uri_function_gtk_link_button_uri_func (GtkLinkButton* button, const gchar* link_, gpointer self);
65 static void gmpc_meta_data_widgets_song_links_finalize (GObject* obj);
66 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
67 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
68 static gint _vala_array_length (gpointer array);
69
70
gmpc_meta_data_widgets_song_links_type_get_type(void)71 GType gmpc_meta_data_widgets_song_links_type_get_type (void) {
72 static volatile gsize gmpc_meta_data_widgets_song_links_type_type_id__volatile = 0;
73 if (g_once_init_enter (&gmpc_meta_data_widgets_song_links_type_type_id__volatile)) {
74 static const GEnumValue values[] = {{GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ARTIST, "GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ARTIST", "artist"}, {GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ALBUM, "GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ALBUM", "album"}, {GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_SONG, "GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_SONG", "song"}, {0, NULL, NULL}};
75 GType gmpc_meta_data_widgets_song_links_type_type_id;
76 gmpc_meta_data_widgets_song_links_type_type_id = g_enum_register_static ("GmpcMetaDataWidgetsSongLinksType", values);
77 g_once_init_leave (&gmpc_meta_data_widgets_song_links_type_type_id__volatile, gmpc_meta_data_widgets_song_links_type_type_id);
78 }
79 return gmpc_meta_data_widgets_song_links_type_type_id__volatile;
80 }
81
82
gmpc_meta_data_widgets_song_links_open_uri_function(GtkLinkButton * but,const gchar * uri)83 static void gmpc_meta_data_widgets_song_links_open_uri_function (GtkLinkButton* but, const gchar* uri) {
84 g_return_if_fail (but != NULL);
85 g_return_if_fail (uri != NULL);
86 open_uri (uri);
87 }
88
89
_mpd_songDup0(gpointer self)90 static gpointer _mpd_songDup0 (gpointer self) {
91 return self ? mpd_songDup (self) : NULL;
92 }
93
94
_gmpc_meta_data_widgets_song_links_open_uri_function_gtk_link_button_uri_func(GtkLinkButton * button,const gchar * link_,gpointer self)95 static void _gmpc_meta_data_widgets_song_links_open_uri_function_gtk_link_button_uri_func (GtkLinkButton* button, const gchar* link_, gpointer self) {
96 gmpc_meta_data_widgets_song_links_open_uri_function (button, link_);
97 }
98
99
gmpc_meta_data_widgets_song_links_construct(GType object_type,GmpcMetaDataWidgetsSongLinksType type,const mpd_Song * song)100 GmpcMetaDataWidgetsSongLinks* gmpc_meta_data_widgets_song_links_construct (GType object_type, GmpcMetaDataWidgetsSongLinksType type, const mpd_Song* song) {
101 GmpcMetaDataWidgetsSongLinks * self = NULL;
102 mpd_Song* _tmp0_;
103 GtkEventBox* _tmp1_ = NULL;
104 GtkEventBox* event;
105 GtkLabel* _tmp2_ = NULL;
106 GtkLabel* label;
107 const gchar* _tmp3_ = NULL;
108 gchar* _tmp4_ = NULL;
109 gchar* _tmp5_;
110 g_return_val_if_fail (song != NULL, NULL);
111 self = (GmpcMetaDataWidgetsSongLinks*) g_object_new (object_type, NULL);
112 g_debug ("gmpc-song-links.vala:53: Links created");
113 self->priv->type = type;
114 _tmp0_ = _mpd_songDup0 (song);
115 _mpd_freeSong0 (self->priv->song);
116 self->priv->song = _tmp0_;
117 _tmp1_ = (GtkEventBox*) gtk_event_box_new ();
118 event = g_object_ref_sink (_tmp1_);
119 _tmp2_ = (GtkLabel*) gtk_label_new ("");
120 label = g_object_ref_sink (_tmp2_);
121 gtk_container_add ((GtkContainer*) event, (GtkWidget*) label);
122 gtk_event_box_set_visible_window (event, FALSE);
123 gtk_frame_set_label_widget ((GtkFrame*) self, (GtkWidget*) event);
124 _tmp3_ = _ ("Web Links");
125 _tmp4_ = g_strdup_printf ("<b>%s:</b>", _tmp3_);
126 _tmp5_ = _tmp4_;
127 gtk_label_set_markup (label, _tmp5_);
128 _g_free0 (_tmp5_);
129 g_object_set ((GtkFrame*) self, "shadow", GTK_SHADOW_NONE, NULL);
130 gmpc_meta_data_widgets_song_links_parse_uris (self);
131 if (!initialized) {
132 gtk_link_button_set_uri_hook (_gmpc_meta_data_widgets_song_links_open_uri_function_gtk_link_button_uri_func, NULL, NULL);
133 initialized = TRUE;
134 }
135 _g_object_unref0 (label);
136 _g_object_unref0 (event);
137 return self;
138 }
139
140
gmpc_meta_data_widgets_song_links_new(GmpcMetaDataWidgetsSongLinksType type,const mpd_Song * song)141 GmpcMetaDataWidgetsSongLinks* gmpc_meta_data_widgets_song_links_new (GmpcMetaDataWidgetsSongLinksType type, const mpd_Song* song) {
142 return gmpc_meta_data_widgets_song_links_construct (GMPC_META_DATA_WIDGETS_TYPE_SONG_LINKS, type, song);
143 }
144
145
_g_object_ref0(gpointer self)146 static gpointer _g_object_ref0 (gpointer self) {
147 return self ? g_object_ref (self) : NULL;
148 }
149
150
string_replace(const gchar * self,const gchar * old,const gchar * replacement)151 static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
152 gchar* result = NULL;
153 gchar* _tmp0_ = NULL;
154 gchar* _tmp1_;
155 GRegex* _tmp2_ = NULL;
156 GRegex* _tmp3_;
157 GRegex* regex;
158 gchar* _tmp4_ = NULL;
159 gchar* _tmp5_;
160 GError * _inner_error_ = NULL;
161 g_return_val_if_fail (self != NULL, NULL);
162 g_return_val_if_fail (old != NULL, NULL);
163 g_return_val_if_fail (replacement != NULL, NULL);
164 _tmp0_ = g_regex_escape_string (old, -1);
165 _tmp1_ = _tmp0_;
166 _tmp2_ = g_regex_new (_tmp1_, 0, 0, &_inner_error_);
167 _tmp3_ = _tmp2_;
168 _g_free0 (_tmp1_);
169 regex = _tmp3_;
170 if (_inner_error_ != NULL) {
171 if (_inner_error_->domain == G_REGEX_ERROR) {
172 goto __catch2_g_regex_error;
173 }
174 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);
175 g_clear_error (&_inner_error_);
176 return NULL;
177 }
178 _tmp4_ = g_regex_replace_literal (regex, self, (gssize) (-1), 0, replacement, 0, &_inner_error_);
179 _tmp5_ = _tmp4_;
180 if (_inner_error_ != NULL) {
181 _g_regex_unref0 (regex);
182 if (_inner_error_->domain == G_REGEX_ERROR) {
183 goto __catch2_g_regex_error;
184 }
185 _g_regex_unref0 (regex);
186 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);
187 g_clear_error (&_inner_error_);
188 return NULL;
189 }
190 result = _tmp5_;
191 _g_regex_unref0 (regex);
192 return result;
193 _g_regex_unref0 (regex);
194 goto __finally2;
195 __catch2_g_regex_error:
196 {
197 GError * e;
198 e = _inner_error_;
199 _inner_error_ = NULL;
200 g_assert_not_reached ();
201 _g_error_free0 (e);
202 }
203 __finally2:
204 if (_inner_error_ != NULL) {
205 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);
206 g_clear_error (&_inner_error_);
207 return NULL;
208 }
209 }
210
211
gmpc_meta_data_widgets_song_links_parse_uris(GmpcMetaDataWidgetsSongLinks * self)212 static void gmpc_meta_data_widgets_song_links_parse_uris (GmpcMetaDataWidgetsSongLinks* self) {
213 GtkWidget* _tmp0_ = NULL;
214 GtkWidget* _tmp1_;
215 GtkWidget* child;
216 GKeyFile* _tmp2_ = NULL;
217 GKeyFile* file;
218 gchar* _tmp3_ = NULL;
219 gchar* path;
220 gboolean _tmp4_;
221 GtkAlignment* _tmp7_ = NULL;
222 GtkAlignment* ali;
223 GtkVBox* _tmp8_ = NULL;
224 GtkVBox* vbox;
225 gsize _tmp9_;
226 gchar** _tmp10_ = NULL;
227 gchar** groups;
228 gint groups_length1;
229 gint _groups_size_;
230 GError * _inner_error_ = NULL;
231 g_return_if_fail (self != NULL);
232 _tmp0_ = gtk_bin_get_child ((GtkBin*) self);
233 _tmp1_ = _g_object_ref0 (_tmp0_);
234 child = _tmp1_;
235 if (child != NULL) {
236 gtk_object_destroy ((GtkObject*) child);
237 }
238 _tmp2_ = g_key_file_new ();
239 file = _tmp2_;
240 _tmp3_ = gmpc_get_user_path ("weblinks.list");
241 path = _tmp3_;
242 _tmp4_ = g_file_test (path, G_FILE_TEST_EXISTS);
243 if (!_tmp4_) {
244 gchar* _tmp5_ = NULL;
245 gboolean _tmp6_;
246 _tmp5_ = gmpc_get_full_glade_path ("weblinks.list");
247 _g_free0 (path);
248 path = _tmp5_;
249 _tmp6_ = g_file_test (path, G_FILE_TEST_EXISTS);
250 if (!_tmp6_) {
251 _g_free0 (path);
252 _g_key_file_free0 (file);
253 _g_object_unref0 (child);
254 return;
255 }
256 }
257 g_key_file_load_from_file (file, path, G_KEY_FILE_NONE, &_inner_error_);
258 if (_inner_error_ != NULL) {
259 goto __catch0_g_error;
260 }
261 goto __finally0;
262 __catch0_g_error:
263 {
264 GError * e;
265 e = _inner_error_;
266 _inner_error_ = NULL;
267 _g_error_free0 (e);
268 _g_free0 (path);
269 _g_key_file_free0 (file);
270 _g_object_unref0 (child);
271 return;
272 }
273 __finally0:
274 if (_inner_error_ != NULL) {
275 _g_free0 (path);
276 _g_key_file_free0 (file);
277 _g_object_unref0 (child);
278 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);
279 g_clear_error (&_inner_error_);
280 return;
281 }
282 _tmp7_ = (GtkAlignment*) gtk_alignment_new (0.0f, 0.0f, 0.0f, 0.0f);
283 ali = g_object_ref_sink (_tmp7_);
284 gtk_alignment_set_padding (ali, (guint) 8, (guint) 8, (guint) 12, (guint) 6);
285 gtk_container_add ((GtkContainer*) self, (GtkWidget*) ali);
286 _tmp8_ = (GtkVBox*) gtk_vbox_new (FALSE, 0);
287 vbox = g_object_ref_sink (_tmp8_);
288 gtk_container_add ((GtkContainer*) ali, (GtkWidget*) vbox);
289 _tmp10_ = g_key_file_get_groups (file, &_tmp9_);
290 groups = _tmp10_;
291 groups_length1 = _tmp9_;
292 _groups_size_ = _tmp9_;
293 {
294 gchar** entry_collection;
295 int entry_collection_length1;
296 int entry_it;
297 entry_collection = groups;
298 entry_collection_length1 = groups_length1;
299 for (entry_it = 0; entry_it < groups_length1; entry_it = entry_it + 1) {
300 gchar* _tmp11_;
301 gchar* entry;
302 _tmp11_ = g_strdup (entry_collection[entry_it]);
303 entry = _tmp11_;
304 {
305 gchar* _tmp12_ = NULL;
306 gchar* typestr;
307 gchar* _tmp13_ = NULL;
308 gchar* uri;
309 GmpcMetaDataWidgetsSongLinksType type = 0;
310 const gchar* _tmp14_;
311 GQuark _tmp15_;
312 static GQuark _tmp15__label0 = 0;
313 static GQuark _tmp15__label1 = 0;
314 gchar* _tmp34_ = NULL;
315 gchar* sar;
316 _tmp12_ = g_key_file_get_string (file, entry, "type", &_inner_error_);
317 typestr = _tmp12_;
318 if (_inner_error_ != NULL) {
319 goto __catch1_g_error;
320 }
321 _tmp13_ = g_key_file_get_string (file, entry, "url", &_inner_error_);
322 uri = _tmp13_;
323 if (_inner_error_ != NULL) {
324 _g_free0 (typestr);
325 goto __catch1_g_error;
326 }
327 _tmp14_ = typestr;
328 _tmp15_ = (NULL == _tmp14_) ? 0 : g_quark_from_string (_tmp14_);
329 if (_tmp15_ == ((0 != _tmp15__label0) ? _tmp15__label0 : (_tmp15__label0 = g_quark_from_static_string ("artist")))) {
330 switch (0) {
331 default:
332 {
333 type = GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ARTIST;
334 if (self->priv->song->artist != NULL) {
335 gchar* _tmp16_ = NULL;
336 gchar* _tmp17_;
337 gchar* _tmp18_ = NULL;
338 _tmp16_ = gmpc_easy_download_uri_escape (self->priv->song->artist);
339 _tmp17_ = _tmp16_;
340 _tmp18_ = string_replace (uri, "%ARTIST%", _tmp17_);
341 _g_free0 (uri);
342 uri = _tmp18_;
343 _g_free0 (_tmp17_);
344 }
345 break;
346 }
347 }
348 } else if (_tmp15_ == ((0 != _tmp15__label1) ? _tmp15__label1 : (_tmp15__label1 = g_quark_from_static_string ("album")))) {
349 switch (0) {
350 default:
351 {
352 type = GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ALBUM;
353 if (self->priv->song->album != NULL) {
354 gchar* _tmp19_ = NULL;
355 gchar* _tmp20_;
356 gchar* _tmp21_ = NULL;
357 _tmp19_ = gmpc_easy_download_uri_escape (self->priv->song->album);
358 _tmp20_ = _tmp19_;
359 _tmp21_ = string_replace (uri, "%ALBUM%", _tmp20_);
360 _g_free0 (uri);
361 uri = _tmp21_;
362 _g_free0 (_tmp20_);
363 }
364 if (self->priv->song->artist != NULL) {
365 gchar* _tmp22_ = NULL;
366 gchar* _tmp23_;
367 gchar* _tmp24_ = NULL;
368 _tmp22_ = gmpc_easy_download_uri_escape (self->priv->song->artist);
369 _tmp23_ = _tmp22_;
370 _tmp24_ = string_replace (uri, "%ARTIST%", _tmp23_);
371 _g_free0 (uri);
372 uri = _tmp24_;
373 _g_free0 (_tmp23_);
374 }
375 break;
376 }
377 }
378 } else {
379 switch (0) {
380 default:
381 {
382 type = GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_SONG;
383 if (self->priv->song->title != NULL) {
384 gchar* _tmp25_ = NULL;
385 gchar* _tmp26_;
386 gchar* _tmp27_ = NULL;
387 _tmp25_ = gmpc_easy_download_uri_escape (self->priv->song->title);
388 _tmp26_ = _tmp25_;
389 _tmp27_ = string_replace (uri, "%TITLE%", _tmp26_);
390 _g_free0 (uri);
391 uri = _tmp27_;
392 _g_free0 (_tmp26_);
393 }
394 if (self->priv->song->album != NULL) {
395 gchar* _tmp28_ = NULL;
396 gchar* _tmp29_;
397 gchar* _tmp30_ = NULL;
398 _tmp28_ = gmpc_easy_download_uri_escape (self->priv->song->album);
399 _tmp29_ = _tmp28_;
400 _tmp30_ = string_replace (uri, "%ALBUM%", _tmp29_);
401 _g_free0 (uri);
402 uri = _tmp30_;
403 _g_free0 (_tmp29_);
404 }
405 if (self->priv->song->artist != NULL) {
406 gchar* _tmp31_ = NULL;
407 gchar* _tmp32_;
408 gchar* _tmp33_ = NULL;
409 _tmp31_ = gmpc_easy_download_uri_escape (self->priv->song->artist);
410 _tmp32_ = _tmp31_;
411 _tmp33_ = string_replace (uri, "%ARTIST%", _tmp32_);
412 _g_free0 (uri);
413 uri = _tmp33_;
414 _g_free0 (_tmp32_);
415 }
416 break;
417 }
418 }
419 }
420 _tmp34_ = g_key_file_get_string (file, entry, "search-and-replace", &_inner_error_);
421 sar = _tmp34_;
422 if (_inner_error_ != NULL) {
423 goto __catch3_g_error;
424 }
425 if (sar != NULL) {
426 gchar** _tmp35_;
427 gchar** _tmp36_ = NULL;
428 gchar** s;
429 gint s_length1;
430 gint _s_size_;
431 _tmp36_ = _tmp35_ = g_strsplit (sar, "::", 0);
432 s = _tmp36_;
433 s_length1 = _vala_array_length (_tmp35_);
434 _s_size_ = _vala_array_length (_tmp35_);
435 if (s_length1 == 2) {
436 GRegex* _tmp37_ = NULL;
437 GRegex* regex;
438 gchar* _tmp38_ = NULL;
439 gchar* _tmp39_;
440 _tmp37_ = g_regex_new (s[0], 0, 0, &_inner_error_);
441 regex = _tmp37_;
442 if (_inner_error_ != NULL) {
443 if (_inner_error_->domain == G_REGEX_ERROR) {
444 goto __catch4_g_regex_error;
445 }
446 s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
447 _g_free0 (sar);
448 _g_free0 (uri);
449 _g_free0 (typestr);
450 _g_free0 (entry);
451 groups = (_vala_array_free (groups, groups_length1, (GDestroyNotify) g_free), NULL);
452 _g_object_unref0 (vbox);
453 _g_object_unref0 (ali);
454 _g_free0 (path);
455 _g_key_file_free0 (file);
456 _g_object_unref0 (child);
457 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);
458 g_clear_error (&_inner_error_);
459 return;
460 }
461 _tmp38_ = g_regex_replace_literal (regex, uri, (gssize) (-1), 0, s[1], 0, &_inner_error_);
462 _tmp39_ = _tmp38_;
463 if (_inner_error_ != NULL) {
464 _g_regex_unref0 (regex);
465 if (_inner_error_->domain == G_REGEX_ERROR) {
466 goto __catch4_g_regex_error;
467 }
468 _g_regex_unref0 (regex);
469 s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
470 _g_free0 (sar);
471 _g_free0 (uri);
472 _g_free0 (typestr);
473 _g_free0 (entry);
474 groups = (_vala_array_free (groups, groups_length1, (GDestroyNotify) g_free), NULL);
475 _g_object_unref0 (vbox);
476 _g_object_unref0 (ali);
477 _g_free0 (path);
478 _g_key_file_free0 (file);
479 _g_object_unref0 (child);
480 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);
481 g_clear_error (&_inner_error_);
482 return;
483 }
484 _g_free0 (uri);
485 uri = _tmp39_;
486 _g_regex_unref0 (regex);
487 goto __finally4;
488 __catch4_g_regex_error:
489 {
490 GError * e;
491 e = _inner_error_;
492 _inner_error_ = NULL;
493 g_debug ("gmpc-song-links.vala:147: Failed to compile regex: '%s'\n", e->message);
494 _g_error_free0 (e);
495 }
496 __finally4:
497 if (_inner_error_ != NULL) {
498 s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
499 _g_free0 (sar);
500 goto __catch3_g_error;
501 }
502 }
503 s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
504 }
505 _g_free0 (sar);
506 goto __finally3;
507 __catch3_g_error:
508 {
509 GError * e;
510 e = _inner_error_;
511 _inner_error_ = NULL;
512 _g_error_free0 (e);
513 }
514 __finally3:
515 if (_inner_error_ != NULL) {
516 _g_free0 (uri);
517 _g_free0 (typestr);
518 goto __catch1_g_error;
519 }
520 if (((gint) type) <= ((gint) self->priv->type)) {
521 GtkLinkButton* _tmp40_ = NULL;
522 GtkLinkButton* label;
523 const gchar* _tmp41_ = NULL;
524 const gchar* _tmp42_ = NULL;
525 gchar* _tmp43_ = NULL;
526 gchar* _tmp44_;
527 _tmp40_ = (GtkLinkButton*) gtk_link_button_new (uri);
528 label = g_object_ref_sink (_tmp40_);
529 _tmp41_ = _ ("Lookup %s on %s");
530 _tmp42_ = _ (typestr);
531 _tmp43_ = g_strdup_printf (_tmp41_, _tmp42_, entry);
532 _tmp44_ = _tmp43_;
533 gtk_button_set_label ((GtkButton*) label, _tmp44_);
534 _g_free0 (_tmp44_);
535 gtk_button_set_alignment ((GtkButton*) label, 0.0f, 0.5f);
536 gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) label, FALSE, TRUE, (guint) 0);
537 _g_object_unref0 (label);
538 }
539 _g_free0 (uri);
540 _g_free0 (typestr);
541 goto __finally1;
542 __catch1_g_error:
543 {
544 GError * e;
545 e = _inner_error_;
546 _inner_error_ = NULL;
547 g_error ("gmpc-song-links.vala:163: Failed to get entry from %s: '%s'\n", path, e->message);
548 _g_error_free0 (e);
549 }
550 __finally1:
551 if (_inner_error_ != NULL) {
552 _g_free0 (entry);
553 groups = (_vala_array_free (groups, groups_length1, (GDestroyNotify) g_free), NULL);
554 _g_object_unref0 (vbox);
555 _g_object_unref0 (ali);
556 _g_free0 (path);
557 _g_key_file_free0 (file);
558 _g_object_unref0 (child);
559 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);
560 g_clear_error (&_inner_error_);
561 return;
562 }
563 _g_free0 (entry);
564 }
565 }
566 }
567 groups = (_vala_array_free (groups, groups_length1, (GDestroyNotify) g_free), NULL);
568 _g_object_unref0 (vbox);
569 _g_object_unref0 (ali);
570 _g_free0 (path);
571 _g_key_file_free0 (file);
572 _g_object_unref0 (child);
573 }
574
575
gmpc_meta_data_widgets_song_links_class_init(GmpcMetaDataWidgetsSongLinksClass * klass)576 static void gmpc_meta_data_widgets_song_links_class_init (GmpcMetaDataWidgetsSongLinksClass * klass) {
577 gmpc_meta_data_widgets_song_links_parent_class = g_type_class_peek_parent (klass);
578 g_type_class_add_private (klass, sizeof (GmpcMetaDataWidgetsSongLinksPrivate));
579 G_OBJECT_CLASS (klass)->finalize = gmpc_meta_data_widgets_song_links_finalize;
580 }
581
582
gmpc_meta_data_widgets_song_links_instance_init(GmpcMetaDataWidgetsSongLinks * self)583 static void gmpc_meta_data_widgets_song_links_instance_init (GmpcMetaDataWidgetsSongLinks * self) {
584 self->priv = GMPC_META_DATA_WIDGETS_SONG_LINKS_GET_PRIVATE (self);
585 self->priv->type = GMPC_META_DATA_WIDGETS_SONG_LINKS_TYPE_ARTIST;
586 self->priv->song = NULL;
587 }
588
589
gmpc_meta_data_widgets_song_links_finalize(GObject * obj)590 static void gmpc_meta_data_widgets_song_links_finalize (GObject* obj) {
591 GmpcMetaDataWidgetsSongLinks * self;
592 self = GMPC_META_DATA_WIDGETS_SONG_LINKS (obj);
593 _mpd_freeSong0 (self->priv->song);
594 G_OBJECT_CLASS (gmpc_meta_data_widgets_song_links_parent_class)->finalize (obj);
595 }
596
597
gmpc_meta_data_widgets_song_links_get_type(void)598 GType gmpc_meta_data_widgets_song_links_get_type (void) {
599 static volatile gsize gmpc_meta_data_widgets_song_links_type_id__volatile = 0;
600 if (g_once_init_enter (&gmpc_meta_data_widgets_song_links_type_id__volatile)) {
601 static const GTypeInfo g_define_type_info = { sizeof (GmpcMetaDataWidgetsSongLinksClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gmpc_meta_data_widgets_song_links_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GmpcMetaDataWidgetsSongLinks), 0, (GInstanceInitFunc) gmpc_meta_data_widgets_song_links_instance_init, NULL };
602 GType gmpc_meta_data_widgets_song_links_type_id;
603 gmpc_meta_data_widgets_song_links_type_id = g_type_register_static (GTK_TYPE_FRAME, "GmpcMetaDataWidgetsSongLinks", &g_define_type_info, 0);
604 g_once_init_leave (&gmpc_meta_data_widgets_song_links_type_id__volatile, gmpc_meta_data_widgets_song_links_type_id);
605 }
606 return gmpc_meta_data_widgets_song_links_type_id__volatile;
607 }
608
609
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)610 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
611 if ((array != NULL) && (destroy_func != NULL)) {
612 int i;
613 for (i = 0; i < array_length; i = i + 1) {
614 if (((gpointer*) array)[i] != NULL) {
615 destroy_func (((gpointer*) array)[i]);
616 }
617 }
618 }
619 }
620
621
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)622 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
623 _vala_array_destroy (array, array_length, destroy_func);
624 g_free (array);
625 }
626
627
_vala_array_length(gpointer array)628 static gint _vala_array_length (gpointer array) {
629 int length;
630 length = 0;
631 if (array) {
632 while (((gpointer*) array)[length]) {
633 length++;
634 }
635 }
636 return length;
637 }
638
639
640
641