Config added.
This commit is contained in:
parent
edb0cd9cca
commit
552e73bfe5
|
@ -1 +1 @@
|
||||||
Subproject commit 972b5e5d882bb590fb5eee248c92cdc13ff19c5f
|
Subproject commit 4b74a70c2806e160ac2ae1cfe8a960cee8d490d4
|
|
@ -1,2 +1,5 @@
|
||||||
SET (GSchemaFile "ws.backbone.gschema-test.gschema.xml")
|
SET (GSchemaFile "ws.backbone.gschema-test")
|
||||||
INCLUDE (GSchemaCommonRules)
|
INCLUDE (GSchemaCommonRules)
|
||||||
|
|
||||||
|
CONFIGURE_FILE ("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[CCode (cheader_filename = "config.h")]
|
||||||
|
namespace Config {
|
||||||
|
static const int VERSION_MAJOR;
|
||||||
|
static const int VERSION_MINOR;
|
||||||
|
static const int VERSION_PATCH;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
#define CONFIG_VERSION_MAJOR @MAJOR@
|
||||||
|
#define CONFIG_VERSION_MINOR @MINOR@
|
||||||
|
#define CONFIG_VERSION_PATCH @PATCH@
|
|
@ -1,5 +1,5 @@
|
||||||
<schemalist>
|
<schemalist>
|
||||||
<schema id="ws.backbone.gschema-test" path="/ws/backbone/gschema-test/" gettext-domain="gschema-test-0">
|
<schema id="ws.backbone.gschema-test-0" path="/ws/backbone/gschema-test-0/" gettext-domain="gschema-test-0">
|
||||||
|
|
||||||
<key name="greeting" type="s">
|
<key name="greeting" type="s">
|
||||||
<default l10n="messages">"Hello, earthlings"</default>
|
<default l10n="messages">"Hello, earthlings"</default>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
SET (BinName gschema-test)
|
SET (BinName gschema-test-${MAJOR})
|
||||||
FILE (GLOB_RECURSE BinSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} GLib.Settings.vala)
|
FILE (GLOB_RECURSE BinSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} GLib.Settings.vala)
|
||||||
SET (BinPackages gio-2.0)
|
SET (BinPackages gio-2.0)
|
||||||
SET (BinPkgModules gio-2.0)
|
SET (BinPkgModules gio-2.0)
|
||||||
|
SET (BinCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
|
||||||
|
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
|
||||||
SET (BinInstall ON)
|
SET (BinInstall ON)
|
||||||
INCLUDE (ValaBinCommonRules)
|
INCLUDE (ValaBinCommonRules)
|
||||||
|
|
|
@ -12,7 +12,7 @@ public static int main (string[] args) {
|
||||||
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
|
||||||
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (settings_dir, null, false);
|
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (settings_dir, null, false);
|
||||||
SettingsSchema schema = sss.lookup ("ws.backbone.gschema-test", false);
|
SettingsSchema schema = sss.lookup ("ws.backbone.gschema-test-"+Config.VERSION_MAJOR.to_string(), false);
|
||||||
if (sss.lookup == null) {
|
if (sss.lookup == null) {
|
||||||
stdout.printf ("ID not found.");
|
stdout.printf ("ID not found.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -20,9 +20,6 @@ public static int main (string[] args) {
|
||||||
|
|
||||||
Settings settings = new Settings.full (schema, null, null);
|
Settings settings = new Settings.full (schema, null, null);
|
||||||
|
|
||||||
// Default location: (XDG_DATA_DIRS)
|
|
||||||
// Settings settings = new Settings ("org.example.glib-settings-schema-source");
|
|
||||||
|
|
||||||
// Output: ``Hello, earthlings``
|
// Output: ``Hello, earthlings``
|
||||||
string greeting = settings.get_string ("greeting");
|
string greeting = settings.get_string ("greeting");
|
||||||
stdout.printf ("%s\n", greeting);
|
stdout.printf ("%s\n", greeting);
|
||||||
|
@ -56,7 +53,7 @@ public static int main (string[] args) {
|
||||||
settings.set_boolean ("lighting", !lighting);
|
settings.set_boolean ("lighting", !lighting);
|
||||||
settings.set_string ("greeting", "hello, world");
|
settings.set_string ("greeting", "hello, world");
|
||||||
|
|
||||||
stdout.puts ("\nPlease start 'dconf-editor' and edit keys in /ws/backbone/gschema-test/\n");
|
stdout.puts ("\nPlease start 'dconf-editor' and edit keys in /ws/backbone/gschema-test-"+Config.VERSION_MAJOR.to_string()+"/\n");
|
||||||
new MainLoop ().run ();
|
new MainLoop ().run ();
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
stdout.printf ("Error: %s\n", e.message);
|
stdout.printf ("Error: %s\n", e.message);
|
||||||
|
|
Loading…
Reference in New Issue