diff options
| author | Colomban Wendling <[email protected]> | 2025-11-25 11:02:22 +0100 |
|---|---|---|
| committer | Colomban Wendling <[email protected]> | 2025-11-25 11:02:22 +0100 |
| commit | f8b5f90adad866c7b287724e93e0fcdfaf6857f7 (patch) | |
| tree | 649704da163ddb93555358ecf236f06181767dc4 | |
| parent | ce2aabc1b0349ffe7f20c273d0fcdb18130371c3 (diff) | |
| download | mate-utils-async-save.tar.bz2 mate-utils-async-save.tar.xz | |
mate-screenshot: Fix compatibility with GLib < 2.74async-save
Older versions don't have g_file_new_tmp_dir_async(), so emulate it
there for compatibility.
| -rw-r--r-- | mate-screenshot/src/screenshot-save.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mate-screenshot/src/screenshot-save.c b/mate-screenshot/src/screenshot-save.c index b98268ee..18a63e2e 100644 --- a/mate-screenshot/src/screenshot-save.c +++ b/mate-screenshot/src/screenshot-save.c @@ -154,6 +154,46 @@ replace_async_ready (GObject* object, GAsyncResult* res, gpointer user_data) } } +#if ! GLIB_CHECK_VERSION (2, 74, 0) +/* poor man's emulation of the temp dir async API -- it's not actually async */ +static void +file_new_tmp_dir_async (const char *tmpl, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GError *error = NULL; + gchar *path; + gpointer task_data[2]; + + path = g_dir_make_tmp (tmpl, &error); + task_data[0] = path; + task_data[1] = error; + callback (NULL, (GAsyncResult *) task_data, user_data); + if (path) + g_free (path); + /* error is freed in finish() */ +} + +static GFile * +file_new_tmp_dir_finish (GAsyncResult *result, + GError **error) +{ + gpointer *task_data = (gpointer *) result; + + if (task_data[0]) + return g_file_new_for_path (task_data[0]); + + g_propagate_error (error, task_data[1]); + + return NULL; +} + +#define g_file_new_tmp_dir_async file_new_tmp_dir_async +#define g_file_new_tmp_dir_finish file_new_tmp_dir_finish +#endif + /* gets a #GFile path, setting @err if there is none */ static gchar * get_path (GFile *file, GError **err) |
