mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
Add async version of find_enclosing_mount with default implementation.
2008-01-17 Alexander Larsson <alexl@redhat.com> * gfile.c: Add async version of find_enclosing_mount with default implementation. svn path=/trunk/; revision=6325
This commit is contained in:
parent
0026537f37
commit
35cf559e3d
@ -1,3 +1,9 @@
|
||||
2008-01-17 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gfile.c:
|
||||
Add async version of find_enclosing_mount
|
||||
with default implementation.
|
||||
|
||||
2008-01-17 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gfile.c:
|
||||
|
101
gio/gfile.c
101
gio/gfile.c
@ -172,6 +172,15 @@ static gboolean g_file_real_set_attributes_finish (GFile
|
||||
GAsyncResult *res,
|
||||
GFileInfo **info,
|
||||
GError **error);
|
||||
static void g_file_real_find_enclosing_mount_async (GFile *file,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
static GMount * g_file_real_find_enclosing_mount_finish (GFile *file,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
|
||||
GType
|
||||
g_file_get_type (void)
|
||||
@ -225,6 +234,8 @@ g_file_class_init (gpointer g_class,
|
||||
iface->create_finish = g_file_real_create_finish;
|
||||
iface->replace_async = g_file_real_replace_async;
|
||||
iface->replace_finish = g_file_real_replace_finish;
|
||||
iface->find_enclosing_mount_async = g_file_real_find_enclosing_mount_async;
|
||||
iface->find_enclosing_mount_finish = g_file_real_find_enclosing_mount_finish;
|
||||
iface->set_attributes_from_info = g_file_real_set_attributes_from_info;
|
||||
}
|
||||
|
||||
@ -1098,6 +1109,47 @@ g_file_find_enclosing_mount (GFile *file,
|
||||
return (* iface->find_enclosing_mount) (file, cancellable, error);
|
||||
}
|
||||
|
||||
void
|
||||
g_file_find_enclosing_mount_async (GFile *file,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GFileIface *iface;
|
||||
|
||||
g_return_if_fail (G_IS_FILE (file));
|
||||
|
||||
iface = G_FILE_GET_IFACE (file);
|
||||
(* iface->find_enclosing_mount_async) (file,
|
||||
io_priority,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
GMount *
|
||||
g_file_find_enclosing_mount_finish (GFile *file,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GFileIface *iface;
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), 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;
|
||||
}
|
||||
|
||||
iface = G_FILE_GET_IFACE (file);
|
||||
return (* iface->find_enclosing_mount_finish) (file, res, error);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_file_read:
|
||||
* @file: #GFile to read.
|
||||
@ -4005,6 +4057,55 @@ g_file_real_set_attributes_finish (GFile *file,
|
||||
return data->res;
|
||||
}
|
||||
|
||||
static void
|
||||
find_enclosing_mount_async_thread (GSimpleAsyncResult *res,
|
||||
GObject *object,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GMount *mount;
|
||||
|
||||
mount = g_file_find_enclosing_mount (G_FILE (object), cancellable, &error);
|
||||
|
||||
if (mount == NULL)
|
||||
{
|
||||
g_simple_async_result_set_from_error (res, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
g_simple_async_result_set_op_res_gpointer (res, mount, (GDestroyNotify)g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
g_file_real_find_enclosing_mount_async (GFile *file,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
|
||||
res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_find_enclosing_mount_async);
|
||||
|
||||
g_simple_async_result_run_in_thread (res, find_enclosing_mount_async_thread, io_priority, cancellable);
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static GMount *
|
||||
g_file_real_find_enclosing_mount_finish (GFile *file,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
GMount *mount;
|
||||
|
||||
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_file_real_find_enclosing_mount_async);
|
||||
|
||||
mount = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
return g_object_ref (mount);
|
||||
}
|
||||
|
||||
|
||||
/********************************************
|
||||
* Default VFS operations *
|
||||
********************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user