[maemo-commits] [maemo-commits] r16451 - in projects/haf/trunk/hildon-thumbnail: . thumbs

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Oct 22 13:13:35 EEST 2008
Author: pvanhoof
Date: 2008-10-22 13:13:33 +0300 (Wed, 22 Oct 2008)
New Revision: 16451

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c
Log:
2008-10-22  Philip Van Hoof  <philip at codeminded.be>
	
	* thumbs/hildon-thumbnail-obj.c
	* thumbs/hildon-thumbnail-factory.h
	* thumbs/hildon-albumart-obj.c
	* thumbs/hildon-albumart-factory.h: API documentation



Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-10-22 07:01:50 UTC (rev 16450)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2008-10-22 10:13:33 UTC (rev 16451)
@@ -1,3 +1,10 @@
+2008-10-22  Philip Van Hoof  <philip at codeminded.be>
+	
+	* thumbs/hildon-thumbnail-obj.c
+	* thumbs/hildon-thumbnail-factory.h
+	* thumbs/hildon-albumart-obj.c
+	* thumbs/hildon-albumart-factory.h: API documentation
+
 2008-10-21  Philip Van Hoof  <philip at codeminded.be>
 
 	* thumbs/hildon-albumart-factory.c

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h	2008-10-22 07:01:50 UTC (rev 16450)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-factory.h	2008-10-22 10:13:33 UTC (rev 16451)
@@ -69,9 +69,47 @@
 GType hildon_albumart_factory_get_type (void);
 GType hildon_albumart_request_get_type (void);
 
+/** 
+ * HildonAlbumartRequestCallback:
+ * @self: the factory
+ * @albumart: (allow-none): A pixbuf containing the albumart or %NULL. If application wishes to keep the structure, it must call g_object_ref() on it. The library does not cache returned pixbufs.
+ * @error: (allow-none): The error or %NULL if there was none. Freed after callback returns.
+ * @user_data: (allow-none): User-supplied data when thumbnail was requested
+ *
+ * Called when the album art preparation finishes or there is an error
+ **/
 typedef void (*HildonAlbumartRequestCallback)	(HildonAlbumartFactory *self,
 		GdkPixbuf *albumart, GError *error, gpointer user_data);
 
+/**
+ * hildon_albumart_factory_get_instance:
+ *
+ * Request the factory singleton. You need to unref when finished with what got
+ * returned to you.
+ *
+ * Returns: (transfer full): the factory
+ **/
+HildonAlbumartFactory* hildon_albumart_factory_get_instance (void);
+
+
+/**
+ * hildon_albumart_factory_queue:
+ * @self: the factory
+ * @artist_or_title: (allow-none): The artist or the title of the feed
+ * @album: (allow-none): The album
+ * @kind: (allow-none) (default "album"): Usually "album", "podcast" or "radio"
+ * @callback: (allow-none): A callback that will be executed when the art is ready
+ * @user_data: (allow-none): User-supplied data for @callback and @destroy
+ * @destroy: (allow-none): a #GDestroyNotify to destroy @user_data as soon as @callback has ran
+ *
+ * Request the preparation, if needed, of album art and return it in @callback
+ * as a #GdkPixbuf as soon as it's ready. This operation is asynchronous, the
+ * creation of the art will not affect your running mainloop unless you
+ * use one of the join methods on either #HildonAlbumartFactory or the 
+ * #HildonAlbumartRequest being returned.
+ *
+ * Returns: (transfer full): A handle for the request that got created on a queue
+ **/
 HildonAlbumartRequest*
 	 hildon_albumart_factory_queue (HildonAlbumartFactory *self,
 									 const gchar *artist_or_title, const gchar *album, const gchar *kind,
@@ -79,6 +117,26 @@
 									 gpointer user_data,
 									 GDestroyNotify destroy);
 
