Skip to content

Commit c587ae1

Browse files
committed
Add the ability to support 'unar' over .zip archives
Closes #210
1 parent 10e665f commit c587ae1

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

data/org.mate.engrampa.gschema.xml.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
<summary>Encrypt the archive header</summary>
127127
<description>Whether to encrypt the archive header. If the header is encrypted the password will be required to list the archive content as well.</description>
128128
</key>
129+
<key name="unar-open-zip" type="b">
130+
<default>false</default>
131+
<summary>Adds 'unar' support over .zip archives.</summary>
132+
<description>It enables the ability to support 'unar' over .zip archives.</description>
133+
</key>
129134
</schema>
130135
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.engrampa.dialogs" path="/org/mate/engrampa/dialogs/">
131136
<child name="extract" schema="org.mate.engrampa.dialogs.extract"/>

src/fr-command-7z.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,24 @@ const char *sevenz_mime_types[] = { "application/x-7z-compressed",
588588
"application/x-ms-dos-executable",
589589
"application/x-ms-wim",
590590
"application/x-rar",
591-
"application/zip",
592-
NULL };
591+
"application/zip", /* zip always at the end and the number of */
592+
NULL }; /* place in fr_command_7z_get_mime_types */
593593

594594

595595
static const char **
596596
fr_command_7z_get_mime_types (FrCommand *comm)
597597
{
598+
GSettings *settings;
599+
settings = g_settings_new ("org.mate.engrampa.general");
600+
601+
if (g_settings_get_boolean (settings, "unar-open-zip") &&
602+
is_program_in_path ("unar") && is_program_in_path ("lsar"))
603+
sevenz_mime_types [8] = NULL;
604+
else
605+
g_settings_set_boolean (settings, "unar-open-zip", FALSE);
606+
607+
g_object_unref (settings);
608+
598609
return sevenz_mime_types;
599610
}
600611

src/fr-command-unarchiver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ fr_command_unarchiver_handle_error (FrCommand *comm,
248248
}
249249

250250

251-
const char *unarchiver_mime_type[] = { "application/x-cbr",
251+
const char *unarchiver_mime_type[] = { "application/zip",
252+
"application/x-cbr",
252253
"application/x-rar",
253254
NULL };
254255

src/fr-command-zip.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,24 @@ const char *zip_mime_type[] = {
392392
"application/x-ear",
393393
"application/x-ms-dos-executable",
394394
"application/x-war",
395-
"application/zip",
396-
NULL };
395+
"application/zip", /* zip always at the end and the number of */
396+
NULL }; /* place in fr_command_zip_get_mime_types */
397397

398398

399399
static const char **
400400
fr_command_zip_get_mime_types (FrCommand *comm)
401401
{
402+
GSettings *settings;
403+
settings = g_settings_new ("org.mate.engrampa.general");
404+
405+
if (g_settings_get_boolean (settings, "unar-open-zip") &&
406+
is_program_in_path ("unar") && is_program_in_path ("lsar"))
407+
zip_mime_type [10] = NULL;
408+
else
409+
g_settings_set_boolean (settings, "unar-open-zip", FALSE);
410+
411+
g_object_unref (settings);
412+
402413
return zip_mime_type;
403414
}
404415

0 commit comments

Comments
 (0)