[gnome-boxes/handle-mime-types: 2/2] app, desktop: Handle mime types
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/handle-mime-types: 2/2] app, desktop: Handle mime types
- Date: Fri, 9 Feb 2018 16:52:51 +0000 (UTC)
commit f9cc3de873b04922e263f5b631030e73940b6418
Author: Felipe Borges <felipeborges gnome org>
Date: Fri Feb 9 17:20:14 2018 +0100
app, desktop: Handle mime types
By implementing GApplication's open() method and listing the
MimeTypes in the desktop file, we can make Boxes able to open
ISOs right from the file manager.
Fixes #19
data/org.gnome.Boxes.desktop.in | 1 +
src/app.vala | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.Boxes.desktop.in b/data/org.gnome.Boxes.desktop.in
index 9294f128..8559896d 100644
--- a/data/org.gnome.Boxes.desktop.in
+++ b/data/org.gnome.Boxes.desktop.in
@@ -11,4 +11,5 @@ Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;System;
+MimeType=application/x-cd-image;
DBusActivatable=true
diff --git a/src/app.vala b/src/app.vala
index 8b50c57a..e56c582c 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -46,7 +46,7 @@ public virtual async void add_source (CollectionSource source) throws GLib.Error
public App () {
application_id = "org.gnome.Boxes";
- flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
+ flags |= ApplicationFlags.HANDLES_COMMAND_LINE | ApplicationFlags.HANDLES_OPEN;
resource_base_path = "/org/gnome/Boxes";
app = this;
@@ -254,6 +254,17 @@ public override int command_line (GLib.ApplicationCommandLine cmdline) {
return 0;
}
+ public override void open (File[] _files, string hint) {
+ activate ();
+
+ File[] files = _files;
+ call_when_ready (() => {
+ foreach (File file in files) {
+ main_window.wizard_window.wizard.open_with_uri (file.get_uri ());
+ }
+ });
+ }
+
public bool quit_app () {
foreach (var window in windows)
window.hide ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]