summaryrefslogtreecommitdiff
path: root/x11-libs/libfm-qt/files/libfm-qt-0.13.1-correctly-handle-mountable-types.patch
blob: adaed387e2799004a09826f87ba810635c536369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From dc7a5753b934e323d4d8d13f3253cbe7ae55a111 Mon Sep 17 00:00:00 2001
From: "Hong Jen Yee (PCMan)" <pcman.tw@gmail.com>
Date: Sun, 10 Jun 2018 00:07:31 +0800
Subject: [PATCH] Correctly handle mountable types.

---
 src/core/basicfilelauncher.cpp | 6 +++---
 src/core/fileinfo.cpp          | 4 ++--
 src/core/fileinfo.h            | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/core/basicfilelauncher.cpp b/src/core/basicfilelauncher.cpp
index 0dc8208..0ae1177 100644
--- a/src/core/basicfilelauncher.cpp
+++ b/src/core/basicfilelauncher.cpp
@@ -30,11 +30,10 @@ bool BasicFileLauncher::launchFiles(const FileInfoList& fileInfos, GAppLaunchCon
     // classify files according to different mimetypes
     for(auto& fileInfo : fileInfos) {
         /*
-        qDebug("path: %s, type: %s, target: %s, isDir: %i, isDesktopEntry: %i",
+        qDebug("path: %s, type: %s, target: %s, isDir: %i, isShortcut: %i, isMountable: %i, isDesktopEntry: %i",
                fileInfo->path().toString().get(), fileInfo->mimeType()->name(), fileInfo->target().c_str(),
-               fileInfo->isDir(), fileInfo->isDesktopEntry());
+               fileInfo->isDir(), fileInfo->isShortcut(), fileInfo->isMountable(), fileInfo->isDesktopEntry());
         */
-
         if(fileInfo->isMountable()) {
             if(fileInfo->target().empty()) {
                 // the mountable is not yet mounted so we have no target URI.
@@ -269,6 +268,7 @@ FilePath BasicFileLauncher::handleShortcut(const FileInfoPtr& fileInfo, GAppLaun
     // if we know the target is a dir, we are not going to open it using other apps
     // for example: `network:///smb-root' is a shortcut targeting `smb:///' and it's also a dir
     if(fileInfo->isDir()) {
+        qDebug("shortcut is dir: %s", target.c_str());
         return FilePath::fromPathStr(target.c_str());
     }
 
diff --git a/src/core/fileinfo.cpp b/src/core/fileinfo.cpp
index b19a751..5838fe5 100644
--- a/src/core/fileinfo.cpp
+++ b/src/core/fileinfo.cpp
@@ -118,7 +118,8 @@ void FileInfo::setFromGFileInfo(const GObjectPtr<GFileInfo>& inf, const FilePath
         isDeletable_ = true;
     }
 
-    isShortcut_ = false;
+    isShortcut_ = (type == G_FILE_TYPE_SHORTCUT);
+    isMountable_ = (type == G_FILE_TYPE_MOUNTABLE);
 
     /* special handling for symlinks */
     if(g_file_info_get_is_symlink(inf.get())) {
@@ -129,7 +130,6 @@ void FileInfo::setFromGFileInfo(const GObjectPtr<GFileInfo>& inf, const FilePath
 
     switch(type) {
     case G_FILE_TYPE_SHORTCUT:
-        isShortcut_ = true;
     /* Falls through. */
     case G_FILE_TYPE_MOUNTABLE:
         uri = g_file_info_get_attribute_string(inf.get(), G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
diff --git a/src/core/fileinfo.h b/src/core/fileinfo.h
index 8437d92..27f7508 100644
--- a/src/core/fileinfo.h
+++ b/src/core/fileinfo.h
@@ -150,7 +150,7 @@ class LIBFM_QT_API FileInfo {
     }
 
     bool isMountable() const {
-        return mimeType_->isMountable();
+        return isMountable_;
     }
 
     bool isShortcut() const {
@@ -238,6 +238,7 @@ class LIBFM_QT_API FileInfo {
     std::string target_; /* target of shortcut or mountable. */
 
     bool isShortcut_ : 1; /* TRUE if file is shortcut type */
+    bool isMountable_ : 1; /* TRUE if file is mountable type */
     bool isAccessible_ : 1; /* TRUE if can be read by user */
     bool isWritable_ : 1; /* TRUE if can be written to by user */
     bool isDeletable_ : 1; /* TRUE if can be deleted by user */