aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/configreader.vala
diff options
context:
space:
mode:
Diffstat (limited to 'configreader.vala')
-rw-r--r--configreader.vala38
1 files changed, 38 insertions, 0 deletions
diff --git a/configreader.vala b/configreader.vala
index 46f6b1f..8336637 100644
--- a/configreader.vala
+++ b/configreader.vala
@@ -208,4 +208,42 @@ class ConfigReader {
return SYSTEM;
}
}
+
+ public OpenWithProgram[] read_open_with(OpenWithProgram[] default) {
+ if (keyfile == null)
+ return default;
+
+ OpenWithProgram[] programs = {};
+
+ string[] keys;
+ try {
+ keys = keyfile.get_keys("open-with");
+ } catch (GLib.KeyFileError e) {
+ return default;
+ }
+
+ foreach (var name in keys) {
+ var command_string = read_string("open-with", name, null);
+ if (command_string == null)
+ continue;
+
+ string[] command;
+ try {
+ Shell.parse_argv(command_string, out command);
+ } catch (ShellError e) {
+ append_warning(_("ignoring open-with.%s due to malformed command: %s").printf(name, e.message));
+ continue;
+ }
+
+ if (!("%" in command)) {
+ append_warning(_("ignoring command in open-with.%s: missing '%%'").printf(name));
+ continue;
+ }
+
+ OpenWithProgram program = {name, command};
+ programs += program;
+ }
+
+ return programs;
+ }
}