[gnome-boxes/handle-mime-types] app, desktop: Handle mime types



commit 79a431344bdec4db8fe6d8a01a5b6a1de3181726
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]