[Pkg-mozext-commits] [automatic-save-folder] 65/133: Change : Set the default folder to desktop if no folder is set by the user (no default folder or first time using 'folderList=2'). Prevents the radio button to be shown without suggested path.

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:53 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch wip
in repository automatic-save-folder.

commit 0598d8cfa5f835de5fbf4a9bfb0de51676cdf9c0
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Sat Feb 13 16:44:32 2010 +0000

    Change :
    Set the default folder to desktop if no folder is set by the user (no default folder or first time using 'folderList=2'). Prevents the radio button to be shown without suggested path.
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@70 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf_download.js    | 23 ++++++++++++++++-------
 content/asf_right_click.js | 17 +++++++++++++----
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/content/asf_download.js b/content/asf_download.js
index 1c63e5d..891617c 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -155,7 +155,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 			{
 				if ( (keeptemp == false) || ((keeptemp == true) && ( tempdomain != domain )) ) // and, if [same domain not checked] OR [ if same domain (keeptemp) is checked and domain not same as previous one]
 				{	// then change the destination folder to user choice
-					if (defaultfolder != "") this.set_savepath(defaultfolder);
+					this.set_savepath(defaultfolder);
 				}
 				else  // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
 				{
@@ -172,7 +172,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 					{
 						lastpath = defaultfolder;
 					}
-					if (lastpath != "") this.set_savepath(lastpath);
+					this.set_savepath(lastpath);
 				}
 			}
 			else // else, if savetype == 0  (folder is set to last folder)
@@ -190,7 +190,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				{
 					lastpath = defaultfolder;
 				}
-				if (lastpath != "") this.set_savepath(lastpath);
+				this.set_savepath(lastpath);
 			}
 		}
 		else // if a filter is found
@@ -249,10 +249,10 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 		var folderList = this.prefManager.getIntPref("browser.download.folderList");
 		
 		var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-		directory.initWithPath(path);
+		
 		
 		// Check if the user use the "do not show file explorer" to automatically save to "desktop" or "downloads" and force the suggested path to those folders instead of filtered path
-		if (useDownloadDir == true)
+		if ( (folderList == 0) || (folderList == 1) )
 		{
 			var desk = Components.classes["@mozilla.org/file/directory_service;1"]
 								.getService(Components.interfaces.nsIProperties)
@@ -266,7 +266,7 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				
 				if ( (folderList == 0) || (folderList == 1 && !supportDownloadLabel) ) // if desktop or if OS doesn't support default Download dir
 				{
-					var directory = desk;
+					directory = desk;
 				}
 				if (folderList == 1 && supportDownloadLabel) // default Downloads folder
 				{
@@ -274,7 +274,16 @@ Copyright (C) 2007-2010 Éric Cassar (Cyan).
 				}
 			}
 		}
-		
+		else if ( (folderList == 2) && (!path) )   // set to filters but no path is define (either no default folder is set, or first time using 'folderList=2' )
+		{
+			directory = Components.classes["@mozilla.org/file/directory_service;1"]
+								.getService(Components.interfaces.nsIProperties)
+								.get("Desk", Components.interfaces.nsILocalFile);
+		}
+		else
+		{
+			directory.initWithPath(path);
+		}
 		
 		if (this.firefoxversion == 2)
 		{
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 092f43e..31af772 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -215,7 +215,7 @@ var automatic_save_folder = {
 				{
 					if ( (keeptemp == false) || ((keeptemp == true) && ( tempdomain != domain )) ) // and, if [same domain not checked] OR [ if same domain (keeptemp) is checked and domain not same as previous one]
 					{	// then change the destination folder to user choice
-						if (defaultfolder != "") this.set_savepath(defaultfolder);
+						this.set_savepath(defaultfolder);
 					}	
 					else  // else, if domain is the same as the last, and the user checked "use the same folder if same domain"
 					{
@@ -232,7 +232,7 @@ var automatic_save_folder = {
 						{
 							lastpath = defaultfolder;
 						}
-						if (lastpath != "") this.set_savepath(lastpath);
+						this.set_savepath(lastpath);
 					}
 				}
 				else // else, if savetype == 0  (folder is set to last folder)
@@ -250,7 +250,7 @@ var automatic_save_folder = {
 					{
 						lastpath = defaultfolder;
 					}
-					if (lastpath != "") this.set_savepath(lastpath);
+					this.set_savepath(lastpath);
 				}
 			}
 			else // if a filter is found 
@@ -292,7 +292,16 @@ var automatic_save_folder = {
 		var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir");	     // for Firefox2 : set save as Ctrl+S too
 		
 		var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-		directory.initWithPath(path);
+		if (!path) 
+		{
+			directory = Components.classes["@mozilla.org/file/directory_service;1"]
+								.getService(Components.interfaces.nsIProperties)
+								.get("Desk", Components.interfaces.nsILocalFile);
+		}
+		else
+		{
+			directory.initWithPath(path);
+		}
 		
 		
 		if (this.firefoxversion == 2)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/automatic-save-folder.git



More information about the Pkg-mozext-commits mailing list