diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-06-16 19:40:15 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-06-16 19:40:15 +0100 |
commit | 4125fd9e2eb0de55d04482b3c035aa91fe7d547a (patch) | |
tree | 10eb6aa44d76a74df0a737946deceb90c867da74 /src | |
parent | 71d315d3abec5b62e43b821232d70262bec92bd1 (diff) | |
download | ayatana-indicator-sound-4125fd9e2eb0de55d04482b3c035aa91fe7d547a.tar.gz ayatana-indicator-sound-4125fd9e2eb0de55d04482b3c035aa91fe7d547a.tar.bz2 ayatana-indicator-sound-4125fd9e2eb0de55d04482b3c035aa91fe7d547a.zip |
album art updates working just fine
Diffstat (limited to 'src')
-rw-r--r-- | src/metadata-widget.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/metadata-widget.c b/src/metadata-widget.c index e69a9dd..e0dca6e 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -34,7 +34,7 @@ struct _MetadataWidgetPrivate { GtkWidget* hbox; GtkWidget* album_art; - gchar* our_path; + gchar* image_path; GtkWidget* artist_label; GtkWidget* piece_label; GtkWidget* container_label; @@ -53,10 +53,10 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); // Dbusmenuitem properties update callback -static void metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, +static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata); -//static void update_content( +static void update_album_art(MetadataWidget* self); G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); @@ -92,14 +92,9 @@ metadata_widget_init (MetadataWidget *self) priv->hbox = hbox; // image - const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); - g_debug("MetadataWidget:init - path = %s", path); - priv->our_path = g_strdup(path); - GdkPixbuf* pixbuf; - pixbuf=gdk_pixbuf_new_from_file(path, NULL); - pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); - priv->album_art = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); + priv->album_art = gtk_image_new(); + priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH)); + update_album_art(self); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0); GtkWidget* vbox = gtk_vbox_new(TRUE, 0); @@ -107,24 +102,28 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* artist; artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST)); priv->artist_label = artist; - gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); + // piece GtkWidget* piece; piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE)); priv->piece_label = piece; - gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); - + + // container GtkWidget* container; container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER)); priv->container_label = container; + + // Pack in the right order + gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(twin_item), "property-changed", - G_CALLBACK(metadata_widget_update_state), self); + G_CALLBACK(metadata_widget_property_update), self); gtk_widget_show_all (priv->hbox); gtk_container_add (GTK_CONTAINER (self), hbox); @@ -160,10 +159,9 @@ metadata_widget_button_release_event (GtkWidget *menuitem, } static void -metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, +metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata) { - //g_debug("metadata_widget_update_state - with property %s", property); MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); @@ -173,6 +171,22 @@ metadata_widget_update_state(DbusmenuMenuitem* item, gchar* property, else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, property) == 0){ gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, property) == 0){ + gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); + } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, property) == 0){ + priv->image_path = g_strdup(g_value_get_string(value)); + update_album_art(mitem); + } +} + +static void update_album_art(MetadataWidget* self){ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + GdkPixbuf* pixbuf; + pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL); + pixbuf = gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); + g_object_unref(pixbuf); } /** |