[seahorse/wip/nielsdg/handle-open] App: Handle opening files from the command line
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nielsdg/handle-open] App: Handle opening files from the command line
- Date: Sun, 17 Mar 2019 13:48:12 +0000 (UTC)
commit fa7e5903daf918cf797ad997e14e13066a8a70af
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Mar 17 14:45:11 2019 +0100
App: Handle opening files from the command line
Implement `GApplcation.open()` for our application: this means
concretely that we will try to import the files that were specified on
the command line.
src/application.vala | 12 +++++++++++-
src/key-manager.vala | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/application.vala b/src/application.vala
index 9bf44702..f21ea66f 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -69,7 +69,7 @@ public class Seahorse.Application : Gtk.Application {
public Application () {
GLib.Object (
application_id: "org.gnome.seahorse.Application",
- flags: ApplicationFlags.FLAGS_NONE
+ flags: ApplicationFlags.HANDLES_OPEN
);
this.search_provider = new SearchProvider(this);
@@ -116,6 +116,16 @@ public class Seahorse.Application : Gtk.Application {
this.key_mgr.present();
}
+ public override void open(File[] files, string hint) {
+ activate();
+ return_if_fail(this.key_mgr != null);
+
+ string[] uris = {};
+ foreach (File file in files)
+ uris += file.get_uri();
+ this.key_mgr.import_files(uris);
+ }
+
public override int handle_local_options (VariantDict options) {
if (options.contains("version")) {
print ("%s\n", Config.PACKAGE_STRING);
diff --git a/src/key-manager.vala b/src/key-manager.vala
index 1ec80e83..5aa91bf4 100644
--- a/src/key-manager.vala
+++ b/src/key-manager.vala
@@ -233,7 +233,7 @@ public class Seahorse.KeyManager : Catalog {
this.store.filter = this.filter_entry.text;
}
- private void import_files(string[]? uris) {
+ public void import_files(string[]? uris) {
ImportDialog dialog = new ImportDialog(this);
dialog.add_uris(uris);
dialog.run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]