[glibmm] Add SettingsSchema, SettingsSchemaKey and SettingsSchemaSource.



commit 4c7f7ac0945a5133a033bbada9c27b7adb30471f
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Jun 21 13:14:26 2015 +0200

    Add SettingsSchema, SettingsSchemaKey and SettingsSchemaSource.
    
    However, these are completely untested, and not all functions
    have been wrapped.

 gio/giomm.h                               |    2 +
 gio/src/filelist.am                       |    3 +
 gio/src/gio_extra_objects.defs            |   12 ++++
 gio/src/gio_signals.defs                  |    6 ++
 gio/src/settings.hg                       |    2 +-
 gio/src/settingsschema.ccg                |   23 ++++++++
 gio/src/settingsschema.hg                 |   82 +++++++++++++++++++++++++++++
 gio/src/settingsschemakey.ccg             |   23 ++++++++
 gio/src/settingsschemakey.hg              |   63 ++++++++++++++++++++++
 gio/src/settingsschemasource.ccg          |   23 ++++++++
 gio/src/settingsschemasource.hg           |   65 +++++++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gio.cc |    3 +
 tools/m4/convert_gio.m4                   |    8 +++
 13 files changed, 314 insertions(+), 1 deletions(-)
---
diff --git a/gio/giomm.h b/gio/giomm.h
index e778d36..43f6ed5 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -114,6 +114,8 @@
 #include <giomm/resource.h>
 #include <giomm/seekable.h>
 #include <giomm/settings.h>
+#include <giomm/settingsschema.h>
+#include <giomm/settingsschemakey.h>
 #include <giomm/simpleaction.h>
 #include <giomm/simpleactiongroup.h>
 #include <giomm/simpleiostream.h>
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 71e4fe0..8f65f78 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -101,6 +101,9 @@ giomm_files_any_hg =                        \
        resource.hg                     \
        seekable.hg                     \
        settings.hg                     \
+       settingsschema.hg \
+       settingsschemakey.hg \
+       settingsschemasource.hg \
        simpleaction.hg                 \
        simpleactiongroup.hg            \
        simpleiostream.hg               \
diff --git a/gio/src/gio_extra_objects.defs b/gio/src/gio_extra_objects.defs
index a47e231..c1ed447 100644
--- a/gio/src/gio_extra_objects.defs
+++ b/gio/src/gio_extra_objects.defs
@@ -193,6 +193,18 @@
   (gtype-id "G_TYPE_RESOURCE")
 )
 
+(define-object SettingsSchema
+  (in-module "Gio")
+  (c-name "GSettingsSchema")
+  (gtype-id "G_TYPE_SETTINGS_SCHEMA")
+)
+
+(define-object SettingsSchemaKey
+  (in-module "Gio")
+  (c-name "GSettingsSchemaKey")
+  (gtype-id "G_TYPE_SETTINGS_SCHEMA_KEY")
+)
+
 (define-object SimpleAction
   (in-module "Gio")
   (c-name "GSimpleAction")
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index d6c76b5..92d6701 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -1784,6 +1784,12 @@
   (construct-only #f)
 )
 
+;; GSettingsSchema is neither a GObject nor a GInterface. Not checked for signals and properties.
+
+;; GSettingsSchemaKey is neither a GObject nor a GInterface. Not checked for signals and properties.
+
+;; GSettingsSchemaSource is neither a GObject nor a GInterface. Not checked for signals and properties.
+
 ;; From GSimplePermission
 
 ;; From GSocket
diff --git a/gio/src/settings.hg b/gio/src/settings.hg
index eb660dd..7d48e72 100644
--- a/gio/src/settings.hg
+++ b/gio/src/settings.hg
@@ -176,7 +176,7 @@ _DEPRECATE_IFDEF_END
 
 #m4 
_CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, 
Glib::OWNERSHIP_DEEP)')
   _WRAP_METHOD(std::vector<Glib::ustring> list_children() const, g_settings_list_children)
