phosh-arch/gtk3-mobile/gtkprivate-Add-an-API-to-check-if-phone.patch
2024-08-13 08:17:11 -07:00

53 lines
1.2 KiB
Diff

From: Mohammed Sadiq <sadiq@sadiqpk.org>
Date: Thu, 27 Aug 2020 14:48:11 +0530
Subject: gtkprivate: Add an API to check if phone
---
gtk/gtkprivate.h | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index aca24fd..635b247 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -127,6 +127,40 @@ GBytes *get_emoji_data (void);
#endif /* G_ENABLE_DEBUG */
+static inline GSettings *
+_gtk_get_purism_settings (void)
+{
+ GSettings *gsettings;
+ GSettingsSchema *schema;
+
+ schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (),
+ "org.gtk.Settings.Purism", TRUE);
+
+ if (!schema)
+ return NULL;
+
+ gsettings = g_settings_new_full (schema, NULL, NULL);
+
+ g_settings_schema_unref (schema);
+
+ return gsettings;
+}
+
+static inline gboolean
+_gtk_get_is_phone (void)
+{
+ GSettings *gsettings = _gtk_get_purism_settings ();
+ gboolean is_phone;
+
+ if (!gsettings)
+ return FALSE;
+
+ is_phone = g_settings_get_boolean (gsettings, "is-phone");
+ g_object_unref (gsettings);
+
+ return is_phone;
+}
+
G_END_DECLS
#endif /* __GTK_PRIVATE_H__ */