[Pkg-privacy-commits] [nautilus-wipe] 161/224: Move path list handling to its own files

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 19:45:46 UTC 2016


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

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

commit ee82f0fab5cdf3b7b239bd43057fbeee331d410d
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Wed May 16 22:05:52 2012 +0200

    Move path list handling to its own files
---
 nautilus-wipe/Makefile.am      |   2 +
 nautilus-wipe/fill-operation.c |   2 +-
 nautilus-wipe/nautilus-wipe.c  | 121 +---------------------------------
 nautilus-wipe/nautilus-wipe.h  |   3 -
 nautilus-wipe/path-list.c      | 146 +++++++++++++++++++++++++++++++++++++++++
 nautilus-wipe/path-list.h      |  40 +++++++++++
 6 files changed, 192 insertions(+), 122 deletions(-)

diff --git a/nautilus-wipe/Makefile.am b/nautilus-wipe/Makefile.am
index 97048cc..dac8ac9 100644
--- a/nautilus-wipe/Makefile.am
+++ b/nautilus-wipe/Makefile.am
@@ -13,6 +13,8 @@ libnautilus_wipe_la_SOURCES  = extension.c \
                                delete-operation.h \
                                fill-operation.c \
                                fill-operation.h \
+                               path-list.c \
+                               path-list.h \
                                progress-dialog.c \
                                progress-dialog.h \
                                type-utils.h \
diff --git a/nautilus-wipe/fill-operation.c b/nautilus-wipe/fill-operation.c
index 7eee3cf..8be6bc8 100644
--- a/nautilus-wipe/fill-operation.c
+++ b/nautilus-wipe/fill-operation.c
@@ -33,7 +33,7 @@
 # include <gio/gunixmounts.h>
 #endif
 #include <gsecuredelete/gsecuredelete.h>
-#include "nautilus-wipe.h"
+#include "path-list.h"
 
 
 GQuark
diff --git a/nautilus-wipe/nautilus-wipe.c b/nautilus-wipe/nautilus-wipe.c
index 25adc6f..2b9fd1d 100644
--- a/nautilus-wipe/nautilus-wipe.c
+++ b/nautilus-wipe/nautilus-wipe.c
@@ -32,10 +32,10 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gio/gio.h>
-#include <gconf/gconf-client.h>
 
 #include <gsecuredelete/gsecuredelete.h>
 
+#include "path-list.h"
 #include "operation-manager.h"
 #include "delete-operation.h"
 #include "fill-operation.h"
@@ -102,121 +102,6 @@ static void       run_delete_operation  (GtkWindow *parent,
                                          GList     *files);
 
 
