1
0
Fork 0

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

This commit is contained in:
Kolan Sh 2018-05-08 19:26:54 +03:00
parent c9963cd9f7
commit d637633290
9 changed files with 62 additions and 20 deletions

View File

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

View File

@ -1,18 +1 @@
SET (LibName laview-object-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
laview-data-example-0)
SET (LibPkgModules gtk+-3.0 gee-0.8 gobject-plugin-0 laview-core-0)
IF (WIN32)
SET (LibPkgModules ${LibPkgModules} laview-data-example-0)
ENDIF (WIN32)
SET (LibCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
SET (LibIsPlugin ON)
SET (LibInstall ON)
SET (LibNoApi 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/object-plugins")
INCLUDE (ValaLibCommonRules)
ADD_SUBDIRECTORY (laview-core)

View File

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

View File

@ -0,0 +1,17 @@
SET (LibName laview-object-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 laview-data-example-0)
SET (LibPkgModules gtk+-3.0 gee-0.8 gobject-plugin-0 laview-core-0)
IF (WIN32)
SET (LibPkgModules ${LibPkgModules} laview-data-example-0)
ENDIF (WIN32)
SET (LibCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
SET (LibIsPlugin ON)
SET (LibInstall ON)
SET (LibNoApi 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/object-plugins")
INCLUDE (ValaLibCommonRules)

View File

@ -0,0 +1,35 @@
namespace LAview.ObjectExample {
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.object-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

@ -10,13 +10,19 @@ namespace LAview.ObjectExample {
MainDialog object_dialog = null;
ObjectExample.PreferencesDialog preferences_dialog = null;
AppSettings settings;
/**
* Constructs a new ``Plugin``.
*/
construct {
stdout.puts ("ObjectExample.Plugin init () called\n");
ObjectExample.AppDirs.init ();
AppDirs.init ();
try {
settings = new AppSettings();
} catch (Error err) {
stderr.printf("Error: %s\n", err.message);
}
}
/**