1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
Copyright (C) 2018 Christian Dywan <christian@twotoats.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
See the file COPYING for the full license text.
*/
namespace Midori {
public class Plugins : Peas.Engine, Loggable {
public string builtin_path { get; construct set; }
static Plugins? _default = null;
internal static new Plugins get_default (string? builtin_path=null) {
if (_default == null) {
_default = new Plugins (builtin_path);
}
return _default;
}
Plugins (string builtin_path) {
Object (builtin_path: builtin_path);
}
construct {
enable_loader ("python");
// Plugins installed by the user
string user_path = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_user_data_dir (), Config.PROJECT_NAME, "extensions");
debug ("Loading plugins from %s", user_path);
add_search_path (user_path, null);
debug ("Loading plugins from %s", builtin_path);
add_search_path (builtin_path, user_path);
var settings = CoreSettings.get_default ();
foreach (var plugin in get_plugin_list ()) {
debug ("Found plugin %s", plugin.get_name ());
if (plugin.is_builtin ()
|| settings.get_plugin_enabled ("lib%s.so".printf (plugin.get_module_name ()))) {
if (!try_load_plugin (plugin)) {
critical ("Failed to load plugin %s", plugin.get_module_name ());
}
}
}
}
/*
* Plug the instance of the given object to make it extensible via Peas.
*/
public Peas.ExtensionSet plug<T> (string name, Object object) {
var extensions = new Peas.ExtensionSet (this, typeof (T), name, object, null);
object.set_data<Object> ("midori-plug", extensions);
return extensions;
}
}
}
|