[Xfce4-commits] [thunar-plugins/thunar-archive-plugin] 01/01: Start archive application from file's directory (Bug #14773)

noreply at xfce.org noreply at xfce.org
Tue Oct 30 20:39:30 CET 2018


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

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository thunar-plugins/thunar-archive-plugin.

commit 5a63c61a2a2bcb18b59e610fa036ae092e08adc1
Author: Alexander Schwinn <alexxcons at xfce.org>
Date:   Mon Oct 29 22:46:37 2018 +0100

    Start archive application from file's directory (Bug #14773)
---
 scripts/ark.tap                      |  4 ++--
 scripts/engrampa.tap                 |  6 ++---
 scripts/file-roller.tap              |  8 +++----
 thunar-archive-plugin/tap-provider.c | 44 ++++++++++++++++++++++++++----------
 4 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/scripts/ark.tap b/scripts/ark.tap
index d42138c..5358ab2 100644
--- a/scripts/ark.tap
+++ b/scripts/ark.tap
@@ -25,7 +25,7 @@
 
 # determine the action and the folder, $@ then contains only the files
 action=$1; shift;
-folder=$1; shift;
+pwd=$1; shift;
 
 # check the action
 case $action in
@@ -34,7 +34,7 @@ create)
 	;;
 
 extract-here)
-	exec ark --extract-to "$folder" "$@"
+	exec ark --extract-to "$pwd" "$@"
 	;;
 
 extract-to)
diff --git a/scripts/engrampa.tap b/scripts/engrampa.tap
index 1081d7c..58fc916 100644
--- a/scripts/engrampa.tap
+++ b/scripts/engrampa.tap
@@ -25,16 +25,16 @@
 
 # determine the action and the folder, $@ then contains only the files
 action=$1; shift;
-folder=$1; shift;
+pwd=$1; shift;
 
 # check the action
 case $action in
 create)
-	exec engrampa --default-dir="$folder" --add "$@"
+	exec engrampa --default-dir="$pwd" --add "$@"
 	;;
 
 extract-here)
-	exec engrampa --extract-to="$(pwd)" --extract-here --force "$@"
+	exec engrampa --extract-to="$pwd" --extract-here --force "$@"
 	;;
 
 extract-to)
diff --git a/scripts/file-roller.tap b/scripts/file-roller.tap
index c238c40..35197ad 100644
--- a/scripts/file-roller.tap
+++ b/scripts/file-roller.tap
@@ -26,20 +26,20 @@
 
 # determine the action and the folder, $@ then contains only the files
 action=$1; shift;
-folder=$1; shift;
+pwd=$1; shift;
 
 # check the action
 case $action in
 create)
-	exec file-roller "--default-dir=$folder" --add "$@"
+	exec file-roller "--default-dir=$pwd" --add "$@"
 	;;
 
 extract-here)
-	exec file-roller "--extract-to=$(pwd)" --extract-here --force "$@"
+	exec file-roller "--extract-to=$pwd" --extract-here --force "$@"
 	;;
 
 extract-to)
-	exec file-roller "--default-dir=$folder" --extract "$@"
+	exec file-roller "--default-dir=$pwd" --extract "$@"
 	;;
 
 *)
diff --git a/thunar-archive-plugin/tap-provider.c b/thunar-archive-plugin/tap-provider.c
index bfc30f5..e276f09 100644
--- a/thunar-archive-plugin/tap-provider.c
+++ b/thunar-archive-plugin/tap-provider.c
@@ -297,9 +297,10 @@ static void
 tap_extract_to (ThunarxMenuItem *item,
                 GtkWidget       *window)
 {
-  TapProvider *tap_provider;
-  const gchar *default_dir;
-  GList       *files;
+  TapProvider     *tap_provider;
+  GList           *files;
+  gchar           *dirname;
+  gchar           *uri;
 
   /* determine the files associated with the item */
   files = g_object_get_qdata (G_OBJECT (item), tap_item_files_quark);
@@ -309,17 +310,36 @@ tap_extract_to (ThunarxMenuItem *item,
   /* determine the provider associated with the item */
   tap_provider = g_object_get_qdata (G_OBJECT (item), tap_item_provider_quark);
   if (G_UNLIKELY (tap_provider == NULL))
-    return;
+    {
+      g_warning ("Failed to determine tap provider");
+      return;
+    }
 
-  /* if $GTK_DEFAULT_FILECHOOSER_DIR is set, we use that as default
-   * folder (i.e. Ubuntu), otherwise we just use $HOME.
-   */
-  default_dir = g_getenv ("GTK_DEFAULT_FILECHOOSER_DIR");
-  if (G_LIKELY (default_dir == NULL))
-    default_dir = g_get_home_dir ();
 
-  /* execute the action associated with the menu item */
-  tap_provider_execute (tap_provider, tap_backend_extract_to, window, default_dir, files, _("Failed to extract files"));
+  /* determine the parent URI of the first selected file */
+  uri = thunarx_file_info_get_parent_uri (files->data);
+  if (G_UNLIKELY (uri == NULL))
+    {
+      g_warning ("Failed to get parent URI");
+      return;
+    }
+
+  /* determine the directory of the first selected file */
+  dirname = g_filename_from_uri (uri, NULL, NULL);
+  g_free (uri);
+
+  /* verify that we were able to determine a local path */
+  if (G_UNLIKELY (dirname == NULL))
+    {
+      g_warning ("Failed to determine local path");
+      return;
+    }
+
+  /* execute the action */
+  tap_provider_execute (tap_provider, tap_backend_extract_to, window, dirname, files, _("Failed to extract files"));
+
+  /* cleanup */
+  g_free (dirname);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list