-  _WRAP_METHOD(std::vector<Glib::ustring> list_keys() const, g_settings_list_keys)
+  _WRAP_METHOD(std::vector<Glib::ustring> list_keys() const, g_settings_list_keys, deprecated "Use 
SettingsSchema::list_kes().")
 
   _IGNORE(g_settings_get_range, g_settings_list_relocatable_schemas) // deprecated
 
diff --git a/gio/src/settingsschema.ccg b/gio/src/settingsschema.ccg
new file mode 100644
index 0000000..a8ef5d4
--- /dev/null
+++ b/gio/src/settingsschema.ccg
@@ -0,0 +1,23 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+} //namespace Gio
diff --git a/gio/src/settingsschema.hg b/gio/src/settingsschema.hg
new file mode 100644
index 0000000..4ff7e83
--- /dev/null
+++ b/gio/src/settingsschema.hg
@@ -0,0 +1,82 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_CONFIGINCLUDE(giommconfig.h)
+
+#include <giomm/settingsschemakey.h>
+#include <glibmm/arrayhandle.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GSettingsSchema GSettingsSchema;
+#endif
+
+namespace Gio
+{
+
+//TODO: Translate more of the class documentation from the C docs.
+
+/** Introspecting and controlling the loading of GSettings schemas.
+ *
+ * The SettingsSchemaSource and SettingsSchema APIs provide a
+ * mechanism for advanced control over the loading of schemas and a
+ * mechanism for introspecting their content.
+ *
+ * Plugin loading systems that wish to provide plugins a way to access
+ * settings face the problem of how to make the schemas for these
+ * settings visible to GSettings.  Typically, a plugin will want to ship
+ * the schema along with itself and it won't be installed into the
+ * standard system directories for schemas.
+ *
+ * SettingsSchemaSource provides a mechanism for dealing with this by
+ * allowing the creation of a new 'schema source' from which schemas can
+ * be acquired.  This schema source can then become part of the metadata
+ * associated with the plugin and queried whenever the plugin requires
+ * access to some settings.
+ *
+ * @newin{2,32}
+ */
+class SettingsSchema
+{
+  _CLASS_OPAQUE_REFCOUNTED(SettingsSchema, GSettingsSchema, NONE, g_settings_schema_ref, 
g_settings_schema_unref)
+
+protected:
+  _IGNORE(g_settings_schema_ref, g_settings_schema_unref)
+
+  //Ignore internal GSettingsSchema functions.
+  _IGNORE(g_settings_schema_get_value, g_settings_schema_list, g_settings_schema_get_string, 
g_settings_schema_get_gettext_domain)
+
+public:
+  _WRAP_METHOD(Glib::ustring get_id() const, g_settings_schema_get_id)
+  _WRAP_METHOD(Glib::ustring get_path() const, g_settings_schema_get_path)
+
+  //Note that these don't need refreturn because they seem to return a reference
+  //(they are documented as transfer:full)
+  _WRAP_METHOD(Glib::RefPtr<SettingsSchemaKey> get_key(const Glib::ustring& name), g_settings_schema_get_key)
+  _WRAP_METHOD(Glib::RefPtr<const SettingsSchemaKey> get_key(const Glib::ustring& name) const, 
g_settings_schema_get_key)
+
+  _WRAP_METHOD(bool has_key(const Glib::ustring& name) const, g_settings_schema_has_key)
+
+#m4 
_CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, 
Glib::OWNERSHIP_DEEP)')
+  _WRAP_METHOD(std::vector<Glib::ustring> list_keys() const, g_settings_schema_list_keys)
+
+  _WRAP_METHOD(std::vector<Glib::ustring> list_children() const, g_settings_schema_list_children)
+};
+
+} // namespace Gio
diff --git a/gio/src/settingsschemakey.ccg b/gio/src/settingsschemakey.ccg
new file mode 100644
index 0000000..a8ef5d4
--- /dev/null
+++ b/gio/src/settingsschemakey.ccg
@@ -0,0 +1,23 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+} //namespace Gio
diff --git a/gio/src/settingsschemakey.hg b/gio/src/settingsschemakey.hg
new file mode 100644
index 0000000..cca21c7
--- /dev/null
+++ b/gio/src/settingsschemakey.hg
@@ -0,0 +1,63 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_CONFIGINCLUDE(giommconfig.h)
+
+#include <glibmm/variant.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GSettingsSchemaKey GSettingsSchemaKey;
+#endif
+
+namespace Gio
+{
+
+//TODO: Add some class documentation, though there is none in the C docs.
+
+/** See SettingsSchema.
+ *
+ * @newin{2,32}
+ */
+class SettingsSchemaKey
+{
+  _CLASS_OPAQUE_REFCOUNTED(SettingsSchemaKey, GSettingsSchemaKey, NONE, g_settings_schema_key_ref, 
g_settings_schema_key_unref)
+
+protected:
+  _IGNORE(g_settings_schema_key_ref, g_settings_schema_key_unref)
+
+  //Ignore internal GSettingsSchemaKey functions.
+  _IGNORE(g_settings_schema_key_init, g_settings_schema_key_clear,
+    g_settings_schema_key_type_check, g_settings_schema_key_range_fixup,
+    g_settings_schema_key_get_translated_default, g_settings_schema_key_to_enum,
+    g_settings_schema_key_from_enum, g_settings_schema_key_to_flags,
+    g_settings_schema_key_from_flags)
+
+public:
+  //TODO: _WRAP_METHOD(const GVariantType *    g_settings_schema_key_get_value_type           (), 
g_settings_schema_key_get_value_type)
+  //_WRAP_METHOD(GVariant *              g_settings_schema_key_get_default_value        (), 
g_settings_schema_key_get_default_value)
+  //_WRAP_METHOD(GVariant *              g_settings_schema_key_get_range                (), 
g_settings_schema_key_get_range)
+  //TODO: _WRAP_METHOD(bool range_check(GVariant               *value), g_settings_schema_key_range_check)
+
+  _WRAP_METHOD(Glib::ustring get_name() const, g_settings_schema_key_get_name)
+  _WRAP_METHOD(Glib::ustring get_summary() const, g_settings_schema_key_get_summary)
+  _WRAP_METHOD(Glib::ustring get_description() const, g_settings_schema_key_get_description)
+};
+
+} // namespace Gio
diff --git a/gio/src/settingsschemasource.ccg b/gio/src/settingsschemasource.ccg
new file mode 100644
index 0000000..a8ef5d4
--- /dev/null
+++ b/gio/src/settingsschemasource.ccg
@@ -0,0 +1,23 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+} //namespace Gio
diff --git a/gio/src/settingsschemasource.hg b/gio/src/settingsschemasource.hg
new file mode 100644
index 0000000..2731f2b
--- /dev/null
+++ b/gio/src/settingsschemasource.hg
@@ -0,0 +1,65 @@
+/* Copyright (C) 2015 The giomm Development Team
+ *
+ * This library 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.
+ *
+ * This library 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_CONFIGINCLUDE(giommconfig.h)
+
+#include <giomm/settingsschema.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GSettingsSchemaSource GSettingsSchemaSource;
+#endif
+
+namespace Gio
+{
+
+//TODO: Add some class documentation, though there is none in the C docs.
+
+/** See SettingsSchema.
+ *
+ * @newin{2,32}
+ */
+class SettingsSchemaSource
+{
+  _CLASS_OPAQUE_REFCOUNTED(SettingsSchemaSource, GSettingsSchemaSource, NONE, g_settings_schema_source_ref, 
g_settings_schema_source_unref)
+
+protected:
+  _IGNORE(g_settings_schema_source_ref, g_settings_schema_source_unref)
+
+public:
+
+  _WRAP_METHOD(static Glib::RefPtr<SettingsSchemaSource> get_default(), g_settings_schema_source_get_default)
+
+/* TODO:
+GLIB_AVAILABLE_IN_2_32
+GSettingsSchemaSource * g_settings_schema_source_new_from_directory     (const gchar            *directory,
+                                                                         GSettingsSchemaSource  *parent,
+                                                                         gboolean                trusted,
+                                                                         GError                **error);
+*/
+
+  //Note this doesn't need refreturn because the C function returns a reference.
+  //- it is documented as transfer:full
+  _WRAP_METHOD(Glib::RefPtr<SettingsSchema> lookup(const Glib::ustring& schema_id, bool recursive), 
g_settings_schema_source_lookup)
+  _WRAP_METHOD(Glib::RefPtr<const SettingsSchema> lookup(const Glib::ustring& schema_id, bool recursive) 
const, g_settings_schema_source_lookup)
+
+  //TODO:_WRAP_METHOD(void list_schemas(bool recursive,  gchar*** non_relocatable, gchar*** relocatable), 
g_settings_schema_source_list_schemas)
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 373e3de..602b59b 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -118,6 +118,9 @@ int main(int, char**)
             << get_defs(G_TYPE_NETWORK_MONITOR)
             << get_defs(G_TYPE_NETWORK_SERVICE)
             << get_defs(G_TYPE_SETTINGS)
