aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter Bolsterlee <wbolster@gnome.org>2006-10-15 22:05:40 +0800
committerWouter Bolsterlee <wbolster@src.gnome.org>2006-10-15 22:05:40 +0800
commitc1e9da9eed75fc314c113000d7fe01e7de1ae913 (patch)
tree8fe52c695808de3066e5a3652035b0406463f0fe
parentccb73eb4348e4fb957fe4a2f8ed5ca7eac6835d9 (diff)
downloadgsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar.gz
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar.bz2
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar.lz
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar.xz
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.tar.zst
gsoc2013-epiphany-c1e9da9eed75fc314c113000d7fe01e7de1ae913.zip
Automatically open a Nautilus window after downloading has finished. Fixes
2006-10-15 Wouter Bolsterlee <wbolster@gnome.org> * embed/mozilla/ContentHandler.cpp: * embed/mozilla/MozDownload.cpp: * lib/ephy-file-helpers.c: (ephy_file_browse_to): * lib/ephy-file-helpers.h: * src/popup-commands.c: (save_property_url_completed_cb), (save_property_url): Automatically open a Nautilus window after downloading has finished. Fixes bug #138876, patch by Ed Catmur.
-rw-r--r--ChangeLog11
-rw-r--r--embed/mozilla/ContentHandler.cpp10
-rw-r--r--embed/mozilla/MozDownload.cpp26
-rw-r--r--lib/ephy-file-helpers.c21
-rw-r--r--lib/ephy-file-helpers.h3
-rw-r--r--src/popup-commands.c21
6 files changed, 91 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 423897f84..ff54a7602 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2006-10-15 Wouter Bolsterlee <wbolster@gnome.org>
+ * embed/mozilla/ContentHandler.cpp:
+ * embed/mozilla/MozDownload.cpp:
+ * lib/ephy-file-helpers.c: (ephy_file_browse_to):
+ * lib/ephy-file-helpers.h:
+ * src/popup-commands.c: (save_property_url_completed_cb),
+ (save_property_url):
+ Automatically open a Nautilus window after downloading
+ has finished. Fixes bug #138876, patch by Ed Catmur.
+
+2006-10-15 Wouter Bolsterlee <wbolster@gnome.org>
+
* src/bookmarks/ephy-bookmarks-editor.c:
(ephy_bookmarks_editor_construct):
Use full width for bookmarks search bar.
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index d6403eb90..2948514eb 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -406,6 +406,8 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
+ char *info = NULL;
+
if (mAction == CONTENT_ACTION_OPEN)
{
g_return_val_if_fail (mHelperApp, NS_ERROR_FAILURE);
@@ -416,9 +418,15 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
/* The current time is fine here as the user has just clicked
* a button (it is used as the time for the application opening)
*/
- char *info;
info = g_strdup_printf ("gnome-default:%d:%s", gtk_get_current_event_time(), id);
+ }
+ else if (mAction == CONTENT_ACTION_DOWNLOAD)
+ {
+ info = g_strdup_printf ("gnome-browse-to-file:%d", gtk_get_current_event_time());
+ }
+ if (info != NULL)
+ {
nsString desc;
NS_CStringToUTF16 (nsCString (info),
NS_CSTRING_ENCODING_UTF8, desc);
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 673aa5788..bf1a1c28f 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -357,6 +357,23 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
gnome_vfs_mime_application_free (helperApp);
g_strfreev (str);
}
+ else if (g_str_has_prefix (cDesc.get(), "gnome-browse-to-file:"))
+ {
+ /* Format gnome-browse-to-file:<usertime> */
+ char **str = g_strsplit (cDesc.get(), ":", -1);
+ g_return_val_if_fail (g_strv_length (str) == 2, NS_ERROR_FAILURE);
+
+ char *end;
+ guint32 user_time = strtoul (str[1], &end, 0);
+
+ nsCString aDest;
+ rv = mDestination->GetSpec (aDest);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ ephy_file_browse_to (aDest.get (), user_time);
+
+ g_strfreev (str);
+ }
}
}
@@ -519,6 +536,15 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
EphyEmbedPersistFlags ephy_flags;
ephy_flags = ephy_embed_persist_get_flags (EPHY_EMBED_PERSIST (embedPersist));
+ if (!ephy_embed_persist_get_dest (EPHY_EMBED_PERSIST (embedPersist)))
+ {
+ nsCString cPath;
+ inDestFile->GetNativePath (cPath);
+
+ ephy_embed_persist_set_dest (EPHY_EMBED_PERSIST (embedPersist),
+ cPath.get());
+ }
+
PRBool isHTML = (contentType &&
(strcmp (contentType, "text/html") == 0 ||
strcmp (contentType, "text/xml") == 0 ||
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index eacde296c..9bc6c04dc 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -1017,6 +1017,27 @@ ephy_file_launch_handler (const char *mime_type,
return ret;
}
+gboolean
+ephy_file_browse_to (const char *parameter,
+ guint32 user_time)
+{
+ GnomeVFSURI *uri, *parent_uri;
+ gboolean ret;
+
+ uri = gnome_vfs_uri_new (parameter);
+ parent_uri = gnome_vfs_uri_get_parent (uri);
+
+ /* TODO find a way to make nautilus scroll to the actual file */
+ ret = ephy_file_launch_handler ("x-directory/normal",
+ gnome_vfs_uri_get_path (parent_uri),
+ user_time);
+
+ gnome_vfs_uri_unref (uri);
+ gnome_vfs_uri_unref (parent_uri);
+
+ return ret;
+}
+
struct _EphyFileMonitor
{
GnomeVFSMonitorHandle *handle;
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 48f655b38..3ded0d36d 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -91,6 +91,9 @@ gboolean ephy_file_launch_handler (const char *mime_type,
const char *address,
guint32 user_time);
+gboolean ephy_file_browse_to (const char *parameter,
+ guint32 user_time);
+
EphyFileMonitor *ephy_file_monitor_add (const char *uri,
GnomeVFSMonitorType monitor_type,
guint delay,
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 48e3f7c9f..2f81614a7 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -168,6 +168,24 @@ popup_cmd_copy_link_address (GtkAction *action,
}
static void
+save_property_url_completed_cb (EphyEmbedPersist *persist)
+{
+ if (!(ephy_embed_persist_get_flags (persist) &
+ EPHY_EMBED_PERSIST_ASK_DESTINATION))
+ {
+ const char *dest;
+ guint32 user_time;
+
+ user_time = ephy_embed_persist_get_user_time (persist);
+ dest = ephy_embed_persist_get_dest (persist);
+ g_return_if_fail (dest != NULL);
+
+ eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
+ ephy_file_browse_to (dest, user_time);
+ }
+}
+
+static void
save_property_url (GtkAction *action,
const char *title,
EphyWindow *window,
@@ -201,6 +219,9 @@ save_property_url (GtkAction *action,
(persist, CONF_STATE_SAVE_DIR);
ephy_embed_persist_set_source (persist, location);
+ g_signal_connect (persist, "completed",
+ G_CALLBACK (save_property_url_completed_cb), NULL);
+
ephy_embed_persist_save (persist);
g_object_unref (G_OBJECT(persist));