Fix GSchema with custom plugins directories. + Separate Settings.vala.
This commit is contained in:
parent
c9963cd9f7
commit
d637633290
|
@ -1,5 +1,5 @@
|
||||||
<schemalist>
|
<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">
|
<key name="greeting" type="s">
|
||||||
<default l10n="messages">"Hello, earthlings"</default>
|
<default l10n="messages">"Hello, earthlings"</default>
|
||||||
|
|
|
@ -1,18 +1 @@
|
||||||
SET (LibName laview-object-example)
|
ADD_SUBDIRECTORY (laview-core)
|
||||||
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)
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ADD_SUBDIRECTORY (object-plugins)
|
|
@ -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)
|
|
@ -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");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,13 +10,19 @@ namespace LAview.ObjectExample {
|
||||||
|
|
||||||
MainDialog object_dialog = null;
|
MainDialog object_dialog = null;
|
||||||
ObjectExample.PreferencesDialog preferences_dialog = null;
|
ObjectExample.PreferencesDialog preferences_dialog = null;
|
||||||
|
AppSettings settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ``Plugin``.
|
* Constructs a new ``Plugin``.
|
||||||
*/
|
*/
|
||||||
construct {
|
construct {
|
||||||
stdout.puts ("ObjectExample.Plugin init () called\n");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
Loading…
Reference in New Issue