background: Replace deprecated GSimpleAsyncResult with GTask
This commit is contained in:
parent
3622c8ff14
commit
122f997493
3 changed files with 35 additions and 34 deletions
|
@ -81,7 +81,9 @@ list_load_cb (GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
cc_background_xml_load_list_finish (res);
|
g_autoptr(GError) error = NULL;
|
||||||
|
if (!cc_background_xml_load_list_finish (CC_BACKGROUND_XML (source_object), res, &error))
|
||||||
|
g_warning ("Failed to load background list: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -431,42 +431,39 @@ cc_background_xml_load_list (CcBackgroundXml *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const GHashTable *
|
gboolean
|
||||||
cc_background_xml_load_list_finish (GAsyncResult *async_result)
|
cc_background_xml_load_list_finish (CcBackgroundXml *xml,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (async_result);
|
g_return_val_if_fail (g_task_is_valid (result, xml), FALSE);
|
||||||
CcBackgroundXml *data;
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
return g_task_propagate_boolean (G_TASK (result), error);
|
||||||
g_return_val_if_fail (G_IS_ASYNC_RESULT (async_result), NULL);
|
|
||||||
g_warn_if_fail (g_simple_async_result_get_source_tag (result) == cc_background_xml_load_list_async);
|
|
||||||
|
|
||||||
data = CC_BACKGROUND_XML (g_simple_async_result_get_op_res_gpointer (result));
|
|
||||||
return data->wp_hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_list_thread (GSimpleAsyncResult *res,
|
load_list_thread (GTask *task,
|
||||||
GObject *object,
|
gpointer source_object,
|
||||||
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
CcBackgroundXml *data;
|
CcBackgroundXml *xml = CC_BACKGROUND_XML (source_object);
|
||||||
|
cc_background_xml_load_list (xml, TRUE);
|
||||||
data = g_simple_async_result_get_op_res_gpointer (res);
|
g_task_return_boolean (task, TRUE);
|
||||||
cc_background_xml_load_list (data, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cc_background_xml_load_list_async (CcBackgroundXml *xml,
|
void
|
||||||
GCancellable *cancellable,
|
cc_background_xml_load_list_async (CcBackgroundXml *xml,
|
||||||
GAsyncReadyCallback callback,
|
GCancellable *cancellable,
|
||||||
gpointer user_data)
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_autoptr(GSimpleAsyncResult) result = NULL;
|
g_autoptr(GTask) task = NULL;
|
||||||
|
|
||||||
g_return_if_fail (CC_IS_BACKGROUND_XML (xml));
|
g_return_if_fail (CC_IS_BACKGROUND_XML (xml));
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (xml), callback, user_data, cc_background_xml_load_list_async);
|
task = g_task_new (xml, cancellable, callback, user_data);
|
||||||
g_simple_async_result_set_op_res_gpointer (result, xml, NULL);
|
g_task_run_in_thread (task, load_list_thread);
|
||||||
g_simple_async_result_run_in_thread (result, (GSimpleAsyncThreadFunc) load_list_thread, G_PRIORITY_LOW, cancellable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
|
@ -31,17 +31,19 @@ G_DECLARE_FINAL_TYPE (CcBackgroundXml, cc_background_xml, CC, BACKGROUND_XML, GO
|
||||||
|
|
||||||
CcBackgroundXml *cc_background_xml_new (void);
|
CcBackgroundXml *cc_background_xml_new (void);
|
||||||
|
|
||||||
void cc_background_xml_save (CcBackgroundItem *item,
|
void cc_background_xml_save (CcBackgroundItem *item,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
CcBackgroundItem *cc_background_xml_get_item (const char *filename);
|
CcBackgroundItem *cc_background_xml_get_item (const char *filename);
|
||||||
gboolean cc_background_xml_load_xml (CcBackgroundXml *data,
|
gboolean cc_background_xml_load_xml (CcBackgroundXml *data,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
void cc_background_xml_load_list_async (CcBackgroundXml *data,
|
void cc_background_xml_load_list_async (CcBackgroundXml *xml,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
const GHashTable *cc_background_xml_load_list_finish (GAsyncResult *async_result);
|
gboolean cc_background_xml_load_list_finish (CcBackgroundXml *xml,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue