--- thunar-archive-plugin/tap-provider.c.old 2018-10-20 01:09:24.363737508 +0300 +++ thunar-archive-plugin/tap-provider.c 2018-10-20 01:10:31.798736575 +0300 @@ -350,9 +350,13 @@ tap_extract_to (GtkAction *action, GtkWidget *window) { - TapProvider *tap_provider; - const gchar *default_dir; - GList *files; +#if THUNARX_CHECK_VERSION(0,4,1) + ThunarxFileInfo *folder; +#endif + TapProvider *tap_provider; + GList *files; + gchar *dirname; + gchar *uri; /* determine the files associated with the action */ files = g_object_get_qdata (G_OBJECT (action), tap_action_files_quark); @@ -364,15 +368,40 @@ if (G_UNLIKELY (tap_provider == NULL)) 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 */ - tap_provider_execute (tap_provider, tap_backend_extract_to, window, default_dir, files, _("Failed to extract files")); +#if THUNARX_CHECK_VERSION(0,4,1) + /* check if a folder was supplied (for the Drag'n'Drop action) */ + folder = g_object_get_qdata (G_OBJECT (action), tap_action_folder_quark); + if (G_UNLIKELY (folder != NULL)) + { + /* determine the URI of the supplied folder */ + uri = thunarx_file_info_get_uri (folder); + } + else +#endif + { + /* determine the parent URI of the first selected file */ + uri = thunarx_file_info_get_parent_uri (files->data); + } + + /* verify that we have an URI */ + if (G_LIKELY (uri != NULL)) + { + /* determine the directory of the first selected file */ + dirname = g_filename_from_uri (uri, NULL, NULL); + + /* verify that we were able to determine a local path */ + if (G_LIKELY (dirname != NULL)) + { + /* execute the action */ + tap_provider_execute (tap_provider, tap_backend_extract_to, window, dirname, files, _("Failed to extract files")); + + /* release the dirname */ + g_free (dirname); + } + + /* release the URI */ + g_free (uri); + } }