[tepl] Metadata: wrap GFile API
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] Metadata: wrap GFile API
- Date: Sat, 18 Apr 2020 17:18:11 +0000 (UTC)
commit 5f6d054b9840903532737a69f63303fe4798a86b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Apr 15 16:38:57 2020 +0200
Metadata: wrap GFile API
po/POTFILES.in | 1 +
tepl/meson.build | 2 ++
tepl/tepl-metadata.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tepl/tepl-metadata.h | 54 +++++++++++++++++++++++++++++++++++++
4 files changed, 132 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8dc1422..4434445 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -19,6 +19,7 @@ tepl/tepl-init.c
tepl/tepl-io-error-info-bars.c
tepl/tepl-iter.c
tepl/tepl-menu-shell.c
+tepl/tepl-metadata.c
tepl/tepl-metadata-store.c
tepl/tepl-notebook.c
tepl/tepl-signal-group.c
diff --git a/tepl/meson.build b/tepl/meson.build
index 2d52d70..7df5dbf 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -61,6 +61,7 @@ TEPL_PRIVATE_HEADERS = [
'tepl-file-content.h',
'tepl-file-content-loader.h',
'tepl-io-error-info-bar.h',
+ 'tepl-metadata.h',
'tepl-progress-info-bar.h',
'tepl-signal-group.h',
'tepl-tab-saving.h'
@@ -73,6 +74,7 @@ tepl_private_c_files = [
'tepl-file-content.c',
'tepl-file-content-loader.c',
'tepl-io-error-info-bar.c',
+ 'tepl-metadata.c',
'tepl-progress-info-bar.c',
'tepl-signal-group.c',
'tepl-tab-saving.c'
diff --git a/tepl/tepl-metadata.c b/tepl/tepl-metadata.c
new file mode 100644
index 0000000..fadbadf
--- /dev/null
+++ b/tepl/tepl-metadata.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 2020 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * Tepl is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * Tepl is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "tepl-metadata.h"
+
+/* Almost a drop-in replacement for, or a wrapping of, the
+ * GFile-metadata-related API (just what we need) to either:
+ * - Call the GFile API in case GVfs metadata is used.
+ * - Use the TeplMetadataStore otherwise. TODO: do it.
+ */
+
+void
+_tepl_metadata_query_info_async (GFile *location,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_file_query_info_async (location,
+ "metadata::*",
+ G_FILE_QUERY_INFO_NONE,
+ io_priority,
+ cancellable,
+ callback,
+ user_data);
+}
+
+GFileInfo *
+_tepl_metadata_query_info_finish (GFile *location,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_file_query_info_finish (location, result, error);
+}
+
+void
+_tepl_metadata_set_attributes_async (GFile *location,
+ GFileInfo *info,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_file_set_attributes_async (location,
+ info,
+ G_FILE_QUERY_INFO_NONE,
+ io_priority,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+_tepl_metadata_set_attributes_finish (GFile *location,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_file_set_attributes_finish (location, result, NULL, error);
+}
diff --git a/tepl/tepl-metadata.h b/tepl/tepl-metadata.h
new file mode 100644
index 0000000..58ce8eb
--- /dev/null
+++ b/tepl/tepl-metadata.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of Tepl, a text editor library.
+ *
+ * Copyright 2020 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * Tepl is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * Tepl is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TEPL_METADATA_H
+#define TEPL_METADATA_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL
+void _tepl_metadata_query_info_async (GFile *location,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+G_GNUC_INTERNAL
+GFileInfo * _tepl_metadata_query_info_finish (GFile *location,
+ GAsyncResult *result,
+ GError **error);
+
+G_GNUC_INTERNAL
+void _tepl_metadata_set_attributes_async (GFile *location,
+ GFileInfo *info,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+G_GNUC_INTERNAL
+gboolean _tepl_metadata_set_attributes_finish (GFile *location,
+ GAsyncResult *result,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* TEPL_METADATA_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]