aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-09-02 11:27:23 +0100
committerConor Curran <conor.curran@canonical.com>2010-09-02 11:27:23 +0100
commit136b92dbb90bd3c9d1905d0f039b8776aa1a1c73 (patch)
treebe9ca938fa04c5b6a1c9b3adf60fc89d0e1c6a20
parentbb73e65c4fd9f698050ff1d2ddb71fc35bac6803 (diff)
downloadayatana-indicator-sound-136b92dbb90bd3c9d1905d0f039b8776aa1a1c73.tar.gz
ayatana-indicator-sound-136b92dbb90bd3c9d1905d0f039b8776aa1a1c73.tar.bz2
ayatana-indicator-sound-136b92dbb90bd3c9d1905d0f039b8776aa1a1c73.zip
album art from remote location working
-rw-r--r--src/common-defs.h2
-rw-r--r--src/metadata-widget.c29
-rw-r--r--src/sound-service.c3
-rw-r--r--vapi/common-defs.vapi2
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 <http://www.gnu.org/licenses/>.
#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 <conor.curran@canonical.com>