diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | data/epiphany.schemas.in | 11 | ||||
-rw-r--r-- | embed/downloader-view.c | 46 | ||||
-rw-r--r-- | embed/ephy-embed-popup-control.c | 3 | ||||
-rw-r--r-- | embed/mozilla/EphyHeaderSniffer.cpp | 43 | ||||
-rw-r--r-- | src/popup-commands.c | 6 |
6 files changed, 99 insertions, 27 deletions
@@ -1,3 +1,20 @@ +2003-10-29 Xan Lopez <xan@masilla.org> + + * embed/downloader-view.c: (downloader_view_remove_download): + + Implement smart selection in the downloader view. + + * data/epiphany.schemas.in: + * embed/ephy-embed-popup-control.c: + (embed_popup_download_link_cmd): + * embed/mozilla/EphyHeaderSniffer.cpp: + * lib/ephy-prefs.h: + * src/popup-commands.c: (popup_cmd_download_link): + + Make persist downloads store the files in the download dir + automatically without asking the user (key only accessible via + gconf atm). CH downloads still need fixing. + 2003-10-28 Christian Persch <chpe@cvs.gnome.org> * src/prefs-dialog.c: (sort_detectors), (create_optionmenu), diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in index f0d6371da..1bcae6033 100644 --- a/data/epiphany.schemas.in +++ b/data/epiphany.schemas.in @@ -121,17 +121,6 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/general/ask_download_dest</key> - <applyto>/apps/epiphany/general/ask_download_dest</applyto> - <owner>epiphany</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Ask for download destination</short> - <long>Ask for download destination.</long> - </locale> - </schema> - <schema> <key>/schemas/apps/epiphany/general/always_show_tabs_bar</key> <applyto>/apps/epiphany/general/always_show_tabs_bar</applyto> <owner>epiphany</owner> diff --git a/embed/downloader-view.c b/embed/downloader-view.c index e557422ca..d67577989 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -438,24 +438,58 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download) { GtkTreeRowReference *row_ref; GtkTreePath *path = NULL; - GtkTreeIter iter; + GtkTreeIter iter, iter2; row_ref = get_row_from_download (dv, download); g_return_if_fail (row_ref); + /* Get the row we'll select after removal ("smart" selection) */ + path = gtk_tree_row_reference_get_path (row_ref); gtk_tree_model_get_iter (GTK_TREE_MODEL (dv->priv->model), &iter, path); + gtk_tree_path_free (path); - gtk_list_store_remove (GTK_LIST_STORE (dv->priv->model), &iter); - - /* FIXME: smart selection */ + row_ref = NULL; + iter2 = iter; + if (gtk_tree_model_iter_next (GTK_TREE_MODEL (dv->priv->model), &iter)) + { + path = gtk_tree_model_get_path (GTK_TREE_MODEL (dv->priv->model), &iter); + row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (dv->priv->model), path); + } + else + { + path = gtk_tree_model_get_path (GTK_TREE_MODEL (dv->priv->model), &iter2); + if (gtk_tree_path_prev (path)) + { + row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (dv->priv->model), + path); + } + } + gtk_tree_path_free (path); + /* Removal */ + + gtk_list_store_remove (GTK_LIST_STORE (dv->priv->model), &iter2); g_hash_table_remove (dv->priv->downloads_hash, download); - gtk_tree_path_free (path); - + /* Actual selection */ + + if (row_ref != NULL) + { + path = gtk_tree_row_reference_get_path (row_ref); + if (path != NULL) + { + gtk_tree_view_set_cursor (GTK_TREE_VIEW (dv->priv->treeview), + path, NULL, FALSE); + gtk_tree_path_free (path); + } + gtk_tree_row_reference_free (row_ref); + } + + /* Close the dialog if there are no more downloads */ + if (!g_hash_table_size (dv->priv->downloads_hash)) g_object_unref (G_OBJECT (dv)); } diff --git a/embed/ephy-embed-popup-control.c b/embed/ephy-embed-popup-control.c index 5cda121e1..650534d86 100644 --- a/embed/ephy-embed-popup-control.c +++ b/embed/ephy-embed-popup-control.c @@ -544,8 +544,7 @@ embed_popup_download_link_cmd (BonoboUIComponent *uic, { save_property_url (popup, _("Download Link"), - eel_gconf_get_boolean - (CONF_ASK_DOWNLOAD_DEST), + FALSE, "link"); } diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp index fb185a0c7..939394bd1 100644 --- a/embed/mozilla/EphyHeaderSniffer.cpp +++ b/embed/mozilla/EphyHeaderSniffer.cpp @@ -67,6 +67,7 @@ #include "nsIDownload.h" #include <bonobo/bonobo-i18n.h> +#include <libgnomevfs/gnome-vfs-utils.h> EphyHeaderSniffer::EphyHeaderSniffer (nsIWebBrowserPersist* aPersist, MozillaEmbedPersist *aEmbedPersist, nsIFile* aFile, nsIURI* aURL, nsIDOMDocument* aDocument, nsIInputStream* aPostData) @@ -203,6 +204,7 @@ filechooser_response_cb (EphyFileChooser *dialog, gint response, EphyHeaderSniff nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI) { nsresult rv; + char *path, *download_dir; EmbedPersistFlags flags; PRBool askDownloadDest; @@ -302,13 +304,46 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI) return NS_OK; } - /* FIXME ask user if overwriting ? */ /* FIXME: how to inform user of failed save ? */ - nsCOMPtr<nsILocalFile> destFile; - rv = NS_NewLocalFile(defaultFileName, PR_TRUE, getter_AddRefs(destFile)); - if (NS_FAILED(rv) || !destFile) return NS_ERROR_FAILURE; + + download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOADING_DIR); + if (!download_dir) + { + /* Emergency download destination */ + download_dir = g_strdup (g_get_home_dir ()); + } + + if (!strcmp (download_dir, "Desktop")) + { + if (eel_gconf_get_boolean (CONF_DESKTOP_IS_HOME_DIR)) + { + path = g_build_filename + (g_get_home_dir (), + NS_ConvertUCS2toUTF8 (defaultFileName).get(), + NULL); + } + else + { + path = g_build_filename + (g_get_home_dir (), "Desktop", + NS_ConvertUCS2toUTF8 (defaultFileName).get(), + NULL); + } + } + else + { + path = g_build_filename + (gnome_vfs_expand_initial_tilde (download_dir), + NS_ConvertUCS2toUTF8 (defaultFileName).get(), + NULL); + } + g_free (download_dir); + + nsCOMPtr<nsILocalFile> destFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID); + destFile->InitWithNativePath (nsDependentCString (path)); + g_free (path); return InitiateDownload (destFile); } diff --git a/src/popup-commands.c b/src/popup-commands.c index 02bfbea2a..38613e216 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -320,10 +320,8 @@ void popup_cmd_download_link (GtkAction *action, EphyWindow *window) { - save_property_url (action, _("Download link"), window, - eel_gconf_get_boolean - (CONF_ASK_DOWNLOAD_DEST), - "link"); + save_property_url (action, _("Download link"), window, + FALSE, "link"); } void |