diff options
author | Ting-Wei Lan <lantw44@gmail.com> | 2013-07-06 14:59:13 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-09-16 22:04:47 +0800 |
commit | 6312d03df0a10a59c8c71f695d1ae574930fc771 (patch) | |
tree | 52909442f31c8a2b0460bbda41989c305d995d25 | |
parent | 1a5eb4d9c9e9a8ed9c0ac18069a983cd712a9dc5 (diff) | |
download | gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar.gz gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar.bz2 gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar.lz gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar.xz gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.tar.zst gsoc2013-epiphany-6312d03df0a10a59c8c71f695d1ae574930fc771.zip |
Add gsettings key "extract-downloaded-archives"
-rw-r--r-- | data/org.gnome.epiphany.gschema.xml | 5 | ||||
-rw-r--r-- | embed/ephy-download.c | 21 | ||||
-rw-r--r-- | embed/ephy-download.h | 1 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 1 |
4 files changed, 28 insertions, 0 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml index 9d61f050d..ccd6d1d2c 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" |