aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2013-07-06 14:59:13 +0800
committerLAN-TW <lantw44@gmail.com>2013-07-07 01:43:32 +0800
commit5c935e468ad4ba669a792af60370357de66af582 (patch)
tree9b2001a7da0273a03849f8108b54530bda5050ba
parent3cbc55d9d48dc1c89e13833c37b192ef4418d182 (diff)
downloadgsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar.gz
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar.bz2
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar.lz
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar.xz
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.tar.zst
gsoc2013-epiphany-5c935e468ad4ba669a792af60370357de66af582.zip
Add gsettings key "extract-downloaded-archives"
-rw-r--r--data/org.gnome.epiphany.gschema.xml5
-rw-r--r--embed/ephy-download.c21
-rw-r--r--embed/ephy-download.h1
-rw-r--r--lib/ephy-prefs.h1
4 files changed, 28 insertions, 0 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index b815635cc..ec031619c 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -24,6 +24,11 @@
<summary>Automatic downloads</summary>
<description>When files cannot be opened by the browser they are automatically downloaded to the download folder and opened with the appropriate application.</description>
</key>
+ <key type="b" name="extract-downloaded-archives">
+ <default>true</default>
+ <summary>Extract downloaded archives</summary>
+ <description>Automatically extract files from downloaded archive files</description>
+ </key>
<key type="b" name="new-windows-in-tabs">
<default>true</default>
<summary>Force new windows to be opened in tabs</summary>
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index b3a7ad3a1..822ae4822 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -36,6 +36,8 @@
#include <errno.h>
#include <glib/gi18n.h>
#include <string.h>
+#include <archive.h>
+#include <archive_entry.h>
G_DEFINE_TYPE (EphyDownload, ephy_download, G_TYPE_OBJECT)
@@ -631,6 +633,21 @@ ephy_download_do_download_action (EphyDownload *download,
return ret;
}
+/**
+ * ephy_download_do_extract_archive:
+ * @download: an #EphyDownload
+ *
+ * Extract downloaded archives for @download.
+ *
+ * Returns: %TRUE if the extraction succeeded.
+ *
+ **/
+gboolean
+ephy_download_do_extract_archive (EphyDownload *download)
+{
+ return TRUE;
+}
+
static void
ephy_download_dispose (GObject *object)
{
@@ -891,6 +908,10 @@ download_finished_cb (WebKitDownload *wk_download,
g_signal_emit_by_name (download, "completed");
+ if(g_settings_get_boolean (EPHY_SETTINGS_MAIN, EPHY_PREFS_EXTRACT_DOWNLOADED_ARCHIVES)){
+ ephy_download_do_extract_archive (download);
+ }
+
if (g_settings_get_boolean (EPHY_SETTINGS_MAIN, EPHY_PREFS_AUTO_DOWNLOADS) &&
priv->action == EPHY_DOWNLOAD_ACTION_NONE)
ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_AUTO);
diff --git a/embed/ephy-download.h b/embed/ephy-download.h
index 17b1a2c46..e0b48c50e 100644
--- a/embed/ephy-download.h
+++ b/embed/ephy-download.h
@@ -104,6 +104,7 @@ void ephy_download_set_action (EphyDownload *download,
EphyDownloadActionType action);
gboolean ephy_download_do_download_action (EphyDownload *download,
EphyDownloadActionType action);
+gboolean ephy_download_do_extract_archive (EphyDownload *download);
GtkWidget *ephy_download_get_widget (EphyDownload *download);
void ephy_download_set_widget (EphyDownload *download,
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 7fe2aeebd..e18a9befd 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -115,6 +115,7 @@ typedef enum
#define EPHY_PREFS_CACHE_SIZE "cache-size"
#define EPHY_PREFS_NEW_WINDOWS_IN_TABS "new-windows-in-tabs"
#define EPHY_PREFS_AUTO_DOWNLOADS "automatic-downloads"
+#define EPHY_PREFS_EXTRACT_DOWNLOADED_ARCHIVES "extract-downloaded-archives"
#define EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA "warn-on-close-unsubmitted-data"
#define EPHY_PREFS_REMEMBER_PASSWORDS "remember-passwords"
#define EPHY_PREFS_KEYWORD_SEARCH_URL "keyword-search-url"