331755 - Use Bookmark option for setting home page is broken. add a new home page selection dialog that uses places. r=annie.sullivan@gmail.com

This commit is contained in:
beng%bengoodger.com 2006-04-04 00:13:58 +00:00
Родитель 80ac2cdd61
Коммит 8101a0d0ac
9 изменённых файлов: 172 добавлений и 4 удалений

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

@ -204,11 +204,12 @@ function asQuery(node) { return QI_node(node, Ci.nsINavHistoryQueryResultNode
/**
* A View Configuration
*/
function ViewConfig(peerDropTypes, childDropTypes, excludeItems, expandQueries,
peerDropIndex) {
function ViewConfig(peerDropTypes, childDropTypes, excludeItems, excludeQueries,
expandQueries, peerDropIndex) {
this.peerDropTypes = peerDropTypes;
this.childDropTypes = childDropTypes;
this.excludeItems = excludeItems;
this.excludeQueries = excludeQueries;
this.expandQueries = expandQueries;
this.peerDropIndex = peerDropIndex;
}
@ -229,7 +230,7 @@ var ViewConfigurator = {
rules: {
"folder=1": new ViewConfig([TYPE_X_MOZ_PLACE_CONTAINER],
ViewConfig.GENERIC_DROP_TYPES,
true, false, 4)
true, false, false, 4)
},
/**
@ -253,6 +254,7 @@ var ViewConfigurator = {
view.peerDropTypes = rules.peerDropTypes;
view.childDropTypes = rules.childDropTypes;
view.excludeItems = rules.excludeItems;
view.excludeQueries = rules.excludeQueries;
view.expandQueries = rules.expandQueries;
view.peerDropIndex = rules.peerDropIndex;
}

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

@ -390,6 +390,9 @@
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- nsIPlacesView -->
<field name="excludeQueries">false</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>

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

@ -339,6 +339,9 @@
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- nsIPlacesView -->
<field name="excludeQueries">false</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>

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

@ -90,6 +90,7 @@
<body><![CDATA[
// override with our local options
options.excludeItems = this.excludeItems;
options.excludeQueries = this.excludeQueries;
options.expandQueries = this.expandQueries;
var result = this.history.executeQueries(queries, queries.length,
options);
@ -477,6 +478,9 @@
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- nsIPlacesView -->
<field name="excludeQueries">false</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>

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

@ -72,7 +72,7 @@ var gGeneralPane = {
setHomePageToBookmark: function ()
{
var rv = { url: null };
document.documentElement.openSubDialog("chrome://browser/content/bookmarks/selectBookmark.xul",
document.documentElement.openSubDialog("chrome://browser/content/preferences/selectBookmark.xul",
"resizable", rv);
if (rv.url) {
var homePageField = document.getElementById("browserStartupHomepage");

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

@ -30,5 +30,7 @@ browser.jar:
* content/browser/preferences/privacy.js
* content/browser/preferences/sanitize.xul
* content/browser/preferences/sanitize.js
* content/browser/preferences/selectBookmark.xul
* content/browser/preferences/selectBookmark.js
* content/browser/preferences/tabs.xul
* content/browser/preferences/tabs.js

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

@ -0,0 +1,108 @@
//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Select Bookmark for Home Page Dialog.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <beng@google.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* SelectBookmarkDialog controls the user interface for the "Use Bookmark for
* Home Page" dialog.
*
* The caller (gGeneralPane.setHomePageToBookmark in general.js) invokes this
* dialog with a single argument - a reference to an object with a .url
* property. This dialog is responsible for updating the contents of the .url
* property with the new value of the "Home Page" text field before it closes.
*/
var SelectBookmarkDialog = {
init: function SBD_init() {
// Initial update of the OK button.
this.selectionChanged();
var bookmarks = document.getElementById("bookmarks");
bookmarks.excludeItems = false;
bookmarks.excludeQueries = true;
bookmarks.place = bookmarks.place;
},
/**
* Update the disabled state of the OK button as the user changes the
* selection within the view.
*/
selectionChanged: function SBD_selectionChanged() {
var accept = document.documentElement.getButton("accept");
var bookmarks = document.getElementById("bookmarks");
accept.disabled = !bookmarks.hasSelection;
},
/**
* The user has double clicked on a tree row that is a link. Take this to
* mean that they want that link to be their homepage, and close the dialog.
*/
linkChosen: function SBD_linkChosen() {
var bookmarks = document.getElementById("bookmarks");
if (bookmarks.hasSingleSelection &&
PlacesController.nodeIsURI(bookmarks.selectedNode))
document.documentElement.getButton("accept").click();
},
/**
* User accepts their selection. Set all the selected URLs or the contents
* of the selected folder as the list of homepages.
*/
accept: function SBD_accept() {
var bookmarks = document.getElementById("bookmarks");
NS_ASSERT(bookmarks.hasSelection,
"Should not be able to accept dialog if there is no selected URL!");
var urls = [];
var selectedNode = bookmarks.selectedNode;
if (bookmarks.hasSingleSelection &&
PlacesController.nodeIsFolder(selectedNode)) {
var contents = PlacesController.getFolderContents(asFolder(selectedNode).folderId);
var cc = contents.childCount;
for (var i = 0; i < cc; ++i) {
var node = contents.getChild(i);
if (PlacesController.nodeIsURI(node));
urls.push(node.uri);
}
}
else {
var nodes = bookmarks.getSelectionNodes();
for (i = 0; i < nodes.length; ++i)
urls.push(nodes[i].uri);
}
window.arguments[0].url = urls.join("|");
},
};
#include ../../../toolkit/content/debug.js

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

@ -0,0 +1,41 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/selectBookmark.dtd">
<dialog id="selectBookmarkDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&selectBookmark.title;" style="width: 32em;"
persist="screenX screenY width height" screenX="24" screenY="24"
onload="SelectBookmarkDialog.init();"
ondialogaccept="SelectBookmarkDialog.accept();">
<script type="application/x-javascript"
src="chrome://browser/content/places/controller.js"/>
<script type="application/x-javascript"
src="chrome://browser/content/preferences/selectBookmark.js"/>
<description>&selectBookmark.label;</description>
<separator class="thin"/>
<tree id="bookmarks" flex="1" type="places"
style="height: 15em;"
place="place:&amp;folder=1&amp;group=3"
hidecolumnpicker="true" seltype="single"
ondblclick="SelectBookmarkDialog.linkChosen();"
onselect="SelectBookmarkDialog.selectionChanged();">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="bookmarksChildren" flex="1"/>
</tree>
<separator class="thin"/>
</dialog>

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

@ -0,0 +1,5 @@
<!ENTITY selectBookmark.title
"Set Home Page">
<!ENTITY selectBookmark.label
"Choose a Bookmark to be your Home Page. If you choose a folder, the Bookmarks in that folder will be opened in Tabs.">