Config added.

This commit is contained in:
Kolan Sh 2015-10-24 19:38:22 +03:00
parent edb0cd9cca
commit 552e73bfe5
7 changed files with 20 additions and 9 deletions

@ -1 +1 @@
Subproject commit 972b5e5d882bb590fb5eee248c92cdc13ff19c5f
Subproject commit 4b74a70c2806e160ac2ae1cfe8a960cee8d490d4

View File

@ -1,2 +1,5 @@
SET (GSchemaFile "ws.backbone.gschema-test.gschema.xml")
SET (GSchemaFile "ws.backbone.gschema-test")
INCLUDE (GSchemaCommonRules)
CONFIGURE_FILE ("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h")

6
config/Config.vapi Normal file
View File

@ -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;
}

3
config/config.h.in Normal file
View File

@ -0,0 +1,3 @@
#define CONFIG_VERSION_MAJOR @MAJOR@
#define CONFIG_VERSION_MINOR @MINOR@
#define CONFIG_VERSION_PATCH @PATCH@

View File

@ -1,5 +1,5 @@
<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">
<default l10n="messages">"Hello, earthlings"</default>

View File

@ -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)
SET (BinPackages 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)
INCLUDE (ValaBinCommonRules)

View File

@ -12,7 +12,7 @@ public static int main (string[] args) {
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
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) {
stdout.printf ("ID not found.");
return 0;
@ -20,9 +20,6 @@ public static int main (string[] args) {
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``
string greeting = settings.get_string ("greeting");
stdout.printf ("%s\n", greeting);
@ -56,7 +53,7 @@ public static int main (string[] args) {
settings.set_boolean ("lighting", !lighting);
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 ();
} catch (Error e) {
stdout.printf ("Error: %s\n", e.message);