+            << get_defs(G_TYPE_SETTINGS_SCHEMA)
+            << get_defs(G_TYPE_SETTINGS_SCHEMA_KEY)
+            << get_defs(G_TYPE_SETTINGS_SCHEMA_SOURCE)
             << get_defs(G_TYPE_SIMPLE_PERMISSION)
             << get_defs(G_TYPE_SOCKET)
             << get_defs(G_TYPE_SOCKET_CLIENT)
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index d0672ba..8219d4d 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -268,6 +268,14 @@ _CONVERSION(`GSettings*',`Glib::RefPtr<Settings>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::StringArrayHandle&',`const gchar*-const*',`($3).data()')
 _CONVERSION(`const Glib::RefPtr<SettingsBackend>&',`GSettingsBackend*',__CONVERT_REFPTR_TO_P)
 
+_CONVERSION(`GSettingsSchemaKey*',`Glib::RefPtr<SettingsSchemaKey>',`Glib::wrap($3)')
+_CONVERSION(`GSettingsSchemaKey*',`Glib::RefPtr<const SettingsSchemaKey>',`Glib::wrap($3)')
+
+_CONVERSION(`GSettingsSchema*',`Glib::RefPtr<SettingsSchema>',`Glib::wrap($3)')
+_CONVERSION(`GSettingsSchema*',`Glib::RefPtr<const SettingsSchema>',`Glib::wrap($3)')
+
+_CONVERSION(`GSettingsSchemaSource*',`Glib::RefPtr<SettingsSchemaSource>',`Glib::wrap($3)')
+
 
 #Socket
 _CONVERSION(`const Glib::RefPtr<Socket>&',`GSocket*',__CONVERT_CONST_REFPTR_TO_P)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]