From c587ae127cf0d6fee6b7e8c21bbe1c903faac13c Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Fri, 3 Aug 2018 02:41:00 +0200 Subject: Add the ability to support 'unar' over .zip archives Closes https://github.com/mate-desktop/engrampa/issues/210 --- data/org.mate.engrampa.gschema.xml.in | 5 +++++ src/fr-command-7z.c | 15 +++++++++++++-- src/fr-command-unarchiver.c | 3 ++- src/fr-command-zip.c | 15 +++++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/data/org.mate.engrampa.gschema.xml.in b/data/org.mate.engrampa.gschema.xml.in index 3916099..c997fd9 100644 --- a/data/org.mate.engrampa.gschema.xml.in +++ b/data/org.mate.engrampa.gschema.xml.in @@ -126,6 +126,11 @@ Encrypt the archive header Whether to encrypt the archive header. If the header is encrypted the password will be required to list the archive content as well. + + false + Adds 'unar' support over .zip archives. + It enables the ability to support 'unar' over .zip archives. + diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c index a41f97d..33e3b3b 100644 --- a/src/fr-command-7z.c +++ b/src/fr-command-7z.c @@ -588,13 +588,24 @@ const char *sevenz_mime_types[] = { "application/x-7z-compressed", "application/x-ms-dos-executable", "application/x-ms-wim", "application/x-rar", - "application/zip", - NULL }; + "application/zip", /* zip always at the end and the number of */ + NULL }; /* place in fr_command_7z_get_mime_types */ static const char ** fr_command_7z_get_mime_types (FrCommand *comm) { + GSettings *settings; + settings = g_settings_new ("org.mate.engrampa.general"); + + if (g_settings_get_boolean (settings, "unar-open-zip") && + is_program_in_path ("unar") && is_program_in_path ("lsar")) + sevenz_mime_types [8] = NULL; + else + g_settings_set_boolean (settings, "unar-open-zip", FALSE); + + g_object_unref (settings); + return sevenz_mime_types; } diff --git a/src/fr-command-unarchiver.c b/src/fr-command-unarchiver.c index 8e78dd2..fc5ed21 100644 --- a/src/fr-command-unarchiver.c +++ b/src/fr-command-unarchiver.c @@ -248,7 +248,8 @@ fr_command_unarchiver_handle_error (FrCommand *comm, } -const char *unarchiver_mime_type[] = { "application/x-cbr", +const char *unarchiver_mime_type[] = { "application/zip", + "application/x-cbr", "application/x-rar", NULL }; diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c index a5326ba..387f27c 100644 --- a/src/fr-command-zip.c +++ b/src/fr-command-zip.c @@ -392,13 +392,24 @@ const char *zip_mime_type[] = { "application/x-ear", "application/x-ms-dos-executable", "application/x-war", - "application/zip", - NULL }; + "application/zip", /* zip always at the end and the number of */ + NULL }; /* place in fr_command_zip_get_mime_types */ static const char ** fr_command_zip_get_mime_types (FrCommand *comm) { + GSettings *settings; + settings = g_settings_new ("org.mate.engrampa.general"); + + if (g_settings_get_boolean (settings, "unar-open-zip") && + is_program_in_path ("unar") && is_program_in_path ("lsar")) + zip_mime_type [10] = NULL; + else + g_settings_set_boolean (settings, "unar-open-zip", FALSE); + + g_object_unref (settings); + return zip_mime_type; } -- cgit v1.2.1