forked from AuroraMiddleware/gtk
gdk: Allow setting task data on (de)serializers
This mirrors GTask.
This commit is contained in:
parent
c146132a4a
commit
cc07800570
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user