From 6312d03df0a10a59c8c71f695d1ae574930fc771 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sat, 6 Jul 2013 14:59:13 +0800 Subject: Add gsettings key "extract-downloaded-archives" --- data/org.gnome.epiphany.gschema.xml | 5 +++++ embed/ephy-download.c | 21 +++++++++++++++++++++ embed/ephy-download.h | 1 + lib/ephy-prefs.h | 1 + 4 files changed, 28 insertions(+) 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 @@ Automatic downloads When files cannot be opened by the browser they are automatically downloaded to the download folder and opened with the appropriate application. + + true + Extract downloaded archives + Automatically extract files from downloaded archive files + true Force new windows to be opened in tabs 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 #include #include +#include +#include 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" -- cgit v1.2.3