st: Port to GTask
GSimpleAsyncResult has been deprecated for a while.
This commit is contained in:
parent
3e63fb7abe
commit
f2731d4d6a
@ -430,38 +430,30 @@ impl_load_pixbuf_file (GFile *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_pixbuf_thread (GSimpleAsyncResult *result,
|
load_pixbuf_thread (GTask *result,
|
||||||
GObject *object,
|
gpointer source,
|
||||||
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
AsyncTextureLoadData *data;
|
AsyncTextureLoadData *data = task_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
data = g_async_result_get_user_data (G_ASYNC_RESULT (result));
|
|
||||||
g_assert (data != NULL);
|
g_assert (data != NULL);
|
||||||
g_assert (data->file != NULL);
|
g_assert (data->file != NULL);
|
||||||
|
|
||||||
pixbuf = impl_load_pixbuf_file (data->file, data->width, data->height, data->scale, &error);
|
pixbuf = impl_load_pixbuf_file (data->file, data->width, data->height, data->scale, &error);
|
||||||
|
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
g_task_return_error (result, error);
|
||||||
g_simple_async_result_set_from_error (result, error);
|
else if (pixbuf)
|
||||||
return;
|
g_task_return_pointer (result, g_object_ref (pixbuf), g_object_unref);
|
||||||
}
|
|
||||||
|
|
||||||
if (pixbuf)
|
|
||||||
g_simple_async_result_set_op_res_gpointer (result, g_object_ref (pixbuf),
|
|
||||||
g_object_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
load_pixbuf_async_finish (StTextureCache *cache, GAsyncResult *result, GError **error)
|
load_pixbuf_async_finish (StTextureCache *cache, GAsyncResult *result, GError **error)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
|
return g_task_propagate_pointer (G_TASK (result), error);
|
||||||
if (g_simple_async_result_propagate_error (simple, error))
|
|
||||||
return NULL;
|
|
||||||
return g_simple_async_result_get_op_res_gpointer (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglTexture *
|
static CoglTexture *
|
||||||
@ -582,10 +574,9 @@ load_texture_async (StTextureCache *cache,
|
|||||||
{
|
{
|
||||||
if (data->file)
|
if (data->file)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result;
|
GTask *task = g_task_new (cache, NULL, on_pixbuf_loaded, data);
|
||||||
result = g_simple_async_result_new (G_OBJECT (cache), on_pixbuf_loaded, data, load_texture_async);
|
g_task_run_in_thread (task, load_pixbuf_thread);
|
||||||
g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, NULL);
|
g_object_unref (task);
|
||||||
g_object_unref (result);
|
|
||||||
}
|
}
|
||||||
else if (data->icon_info)
|
else if (data->icon_info)
|
||||||
{
|
{
|
||||||
@ -1024,13 +1015,13 @@ on_sliced_image_loaded (GObject *source_object,
|
|||||||
{
|
{
|
||||||
GObject *cache = source_object;
|
GObject *cache = source_object;
|
||||||
AsyncImageData *data = (AsyncImageData *)user_data;
|
AsyncImageData *data = (AsyncImageData *)user_data;
|
||||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
GTask *task = G_TASK (res);
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
if (g_simple_async_result_propagate_error (simple, NULL))
|
if (g_task_had_error (task))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (list = g_simple_async_result_get_op_res_gpointer (simple); list; list = g_list_next (list))
|
for (list = g_task_propagate_pointer (task, NULL); list; list = list->next)
|
||||||
{
|
{
|
||||||
ClutterActor *actor = load_from_pixbuf (GDK_PIXBUF (list->data));
|
ClutterActor *actor = load_from_pixbuf (GDK_PIXBUF (list->data));
|
||||||
clutter_actor_hide (actor);
|
clutter_actor_hide (actor);
|
||||||
@ -1065,8 +1056,9 @@ on_loader_size_prepared (GdkPixbufLoader *loader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_sliced_image (GSimpleAsyncResult *result,
|
load_sliced_image (GTask *result,
|
||||||
GObject *object,
|
gpointer object,
|
||||||
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
AsyncImageData *data;
|
AsyncImageData *data;
|
||||||
@ -1079,7 +1071,7 @@ load_sliced_image (GSimpleAsyncResult *result,
|
|||||||
|
|
||||||
g_assert (!cancellable);
|
g_assert (!cancellable);
|
||||||
|
|
||||||
data = g_object_get_data (G_OBJECT (result), "load_sliced_image");
|
data = task_data;
|
||||||
g_assert (data);
|
g_assert (data);
|
||||||
|
|
||||||
loader = gdk_pixbuf_loader_new ();
|
loader = gdk_pixbuf_loader_new ();
|
||||||
@ -1114,7 +1106,7 @@ load_sliced_image (GSimpleAsyncResult *result,
|
|||||||
* though the subpixbufs will hold a reference. */
|
* though the subpixbufs will hold a reference. */
|
||||||
g_object_unref (loader);
|
g_object_unref (loader);
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
g_simple_async_result_set_op_res_gpointer (result, res, free_glist_unref_gobjects);
|
g_task_return_pointer (result, res, free_glist_unref_gobjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1144,7 +1136,7 @@ st_texture_cache_load_sliced_image (StTextureCache *cache,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
AsyncImageData *data;
|
AsyncImageData *data;
|
||||||
GSimpleAsyncResult *result;
|
GTask *result;
|
||||||
ClutterActor *actor = clutter_actor_new ();
|
ClutterActor *actor = clutter_actor_new ();
|
||||||
|
|
||||||
data = g_new0 (AsyncImageData, 1);
|
data = g_new0 (AsyncImageData, 1);
|
||||||
@ -1157,10 +1149,9 @@ st_texture_cache_load_sliced_image (StTextureCache *cache,
|
|||||||
data->load_callback_data = user_data;
|
data->load_callback_data = user_data;
|
||||||
g_object_ref (G_OBJECT (actor));
|
g_object_ref (G_OBJECT (actor));
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (cache), on_sliced_image_loaded, data, st_texture_cache_load_sliced_image);
|
result = g_task_new (cache, NULL, on_sliced_image_loaded, data);
|
||||||
|
g_task_set_task_data (result, data, on_data_destroy);
|
||||||
g_object_set_data_full (G_OBJECT (result), "load_sliced_image", data, on_data_destroy);
|
g_task_run_in_thread (result, load_sliced_image);
|
||||||
g_simple_async_result_run_in_thread (result, load_sliced_image, G_PRIORITY_DEFAULT, NULL);
|
|
||||||
|
|
||||||
g_object_unref (result);
|
g_object_unref (result);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user