diff options
Diffstat (limited to 'src/player-item.c')
-rw-r--r-- | src/player-item.c | 122 |
1 files changed, 57 insertions, 65 deletions
diff --git a/src/player-item.c b/src/player-item.c index f70c04c..2449bfb 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -1,4 +1,4 @@ -/* player-item.c generated by valac 0.9.7, the Vala compiler +/* player-item.c generated by valac 0.9.8, the Vala compiler * generated from player-item.vala, do not modify */ /* @@ -53,7 +53,17 @@ typedef struct _PlayerController PlayerController; typedef struct _PlayerControllerClass PlayerControllerClass; #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_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 __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL))) struct _PlayerItem { DbusmenuMenuitem parent_instance; @@ -86,6 +96,9 @@ PlayerItem* player_item_construct (GType object_type, const char* type); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes); static GValue* _g_value_dup (GValue* self); +GType metadata_menuitem_get_type (void) G_GNUC_CONST; +void metadata_menuitem_fetch_art (MetadataMenuitem* self, const char* uri, const char* prop); +static void _vala_GValue_free (GValue* self); gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); PlayerController* player_item_get_owner (PlayerItem* self); static void player_item_set_owner (PlayerItem* self, PlayerController* value); @@ -135,6 +148,12 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs) { } +/** + * update() + * Base update method for playeritems, takes the attributes and the incoming updates + * and attmepts to update the appropriate props on the object. + * Album art is handled separately to deal with remote and local file paths. + */ static GValue* _g_value_dup (GValue* self) { return g_boxed_copy (G_TYPE_VALUE, self); } @@ -165,6 +184,17 @@ static gboolean string_contains (const char* self, const char* needle) { } +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static void _vala_GValue_free (GValue* self) { + g_value_unset (self); + g_free (self); +} + + static char* bool_to_string (gboolean self) { char* result = NULL; if (self) { @@ -178,13 +208,12 @@ static char* bool_to_string (gboolean self) { void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes) { - GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (data != NULL); g_return_if_fail (attributes != NULL); - g_debug ("player-item.vala:47: PlayerItem::update()"); + g_debug ("player-item.vala:53: PlayerItem::update()"); if (data == NULL) { - g_debug ("player-item.vala:49: PlayerItem::Update -> The hashtable was null - ju" \ + g_debug ("player-item.vala:55: PlayerItem::Update -> The hashtable was null - ju" \ "st leave it!"); return; } @@ -208,80 +237,48 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu property = (char*) gee_iterator_get (_property_it); input_keys = (_tmp1_ = _tmp0_ = g_strsplit (property, "-", 0), input_keys_length1 = _vala_array_length (_tmp0_), _input_keys_size_ = input_keys_length1, _tmp1_); search_key = g_strdup ((_tmp3_ = input_keys + (input_keys_length1 - 1), _tmp2_ = input_keys_length1 - (input_keys_length1 - 1), _tmp3_)[0]); - g_debug ("player-item.vala:56: search key = %s", search_key); + g_debug ("player-item.vala:62: search key = %s", search_key); v = __g_value_dup0 ((GValue*) g_hash_table_lookup (data, search_key)); if (G_VALUE_HOLDS (v, G_TYPE_STRING)) { char* update; update = string_strip (g_value_get_string (v)); - g_debug ("player-item.vala:61: with value : %s", update); + g_debug ("player-item.vala:67: with value : %s", update); if (string_contains (property, "mpris:artUrl")) { - { - char* _tmp4_; - char* _tmp5_; - char* _tmp6_; - char* _tmp7_; - _tmp6_ = (_tmp5_ = g_filename_from_uri (_tmp4_ = string_strip (update), NULL, &_inner_error_), _g_free0 (_tmp4_), _tmp5_); - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_CONVERT_ERROR) { - goto __catch8_g_convert_error; - } - _g_free0 (update); - _g_free0 (v); - _g_free0 (search_key); - input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL); - _g_free0 (property); - _g_object_unref0 (_property_it); - 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; - } - update = (_tmp7_ = _tmp6_, _g_free0 (update), _tmp7_); - } - goto __finally8; - __catch8_g_convert_error: - { - GError * e; - e = _inner_error_; - _inner_error_ = NULL; - { - g_warning ("player-item.vala:68: Problem converting URI %s to file path", update); - _g_error_free0 (e); - } - } - __finally8: - if (_inner_error_ != NULL) { - _g_free0 (update); - _g_free0 (v); - _g_free0 (search_key); - input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL); - _g_free0 (property); - _g_object_unref0 (_property_it); - 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; - } + PlayerItem* _tmp4_; + MetadataMenuitem* metadata; + char* _tmp5_; + metadata = _g_object_ref0 ((_tmp4_ = self, IS_METADATA_MENUITEM (_tmp4_) ? ((MetadataMenuitem*) _tmp4_) : NULL)); + metadata_menuitem_fetch_art (metadata, _tmp5_ = string_strip (update), property); + _g_free0 (_tmp5_); + _g_object_unref0 (metadata); + _g_free0 (update); + __vala_GValue_free0 (v); + _g_free0 (search_key); + input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL); + _g_free0 (property); + continue; } dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, update); _g_free0 (update); } else { if (G_VALUE_HOLDS (v, G_TYPE_INT)) { - g_debug ("player-item.vala:74: with value : %i", g_value_get_int (v)); + g_debug ("player-item.vala:78: with value : %i", g_value_get_int (v)); dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, g_value_get_int (v)); } else { if (G_VALUE_HOLDS (v, G_TYPE_INT64)) { - g_debug ("player-item.vala:78: with value : %i", (gint) g_value_get_int64 (v)); + g_debug ("player-item.vala:82: with value : %i", (gint) g_value_get_int64 (v)); dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) g_value_get_int64 (v)); } else { if (G_VALUE_HOLDS (v, G_TYPE_BOOLEAN)) { - char* _tmp8_; - g_debug ("player-item.vala:82: with value : %s", _tmp8_ = bool_to_string (g_value_get_boolean (v))); - _g_free0 (_tmp8_); + char* _tmp6_; + g_debug ("player-item.vala:86: with value : %s", _tmp6_ = bool_to_string (g_value_get_boolean (v))); + _g_free0 (_tmp6_); dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, property, g_value_get_boolean (v)); } } } } - _g_free0 (v); + __vala_GValue_free0 (v); _g_free0 (search_key); input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL); _g_free0 (property); @@ -308,9 +305,9 @@ gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs) { break; } prop = (char*) gee_iterator_get (_prop_it); - g_debug ("player-item.vala:95: populated ? - prop: %s", prop); + g_debug ("player-item.vala:98: populated ? - prop: %s", prop); value_int = dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop); - g_debug ("player-item.vala:97: populated ? - prop %s and value %i", prop, value_int); + g_debug ("player-item.vala:100: populated ? - prop %s and value %i", prop, value_int); if (dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop) != PLAYER_ITEM_EMPTY) { result = TRUE; _g_free0 (prop); @@ -334,11 +331,6 @@ PlayerController* player_item_get_owner (PlayerItem* self) { } -static gpointer _g_object_ref0 (gpointer self) { - return self ? g_object_ref (self) : NULL; -} - - static void player_item_set_owner (PlayerItem* self, PlayerController* value) { PlayerController* _tmp0_; g_return_if_fail (self != NULL); |