aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@gnome.org>2007-08-27 05:49:58 +0800
committerDiego Escalante Urrelo <diegoe@src.gnome.org>2007-08-27 05:49:58 +0800
commit3e87142caf4b143d59ebae348ace706917b7eb51 (patch)
tree228beeb412ba4b5034c45f3447c33ae241bc8dcc
parent53075e8f45b40da4260a9d46ce2b41668381dacb (diff)
downloadgsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar.gz
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar.bz2
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar.lz
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar.xz
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.tar.zst
gsoc2013-epiphany-3e87142caf4b143d59ebae348ace706917b7eb51.zip
Add saved files to the GtkRecent list, gnome-panel is broken so don't
2007-08-26 Diego Escalante Urrelo <diegoe@gnome.org> * lib/ephy-file-helpers.c: * lib/ephy-file-helpers.h: * embed/mozilla/MozDownload.h: * embed/mozilla/MozDownload.cpp: Add saved files to the GtkRecent list, gnome-panel is broken so don't expect to see the effects of this working there, you can use it on the GtkFileChooser dialog however. Fixes Bug #148401. Original patch by Christian Persch, updated by Cosimo Cecchi. svn path=/trunk/; revision=7300
-rw-r--r--ChangeLog12
-rw-r--r--embed/mozilla/MozDownload.cpp36
-rw-r--r--embed/mozilla/MozDownload.h1
-rw-r--r--lib/ephy-file-helpers.c12
-rw-r--r--lib/ephy-file-helpers.h3
5 files changed, 59 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index db70db1c3..c73e05fa7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-08-26 Diego Escalante Urrelo <diegoe@gnome.org>
+
+ * lib/ephy-file-helpers.c:
+ * lib/ephy-file-helpers.h:
+ * embed/mozilla/MozDownload.h:
+ * embed/mozilla/MozDownload.cpp:
+
+ Add saved files to the GtkRecent list, gnome-panel is broken so don't
+ expect to see the effects of this working there, you can use it on the
+ GtkFileChooser dialog however. Fixes Bug #148401. Original patch by
+ Christian Persch, updated by Cosimo Cecchi.
+
2007-08-25 Christian Persch <chpe@gnome.org>
* data/mime-types-permissions.xml:
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 29fa4d147..b5efe085a 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -58,6 +58,7 @@
#include <nsIIOService.h>
#include <nsILocalFile.h>
#include <nsIMIMEInfo.h>
+#include <nsIMIMEService.h>
#include <nsIObserver.h>
#include <nsIRequest.h>
#include <nsIURI.h>
@@ -88,6 +89,7 @@ MozDownload::MozDownload() :
mTotalProgress(-1),
mCurrentProgress(0),
mMaxSize(-1),
+ mAddToRecent(PR_TRUE),
mStatus(NS_OK),
mEmbedPersist(nsnull),
mDownloadState(EPHY_DOWNLOAD_INITIALISING)
@@ -149,6 +151,7 @@ MozDownload::Init (nsIURI *aSource,
mInterval = PROGRESS_RATE;
mLastUpdate = mStartTime;
mMIMEInfo = aMIMEInfo;
+ mAddToRecent = addToView;
/* This will create a refcount cycle, which needs to be broken in ::OnStateChange */
mCancelable = aCancelable;
@@ -311,6 +314,22 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
/* break refcount cycle */
mCancelable = nsnull;
+
+ nsCString destSpec;
+ nsCString mimeType;
+
+ mDestination->GetSpec (destSpec);
+
+ if (NS_SUCCEEDED (aStatus) && mMIMEInfo)
+ {
+ rv = mMIMEInfo->GetMIMEType (mimeType);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ }
+
+ if (mAddToRecent)
+ {
+ ephy_file_add_recent_item (destSpec.get(), mimeType.get());
+ }
if (mEmbedPersist)
{
@@ -330,9 +349,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
return NS_OK;
#else
GnomeVFSMimeApplication *helperApp;
- nsCString mimeType;
- rv = mMIMEInfo->GetMIMEType (mimeType);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE (mMIMEInfo, NS_ERROR_FAILURE);
nsString description;
mMIMEInfo->GetApplicationDescription (description);
@@ -358,7 +375,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
rv = mDestination->GetSpec (aDest);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- ephy_file_launch_application (helperApp, aDest.get (), user_time);
+ ephy_file_launch_application (helperApp, destSpec.get (), user_time);
gnome_vfs_mime_application_free (helperApp);
g_strfreev (str);
@@ -565,6 +582,15 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
ephy_embed_persist_set_dest (EPHY_EMBED_PERSIST (embedPersist),
cPath.get());
}
+
+ nsCOMPtr<nsIMIMEService> mimeService (do_GetService ("@mozilla.org/mime;1"));
+ nsCOMPtr<nsIMIMEInfo> mimeInfo;
+ if (mimeService)
+ {
+ mimeService->GetFromTypeAndExtension (nsCString(contentType),
+ nsCString(),
+ getter_AddRefs (mimeInfo));
+ }
PRBool isHTML = (contentType &&
(strcmp (contentType, "text/html") == 0 ||
@@ -590,7 +616,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
/* dlListener attaches to its progress dialog here, which gains ownership */
/* FIXME is that still true? */
rv = downloader->InitForEmbed (inOriginalURI, destURI, fileDisplayName,
- nsnull, timeNow, nsnull, webPersist, embedPersist, aMaxSize);
+ mimeInfo, timeNow, nsnull, webPersist, embedPersist, aMaxSize);
NS_ENSURE_SUCCESS (rv, rv);
rv = webPersist->SetProgressListener (downloader);
diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h
index bf7f11e1b..27fef41c7 100644
--- a/embed/mozilla/MozDownload.h
+++ b/embed/mozilla/MozDownload.h
@@ -138,6 +138,7 @@ protected:
PRInt64 mTotalProgress;
PRInt64 mCurrentProgress;
PRInt64 mMaxSize;
+ PRBool mAddToRecent;
nsresult mStatus;
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index fb00f5d34..283715c59 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -46,6 +46,7 @@
#include <libsn/sn.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#include <gtk/gtkrecentmanager.h>
#include <string.h>
#include <stdlib.h>
@@ -488,6 +489,17 @@ ephy_file_delete_on_exit (const char *path)
/* does nothing now */
}
+void
+ephy_file_add_recent_item (const char *uri,
+ const char *mime_type)
+{
+ GtkRecentManager *manager = gtk_recent_manager_get_default ();
+
+ g_return_if_fail (mime_type != NULL && uri != NULL);
+
+ gtk_recent_manager_add_item (manager, uri);
+}
+
static void
load_mime_from_xml (void)
{
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 75a0ac088..f7aa71281 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -77,6 +77,9 @@ gboolean ephy_file_switch_temp_file (const char *filename,
void ephy_file_delete_on_exit (const char *path);
+void ephy_file_add_recent_item (const char *uri,
+ const char *mime_type);
+
EphyMimePermission ephy_file_check_mime (const char *mime_type);
gboolean ephy_file_launch_desktop_file (const char *filename,