1
0
Fork 0

Fix GSchema with custom plugins directories. + Separate Settings.vala.

This commit is contained in:
Kolan Sh 2018-05-08 19:27:07 +03:00
parent 8928e10ee2
commit ccf7c4f373
8 changed files with 57 additions and 14 deletions

View File

@ -1,5 +1,5 @@
<schemalist>
<schema id="ws.backbone.lavew.data-example-@MAJOR@" path="/ws/backbone/laview/data-example-@MAJOR@/" gettext-domain="laview-data-example-@MAJOR@">
<schema id="ws.backbone.laview.data-example-@MAJOR@" path="/ws/backbone/laview/data-example-@MAJOR@/" gettext-domain="laview-data-example-@MAJOR@">
<key name="greeting" type="s">
<default l10n="messages">"Hello, earthlings"</default>

View File

@ -1,13 +1 @@
SET (LibName laview-data-example)
FILE (GLOB_RECURSE LibSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.vala)
SET (LibPackages gtk+-3.0 gee-0.8 gobject-plugin-iface-0 laview-core-iface-0 laview-core-0)
SET (LibPkgModules gtk+-3.0 gee-0.8 gobject-plugin-0 laview-core-0)
SET (LibCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
SET (LibIsPlugin ON)
SET (LibInstall ON)
SET (LibExtraSources ${CMAKE_CURRENT_BINARY_DIR}/library_constructor.c)
SET (LC_RELATIVE_PREFIX "../../../..")
CONFIGURE_FILE ("${CMAKE_SOURCE_DIR}/cmake/backbone/templates/library_constructor.c.in" "${LibExtraSources}")
SET (LibInstallPrefix "laview-core-0/data-plugins")
INCLUDE (ValaLibCommonRules)
ADD_SUBDIRECTORY (laview-core)

View File

@ -0,0 +1 @@
ADD_SUBDIRECTORY (data-plugins)

View File

@ -0,0 +1,13 @@
SET (LibName laview-data-example)
FILE (GLOB_RECURSE LibSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.vala)
SET (LibPackages gtk+-3.0 gee-0.8 gobject-plugin-iface-0 laview-core-iface-0 laview-core-0)
SET (LibPkgModules gtk+-3.0 gee-0.8 gobject-plugin-0 laview-core-0)
SET (LibCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
SET (LibIsPlugin ON)
SET (LibInstall ON)
SET (LibExtraSources ${CMAKE_CURRENT_BINARY_DIR}/library_constructor.c)
SET (LC_RELATIVE_PREFIX "../../../..")
CONFIGURE_FILE ("${CMAKE_SOURCE_DIR}/cmake/backbone/templates/library_constructor.c.in" "${LibExtraSources}")
SET (LibInstallPrefix "laview-core-0/data-plugins")
INCLUDE (ValaLibCommonRules)

View File

@ -0,0 +1,35 @@
namespace LAview.DataExample {
public class AppSettings : Object {
Settings settings;
string _greeting;
public string greeting {
get { return _greeting; }
set {
if (settings != null) settings.set_string ("greeting", value);
_greeting = value;
}
default = "lyx";
}
public AppSettings () throws Error {
string schema_file = AppDirs.settings_dir+"/gschemas.compiled";
if (!File.new_for_path (schema_file).query_exists ())
throw new IOError.NOT_FOUND ("File "+schema_file+" not found");
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (AppDirs.settings_dir, null, false);
string schema_name = "ws.backbone.laview.data-example-"+Config.VERSION_MAJOR.to_string();
SettingsSchema schema = sss.lookup (schema_name, false);
if (schema == null) {
throw new IOError.NOT_FOUND ("Schema "+schema_name+" not found in "+schema_file);
}
settings = new Settings.full (schema, null, null);
_greeting = settings.get_string("greeting");
settings.changed["greeting"].connect (() => {
_greeting = settings.get_string("greeting");
});
}
}
}

View File

@ -9,6 +9,7 @@ namespace LAview.DataExample {
public class Plugin : LAview.Core.PluginData {
PreferencesDialog preferences_dialog = null;
AppSettings settings;
/**
* Constructs a new ``Plugin``.
@ -17,6 +18,11 @@ namespace LAview.DataExample {
// Initialize the data object, open database connection for example.
stdout.puts ("DataExample.Plugin init () called\n");
AppDirs.init ();
try {
settings = new AppSettings();
} catch (Error err) {
stderr.printf("Error: %s\n", err.message);
}
}
/**