projects
/
platform
/
upstream
/
glib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cleanup
[platform/upstream/glib.git]
/
gio
/
gloadableicon.c
diff --git
a/gio/gloadableicon.c
b/gio/gloadableicon.c
index
db86fd0
..
17321bc
100644
(file)
--- a/
gio/gloadableicon.c
+++ b/
gio/gloadableicon.c
@@
-13,18
+13,16
@@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
-#include "gasyncresult.h"
-#include "gsimpleasyncresult.h"
#include "gicon.h"
#include "gloadableicon.h"
#include "gicon.h"
#include "gloadableicon.h"
+#include "gasyncresult.h"
+#include "gtask.h"
#include "glibintl.h"
#include "glibintl.h"
@@
-62,11
+60,12
@@
g_loadable_icon_default_init (GLoadableIconIface *iface)
* g_loadable_icon_load:
* @icon: a #GLoadableIcon.
* @size: an integer.
* g_loadable_icon_load:
* @icon: a #GLoadableIcon.
* @size: an integer.
- * @type: (out) (allow-none): a location to store the type of the
- * loaded icon, %NULL to ignore.
- * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
- * @error: a #GError location to store the error occuring, or %NULL to
+ * @type: (out) (optional): a location to store the type of the loaded
+ * icon, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to
* ignore.
* ignore.
+ * @error: a #GError location to store the error occurring, or %NULL
+ * to ignore.
*
* Loads a loadable icon. For the asynchronous version of this function,
* see g_loadable_icon_load_async().
*
* Loads a loadable icon. For the asynchronous version of this function,
* see g_loadable_icon_load_async().
@@
-122,8
+121,9
@@
g_loadable_icon_load_async (GLoadableIcon *icon,
* g_loadable_icon_load_finish:
* @icon: a #GLoadableIcon.
* @res: a #GAsyncResult.
* g_loadable_icon_load_finish:
* @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
+ * @type: (out) (optional): a location to store the type of the loaded
+ * icon, %NULL to ignore.
+ * @error: a #GError location to store the error occurring, or %NULL to
* ignore.
*
* Finishes an asynchronous icon load started in g_loadable_icon_load_async().
* ignore.
*
* Finishes an asynchronous icon load started in g_loadable_icon_load_async().
@@
-141,13
+141,9
@@
g_loadable_icon_load_finish (GLoadableIcon *icon,
g_return_val_if_fail (G_IS_LOADABLE_ICON (icon), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
g_return_val_if_fail (G_IS_LOADABLE_ICON (icon), NULL);
g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
+ if (g_async_result_legacy_propagate_error (res, error))
+ return NULL;
+
iface = G_LOADABLE_ICON_GET_IFACE (icon);
return (* iface->load_finish) (icon, res, type, error);
iface = G_LOADABLE_ICON_GET_IFACE (icon);
return (* iface->load_finish) (icon, res, type, error);
@@
-160,43
+156,35
@@
g_loadable_icon_load_finish (GLoadableIcon *icon,
typedef struct {
int size;
char *type;
typedef struct {
int size;
char *type;
- GInputStream *stream;
} LoadData;
static void
load_data_free (LoadData *data)
{
} LoadData;
static void
load_data_free (LoadData *data)
{
- if (data->stream)
- g_object_unref (data->stream);
g_free (data->type);
g_free (data);
}
static void
g_free (data->type);
g_free (data);
}
static void
-load_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
+load_async_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
{
+ GLoadableIcon *icon = source_object;
+ LoadData *data = task_data;
GLoadableIconIface *iface;
GInputStream *stream;
GLoadableIconIface *iface;
GInputStream *stream;
- LoadData *data;
GError *error = NULL;
GError *error = NULL;
- char *type = NULL;
- data = g_simple_async_result_get_op_res_gpointer (res);
-
- iface = G_LOADABLE_ICON_GET_IFACE (object);
- stream = iface->load (G_LOADABLE_ICON (object), data->size, &type, cancellable, &error);
+ iface = G_LOADABLE_ICON_GET_IFACE (icon);
+ stream = iface->load (icon, data->size, &data->type,
+ cancellable, &error);
- if (stream == NULL)
- {
- g_simple_async_result_take_error (res, error);
- }
+ if (stream)
+ g_task_return_pointer (task, stream, g_object_unref);
else
else
- {
- data->stream = stream;
- data->type = type;
- }
+ g_task_return_error (task, error);
}
}
@@
-208,14
+196,14
@@
g_loadable_icon_real_load_async (GLoadableIcon *icon,
GAsyncReadyCallback callback,
gpointer user_data)
{
GAsyncReadyCallback callback,
gpointer user_data)
{
- G
SimpleAsyncResult *res
;
+ G
Task *task
;
LoadData *data;
LoadData *data;
-
-
res = g_simple_async_result_new (G_OBJECT (icon), callback, user_data, g_loadable_icon_real_load_async
);
+
+
task = g_task_new (icon, cancellable, callback, user_data
);
data = g_new0 (LoadData, 1);
data = g_new0 (LoadData, 1);
- g_
simple_async_result_set_op_res_gpointer (res
, data, (GDestroyNotify) load_data_free);
- g_
simple_async_result_run_in_thread (res, load_async_thread, 0, cancellable
);
- g_object_unref (
res
);
+ g_
task_set_task_data (task
, data, (GDestroyNotify) load_data_free);
+ g_
task_run_in_thread (task, load_async_thread
);
+ g_object_unref (
task
);
}
static GInputStream *
}
static GInputStream *
@@
-224,18
+212,21
@@
g_loadable_icon_real_load_finish (GLoadableIcon *icon,
char **type,
GError **error)
{
char **type,
GError **error)
{
- G
SimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res)
;
+ G
Task *task
;
LoadData *data;
LoadData *data;
+ GInputStream *stream;
- g_
warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async
);
+ g_
return_val_if_fail (g_task_is_valid (res, icon), NULL
);
- data = g_simple_async_result_get_op_res_gpointer (simple);
+ task = G_TASK (res);
+ data = g_task_get_task_data (task);
- if (type)
+ stream = g_task_propagate_pointer (task, error);
+ if (stream && type)
{
*type = data->type;
data->type = NULL;
}
{
*type = data->type;
data->type = NULL;
}
- return
g_object_ref (data->stream)
;
+ return
stream
;
}
}