+/**
+ * hildon_albumart_factory_queue_thumbnail:
+ * @self: the factory
+ * @artist_or_title: (allow-none): The artist or the title of the feed
+ * @album: (allow-none): The album
+ * @kind: (allow-none) (default "album"): Usually "album", "podcast" or "radio"
+ * @width: Wanted width
+ * @height: Wanted height
+ * @callback: (allow-none): A callback that will be executed when the art is ready
+ * @user_data: (allow-none): User-supplied data for @callback and @destroy
+ * @destroy: (allow-none): a #GDestroyNotify to destroy @user_data as soon as @callback has ran
+ *
+ * Request the preparation, if needed, of album art and return a thumbnail of it 
+ * in @callback as a #GdkPixbuf as soon as it's ready. This operation is 
+ * asynchronous, the creation of the thumbnail will not affect your running 
+ * mainloop unless you use one of the join methods on either #HildonAlbumartFactory
+ * or the #HildonAlbumartRequest being returned.
+ *
+ * Returns: (transfer full): A handle for the request that got created on a queue
+ **/
 HildonAlbumartRequest*
 	 hildon_albumart_factory_queue_thumbnail (HildonAlbumartFactory *self,
 									 const gchar *artist_or_title, const gchar *album, const gchar *kind,
@@ -87,10 +145,29 @@
 									 gpointer user_data,
 									 GDestroyNotify destroy);
 
+/**
+ * hildon_albumart_factory_join:
+ * @self: the factory
+ *
+ * Waits until all queued requests in @self are completed.
+ **/
 void hildon_albumart_factory_join (HildonAlbumartFactory *self);
 
+/**
+ * hildon_albumart_request_unqueue:
+ * @self: the request
+ *
+ * Attempts to unqueue a request. If the request is already active, then this
+ * method has no guaranteed effect.
+ **/
 void hildon_albumart_request_unqueue (HildonAlbumartRequest *self);
 
+/**
+ * hildon_albumart_request_join:
+ * @self: the request
+ *
+ * Waits until the queued requests is completed.
+ **/
 void hildon_albumart_request_join (HildonAlbumartRequest *self);
 
 typedef gpointer HildonAlbumartFactoryHandle;

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c	2008-10-22 07:01:50 UTC (rev 16450)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-albumart-obj.c	2008-10-22 10:13:33 UTC (rev 16451)
@@ -417,6 +417,23 @@
 	}
 }
 
+static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+static HildonAlbumartFactory *singleton = NULL;
+
+HildonAlbumartFactory* 
+hildon_albumart_factory_get_instance (void)
+{
+	g_static_mutex_lock (&mutex);
+
+	if (!singleton) {
+		singleton = g_object_new (HILDON_TYPE_ALBUMART_FACTORY, NULL);
+	}
+
+	g_static_mutex_unlock (&mutex);
+
+	return g_object_ref (singleton);
+}
+
 G_DEFINE_TYPE (HildonAlbumartFactory, hildon_albumart_factory, G_TYPE_OBJECT)
 
 G_DEFINE_TYPE (HildonAlbumartRequest, hildon_albumart_request, G_TYPE_OBJECT)

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h	2008-10-22 07:01:50 UTC (rev 16450)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-factory.h	2008-10-22 10:13:33 UTC (rev 16451)
@@ -69,9 +69,47 @@
 GType hildon_thumbnail_factory_get_type (void);
 GType hildon_thumbnail_request_get_type (void);
 
+/** 
+ * HildonThumbnailRequestCallback:
+ * @self: the factory
+ * @thumbnail: (allow-none): A pixbuf containing the thumbnail or %NULL. If application wishes to keep the structure, it must call g_object_ref() on it. The library does not cache returned pixbufs.
+ * @error: (allow-none): The error or %NULL if there was none. Freed after callback returns.
+ * @user_data: (allow-none): User-supplied data when thumbnail was requested
+ *
+ * Called when the thumbnailing process finishes or there is an error
+ **/
 typedef void (*HildonThumbnailRequestCallback)	(HildonThumbnailFactory *self,
 		GdkPixbuf *thumbnail, GError *error, gpointer user_data);
 
+/**
+ * hildon_thumbnail_factory_get_instance:
+ *
+ * Request the factory singleton. You need to unref when finished with what got
+ * returned to you.
+ *
+ * Returns: (transfer full): the factory
+ **/
+HildonThumbnailFactory* hildon_thumbnail_factory_get_instance (void);
+
+/**
+ * hildon_thumbnail_factory_request:
+ * @self: the factory
+ * @uri: an URI to the file which you want to request a thumbnail for
+ * @width: Wanted width of the thumbnail
+ * @height: Wanted height of the thumbnail
+ * @mime_type: (allow-none): A MIME type hint for @uri
+ * @callback: (allow-none): A callback that will be executed when the thumbnail is ready
+ * @user_data: (allow-none): User-supplied data for @callback and @destroy
+ * @destroy: (allow-none): a #GDestroyNotify to destroy @user_data as soon as @callback has ran
+ *
+ * Request the preparation, if needed, of a thumbnail and return it in @callback
+ * as a #GdkPixbuf as soon as it's ready. This operation is asynchronous, the
+ * creation of the thumbnail will not affect your running mainloop unless you
+ * use one of the join methods on either #HildonThumbnailFactory or the 
+ * #HildonThumbnailRequest being returned.
+ *
+ * Returns: (transfer full): A handle for the request that got created on a queue
+ **/
 HildonThumbnailRequest*
 	 hildon_thumbnail_factory_request (HildonThumbnailFactory *self,
 									 const gchar *uri,
@@ -82,10 +120,29 @@
 									 gpointer user_data,
 									 GDestroyNotify destroy);
 
