Commit cc078005 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

gdk: Allow setting task data on (de)serializers

This mirrors GTask.
parent c146132a
......@@ -59,6 +59,9 @@ struct _GdkContentDeserializer
GAsyncReadyCallback callback;
gpointer callback_data;
gpointer task_data;
GDestroyNotify task_notify;
GError *error;
gboolean returned;
};
......@@ -100,6 +103,9 @@ gdk_content_deserializer_finalize (GObject *object)
g_clear_object (&deserializer->cancellable);
g_clear_error (&deserializer->error);
if (deserializer->task_notify)
deserializer->task_notify (deserializer->task_data);
G_OBJECT_CLASS (gdk_content_deserializer_parent_class)->finalize (object);
}
......@@ -200,6 +206,28 @@ gdk_content_deserializer_get_user_data (GdkContentDeserializer *deserializer)
return deserializer->user_data;
}
void
gdk_content_deserializer_set_task_data (GdkContentDeserializer *deserializer,
gpointer data,
GDestroyNotify notify)
{
g_return_if_fail (GDK_IS_CONTENT_DESERIALIZER (deserializer));
if (deserializer->task_notify)
deserializer->task_notify (deserializer->task_data);
deserializer->task_data = data;
deserializer->task_notify = notify;
}
gpointer
gdk_content_deserializer_get_task_data (GdkContentDeserializer *deserializer)
{
g_return_val_if_fail (GDK_IS_CONTENT_DESERIALIZER (deserializer), NULL);
return deserializer->task_data;
}
static gboolean
gdk_content_deserializer_emit_callback (gpointer data)
{
......
......@@ -54,6 +54,12 @@ GDK_AVAILABLE_IN_3_94
GCancellable * gdk_content_deserializer_get_cancellable (GdkContentDeserializer *deserializer);
GDK_AVAILABLE_IN_3_94
gpointer gdk_content_deserializer_get_user_data (GdkContentDeserializer *deserializer);
GDK_AVAILABLE_IN_3_94
void gdk_content_deserializer_set_task_data (GdkContentDeserializer *deserializer,
gpointer data,
GDestroyNotify notify);
GDK_AVAILABLE_IN_3_94
gpointer gdk_content_deserializer_get_task_data (GdkContentDeserializer *deserializer);
GDK_AVAILABLE_IN_3_94
void gdk_content_deserializer_return_success (GdkContentDeserializer *deserializer);
......
......@@ -60,6 +60,9 @@ struct _GdkContentSerializer
GAsyncReadyCallback callback;
gpointer callback_data;
gpointer task_data;
GDestroyNotify task_notify;
GError *error;
gboolean returned;
};
......@@ -101,6 +104,9 @@ gdk_content_serializer_finalize (GObject *object)
g_clear_object (&serializer->cancellable);
g_clear_error (&serializer->error);
if (serializer->task_notify)
serializer->task_notify (serializer->task_data);
G_OBJECT_CLASS (gdk_content_serializer_parent_class)->finalize (object);
}
......@@ -202,6 +208,28 @@ gdk_content_serializer_get_user_data (GdkContentSerializer *serializer)
return serializer->user_data;
}
void
gdk_content_serializer_set_task_data (GdkContentSerializer *serializer,
gpointer data,
GDestroyNotify notify)
{
g_return_if_fail (GDK_IS_CONTENT_SERIALIZER (serializer));
if (serializer->task_notify)
serializer->task_notify (serializer->task_data);
serializer->task_data = data;
serializer->task_notify = notify;
}
gpointer
gdk_content_serializer_get_task_data (GdkContentSerializer *serializer)
{
g_return_val_if_fail (GDK_IS_CONTENT_SERIALIZER (serializer), NULL);
return serializer->task_data;
}
static gboolean
gdk_content_serializer_emit_callback (gpointer data)
{
......
......@@ -54,6 +54,12 @@ GDK_AVAILABLE_IN_3_94
GCancellable * gdk_content_serializer_get_cancellable (GdkContentSerializer *serializer);
GDK_AVAILABLE_IN_3_94
gpointer gdk_content_serializer_get_user_data (GdkContentSerializer *serializer);
GDK_AVAILABLE_IN_3_94
void gdk_content_serializer_set_task_data (GdkContentSerializer *serializer,
gpointer data,
GDestroyNotify notify);
GDK_AVAILABLE_IN_3_94
gpointer gdk_content_serializer_get_task_data (GdkContentSerializer *serializer);
GDK_AVAILABLE_IN_3_94
void gdk_content_serializer_return_success (GdkContentSerializer *serializer);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment