[baobab/wip/oholy/fix-opening-files] window: Fix issues with opening files



commit c4b73e3347097ae0caebdbcf11041a396219cafd
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Oct 7 15:04:18 2019 +0200

    window: Fix issues with opening files
    
    Baobab doesn't expect that file handler doesn't have to exists for certain
    mime type and consequently fails when opening file with "g_app_info_launch:
    assertion 'G_IS_APP_INFO (appinfo)' failed" critical in such case.
    
    It also requires only handlers which supports URIs. Consequently, for
    example, it is not possible to open folders in Thunar as it uses "%F" on
    its Exec line. But all supported URIs should be accessible over gvfsd-fuse
    mountpoint.
    
    Let's replace the whole logic to open files by simple
    g_app_info_launch_default_for_uri() to fix those issues.
    
    Fixes: https://gitlab.gnome.org/GNOME/baobab/issues/31

 src/baobab-window.vala | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
---
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index c91bf46..d6ced73 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -373,16 +373,8 @@ namespace Baobab {
         public void open_item (Gtk.TreeIter iter) {
             string parse_name;
             active_location.scanner.get (iter, Scanner.Columns.PARSE_NAME, out parse_name);
-            var file = File.parse_name (parse_name);
             try {
-                var info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 0, null);
-                var content = info.get_content_type ();
-                var appinfo = AppInfo.get_default_for_type (content, true);
-                var context = get_display ().get_app_launch_context ();
-                context.set_timestamp (Gtk.get_current_event_time ());
-                var files = new List<File>();
-                files.append (file);
-                appinfo.launch(files, context);
+                AppInfo.launch_default_for_uri (parse_name, null);
             } catch (Error e) {
                 message (_("Failed to open file"), e.message, Gtk.MessageType.ERROR);
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]