[Pkg-privacy-commits] [nautilus-wipe] 19/37: Fix resolving path to virtual (desktop shortcut) locations

Intrigeri intrigeri at moszumanska.debian.org
Wed Dec 7 18:46:03 UTC 2016


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to branch master
in repository nautilus-wipe.

commit d7b46ce43ad5e7fca9d4f9ff14e85383340d123d
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Thu Jul 21 23:33:34 2016 +0200

    Fix resolving path to virtual (desktop shortcut) locations
    
    Do not consider every URI with an x-nautilus-desktop scheme as pointing
    directly to the desktop, as "Computer", "Trash" and other virtual
    shortcuts share this scheme on the desktop.
    
    This fixes handling of all virtual shortcuts pointing to simple local
    locations, like drives and home directory.  It doesn't handle trash
    yet, because it's a lot less straightforward and Nautilus doesn't help
    much on that.
    
    Fixes https://labs.riseup.net/code/issues/9710
---
 nautilus-wipe/nw-path-list.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/nautilus-wipe/nw-path-list.c b/nautilus-wipe/nw-path-list.c
index d3cbf5f..033c707 100644
--- a/nautilus-wipe/nw-path-list.c
+++ b/nautilus-wipe/nw-path-list.c
@@ -33,23 +33,6 @@
 #endif
 
 
-/* checks whether a #NautilusFileInfo have the given URI scheme */
-static gboolean
-nfi_has_uri_scheme (NautilusFileInfo *nfi,
-                    const gchar      *scheme)
-{
-  gboolean  matches = FALSE;
-  gchar    *nfi_scheme;
-  
-  nfi_scheme = nautilus_file_info_get_uri_scheme (nfi);
-  if (nfi_scheme == scheme || strcmp (nfi_scheme, scheme) == 0) {
-    matches = TRUE;
-  }
-  g_free (nfi_scheme);
-  
-  return matches;
-}
-
 /* gets the Nautilus' desktop path (to handle x-nautilus-desktop:// URIs)
  * heavily based on the implementation from nautilus-open-terminal */
 static gchar *
@@ -87,15 +70,34 @@ nw_path_from_nfi (NautilusFileInfo *nfi)
   GFile *file;
   gchar *path;
   
+  g_object_ref (nfi);
+  
   file = nautilus_file_info_get_location (nfi);
   path = g_file_get_path (file);
   if (! path) {
-    if (nfi_has_uri_scheme (nfi, "x-nautilus-desktop")) {
-      path = get_desktop_path ();
+    /* if we don't have a path, let's see if it's got a different activation
+     * URI, and if so what it points to */
+    gchar *activation_uri = nautilus_file_info_get_activation_uri (nfi);
+    
+    g_object_unref (nfi);
+    g_object_unref (file);
+    nfi = nautilus_file_info_create_for_uri (activation_uri);
+    file = nautilus_file_info_get_location (nfi);
+    path = g_file_get_path (file);
+    
+    if (! path) {
+      /* if we still don't have a path, handle some specific URIs manually */
+      if (g_strcmp0 (activation_uri, "x-nautilus-desktop:///") == 0) {
+        path = get_desktop_path ();
+      }
+      /* TODO: implement trash:/// */
     }
+    
+    g_free (activation_uri);
   }
   
   g_object_unref (file);
+  g_object_unref (nfi);
   
   return path;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/nautilus-wipe.git



More information about the Pkg-privacy-commits mailing list