-/* gets the Nautilus' desktop path (to handle x-nautilus-desktop:// URIs)
- * heavily based on the implementation from nautilus-open-terminal */
-static gchar *
-nautilus_wipe_get_desktop_path (void)
-{
-  gchar        *path = NULL;
-  GConfClient  *conf_client;
-  
-  conf_client = gconf_client_get_default ();
-  if (gconf_client_get_bool (conf_client,
-                             "/apps/nautilus/preferences/desktop_is_home_dir",
-                             NULL)) {
-    path = g_strdup (g_get_home_dir ());
-  } else {
-    path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
-  }
-  g_object_unref (conf_client);
-  
-  return path;
-}
-
-/* checks whether a #NautilusFileInfo have the given URI scheme */
-static gboolean
-nautilus_wipe_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 path of a #NautilusFileInfo.
- * this is different from getting if GFile then getting the path since it tries
- * handle x-nautilus-desktop */
-static gchar *
-nautilus_wipe_nfi_get_path (NautilusFileInfo *nfi)
-{
-  GFile *file;
-  gchar *path;
-  
-  file = nautilus_file_info_get_location (nfi);
-  path = g_file_get_path (file);
-  if (! path) {
-    if (nautilus_wipe_nfi_has_uri_scheme (nfi, "x-nautilus-desktop")) {
-      path = nautilus_wipe_get_desktop_path ();
-    }
-  }
-  
-  return path;
-}
-
-/* frees a list of paths */
-void
-nautilus_wipe_path_list_free (GList *paths)
-{
-  g_list_foreach (paths, (GFunc)g_free, NULL);
-  g_list_free (paths);
-}
-
-/* copies a list of paths
- * free the returned list with nautilus_wipe_path_list_free() */
-GList *
-nautilus_wipe_path_list_copy (GList *src)
-{
-  GList *paths = NULL;
-  
-  while (src) {
-    paths = g_list_prepend (paths, g_strdup (src->data));
-    src = g_list_next (src);
-  }
-  paths = g_list_reverse (paths);
-  
-  return paths;
-}
-
-/* converts a list of #NautilusFileInfo to a list of paths.
- * free the returned list with nautilus_wipe_path_list_free()
- * 
- * Returns: The list of paths on success, or %NULL on failure. This function
- *          will always fail on non-local-mounted (then without paths) files */
-static GList *
-nautilus_wipe_nfi_list_to_path_list (GList *nfis)
-{
-  gboolean  success = TRUE;
-  GList    *paths   = NULL;
-  
-  while (nfis && success) {
-    gchar *path;
-    
-    path = nautilus_wipe_nfi_get_path (nfis->data);
-    if (path) {
-      paths = g_list_prepend (paths, path);
-    } else {
-      success = FALSE;
-    }
-    nfis = g_list_next (nfis);
-  }
-  if (! success) {
-    nautilus_wipe_path_list_free (paths);
-    paths = NULL;
-  } else {
-    paths = g_list_reverse (paths);
-  }
-  
-  return paths;
-}
-
-
 /* Data needed to be able to start an operation.
  * We don't use private filed of the extension's object because there is only
  * one extension object for more than one window. Actually, it would attach all
@@ -361,7 +246,7 @@ nautilus_wipe_get_file_items (NautilusMenuProvider *provider,
   GList *items = NULL;
   GList *paths;
   
-  paths = nautilus_wipe_nfi_list_to_path_list (files);
+  paths = nautilus_wipe_path_list_new_from_nfi_list (files);
   if (paths) {
     ADD_ITEM (items, nautilus_wipe_menu_item_wipe (provider,
                                           "nautilus-wipe::files-items::wipe",
@@ -384,7 +269,7 @@ nautilus_wipe_get_background_items (NautilusMenuProvider *provider,
   GList *items = NULL;
   GList *paths = NULL;
   
-  paths = g_list_append (paths, nautilus_wipe_nfi_get_path (current_folder));
+  paths = g_list_append (paths, nautilus_wipe_path_from_nfi (current_folder));
   if (paths && paths->data) {
     ADD_ITEM (items, nautilus_wipe_menu_item_fill (provider,
                                                    "nautilus-wipe::background-items::fill",
diff --git a/nautilus-wipe/nautilus-wipe.h b/nautilus-wipe/nautilus-wipe.h
index 5ca862d..ba9cf5f 100644
--- a/nautilus-wipe/nautilus-wipe.h
+++ b/nautilus-wipe/nautilus-wipe.h
@@ -67,9 +67,6 @@ GType   nautilus_wipe_get_type        (void) G_GNUC_CONST;
 GType   nautilus_wipe_register_type   (GTypeModule *module);
 GQuark  nautilus_wipe_error_quark     (void) G_GNUC_CONST;
 
-void    nautilus_wipe_path_list_free  (GList *paths);
-GList  *nautilus_wipe_path_list_copy  (GList *src);
-
 
 G_END_DECLS
 
diff --git a/nautilus-wipe/path-list.c b/nautilus-wipe/path-list.c
new file mode 100644
index 0000000..5f11ebb
--- /dev/null
+++ b/nautilus-wipe/path-list.c
@@ -0,0 +1,146 @@
+/*
+ *  nautilus-wipe - a nautilus extension to wipe file(s)
+ * 
+ *  Copyright (C) 2009-2012 Colomban Wendling <ban at herbesfolles.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 3 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "path-list.h"
+
+#include <string.h>
+#include <glib.h>
+#include <libnautilus-extension/nautilus-file-info.h>
+#include <gconf/gconf-client.h>
+
+
+/* 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 *
+get_desktop_path (void)
+{
+  gchar        *path = NULL;
+  GConfClient  *conf_client;
+  
+  conf_client = gconf_client_get_default ();
+  if (gconf_client_get_bool (conf_client,
+                             "/apps/nautilus/preferences/desktop_is_home_dir",
+                             NULL)) {
+    path = g_strdup (g_get_home_dir ());
+  } else {
+    path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
+  }
+  g_object_unref (conf_client);
+  
+  return path;
+}
+
+/* gets the path of a #NautilusFileInfo.
+ * this is different from getting if GFile then getting the path since it tries
+ * handle x-nautilus-desktop */
+gchar *
+nautilus_wipe_path_from_nfi (NautilusFileInfo *nfi)
+{
+  GFile *file;
+  gchar *path;
+  
+  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 ();
+    }
+  }
+  
+  return path;
+}
+
+/* frees a list of paths */
+void
+nautilus_wipe_path_list_free (GList *paths)
+{
+  g_list_foreach (paths, (GFunc) g_free, NULL);
+  g_list_free (paths);
+}
+
+/* copies a list of paths
+ * free the returned list with nautilus_wipe_path_list_free() */
+GList *
+nautilus_wipe_path_list_copy (GList *src)
+{
+  GList *paths = NULL;
+  
+  while (src) {
+    paths = g_list_prepend (paths, g_strdup (src->data));
+    src = g_list_next (src);
+  }
+  paths = g_list_reverse (paths);
+  
+  return paths;
+}
+
+/* converts a list of #NautilusFileInfo to a list of paths.
+ * free the returned list with nautilus_wipe_path_list_free()
+ * 
+ * Returns: The list of paths on success, or %NULL on failure. This function
+ *          will always fail on non-local-mounted (then without paths) files */
+GList *
+nautilus_wipe_path_list_new_from_nfi_list (GList *nfis)
+{
+  gboolean  success = TRUE;
+  GList    *paths   = NULL;
+  
+  while (nfis && success) {
+    gchar *path;
+    
+    path = nautilus_wipe_path_from_nfi (nfis->data);
+    if (path) {
+      paths = g_list_prepend (paths, path);
+    } else {
+      success = FALSE;
+    }
+    nfis = g_list_next (nfis);
+  }
+  if (! success) {
+    nautilus_wipe_path_list_free (paths);
+    paths = NULL;
+  } else {
+    paths = g_list_reverse (paths);
+  }
+  
+  return paths;
+}
diff --git a/nautilus-wipe/path-list.h b/nautilus-wipe/path-list.h
new file mode 100644
index 0000000..fdecef5
--- /dev/null
+++ b/nautilus-wipe/path-list.h
@@ -0,0 +1,40 @@
+/*
+ *  nautilus-wipe - a nautilus extension to wipe file(s)
+ * 
+ *  Copyright (C) 2009-2011 Colomban Wendling <ban at herbesfolles.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 3 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef NAUTILUS_WIPE_PATH_LIST_H
+#define NAUTILUS_WIPE_PATH_LIST_H
+
+#include <glib.h>
+
+#include <libnautilus-extension/nautilus-file-info.h>
+
+G_BEGIN_DECLS
+
+
+gchar  *nautilus_wipe_path_from_nfi               (NautilusFileInfo *nfi);
+GList  *nautilus_wipe_path_list_new_from_nfi_list (GList *nfis);
+void    nautilus_wipe_path_list_free              (GList *paths);
+GList  *nautilus_wipe_path_list_copy              (GList *src);
+
+
+G_END_DECLS
+
+#endif /* guard */

-- 
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