+/**
+ * hildon_thumbnail_factory_join:
+ * @self: the factory
+ *
+ * Waits until all queued requests in @self are completed.
+ **/
 void hildon_thumbnail_factory_join (HildonThumbnailFactory *self);
 
+/**
+ * hildon_thumbnail_request_unqueue:
+ * @self: the request
+ *
+ * Attempts to unqueue a request. If the request is already active, then this
+ * method has no guaranteed effect.
+ **/
 void hildon_thumbnail_request_unqueue (HildonThumbnailRequest *self);
 
+/**
+ * hildon_thumbnail_request_join:
+ * @self: the request
+ *
+ * Waits until the queued requests is completed.
+ **/
 void hildon_thumbnail_request_join (HildonThumbnailRequest *self);
 
 typedef gpointer HildonThumbnailFactoryHandle;
@@ -114,6 +171,8 @@
  * @error: The error or %NULL if there was none. Freed after callback returns.
  *
  * Called when the thumbnailing process finishes or there is an error
+ *
+ * Decprecated use hildon_thumbnail_factory_request and HildonThumbnailRequestCallback instead
  */
 typedef void (*HildonThumbnailFactoryFinishedCallback)(HildonThumbnailFactoryHandle handle,
     gpointer user_data, GdkPixbuf *thumbnail, GError *error);
@@ -134,6 +193,8 @@
  *
  * Returns: A #HildonThumbnailFactoryHandle if request succeeded or %NULL if there was
  *  a critical error
+ *
+ * Decprecated use hildon_thumbnail_factory_request instead
  */
 HildonThumbnailFactoryHandle hildon_thumbnail_factory_load(
             const gchar *uri, const gchar *mime_type,
@@ -148,6 +209,8 @@
  * Same as hildon_thumbnail_factory_load, but with custom options for thumbnail creation.
  * Argument list ends with key-value pairs for customizing.
  * Terminate argument list with -1.
+ *
+ * Decprecated use hildon_thumbnail_factory_request instead
  */
 HildonThumbnailFactoryHandle hildon_thumbnail_factory_load_custom(
             const gchar *uri, const gchar *mime_type,
@@ -161,6 +224,8 @@
  * @handle: Handle to cancel
  *
  * Removes specified thumbnail request from the queue
+ *
+ * Deprecated use hildon_thumbnail_request_unqueue
  */
 void hildon_thumbnail_factory_cancel(HildonThumbnailFactoryHandle handle);
 
@@ -217,6 +282,8 @@
  * hildon_thumbnail_factory_wait:
  *
  * Wait until all thumbnailing processes have finished
+ *
+ * Deprecated use hildon_thumbnail_factory_join instead
  */
 void hildon_thumbnail_factory_wait();
 

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c	2008-10-22 07:01:50 UTC (rev 16450)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c	2008-10-22 10:13:33 UTC (rev 16451)
@@ -370,6 +370,23 @@
 	}
 }
 
+static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+static HildonThumbnailFactory *singleton = NULL;
+
+HildonThumbnailFactory* 
+hildon_thumbnail_factory_get_instance (void)
+{
+	g_static_mutex_lock (&mutex);
+
+	if (!singleton) {
+		singleton = g_object_new (HILDON_TYPE_THUMBNAIL_FACTORY, NULL);
+	}
+
+	g_static_mutex_unlock (&mutex);
+
+	return g_object_ref (singleton);
+}
+
 G_DEFINE_TYPE (HildonThumbnailFactory, hildon_thumbnail_factory, G_TYPE_OBJECT)
 
 G_DEFINE_TYPE (HildonThumbnailRequest, hildon_thumbnail_request, G_TYPE_OBJECT)


More information about the maemo-commits mailing list