[PATCHES] Better use of download directory.

Crispin Flowerday <[email protected]>
Newsgroups gmane.comp.web.galeon.devel
Message-ID <1057530927.23844.28.camel@drno>
Hi,

Attached is a patch to fix http://bugs.debian.org/197683 . Also attached
is a patch to make the "save page as" right click menu item ask whether
to save the images and other stuff.

I realised a couple of things while looking at all the download code:

1) The external download program isn't used for that many things, e.g.
File/Save as doesn't actually use it (and neither does right clicking on
items on a page and selecting save). Is this behaviour on purpose?

2) Also we have 4 gconf variables that determine what directory to
download to:

 - /apps/galeon/State/savedir
 - /apps/galeon/State/saveimagedir (doesn't seem to be used)
 - /apps/galeon/State/last_download_dir (not in gconf schema)
 - /apps/galeon/Handlers/Downloading/download_dir

I was wondering whether it would make more sense to only maintain 2
gconf variables, the 'download_dir' one for when the user has set the
'ask_for_download_dir' to false, and a single state variable for use
when asking a normal user where to download to?

Therefore I propose removing the 'savedir' and 'saveimagedir' and
forcing the internal API (the galeon_embed_utils_save) to always save to
the 'download_dir' when it isn't asking, and when it is asking to always
use the 'last_download_dir' key.

Does that actually make sense :)

Crispin

-- 
http://patches.theflowerdays.com
galeon_link_right_click_download.diff (text/x-patch, 1.9 KB)
Index: embed/galeon-embed-popup.c
===================================================================
RCS file: /cvs/gnome/galeon/embed/galeon-embed-popup.c,v
retrieving revision 1.31
diff -u -r1.31 galeon-embed-popup.c
--- embed/galeon-embed-popup.c	30 Jun 2003 18:09:31 -0000	1.31
+++ embed/galeon-embed-popup.c	6 Jul 2003 22:11:42 -0000
@@ -754,47 +754,32 @@
 	embed_popup_copy_to_clipboard (popup, location);
 }
 
-static void
-save_url (GaleonEmbedPopup *popup,
-	  gboolean ask_dest,
-	  gboolean show_progress,
-	  const char *url)
+static void 
+embed_popup_save_page_as_cmd (BonoboUIComponent *uic, 
+			      GaleonEmbedPopup *popup, 
+			      const char* verbname)
 {
+	char *location;
 	GtkWidget *widget;
 	GtkWidget *window;
 	GaleonEmbedPersist *persist;
 	
+	galeon_embed_get_location (popup->priv->embed,
+				   FALSE, FALSE, &location);
+
 	widget = GTK_WIDGET (popup->priv->embed);
 	window = gtk_widget_get_toplevel (widget);
 	
 	persist = galeon_embed_persist_new (popup->priv->embed);
-	galeon_embed_persist_set_source (persist, url);
+	galeon_embed_persist_set_source (persist, location);
 
-	if (show_progress)
-	{
-		galeon_embed_persist_set_flags (persist, 
-						EMBED_PERSIST_SHOW_PROGRESS);
-	}
-	
 	galeon_embed_utils_save (window,
-				 CONF_DOWNLOADING_DIR,
-				 ask_dest,
-                                 FALSE,
-                                 persist);
-
-	g_object_unref (persist);
-}
+				 CONF_STATE_SAVE_DIR,
+				 TRUE, /* ask for directory */
+				 TRUE, /* ask for content */
+				 persist);
 
-static void 
-embed_popup_save_page_as_cmd (BonoboUIComponent *uic, 
-                      	      GaleonEmbedPopup *popup, 
-                              const char* verbname)
-{
-	char *location;
-	
-	galeon_embed_get_location (popup->priv->embed,
-				   FALSE, FALSE, &location);
-	save_url (popup, TRUE, FALSE, location);
+	g_object_unref (persist);	
 	g_free (location);
 }
galeon_link_shift_click_download_dir.diff (text/x-patch, 821 B)
Index: src/galeon-tab.c
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-tab.c,v
retrieving revision 1.95
diff -u -r1.95 galeon-tab.c
--- src/galeon-tab.c	30 Jun 2003 18:09:34 -0000	1.95
+++ src/galeon-tab.c	6 Jul 2003 22:11:17 -0000
@@ -1081,6 +1081,16 @@
 
 			ask_dir = eel_gconf_get_boolean(CONF_DOWNLOADING_ASK_DIR);
 
+			if (!ask_dir)
+			{
+				/* if we're not asking for download directory, make sure the
+				 * file is downloaded in the specified download directory and
+				 * not somewhere else */
+				char *dir = eel_gconf_get_string (CONF_DOWNLOADING_DIR);
+				eel_gconf_set_string (CONF_STATE_SAVE_DIR, dir);
+				g_free (dir);
+			}
+
 			galeon_embed_utils_save(GTK_WIDGET(window),
 						CONF_STATE_SAVE_DIR,
 						ask_dir, FALSE, persist);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.