[maemo-commits] [maemo-commits] r16579 - in projects/haf/trunk/hildon-thumbnail: . daemon tests thumbs

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Nov 5 14:52:09 EET 2008
Author: pvanhoof
Date: 2008-11-05 14:52:06 +0200 (Wed, 05 Nov 2008)
New Revision: 16579

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/daemon/utils.c
   projects/haf/trunk/hildon-thumbnail/tests/artist-art-test.c
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.c
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c
Log:
2008-11-05  Philip Van Hoof  <philip at codeminded.be>

	* thumbs/hildon-albumart-factory.c
	* thumbs/hildon-albumart-obj.c
	* tests/artist-art-test.c
	* daemon/utils.c: Saw the hope for change become materialized and then
	fixed some problems in the new album art client library. Also adapted
	the test to use the new library instead of the old one.



Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-11-05 12:29:28 UTC (rev 16578)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-11-05 12:52:06 UTC (rev 16579)
@@ -1,3 +1,12 @@
+2008-11-05  Philip Van Hoof  <philip at codeminded.be>
+
+	* thumbs/hildon-albumart-factory.c
+	* thumbs/hildon-albumart-obj.c
+	* tests/artist-art-test.c
+	* daemon/utils.c: Saw the hope for change become materialized and then
+	fixed some problems in the new album art client library. Also adapted
+	the test to use the new library instead of the old one.
+
 2008-11-04  Philip Van Hoof  <philip at codeminded.be>
 
 	* thumbs/hildon-thumbnail-factory.c

Modified: projects/haf/trunk/hildon-thumbnail/daemon/utils.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/utils.c	2008-11-05 12:29:28 UTC (rev 16578)
+++ projects/haf/trunk/hildon-thumbnail/daemon/utils.c	2008-11-05 12:52:06 UTC (rev 16579)
@@ -151,7 +151,7 @@
 {
 	const gchar *foo = "()[]<>{}_!@#$^&*+=|\\/\"'?~";
 	guint osize = strlen (original);
-	gchar *retval = (gchar *) g_malloc0 (sizeof (gchar *) * osize);
+	gchar *retval = (gchar *) g_malloc0 (sizeof (gchar *) * osize + 1);
 	guint i = 0, y = 0;
 
 	while (i < osize) {

Modified: projects/haf/trunk/hildon-thumbnail/tests/artist-art-test.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/tests/artist-art-test.c	2008-11-05 12:29:28 UTC (rev 16578)
+++ projects/haf/trunk/hildon-thumbnail/tests/artist-art-test.c	2008-11-05 12:52:06 UTC (rev 16579)
@@ -1,22 +1,33 @@
 #include <gtk/gtk.h>
 #include <hildon-albumart-factory.h>
 
+
 GtkWindow *window;
 GtkHBox *box;
 GtkVBox *hbox;
-GtkImage *image;
+GtkImage *image, *imaget;
 GtkEntry *atext;
 GtkEntry *btext;
 GtkButton *button;
 
 
+#ifdef OLDAPI
 static void
 on_art_back (HildonAlbumartFactoryHandle handle, gpointer user_data, GdkPixbuf *albumart, GError *error)
 {
 	if (albumart) {
-		gtk_image_set_from_pixbuf (image, albumart);
+		gtk_image_set_from_pixbuf (user_data, albumart);
 	}
 }
+#else
+static void 
+on_art_back (HildonAlbumartFactory *self, GdkPixbuf *albumart, GError *error, gpointer user_data)
+{
+	if (albumart) {
+		gtk_image_set_from_pixbuf (user_data, albumart);
+	}
+}
+#endif
 
 static void
 on_button_clicked (GtkButton *button, gpointer user_data)
@@ -26,7 +37,24 @@
 	album = gtk_entry_get_text (btext);
 	artist = gtk_entry_get_text (atext);
 
-	hildon_albumart_factory_load(artist, album, "album", on_art_back, NULL);
+#ifdef OLDAPI
+	hildon_albumart_factory_load(artist, album, "album", on_art_back, image);
+#else
+	HildonAlbumartFactory *f = hildon_albumart_factory_get_instance ();
+	HildonAlbumartRequest *r1, *r2;
+
+	r1 = hildon_albumart_factory_queue (f, artist, album, "album",
+		on_art_back, image, NULL);
+
+	r2 = hildon_albumart_factory_queue_thumbnail (f, artist, album, "album",
+		256, 256,
+		on_art_back, imaget, NULL);
+
+	g_object_unref (f);
+	g_object_unref (r1);
+	g_object_unref (r2);
+#endif
+
 }
 
 int
@@ -50,6 +78,9 @@
 	image = gtk_image_new ();
 	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (image), TRUE, TRUE, 0);
 
