* Author: Alexander Larsson <alexl@redhat.com>
*/
-#include <config.h>
-
+#include "config.h"
+#include "gasyncresult.h"
#include "gsimpleasyncresult.h"
+#include "gicon.h"
#include "gloadableicon.h"
#include "glibintl.h"
+
+/**
+ * SECTION:gloadableicon
+ * @short_description: Loadable Icons
+ * @include: gio/gio.h
+ * @see_also: #GIcon, #GThemedIcon
+ *
+ * Extends the #GIcon interface and adds the ability to
+ * load icons from streams.
+ **/
+
static void g_loadable_icon_real_load_async (GLoadableIcon *icon,
int size,
GCancellable *cancellable,
GAsyncResult *res,
char **type,
GError **error);
-static void g_loadable_icon_base_init (gpointer g_class);
-static void g_loadable_icon_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_loadable_icon_get_type (void)
-{
- static GType loadable_icon_type = 0;
-
- if (! loadable_icon_type)
- {
- static const GTypeInfo loadable_icon_info =
- {
- sizeof (GLoadableIconIface), /* class_size */
- g_loadable_icon_base_init, /* base_init */
- NULL, /* base_finalize */
- g_loadable_icon_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- loadable_icon_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GLoadableIcon"),
- &loadable_icon_info, 0);
- g_type_interface_add_prerequisite (loadable_icon_type, G_TYPE_ICON);
- }
-
- return loadable_icon_type;
-}
+typedef GLoadableIconIface GLoadableIconInterface;
+G_DEFINE_INTERFACE(GLoadableIcon, g_loadable_icon, G_TYPE_ICON)
static void
-g_loadable_icon_class_init (gpointer g_class,
- gpointer class_data)
+g_loadable_icon_default_init (GLoadableIconIface *iface)
{
- GLoadableIconIface *iface = g_class;
-
iface->load_async = g_loadable_icon_real_load_async;
iface->load_finish = g_loadable_icon_real_load_finish;
}
-static void
-g_loadable_icon_base_init (gpointer g_class)
-{
-}
-
/**
* g_loadable_icon_load:
- * @icon:
- * @size:
- * @type:
+ * @icon: a #GLoadableIcon.
+ * @size: an integer.
+ * @type: a location to store the type of the loaded icon, %NULL to ignore.
* @cancellable: optional #GCancellable object, %NULL to ignore.
* @error: a #GError location to store the error occuring, or %NULL to
* ignore.
- * Returns:
+ *
+ * Loads a loadable icon. For the asynchronous version of this function,
+ * see g_loadable_icon_load_async().
+ *
+ * Returns: (transfer full): a #GInputStream to read the icon from.
**/
GInputStream *
-g_loadable_icon_load (GLoadableIcon *icon,
- int size,
- char **type,
- GCancellable *cancellable,
- GError **error)
+g_loadable_icon_load (GLoadableIcon *icon,
+ int size,
+ char **type,
+ GCancellable *cancellable,
+ GError **error)
{
GLoadableIconIface *iface;
iface = G_LOADABLE_ICON_GET_IFACE (icon);
return (* iface->load) (icon, size, type, cancellable, error);
-
}
/**
* g_loadable_icon_load_async:
- * @icon:
- * @size:
- * @cancellable: optional #GCancellable object, %NULL to ignore. @callback:
- * @user_data:
- *
- * Loads an icon asynchronously.
+ * @icon: a #GLoadableIcon.
+ * @size: an integer.
+ * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @callback: a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: the data to pass to callback function
*
+ * Loads an icon asynchronously. To finish this function, see
+ * g_loadable_icon_load_finish(). For the synchronous, blocking
+ * version of this function, see g_loadable_icon_load().
**/
void
-g_loadable_icon_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+g_loadable_icon_load_async (GLoadableIcon *icon,
+ int size,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GLoadableIconIface *iface;
iface = G_LOADABLE_ICON_GET_IFACE (icon);
(* iface->load_async) (icon, size, cancellable, callback, user_data);
-
}
/**
* g_loadable_icon_load_finish:
- * @icon:
- * @res:
- * @type:
+ * @icon: a #GLoadableIcon.
+ * @res: a #GAsyncResult.
+ * @type: a location to store the type of the loaded icon, %NULL to ignore.
* @error: a #GError location to store the error occuring, or %NULL to
* ignore.
- * Returns:
+ *
+ * Finishes an asynchronous icon load started in g_loadable_icon_load_async().
+ *
+ * Returns: (transfer full): a #GInputStream to read the icon from.
**/
GInputStream *
-g_loadable_icon_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error)
+g_loadable_icon_load_finish (GLoadableIcon *icon,
+ GAsyncResult *res,
+ char **type,
+ GError **error)
{
GLoadableIconIface *iface;
iface = G_LOADABLE_ICON_GET_IFACE (icon);
return (* iface->load_finish) (icon, res, type, error);
-
}
/********************************************
static void
load_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
+ GObject *object,
+ GCancellable *cancellable)
{
GLoadableIconIface *iface;
GInputStream *stream;
static void
-g_loadable_icon_real_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+g_loadable_icon_real_load_async (GLoadableIcon *icon,
+ int size,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GSimpleAsyncResult *res;
LoadData *data;
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
LoadData *data;
- g_assert (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
data = g_simple_async_result_get_op_res_gpointer (simple);