[nautilus] file-utilities: Add ability to check for installed schema
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] file-utilities: Add ability to check for installed schema
- Date: Fri, 15 Jul 2022 06:59:48 +0000 (UTC)
commit 6ec528bae241d0279efbafc93d38f01290196d80
Author: Corey Berla <corey berla me>
Date: Thu Jul 14 15:04:18 2022 -0700
file-utilities: Add ability to check for installed schema
Now that we are bringing the gnome-user-share extension
into Nautilus itself, we need the ability to check
if gnome-user-share is installed. GNOME Settings
does this by checking the schema. Let's use the same
code that Settings uses.
This doesn't work within sandboxes, so if we are
sandboxed always return TRUE;
src/nautilus-file-utilities.c | 28 ++++++++++++++++++++++++++++
src/nautilus-file-utilities.h | 2 ++
2 files changed, 30 insertions(+)
---
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index 3b161f52b..b79c8728d 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "nautilus-file-utilities.h"
+#include "nautilus-application.h"
#include "nautilus-global-preferences.h"
#include "nautilus-icon-names.h"
#include "nautilus-lib-self-check-functions.h"
@@ -1487,3 +1488,30 @@ location_settings_search_get_recursive_for_location (GFile *location)
return recursive;
}
+
+/* check_schema_available() was copied from GNOME Settings */
+gboolean
+check_schema_available (const gchar *schema_id)
+{
+ GSettingsSchemaSource *source;
+ g_autoptr (GSettingsSchema) schema = NULL;
+
+ if (nautilus_application_is_sandboxed ())
+ {
+ return TRUE;
+ }
+
+ source = g_settings_schema_source_get_default ();
+ if (!source)
+ {
+ return FALSE;
+ }
+
+ schema = g_settings_schema_source_lookup (source, schema_id, TRUE);
+ if (!schema)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/src/nautilus-file-utilities.h b/src/nautilus-file-utilities.h
index 67df0e4d9..e87c02417 100644
--- a/src/nautilus-file-utilities.h
+++ b/src/nautilus-file-utilities.h
@@ -141,3 +141,5 @@ gchar * nautilus_uri_to_native_uri (const gchar *uri);
NautilusQueryRecursive location_settings_search_get_recursive (void);
NautilusQueryRecursive location_settings_search_get_recursive_for_location (GFile *location);
+
+gboolean check_schema_available (const gchar *schema_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]