Bug 1232998 - Add an 'Open directory' button in about:profiles, r=ehsan

This commit is contained in:
Andrea Marchesini 2015-12-18 02:02:00 +00:00
Родитель aa1f9b32cb
Коммит d24fdd1db2
3 изменённых файлов: 38 добавлений и 4 удалений

Просмотреть файл

@ -49,6 +49,12 @@ function refreshUI() {
restartNormalModeButton.onclick = function() { restart(false); }
}
function openDirectory(dir) {
let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
"nsILocalFile", "initWithPath");
new nsLocalFile(dir).reveal();
}
function display(profileData) {
let parent = document.getElementById('profiles');
@ -73,7 +79,7 @@ function display(profileData) {
let tbody = document.createElement('tbody');
table.appendChild(tbody);
function createItem(title, value) {
function createItem(title, value, dir = false) {
let tr = document.createElement('tr');
tbody.appendChild(tr);
@ -85,15 +91,35 @@ function display(profileData) {
let td = document.createElement('td');
td.appendChild(document.createTextNode(value));
tr.appendChild(td);
if (dir) {
td.appendChild(document.createTextNode(' '));
let button = document.createElement('button');
let buttonText = document.createTextNode(bundle.GetStringFromName(
#ifdef XP_WIN
'winOpenDir'
#elif XP_MACOSX
'macOpenDir'
#else
'openDir'
#endif
));
button.appendChild(buttonText);
td.appendChild(button);
button.addEventListener('click', function(e) {
openDirectory(value);
});
}
}
createItem(bundle.GetStringFromName('isDefault'),
profileData.isDefault ? bundle.GetStringFromName('yes') : bundle.GetStringFromName('no'));
createItem(bundle.GetStringFromName('rootDir'), profileData.profile.rootDir.path);
createItem(bundle.GetStringFromName('rootDir'), profileData.profile.rootDir.path, true);
if (profileData.profile.localDir.path != profileData.profile.rootDir.path) {
createItem(bundle.GetStringFromName('localDir'), profileData.profile.localDir.path);
createItem(bundle.GetStringFromName('localDir'), profileData.profile.localDir.path, true);
}
let renameButton = document.createElement('button');

Просмотреть файл

@ -23,7 +23,7 @@ toolkit.jar:
#endif
content/global/aboutNetworking.js
content/global/aboutNetworking.xhtml
content/global/aboutProfiles.js
* content/global/aboutProfiles.js
content/global/aboutProfiles.xhtml
content/global/aboutServiceWorkers.js
content/global/aboutServiceWorkers.xhtml

Просмотреть файл

@ -32,3 +32,11 @@ deleteProfileTitle = Delete Profile
deleteProfileConfirm = Deleting a profile will remove the profile from the list of available profiles and cannot be undone.\nYou may also choose to delete the profile data files, including your settings, certificates and other user-related data. This option will delete the folder "%S" and cannot be undone.\nWould you like to delete the profile data files?
deleteFiles = Delete Files
dontDeleteFiles = Don't Delete Files
openDir = Open Directory
# LOCALIZATION NOTE (macOpenDir): This is the Mac-specific variant of openDir.
# This allows us to use the preferred"Finder" terminology on Mac.
macOpenDir = Show in Finder
# LOCALIZATION NOTE (winOpenDir): This is the Windows-specific variant of
# openDir.
winOpenDir = Show Folder