From 2e0dd336905735dc75d3ab7e676ef60af76ae746 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 14 Jun 2011 18:24:46 +0200 Subject: caught most of the little bugs I could find@ --- src/metadata-menu-item.vala | 12 +++++++++--- src/metadata-widget.c | 18 ++++++++++++------ src/mpris2-controller.vala | 4 ++-- src/player-item.vala | 1 + 4 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index dccf478..995d248 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -104,10 +104,16 @@ public class MetadataMenuitem : PlayerItem public void fetch_art(string uri, string prop) { File art_file = File.new_for_uri(uri); - if(art_file.is_native() == true){ + if (art_file.is_native() == true){ + if (art_file.query_exists() == false){ + // Can't load the image, set prop to empty and return. + this.property_set_int ( prop, EMPTY ); + return; + } string path; try{ - path = Filename.from_uri ( uri.strip() ); + path = Filename.from_uri ( uri.strip() ); + debug ("Populating the artwork field with %s", uri.strip()); this.property_set ( prop, path ); } catch(ConvertError e){ @@ -150,7 +156,7 @@ public class MetadataMenuitem : PlayerItem if(this.previous_temp_album_art_path != null){ FileUtils.remove(this.previous_temp_album_art_path); } - this.previous_temp_album_art_path = path; + this.previous_temp_album_art_path = path; } } catch(GLib.Error e){ diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 41a4f3f..779f60c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -232,6 +232,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); if(GDK_IS_PIXBUF(pixbuf) == FALSE){ + gtk_image_clear ( GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; @@ -242,13 +243,14 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); - g_string_erase(priv->old_image_path, 0, -1); - g_string_overwrite(priv->old_image_path, 0, priv->image_path->str); + g_string_erase (priv->old_image_path, 0, -1); + g_string_overwrite (priv->old_image_path, 0, priv->image_path->str); g_object_unref(pixbuf); } return FALSE; } + gtk_image_clear (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); return FALSE; @@ -347,6 +349,8 @@ draw_album_border(GtkWidget *metadata, gboolean selected) static void draw_album_art_placeholder(GtkWidget *metadata) { + g_debug ("Attempting to draw the image !"); + cairo_t *cr; cr = gdk_cairo_create (metadata->window); GtkStyle *style; @@ -479,9 +483,9 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_string_erase(priv->image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL)); // if its a remote image queue a redraw incase the download took too long - if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){ - gtk_widget_queue_draw(GTK_WIDGET(mitem)); - } + //if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){ + gtk_widget_queue_draw(GTK_WIDGET(mitem)); + //} } else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, property) == 0){ gtk_label_set_label (GTK_LABEL (priv->player_label), @@ -656,8 +660,10 @@ metadata_widget_triangle_draw_cb (GtkWidget *widget, arrow_width = 5; arrow_height = 9; + gint vertical_offset = 3; + x = widget->allocation.x; - y = widget->allocation.y + (double)arrow_height/2.0; + y = widget->allocation.y + (double)arrow_height/2.0 + vertical_offset; cr = (cairo_t*) gdk_cairo_create (widget->window); diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 74e9823..2975066 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -87,12 +87,12 @@ public class Mpris2Controller : GLib.Object PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA]; metadata.reset (MetadataMenuitem.relevant_attributes_for_ui()); metadata.update ( changed_updates, - MetadataMenuitem.attributes_format()); + MetadataMenuitem.relevant_attributes_for_ui()); MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; bool collapsing = !metadata.populated(MetadataMenuitem.relevant_attributes_for_ui()); md.should_collapse(collapsing); - debug ("metadata should collapse = %s", collapsing.to_string()); + debug ("Should metadata collapse %s", collapsing.to_string()); } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null && this.owner.use_playlists == true ){ diff --git a/src/player-item.vala b/src/player-item.vala index 6d9c8e5..2af3f36 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -86,6 +86,7 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } + // TODO- is this only relevant for the metadata, if so please call for just that case this.property_set_bool(MENUITEM_PROP_VISIBLE, populated(attributes)); } -- cgit v1.2.3