[glibmm] Initial implementation of Gio::Settings
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Initial implementation of Gio::Settings
- Date: Thu, 22 Apr 2010 03:00:23 +0000 (UTC)
commit 40461cabaad1ecdec132996d75d4edd8fd74ef58
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Tue Apr 20 23:43:39 2010 -0500
Initial implementation of Gio::Settings
ChangeLog | 9 +++
gio/src/filelist.am | 1 +
gio/src/gio_signals.defs | 75 +++++++++++++++++++++++++
gio/src/settings.ccg | 27 +++++++++
gio/src/settings.hg | 86 +++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gio.cc | 1 +
tools/m4/convert_gio.m4 | 4 +
7 files changed, 203 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 899422e..f026e67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-04-20 Jonathon Jongsma <jonathon jongsma collabora co uk>
+
+ * gio/src/filelist.am:
+ * gio/src/gio_signals.defs:
+ * gio/src/settings.ccg: Added.
+ * gio/src/settings.hg: Added.
+ * tools/extra_defs_gen/generate_defs_gio.cc:
+ * tools/m4/convert_gio.m4: Initial implementation of Gio::Settings
+
2010-04-20 Jonathon Jongsma <jonathon quotidian org>
* gio/src/gio_docs.xml
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 544c223..894f3d7 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -52,6 +52,7 @@ giomm_files_any_hg = \
outputstream.hg \
resolver.hg \
seekable.hg \
+ settings.hg \
socket.hg \
socketaddress.hg \
socketaddressenumerator.hg \
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index 6e44a59..ace64e9 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -877,6 +877,81 @@
(construct-only #t)
)
+;; From GSettings
+
+(define-signal changed
+ (of-object "GSettings")
+ (return-type "void")
+ (when "last")
+ (parameters
+ '("const-gchar*" "p0")
+ )
+)
+
+(define-signal change-event
+ (of-object "GSettings")
+ (return-type "gboolean")
+ (when "last")
+ (parameters
+ '("gpointer" "p0")
+ '("gint" "p1")
+ )
+)
+
+(define-signal writable-changed
+ (of-object "GSettings")
+ (return-type "void")
+ (when "last")
+ (parameters
+ '("const-gchar*" "p0")
+ )
+)
+
+(define-signal writable-change-event
+ (of-object "GSettings")
+ (return-type "gboolean")
+ (when "last")
+ (parameters
+ '("guint" "p0")
+ )
+)
+
+(define-property schema
+ (of-object "GSettings")
+ (prop-type "GParamString")
+ (docs "The name of the schema for this settings object")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property context
+ (of-object "GSettings")
+ (prop-type "GParamString")
+ (docs "The name of the context for this settings object")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property path
+ (of-object "GSettings")
+ (prop-type "GParamString")
+ (docs "The path within the backend where the settings are")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property has-unapplied
+ (of-object "GSettings")
+ (prop-type "GParamBoolean")
+ (docs "TRUE if there are outstanding changes to apply()")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
;; From GSocket
(define-property family
diff --git a/gio/src/settings.ccg b/gio/src/settings.ccg
new file mode 100644
index 0000000..14f649c
--- /dev/null
+++ b/gio/src/settings.ccg
@@ -0,0 +1,27 @@
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+Glib::RefPtr<Settings> Settings::create_with_context(const Glib::ustring& schema,
+ const Glib::ustring& context)
+{
+ return Glib::RefPtr<Settings>(new Settings(g_settings_new_with_context(schema.c_str(), context.c_str())));
+}
+
+void Settings::bind(const Glib::ustring& key,
+ const Glib::PropertyProxy_Base& property_proxy,
+ SettingsBindFlags flags)
+{
+ bind(key, property_proxy.get_object(), property_proxy.get_name(), flags);
+}
+
+void Settings::bind_writable(const Glib::ustring& key,
+ const Glib::PropertyProxy_Base& property_proxy,
+ bool inverted)
+{
+ bind_writable(key, property_proxy.get_object(), property_proxy.get_name(), inverted);
+}
+
+
+}
diff --git a/gio/src/settings.hg b/gio/src/settings.hg
new file mode 100644
index 0000000..ea7026f
--- /dev/null
+++ b/gio/src/settings.hg
@@ -0,0 +1,86 @@
+/* Copyright (C) 2010 Jonathon Jongsma
+ *
+ * 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 <glibmm/object.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+ _WRAP_ENUM(SettingsBindFlags, GSettingsBindFlags)
+
+/** A high-level API for application settings
+ *
+ * The Settings class provides a convenient API for storing and retrieving
+ * application settings.
+ *
+ * @newin{2,26}
+ */
+class Settings : public Glib::Object
+{
+ _CLASS_GOBJECT(Settings, GSettings, G_SETTINGS, Glib::Object, GObject)
+
+protected:
+ _WRAP_CTOR(Settings(const Glib::ustring& schema), g_settings_new)
+ _WRAP_CTOR(Settings(const Glib::ustring& schema, const Glib::ustring& path), g_settings_new_with_path)
+ // can't wrap both new_with_path and new_with_context since they both have the
+ // same signature...
+ _WRAP_CTOR(Settings(const Glib::ustring& schema, const Glib::ustring& context, const Glib::ustring& path), g_settings_new_with_context_and_path)
+
+public:
+ _WRAP_CREATE(const Glib::ustring& schema)
+ _WRAP_CREATE(const Glib::ustring& schema, const Glib::ustring& path)
+ _WRAP_CREATE(const Glib::ustring& schema, const Glib::ustring& context, const Glib::ustring& path)
+ static Glib::RefPtr<Settings> create_with_context(const Glib::ustring& schema, const Glib::ustring& context);
+
+ // FIXME: implement the GVariant stuff
+
+ _WRAP_METHOD(int get_int(const Glib::ustring& key) const, g_settings_get_int)
+ _WRAP_METHOD(void set_int(const Glib::ustring& key, int value), g_settings_set_int)
+ _WRAP_METHOD(bool get_boolean(const Glib::ustring& key) const, g_settings_get_boolean)
+ _WRAP_METHOD(void set_boolean(const Glib::ustring& key, bool value), g_settings_set_boolean)
+ _WRAP_METHOD(Glib::ustring get_string(const Glib::ustring& key) const, g_settings_get_string)
+ _WRAP_METHOD(void set_string(const Glib::ustring& key, const Glib::ustring& value), g_settings_set_string)
+ _WRAP_METHOD(double get_double(const Glib::ustring& key) const, g_settings_get_double)
+ _WRAP_METHOD(void set_double(const Glib::ustring& key, double value), g_settings_set_double)
+ // FIXME: get/set strv
+
+ _WRAP_METHOD(Glib::RefPtr<Settings> get_child(const Glib::ustring& name), g_settings_get_child)
+ _WRAP_METHOD(bool is_writable(const Glib::ustring& key) const, g_settings_is_writable)
+
+ _WRAP_METHOD(void delay(), g_settings_delay)
+ _WRAP_METHOD(void apply(), g_settings_apply)
+ _WRAP_METHOD(void revert(), g_settings_revert)
+ _WRAP_METHOD(bool get_has_unapplied(), g_settings_get_has_unapplied)
+
+#m4 _CONVERSION(`Glib::ObjectBase*',`gpointer',(gpointer)$3->gobj())
+ _WRAP_METHOD(void bind(const Glib::ustring& key, Glib::ObjectBase* object, const Glib::ustring& property, SettingsBindFlags flags=SETTINGS_BIND_DEFAULT), g_settings_bind)
+ void bind(const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, SettingsBindFlags flags=SETTINGS_BIND_DEFAULT);
+ // FIXME: implement bind_with_mapping
+ _WRAP_METHOD(void bind_writable(const Glib::ustring& key, Glib::ObjectBase* object, const Glib::ustring& property, bool inverted=false), g_settings_bind_writable)
+ void bind_writable(const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, bool inverted=false);
+ // FIXME: unbind is not actually a class method
+
+#m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
+ _WRAP_SIGNAL(void writable_changed(const Glib::ustring& key), writable_changed)
+ _WRAP_SIGNAL(void changed(const Glib::ustring& key), changed)
+
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 920c705..6163394 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -82,6 +82,7 @@ int main(int, char**)
<< get_defs(G_TYPE_RESOLVER)
<< get_defs(G_TYPE_NETWORK_ADDRESS)
<< get_defs(G_TYPE_NETWORK_SERVICE)
+ << get_defs(G_TYPE_SETTINGS)
<< get_defs(G_TYPE_SOCKET)
<< get_defs(G_TYPE_SOCKET_CLIENT)
<< get_defs(G_TYPE_SOCKET_CONNECTION)
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index d2f1f9a..feb2032 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -23,6 +23,7 @@ _CONV_ENUM(G,SocketMsgFlags)
_CONV_ENUM(G,DriveStartFlags)
_CONV_ENUM(G,DriveStartFlags)
_CONV_ENUM(G,DriveStartStopType)
+_CONV_ENUM(G,SettingsBindFlags)
# AppInfo
@@ -125,6 +126,9 @@ _CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3')
_CONVERSION(`GOutputStream*',`Glib::RefPtr<OutputStream>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<OutputStream>&',`GOutputStream*',__CONVERT_CONST_REFPTR_TO_P)
+#Settings
+_CONVERSION(`GSettings*',`Glib::RefPtr<Settings>',`Glib::wrap($3)')
+
#Socket
_CONVERSION(`const Glib::RefPtr<Socket>&',`GSocket*',__CONVERT_CONST_REFPTR_TO_P)
_CONVERSION(`GSocket*',`Glib::RefPtr<Socket>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]