[Xfce-bugs] [Bug 15917] New: Thunar SendTo Email: improve archives detection
bugzilla-daemon at xfce.org
bugzilla-daemon at xfce.org
Mon Sep 2 15:08:27 CEST 2019
https://bugzilla.xfce.org/show_bug.cgi?id=15917
Bug ID: 15917
Summary: Thunar SendTo Email: improve archives detection
Classification: Xfce Core
Product: Thunar
Version: git
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: Medium
Component: General
Assignee: xfce-bugs at xfce.org
Reporter: stokito at gmail.com
Target Milestone: 1.8.10
Created attachment 8983
--> https://bugzilla.xfce.org/attachment.cgi?id=8983&action=edit
sendto plugin: get rid of archives content types and use shared-mime-info
instead
When user selects few files to send then internally sendto-email checks that
all files are already archives and if not it shows a dialog window to ask to
compress the files (see tse_ask_compress function).
To detect that the file is an archive the plugin contains a full list of
archive MIME types on plugins/thunar-sendto-email/main.c:78:
/* well known archive types */
static const char *TSE_MIME_TYPES[] = {
"application/x-ar",
..
"application/x-tar",
"application/zip"
}
The problem here is that in fact there are more compressor algorithms. In the
TSE_MIME_TYPES list is missing LZMA and recently was published ZStandard (zstd)
*.zst and Brotli *.br.
I wanted to add them but in fact I decided to find a way to get rid of the
TSE_MIME_TYPES list at all.
To determine a content type internally the sendto-email calls the
g_file_info_get_content_type function from GLib which uses the Shared MIME Info
library https://www.freedesktop.org/wiki/Software/shared-mime-info/ which is
kind of clone of libmagic + icons + translations.
Unfortunately the shared-mime-info doesn't have a clear flag that the type is
an archive. But all archive types (tar, zip, gz etc) always have the same icon
"package-x-generic".
So we can use the content type's icon name to determine that it is an archive
or compressed file:
generic_icon_name = g_content_type_get_generic_icon_name (content_type);
file_is_archive = g_strcmp0 (generic_icon_name, "package-x-generic") == 0;
This looks like a hack but it always works and when zst and br or any other
will be added to Shared MIME Info then the plugin starts to recognize them.
I implemented this solution but before I did a small refactoring and bug fix:
#15916 BUG: Thunar SendTo Email doesn't detects files that are already archives
https://bugzilla.xfce.org/show_bug.cgi?id=15916
So my patch assumes that the patches from that bug was already accepted
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Xfce-bugs
mailing list