+	imaget = gtk_image_new ();
+	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (imaget), TRUE, TRUE, 0);
+
 	button = gtk_button_new_with_label ("Get album art");
 	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (button), FALSE, TRUE, 0);
 

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.c	2008-11-05 12:29:28 UTC (rev 16578)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.c	2008-11-05 12:52:06 UTC (rev 16579)
@@ -303,6 +303,8 @@
 	g_free (a_dir);
 }
 
+static gboolean waiting_for_cb = FALSE;
+
 static void 
 on_got_handle (DBusGProxy *proxy, guint OUT_handle, GError *error, gpointer userdata)
 {
@@ -312,6 +314,8 @@
 
 	/* Register the item as being handled */
 	g_hash_table_replace (tasks, key, item);
+
+	waiting_for_cb = FALSE;
 }
 
 typedef struct {
@@ -385,6 +389,7 @@
 
 		init ();
 
+		waiting_for_cb = TRUE;
 		com_nokia_albumart_Requester_queue_async (proxy, artist, 
 												  album, 
 												  kind, 0, 
@@ -429,6 +434,9 @@
 {
 	init();
 
+	while (waiting_for_cb)
+		g_main_context_iteration (NULL, FALSE);
+
 	while(g_hash_table_size (tasks) != 0) {
 		g_main_context_iteration(NULL, TRUE);
 	}

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c	2008-11-05 12:29:28 UTC (rev 16578)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c	2008-11-05 12:52:06 UTC (rev 16579)
@@ -244,6 +244,8 @@
 	g_type_class_add_private (object_class, sizeof (HildonAlbumartFactoryPrivate));
 }
 
+static gboolean waiting_for_cb = FALSE;
+
 static void 
 on_got_handle (DBusGProxy *proxy, guint OUT_handle, GError *error, gpointer userdata)
 {
@@ -256,10 +258,12 @@
 	g_hash_table_replace (f_priv->tasks, key, 
 			      g_object_ref (request));
 	g_object_unref (request);
+
+	waiting_for_cb = FALSE;
 }
 
 HildonAlbumartRequest*
-hildon_albumart_factory_request (HildonAlbumartFactory *self,
+hildon_albumart_factory_queue (HildonAlbumartFactory *self,
 				  const gchar *artist_or_title, const gchar *album, const gchar *kind,
 				  HildonAlbumartRequestCallback callback,
 				  gpointer user_data,
@@ -277,6 +281,8 @@
 	r_priv->callback = callback;
 	r_priv->destroy = destroy;
 
+	waiting_for_cb = TRUE;
+
 	com_nokia_albumart_Requester_queue_async (f_priv->proxy, 
 						  r_priv->artist_or_title, 
 						  r_priv->album, 
@@ -361,7 +367,7 @@
 	info->width = width;
 	info->height = height;
 
-	r_priv->real = hildon_albumart_factory_request (self, artist_or_title, 
+	r_priv->real = hildon_albumart_factory_queue (self, artist_or_title, 
 							album, kind,
 							intercept_callback,
 							info,
@@ -376,8 +382,11 @@
 {
 	HildonAlbumartFactoryPrivate *f_priv = FACTORY_GET_PRIVATE (self);
 
+	while (waiting_for_cb)
+		g_main_context_iteration (NULL, FALSE);
+
 	while(g_hash_table_size (f_priv->tasks) != 0) {
-		g_main_context_iteration (NULL, TRUE);
+		g_main_context_iteration (NULL, FALSE);
 	}
 }
 
@@ -419,8 +428,11 @@
 		HildonAlbumartFactoryPrivate *f_priv = FACTORY_GET_PRIVATE (r_priv->factory);
 		HildonAlbumartRequest *found = g_hash_table_lookup (f_priv->tasks, r_priv->key);
 
+		while (waiting_for_cb)
+			g_main_context_iteration (NULL, FALSE);
+
 		while (found) {
-			g_main_context_iteration (NULL, TRUE);
+			g_main_context_iteration (NULL, FALSE);
 			found = g_hash_table_lookup (f_priv->tasks, r_priv->key);
 		}
 	}


More information about the maemo-commits mailing list