From 67bdc60671c338045771b52a670c8788e565fcb3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 1 Sep 2010 15:29:26 +0100 Subject: now has the ability to fetch album art from last fm --- src/Makefile.am | 8 ++++-- src/fetch-file.vala | 65 +++++++++++++++++++++++++++++++++++++++++++++ src/metadata-menu-item.vala | 2 +- src/metadata-widget.c | 1 + src/player-item.vala | 56 ++++++++++++++++++++++++++++++++++---- src/sound-service.c | 4 +-- 6 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 src/fetch-file.vala diff --git a/src/Makefile.am b/src/Makefile.am index 2a4e937..e85ed93 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,9 @@ music_bridge_VALASOURCES = \ player-controller.vala \ mpris2-controller.vala \ player-item.vala \ - familiar-players-db.vala + familiar-players-db.vala \ + fetch-file.vala + music_bridge_VALAFLAGS = \ --ccode \ @@ -81,7 +83,9 @@ music_bridge_VALAFLAGS = \ --pkg Dbusmenu-Glib-0.2 \ --pkg common-defs \ --pkg dbus-glib-1 \ - --pkg gio-unix-2.0 + --pkg gio-unix-2.0 \ + --pkg gdk-pixbuf-2.0 + $(MAINTAINER_VALAFLAGS) diff --git a/src/fetch-file.vala b/src/fetch-file.vala new file mode 100644 index 0000000..55bfdc3 --- /dev/null +++ b/src/fetch-file.vala @@ -0,0 +1,65 @@ +public class FetchFile : Object +{ + /* public variables */ + public string uri {get; construct;} + + /* private variables */ + private DataInputStream stream; + private File? file; + private ByteArray data; + + /* public signals */ + public signal void failed (); + public signal void completed (ByteArray data); + + public FetchFile (string uri) + { + Object (uri: uri); + } + + construct + { + this.file = File.new_for_uri(this.uri); + this.data = new ByteArray (); + } + + public async void fetch_data () + { + //grab our data from our uri + try { + this.stream = new DataInputStream(this.file.read(null)); + this.stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN); + } catch (GLib.Error e) { + this.failed (); + } + this.read_something_async (); + } + + private async void read_something_async () + { + ssize_t size = 1024; + uint8[] buffer = new uint8[size]; + + ssize_t bufsize = 1; + do { + try { + bufsize = yield this.stream.read_async (buffer, size, GLib.Priority.DEFAULT, null); + if (bufsize < 1) { break;} + + if (bufsize != size) + { + uint8[] cpybuf = new uint8[bufsize]; + Memory.copy (cpybuf, buffer, bufsize); + this.data.append (cpybuf); + } + else + { + this.data.append (buffer); + } + } catch (Error e) { + this.failed (); + } + } while (bufsize > 0); + this.completed (this.data); + } +} diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 0bb4a85..090952b 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -using Dbusmenu; using Gee; using DbusmenuMetadata; +using Gdk; public class MetadataMenuitem : PlayerItem { diff --git a/src/metadata-widget.c b/src/metadata-widget.c index f600238..5e75b29 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -190,6 +190,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){ + GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); g_debug("metadata_widget_expose, album art update -> pixbuf from %s", diff --git a/src/player-item.vala b/src/player-item.vala index fbfacbd..82b9f07 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -61,14 +61,20 @@ public class PlayerItem : Dbusmenu.Menuitem debug("with value : %s", update); // Special case for the arturl URI's. if(property.contains("mpris:artUrl")){ - try{ - update = Filename.from_uri(update.strip()); + if(update.has_prefix("http://")){ } - catch(ConvertError e){ - warning("Problem converting URI %s to file path", update); + else{ + // The file is local, just parse the string + try{ + update = Filename.from_uri(update.strip()); + } + catch(ConvertError e){ + warning("Problem converting URI %s to file path", + update); + } } } - this.property_set(property, update); + this.property_set(property, update); } else if (v.holds (typeof (int))){ debug("with value : %i", v.get_int()); @@ -101,5 +107,45 @@ public class PlayerItem : Dbusmenu.Menuitem } return false; } + + public fetch_remote_art(uri) + { + this.fetcher = new FetchFile (uri); + this.fetcher.failed.connect (() => { this.on_fetcher_failed ();}); + this.fetcher.completed.connect (this.on_fetcher_completed); + this.fetcher.fetch_data (); + } + + public string parse_art_url(string update) + { + if(update == null) + return null; + string temp_path = "/home/ronoc/Desktop/tempy.jpg"; + string local_path = ""; + string temp_name = ""; + + debug("MetadataMenuitem: parse art url - result %s", local_path); + return local_path; + } + + public extract_downloaded_file() + { + try{ + PixbufLoader loader = new PixbufLoader (); + bool write_result = loader.write (update.data, update.len()); + loader.close (); + unowned PixbufFormat format = loader.get_format(); + debug("the bloody format name is %s", format.get_name()); + debug("is the format null %s", (format == null).to_string()); + Pixbuf icon = loader.get_pixbuf (); + temp_name = loader.get_format().get_name(); + icon.save (temp_path, "jpeg"); + local_path = temp_path; + } + catch(GLib.Error e){ + warning("Problem taking file from the interweb - error: %s and name: %s", + e.message, + temp_name); + } } diff --git a/src/sound-service.c b/src/sound-service.c index 12f067e..42ce116 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 9ab9b175e1f77457157211f5f93c54e8ae87e3dc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 1 Sep 2010 17:22:55 +0100 Subject: almost bug free --- src/common-defs.h | 1 + src/fetch-file.vala | 9 +++++---- src/metadata-menu-item.vala | 1 - src/metadata-widget.c | 22 +++++++++++++++------ src/player-item.vala | 48 +++++++++++++++++++++------------------------ vapi/common-defs.vapi | 5 +++++ 6 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index e554c11..faffcb2 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,6 +25,7 @@ with this program. If not, see . #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" #define DBUSMENU_PROPERTY_EMPTY -1 +#define DBUSMENU_PLAYERITEM_REMOTE_FILEPATH "/home/ronoc/Desktop/tempy" /* DBUS Custom Items */ #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type" diff --git a/src/fetch-file.vala b/src/fetch-file.vala index 55bfdc3..f172853 100644 --- a/src/fetch-file.vala +++ b/src/fetch-file.vala @@ -2,6 +2,7 @@ public class FetchFile : Object { /* public variables */ public string uri {get; construct;} + public string intended_property {get; construct;} /* private variables */ private DataInputStream stream; @@ -10,11 +11,11 @@ public class FetchFile : Object /* public signals */ public signal void failed (); - public signal void completed (ByteArray data); + public signal void completed (ByteArray data, string property); - public FetchFile (string uri) + public FetchFile (string uri, string prop) { - Object (uri: uri); + Object (uri: uri, intended_property: prop); } construct @@ -60,6 +61,6 @@ public class FetchFile : Object this.failed (); } } while (bufsize > 0); - this.completed (this.data); + this.completed (this.data, this.intended_property); } } diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 090952b..04284d4 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -19,7 +19,6 @@ with this program. If not, see . using Gee; using DbusmenuMetadata; -using Gdk; public class MetadataMenuitem : PlayerItem { diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 5e75b29..72acc8c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -36,6 +36,7 @@ struct _MetadataWidgetPrivate GtkWidget* album_art; GString* image_path; GString* old_image_path; + GString* remote_image_path; GtkWidget* artist_label; GtkWidget* piece_label; GtkWidget* container_label; @@ -104,6 +105,7 @@ metadata_widget_init (MetadataWidget *self) priv->album_art = gtk_image_new(); priv->image_path = g_string_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL)); priv->old_image_path = g_string_new(""); + priv->remote_image_path = g_string_new(DBUSMENU_PLAYERITEM_REMOTE_FILEPATH); g_debug("Metadata::At startup and image path = %s", priv->image_path->str); g_signal_connect(priv->album_art, "expose-event", @@ -176,6 +178,10 @@ metadata_widget_finalize (GObject *object) G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); } +static void metadata_load_new_image(MetadataWidget* self) +{ +} + /** * We override the expose method to enable primitive drawing of the * empty album art image (and soon rounded rectangles on the album art) @@ -188,19 +194,20 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); if(priv->image_path->len > 0){ - - if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){ - + if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || + (g_string_equal(priv->image_path, priv->remote_image_path) == TRUE && + g_string_equal(priv->old_image_path, priv->remote_image_path) == FALSE)){ GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); - g_debug("metadata_widget_expose, album art update -> pixbuf from %s", - priv->image_path->str); + g_debug("metadata_load_new_image -> pixbuf from %s", + priv->image_path->str); pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR); image_set_from_pixbuf (metadata, widget, pixbuf); 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); + g_object_unref(pixbuf); + } return FALSE; } @@ -315,7 +322,10 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ g_string_erase(priv->image_path, 0, -1); + //gchar* empty = ""; + g_string_erase(priv->old_image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); + //g_free(empty); } } diff --git a/src/player-item.vala b/src/player-item.vala index 82b9f07..7de6840 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -19,13 +19,15 @@ with this program. If not, see . using Dbusmenu; using Gee; +using Gdk; public class PlayerItem : Dbusmenu.Menuitem { public PlayerController owner {get; construct;} public string item_type { get; construct; } private const int EMPTY = -1; - + private FetchFile fetcher; + public PlayerItem(string type) { Object(item_type: type); @@ -62,6 +64,9 @@ public class PlayerItem : Dbusmenu.Menuitem // Special case for the arturl URI's. if(property.contains("mpris:artUrl")){ if(update.has_prefix("http://")){ + // This is asyncronous so handle it offline + this.fetch_remote_art(update.strip(), property); + continue; } else{ // The file is local, just parse the string @@ -108,44 +113,35 @@ public class PlayerItem : Dbusmenu.Menuitem return false; } - public fetch_remote_art(uri) + public void fetch_remote_art(string uri, string prop) { - this.fetcher = new FetchFile (uri); + this.fetcher = new FetchFile (uri, prop); this.fetcher.failed.connect (() => { this.on_fetcher_failed ();}); this.fetcher.completed.connect (this.on_fetcher_completed); this.fetcher.fetch_data (); } - - public string parse_art_url(string update) - { - if(update == null) - return null; - string temp_path = "/home/ronoc/Desktop/tempy.jpg"; - string local_path = ""; - string temp_name = ""; - debug("MetadataMenuitem: parse art url - result %s", local_path); - return local_path; + private void on_fetcher_failed () + { + warning("on_fetcher_failed -> could not fetch artwork"); } - - public extract_downloaded_file() + + private void on_fetcher_completed(ByteArray update, string property) { + string temp_path = "/home/ronoc/Desktop/tempy"; + //"/tmp/indicator-sound-remote-image"; try{ PixbufLoader loader = new PixbufLoader (); - bool write_result = loader.write (update.data, update.len()); + loader.write (update.data, update.len); loader.close (); - unowned PixbufFormat format = loader.get_format(); - debug("the bloody format name is %s", format.get_name()); - debug("is the format null %s", (format == null).to_string()); Pixbuf icon = loader.get_pixbuf (); - temp_name = loader.get_format().get_name(); - icon.save (temp_path, "jpeg"); - local_path = temp_path; + icon.save (temp_path, loader.get_format().get_name()); + this.property_set(property, temp_path); } catch(GLib.Error e){ - warning("Problem taking file from the interweb - error: %s and name: %s", - e.message, - temp_name); - } + warning("Problem taking file from the interweb - error: %s", + e.message); + } + } } diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index c083e2a..54d4ed2 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -26,6 +26,11 @@ namespace DbusmenuMetadata{ public const string MENUITEM_ARTURL; } +[CCode (cheader_filename = "common-defs.h")] +namespace DbusmenuPlayer{ + public const string ITEM_REMOTE_FILEPATH; +} + [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuTransport{ public const string MENUITEM_TYPE; -- cgit v1.2.3 From bb73e65c4fd9f698050ff1d2ddb71fc35bac6803 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 1 Sep 2010 17:51:30 +0100 Subject: last fm art work should load correctly now --- src/common-defs.h | 2 +- src/fetch-file.vala | 22 +++++++++++++++++++++- src/metadata-widget.c | 14 ++++++-------- src/player-item.vala | 9 ++++----- src/sound-service.c | 4 ++-- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index faffcb2..2590692 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,7 +25,7 @@ with this program. If not, see . #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" #define DBUSMENU_PROPERTY_EMPTY -1 -#define DBUSMENU_PLAYERITEM_REMOTE_FILEPATH "/home/ronoc/Desktop/tempy" +#define DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH "/home/ronoc/Desktop/tempy" /* DBUS Custom Items */ #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type" diff --git a/src/fetch-file.vala b/src/fetch-file.vala index f172853..1811cc1 100644 --- a/src/fetch-file.vala +++ b/src/fetch-file.vala @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2010 Canonical, Ltd. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License + * version 3.0 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3.0 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Authors + * Gordon Allott + * Conor Curran + */ + public class FetchFile : Object { /* public variables */ @@ -26,7 +47,6 @@ public class FetchFile : Object public async void fetch_data () { - //grab our data from our uri try { this.stream = new DataInputStream(this.file.read(null)); this.stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN); diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 72acc8c..cfff098 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -105,7 +105,7 @@ metadata_widget_init (MetadataWidget *self) priv->album_art = gtk_image_new(); priv->image_path = g_string_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL)); priv->old_image_path = g_string_new(""); - priv->remote_image_path = g_string_new(DBUSMENU_PLAYERITEM_REMOTE_FILEPATH); + priv->remote_image_path = g_string_new(DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH); g_debug("Metadata::At startup and image path = %s", priv->image_path->str); g_signal_connect(priv->album_art, "expose-event", @@ -178,10 +178,6 @@ metadata_widget_finalize (GObject *object) G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); } -static void metadata_load_new_image(MetadataWidget* self) -{ -} - /** * We override the expose method to enable primitive drawing of the * empty album art image (and soon rounded rectangles on the album art) @@ -322,10 +318,12 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ g_string_erase(priv->image_path, 0, -1); - //gchar* empty = ""; - g_string_erase(priv->old_image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); - //g_free(empty); + // Basically force expose the reload the image because we have an image update + // but we are using remote images i.e. the same file + if(g_string_equal(priv->image_path, priv->remote_image_path) == TRUE){ + g_string_erase(priv->old_image_path, 0, -1); + } } } diff --git a/src/player-item.vala b/src/player-item.vala index 7de6840..1e16742 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -20,6 +20,7 @@ with this program. If not, see . using Dbusmenu; using Gee; using Gdk; +using DbusmenuPlayer; public class PlayerItem : Dbusmenu.Menuitem { @@ -128,18 +129,16 @@ public class PlayerItem : Dbusmenu.Menuitem private void on_fetcher_completed(ByteArray update, string property) { - string temp_path = "/home/ronoc/Desktop/tempy"; - //"/tmp/indicator-sound-remote-image"; try{ PixbufLoader loader = new PixbufLoader (); loader.write (update.data, update.len); loader.close (); Pixbuf icon = loader.get_pixbuf (); - icon.save (temp_path, loader.get_format().get_name()); - this.property_set(property, temp_path); + icon.save (ITEM_REMOTE_FILEPATH, loader.get_format().get_name()); + this.property_set(property, ITEM_REMOTE_FILEPATH); } catch(GLib.Error e){ - warning("Problem taking file from the interweb - error: %s", + warning("Problem fetching file from the interweb - error: %s", e.message); } } diff --git a/src/sound-service.c b/src/sound-service.c index 42ce116..12f067e 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); // TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 136b92dbb90bd3c9d1905d0f039b8776aa1a1c73 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 2 Sep 2010 11:27:23 +0100 Subject: album art from remote location working --- src/common-defs.h | 2 +- src/metadata-widget.c | 29 ++++++++++++++++++++--------- src/sound-service.c | 3 +-- vapi/common-defs.vapi | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index 2590692..fc4e323 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,7 +25,7 @@ with this program. If not, see . #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" #define DBUSMENU_PROPERTY_EMPTY -1 -#define DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH "/home/ronoc/Desktop/tempy" +#define DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH "/tmp/indicator-sound-downloaded-album-art" /* DBUS Custom Items */ #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type" diff --git a/src/metadata-widget.c b/src/metadata-widget.c index cfff098..3e01aec 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -70,7 +70,7 @@ static void image_set_from_pixbuf (GtkWidget *widget, MetadataWidget* metadata, GdkPixbuf *source); - +static void draw_album_art_placeholder(GtkWidget *metadata); G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -180,7 +180,7 @@ metadata_widget_finalize (GObject *object) /** * We override the expose method to enable primitive drawing of the - * empty album art image (and soon rounded rectangles on the album art) + * empty album art image and rounded rectangles on the album art. */ static gboolean metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user_data) @@ -188,26 +188,37 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* widget = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); - + g_debug("expose"); if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || (g_string_equal(priv->image_path, priv->remote_image_path) == TRUE && - g_string_equal(priv->old_image_path, priv->remote_image_path) == FALSE)){ + g_string_equal(priv->old_image_path, priv->remote_image_path) == FALSE)){ + g_debug("and we are in"); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); g_debug("metadata_load_new_image -> pixbuf from %s", priv->image_path->str); + if(GDK_IS_PIXBUF(pixbuf) == FALSE){ + g_debug("problem loading the downloaded image just use the placeholder instead"); + draw_album_art_placeholder(metadata); + return TRUE; + } pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR); image_set_from_pixbuf (metadata, widget, pixbuf); 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; } - + draw_album_art_placeholder(metadata); + return TRUE; +} + +static void draw_album_art_placeholder(GtkWidget *metadata) +{ + cairo_t *cr; cr = gdk_cairo_create (metadata->window); GtkAllocation alloc; @@ -259,8 +270,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user g_object_unref(pcontext); g_string_free (string, TRUE); cairo_destroy (cr); - - return TRUE; + } /* Suppress/consume keyevents */ @@ -320,9 +330,10 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_string_erase(priv->image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); // Basically force expose the reload the image because we have an image update - // but we are using remote images i.e. the same file + // but we are using remote images i.e. the same file path but different images if(g_string_equal(priv->image_path, priv->remote_image_path) == TRUE){ g_string_erase(priv->old_image_path, 0, -1); + gtk_widget_queue_draw(GTK_WIDGET(mitem)); } } } diff --git a/src/sound-service.c b/src/sound-service.c index 12f067e..f19379d 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,14 +40,13 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - // TODO: uncomment for release !! + //TODO: uncomment for release !! close_pulse_activites(); g_main_loop_quit(mainloop); } return; } - /** main: **/ diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 54d4ed2..93f4795 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -1,6 +1,6 @@ /* Copyright 2010 Canonical Ltd. - + Authors: Conor Curran -- cgit v1.2.3 From 779bb004a88acc14c7a505e531731e7d89d65eeb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 3 Sep 2010 14:06:00 +0100 Subject: reworked album art handling using gio exclusively with mkstemp --- src/common-defs.h | 1 - src/metadata-menu-item.vala | 2 +- src/metadata-widget.c | 15 ++++------- src/player-item.vala | 62 +++++++++++++++++++++++++++------------------ vapi/common-defs.vapi | 5 ---- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/common-defs.h b/src/common-defs.h index fc4e323..e554c11 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,7 +25,6 @@ with this program. If not, see . #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" #define DBUSMENU_PROPERTY_EMPTY -1 -#define DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH "/tmp/indicator-sound-downloaded-album-art" /* DBUS Custom Items */ #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 04284d4..6e7230b 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -38,5 +38,5 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ARTURL); return attrs; } - + } diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 3e01aec..a88d38c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -36,7 +36,6 @@ struct _MetadataWidgetPrivate GtkWidget* album_art; GString* image_path; GString* old_image_path; - GString* remote_image_path; GtkWidget* artist_label; GtkWidget* piece_label; GtkWidget* container_label; @@ -105,7 +104,6 @@ metadata_widget_init (MetadataWidget *self) priv->album_art = gtk_image_new(); priv->image_path = g_string_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL)); priv->old_image_path = g_string_new(""); - priv->remote_image_path = g_string_new(DBUSMENU_PLAYER_ITEM_REMOTE_FILEPATH); g_debug("Metadata::At startup and image path = %s", priv->image_path->str); g_signal_connect(priv->album_art, "expose-event", @@ -190,9 +188,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); g_debug("expose"); if(priv->image_path->len > 0){ - if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || - (g_string_equal(priv->image_path, priv->remote_image_path) == TRUE && - g_string_equal(priv->old_image_path, priv->remote_image_path) == FALSE)){ + if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){ g_debug("and we are in"); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); @@ -328,11 +324,10 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ g_string_erase(priv->image_path, 0, -1); - g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); - // Basically force expose the reload the image because we have an image update - // but we are using remote images i.e. the same file path but different images - if(g_string_equal(priv->image_path, priv->remote_image_path) == TRUE){ - g_string_erase(priv->old_image_path, 0, -1); + g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); + // if its a remote image queue a redraw incase the download took too long + if (g_str_has_prefix(g_value_get_string (value), get_user_special_dir(GUserDirectory.PICTURES))){ + g_debug("the image update is a download so redraw"); gtk_widget_queue_draw(GTK_WIDGET(mitem)); } } diff --git a/src/player-item.vala b/src/player-item.vala index 1e16742..83b19d6 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -20,7 +20,6 @@ with this program. If not, see . using Dbusmenu; using Gee; using Gdk; -using DbusmenuPlayer; public class PlayerItem : Dbusmenu.Menuitem { @@ -28,6 +27,7 @@ public class PlayerItem : Dbusmenu.Menuitem public string item_type { get; construct; } private const int EMPTY = -1; private FetchFile fetcher; + private string previous_temp_album_art_path; public PlayerItem(string type) { @@ -36,6 +36,7 @@ public class PlayerItem : Dbusmenu.Menuitem construct { this.property_set(MENUITEM_PROP_TYPE, item_type); + this.previous_temp_album_art_path = null; } public void reset(HashSet attrs){ @@ -45,6 +46,12 @@ public class PlayerItem : Dbusmenu.Menuitem } } + /** + * 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. + */ public void update(HashTable data, HashSet attributes) { debug("PlayerItem::update()"); @@ -62,25 +69,11 @@ public class PlayerItem : Dbusmenu.Menuitem if (v.holds (typeof (string))){ string update = v.get_string().strip(); debug("with value : %s", update); - // Special case for the arturl URI's. if(property.contains("mpris:artUrl")){ - if(update.has_prefix("http://")){ - // This is asyncronous so handle it offline - this.fetch_remote_art(update.strip(), property); + this.fetch_art(update.strip(), property); continue; - } - else{ - // The file is local, just parse the string - try{ - update = Filename.from_uri(update.strip()); - } - catch(ConvertError e){ - warning("Problem converting URI %s to file path", - update); - } - } } - this.property_set(property, update); + this.property_set(property, update); } else if (v.holds (typeof (int))){ debug("with value : %i", v.get_int()); @@ -95,7 +88,6 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } - if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){ this.property_set_bool(MENUITEM_PROP_VISIBLE, true); } @@ -114,14 +106,29 @@ public class PlayerItem : Dbusmenu.Menuitem return false; } - public void fetch_remote_art(string uri, string prop) - { + public void fetch_art(string uri, string prop) + { + File art_file = File.new_for_uri(uri); + if(art_file.is_native() == true){ + string path; + try{ + path = Filename.from_uri(uri.strip()); + this.property_set(prop, path); + } + catch(ConvertError e){ + warning("Problem converting URI %s to file path", + uri); + } + // eitherway return, the artwork was local + return; + } + // otherwise go remote this.fetcher = new FetchFile (uri, prop); this.fetcher.failed.connect (() => { this.on_fetcher_failed ();}); this.fetcher.completed.connect (this.on_fetcher_completed); this.fetcher.fetch_data (); } - + private void on_fetcher_failed () { warning("on_fetcher_failed -> could not fetch artwork"); @@ -134,13 +141,20 @@ public class PlayerItem : Dbusmenu.Menuitem loader.write (update.data, update.len); loader.close (); Pixbuf icon = loader.get_pixbuf (); - icon.save (ITEM_REMOTE_FILEPATH, loader.get_format().get_name()); - this.property_set(property, ITEM_REMOTE_FILEPATH); + string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat("/indicator-sound-XXXXXX"); + int r = FileUtils.mkstemp(path); + icon.save (path, loader.get_format().get_name()); + if(this.previous_temp_album_art_path != null){ + FileUtils.remove(this.previous_temp_album_art_path); + } + this.previous_temp_album_art_path = path; + this.property_set(property, path); } catch(GLib.Error e){ - warning("Problem fetching file from the interweb - error: %s", + warning("Problem creating file from bytearray fetched from the interweb - error: %s", e.message); } } + } diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 93f4795..84fb924 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -26,11 +26,6 @@ namespace DbusmenuMetadata{ public const string MENUITEM_ARTURL; } -[CCode (cheader_filename = "common-defs.h")] -namespace DbusmenuPlayer{ - public const string ITEM_REMOTE_FILEPATH; -} - [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuTransport{ public const string MENUITEM_TYPE; -- cgit v1.2.3 From eeefcb48bf469a2268601978353790f4e449db5f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 3 Sep 2010 15:24:46 +0100 Subject: working nicely --- src/metadata-widget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index a88d38c..1d50779 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -25,6 +25,7 @@ with this program. If not, see . #include "metadata-widget.h" #include "common-defs.h" #include +#include static DbusmenuMenuitem* twin_item; @@ -326,7 +327,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_string_erase(priv->image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); // if its a remote image queue a redraw incase the download took too long - if (g_str_has_prefix(g_value_get_string (value), get_user_special_dir(GUserDirectory.PICTURES))){ + if (g_str_has_prefix(g_value_get_string (value), g_get_user_special_dir(G_USER_DIRECTORY_PICTURES))){ g_debug("the image update is a download so redraw"); gtk_widget_queue_draw(GTK_WIDGET(mitem)); } -- cgit v1.2.3 From de523f44dbe55351c8fb8375823fe872a7d362e1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 3 Sep 2010 20:05:42 +0100 Subject: big refactor --- src/metadata-menu-item.vala | 132 +++++++++++++++++++++++++++++++++++++++++++- src/metadata-widget.c | 2 - src/player-item.vala | 61 ++------------------ src/sound-service.c | 4 +- 4 files changed, 137 insertions(+), 62 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 6e7230b..941fafd 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -19,15 +19,144 @@ with this program. If not, see . using Gee; using DbusmenuMetadata; +using Gdk; public class MetadataMenuitem : PlayerItem { + public const string ALBUM_ART_DIR_SUFFIX = "/sound-menu-album-art"; + public static string album_art_cache_dir; + private static FetchFile fetcher; + private string previous_temp_album_art_path; + public MetadataMenuitem() { Object(item_type: MENUITEM_TYPE); reset(attributes_format()); } + + construct{ + MetadataMenuitem.clean_album_art_temp_dir(); + this.previous_temp_album_art_path = null; + this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir(); + } + + private static void clean_album_art_temp_dir() + { + string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat(ALBUM_ART_DIR_SUFFIX); + + GLib.File? album_art_dir = GLib.File.new_for_uri(path); + + if(album_art_dir == null || album_art_dir.query_exists(null) == false){ + warning("here %s %s", (album_art_dir.query_exists(null) == false).to_string(), path); + return; + } + + if(delete_album_art_contents(album_art_dir) == true) + { + if(DirUtils.remove(path) == -1){ + warning("could not remove the temp album art directory %s", path); + } + } + } + + private static string? create_album_art_temp_dir() + { + string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat(ALBUM_ART_DIR_SUFFIX); + if(DirUtils.create(path, 0700) == -1){ + warning("could not create a temp dir for remote album art - that means we are not going to bother with remote art"); + return null; + } + return path; + } + + private static bool delete_album_art_contents (GLib.File dir) + { + bool result = true; + try { + var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME + "," + FILE_ATTRIBUTE_STANDARD_TYPE , + FileQueryInfoFlags.NOFOLLOW_SYMLINKS, + null); + while (true) + { + var file = e.next_file (null); + if (file == null) + break; + + var child = dir.get_child (file.get_name ()); + + try { + child.delete (null); + } catch (Error error_) { + warning (@"Unable to delete file '$(child.get_basename ()): $(error_.message)"); + result = false; + } + } + } catch (Error error) { + warning (@"Unable to read files from directory '$(dir.get_basename ())': %s", + error.message); + result = false; + } + return result; + } + + public void fetch_art(string uri, string prop) + { + File art_file = File.new_for_uri(uri); + if(art_file.is_native() == true){ + string path; + try{ + path = Filename.from_uri(uri.strip()); + this.property_set(prop, path); + } + catch(ConvertError e){ + warning("Problem converting URI %s to file path", + uri); + } + // eitherway return, the artwork was local + return; + } + // If we didn't manage to create the temp dir + // don't bother with remote + debug("fetch_art -remotely %s", this.album_art_cache_dir); + + if(this.album_art_cache_dir == null){ + return; + } + // green light to go remote + this.fetcher = new FetchFile (uri, prop); + this.fetcher.failed.connect (() => { this.on_fetcher_failed ();}); + this.fetcher.completed.connect (this.on_fetcher_completed); + this.fetcher.fetch_data (); + } + + private void on_fetcher_failed () + { + warning("on_fetcher_failed -> could not fetch artwork"); + } + private void on_fetcher_completed(ByteArray update, string property) + { + try{ + PixbufLoader loader = new PixbufLoader (); + loader.write (update.data, update.len); + loader.close (); + Pixbuf icon = loader.get_pixbuf (); + string path = this.album_art_cache_dir.concat("/XXXXXX"); + int r = FileUtils.mkstemp(path); + if(r != -1){ + icon.save (path, loader.get_format().get_name()); + this.property_set(property, path); + if(this.previous_temp_album_art_path != null){ + FileUtils.remove(this.previous_temp_album_art_path); + } + this.previous_temp_album_art_path = path; + } + } + catch(GLib.Error e){ + warning("Problem creating file from bytearray fetched from the interweb - error: %s", + e.message); + } + } public static HashSet attributes_format() { @@ -37,6 +166,5 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ALBUM); attrs.add(MENUITEM_ARTURL); return attrs; - } - + } } diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 1d50779..dc6aaa6 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -187,10 +187,8 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* widget = METADATA_WIDGET(user_data); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); - g_debug("expose"); if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){ - g_debug("and we are in"); GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL); g_debug("metadata_load_new_image -> pixbuf from %s", diff --git a/src/player-item.vala b/src/player-item.vala index 83b19d6..68ae6ef 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -19,15 +19,12 @@ with this program. If not, see . using Dbusmenu; using Gee; -using Gdk; public class PlayerItem : Dbusmenu.Menuitem { public PlayerController owner {get; construct;} public string item_type { get; construct; } private const int EMPTY = -1; - private FetchFile fetcher; - private string previous_temp_album_art_path; public PlayerItem(string type) { @@ -36,7 +33,6 @@ public class PlayerItem : Dbusmenu.Menuitem construct { this.property_set(MENUITEM_PROP_TYPE, item_type); - this.previous_temp_album_art_path = null; } public void reset(HashSet attrs){ @@ -69,8 +65,11 @@ public class PlayerItem : Dbusmenu.Menuitem if (v.holds (typeof (string))){ string update = v.get_string().strip(); debug("with value : %s", update); - if(property.contains("mpris:artUrl")){ - this.fetch_art(update.strip(), property); + if(property.contains("mpris:artUrl")){ + // We know its a metadata instance because thats the only + // object with the arturl prop + MetadataMenuitem metadata = this as MetadataMenuitem; + metadata.fetch_art(update.strip(), property); continue; } this.property_set(property, update); @@ -106,55 +105,5 @@ public class PlayerItem : Dbusmenu.Menuitem return false; } - public void fetch_art(string uri, string prop) - { - File art_file = File.new_for_uri(uri); - if(art_file.is_native() == true){ - string path; - try{ - path = Filename.from_uri(uri.strip()); - this.property_set(prop, path); - } - catch(ConvertError e){ - warning("Problem converting URI %s to file path", - uri); - } - // eitherway return, the artwork was local - return; - } - // otherwise go remote - this.fetcher = new FetchFile (uri, prop); - this.fetcher.failed.connect (() => { this.on_fetcher_failed ();}); - this.fetcher.completed.connect (this.on_fetcher_completed); - this.fetcher.fetch_data (); - } - - private void on_fetcher_failed () - { - warning("on_fetcher_failed -> could not fetch artwork"); - } - - private void on_fetcher_completed(ByteArray update, string property) - { - try{ - PixbufLoader loader = new PixbufLoader (); - loader.write (update.data, update.len); - loader.close (); - Pixbuf icon = loader.get_pixbuf (); - string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat("/indicator-sound-XXXXXX"); - int r = FileUtils.mkstemp(path); - icon.save (path, loader.get_format().get_name()); - if(this.previous_temp_album_art_path != null){ - FileUtils.remove(this.previous_temp_album_art_path); - } - this.previous_temp_album_art_path = path; - this.property_set(property, path); - } - catch(GLib.Error e){ - warning("Problem creating file from bytearray fetched from the interweb - error: %s", - e.message); - } - } - } diff --git a/src/sound-service.c b/src/sound-service.c index f19379d..51f5f37 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); //TODO: uncomment for release !! - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From 0c8770bdf288089fe2e0dce4e3c4b2743bb7a15d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Sep 2010 10:32:30 +0100 Subject: shifted to use the more appropriate cache dir --- src/metadata-menu-item.vala | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 941fafd..4e66bb0 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -23,7 +23,8 @@ using Gdk; public class MetadataMenuitem : PlayerItem { - public const string ALBUM_ART_DIR_SUFFIX = "/sound-menu-album-art"; + public const string ALBUM_ART_DIR_SUFFIX = "/indicators/sound/album-art-cache"; + public static string album_art_cache_dir; private static FetchFile fetcher; private string previous_temp_album_art_path; @@ -42,29 +43,27 @@ public class MetadataMenuitem : PlayerItem private static void clean_album_art_temp_dir() { - string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat(ALBUM_ART_DIR_SUFFIX); + string path = Environment.get_user_cache_dir().dup().concat(ALBUM_ART_DIR_SUFFIX); GLib.File? album_art_dir = GLib.File.new_for_uri(path); - if(album_art_dir == null || album_art_dir.query_exists(null) == false){ + /*if(album_art_dir == null || album_art_dir.query_exists(null) == false){ warning("here %s %s", (album_art_dir.query_exists(null) == false).to_string(), path); return; } + */ - if(delete_album_art_contents(album_art_dir) == true) + if(delete_album_art_contents(album_art_dir) == false) { - if(DirUtils.remove(path) == -1){ - warning("could not remove the temp album art directory %s", path); - } + warning("could not remove the temp album art files %s", path); } } private static string? create_album_art_temp_dir() { - string path = Environment.get_user_special_dir(UserDirectory.PICTURES).dup().concat(ALBUM_ART_DIR_SUFFIX); + string path = Environment.get_user_cache_dir().dup().concat(ALBUM_ART_DIR_SUFFIX); if(DirUtils.create(path, 0700) == -1){ - warning("could not create a temp dir for remote album art - that means we are not going to bother with remote art"); - return null; + warning("could not create a temp dir for remote album art, it must have been created already"); } return path; } @@ -79,7 +78,10 @@ public class MetadataMenuitem : PlayerItem while (true) { var file = e.next_file (null); - if (file == null) + + debug("file name = %s", file.get_name()); + + if (file == null) break; var child = dir.get_child (file.get_name ()); -- cgit v1.2.3 From b69ebdb28bb8b2d508c5788977d3c49f1d2fd28a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 15:34:18 +0100 Subject: tidy up on the print outs --- src/metadata-menu-item.vala | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 4e66bb0..581fa10 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -46,12 +46,6 @@ public class MetadataMenuitem : PlayerItem string path = Environment.get_user_cache_dir().dup().concat(ALBUM_ART_DIR_SUFFIX); GLib.File? album_art_dir = GLib.File.new_for_uri(path); - - /*if(album_art_dir == null || album_art_dir.query_exists(null) == false){ - warning("here %s %s", (album_art_dir.query_exists(null) == false).to_string(), path); - return; - } - */ if(delete_album_art_contents(album_art_dir) == false) { @@ -72,7 +66,7 @@ public class MetadataMenuitem : PlayerItem { bool result = true; try { - var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME + "," + FILE_ATTRIBUTE_STANDARD_TYPE , + var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null); while (true) @@ -117,10 +111,9 @@ public class MetadataMenuitem : PlayerItem // eitherway return, the artwork was local return; } - // If we didn't manage to create the temp dir - // don't bother with remote debug("fetch_art -remotely %s", this.album_art_cache_dir); - + // If we didn't manage to create the temp dir + // don't bother with remote if(this.album_art_cache_dir == null){ return; } -- cgit v1.2.3 From cfd5b54dfa45a7d469059b93e0201401c5017ece Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 16:10:41 +0100 Subject: remote art url fixed --- src/metadata-menu-item.vala | 8 ++++---- src/metadata-widget.c | 2 +- src/sound-service.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 581fa10..cd50129 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -23,7 +23,7 @@ using Gdk; public class MetadataMenuitem : PlayerItem { - public const string ALBUM_ART_DIR_SUFFIX = "/indicators/sound/album-art-cache"; + public const string ALBUM_ART_DIR_SUFFIX = "indicators/sound/album-art-cache"; public static string album_art_cache_dir; private static FetchFile fetcher; @@ -43,9 +43,9 @@ public class MetadataMenuitem : PlayerItem private static void clean_album_art_temp_dir() { - string path = Environment.get_user_cache_dir().dup().concat(ALBUM_ART_DIR_SUFFIX); + string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX); - GLib.File? album_art_dir = GLib.File.new_for_uri(path); + GLib.File? album_art_dir = GLib.File.new_for_path(path); if(delete_album_art_contents(album_art_dir) == false) { @@ -55,7 +55,7 @@ public class MetadataMenuitem : PlayerItem private static string? create_album_art_temp_dir() { - string path = Environment.get_user_cache_dir().dup().concat(ALBUM_ART_DIR_SUFFIX); + string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX); if(DirUtils.create(path, 0700) == -1){ warning("could not create a temp dir for remote album art, it must have been created already"); } diff --git a/src/metadata-widget.c b/src/metadata-widget.c index dc6aaa6..2bca072 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -325,7 +325,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_string_erase(priv->image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); // if its a remote image queue a redraw incase the download took too long - if (g_str_has_prefix(g_value_get_string (value), g_get_user_special_dir(G_USER_DIRECTORY_PICTURES))){ + if (g_str_has_prefix(g_value_get_string (value), g_get_user_cache_dir())){ g_debug("the image update is a download so redraw"); gtk_widget_queue_draw(GTK_WIDGET(mitem)); } diff --git a/src/sound-service.c b/src/sound-service.c index 51f5f37..f19379d 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) if (mainloop != NULL) { g_debug("Service shutdown !"); //TODO: uncomment for release !! - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3 From b7c9529e1830961e50ecf664b53b7a64b6643c41 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 7 Sep 2010 16:29:33 +0100 Subject: changed temp name to be more telling of its purpose --- src/metadata-menu-item.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index cd50129..3f71653 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -136,7 +136,7 @@ public class MetadataMenuitem : PlayerItem loader.write (update.data, update.len); loader.close (); Pixbuf icon = loader.get_pixbuf (); - string path = this.album_art_cache_dir.concat("/XXXXXX"); + string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX"); int r = FileUtils.mkstemp(path); if(r != -1){ icon.save (path, loader.get_format().get_name()); -- cgit v1.2.3