зеркало из https://github.com/mozilla/pjs.git
Fix for bug 155560 -- renaming bookmark does not update menu/toolbar. Also fixes crash when deleting a toolbar bookmark (bug 157229). Patch from David Hass.
This commit is contained in:
Родитель
8ae1c86928
Коммит
9b57cc7ac7
|
@ -57,7 +57,7 @@
|
|||
|
||||
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
if (![mBookmarkItem contentNode])
|
||||
return;
|
||||
|
||||
unsigned int len;
|
||||
|
@ -109,6 +109,7 @@
|
|||
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
|
||||
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
-(void)setBookmark: (BookmarkItem*) aBookmark
|
||||
|
|
|
@ -344,10 +344,10 @@
|
|||
[self deleteBookmark: item];
|
||||
}
|
||||
|
||||
// restore selection to location near last item deleted
|
||||
// restore selection to location near last item deleted or last item
|
||||
int total = [mOutlineView numberOfRows];
|
||||
if (index == total)
|
||||
index--;
|
||||
if (index >= total)
|
||||
index = total - 1;
|
||||
[mOutlineView selectRow: index byExtendingSelection: NO];
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,29 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
|
|||
BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
|
||||
|
||||
if (instance->mDataSource) {
|
||||
// We're a tree view
|
||||
BookmarkItem* item = GetWrapperFor(aItem);
|
||||
[(instance->mDataSource) reloadDataForItem: item reloadChildren: NO];
|
||||
}
|
||||
else if (instance->mToolbar) {
|
||||
// We're a personal toolbar. It'll figure out what to do.
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aItem));
|
||||
[(instance->mToolbar) editButton: elt];
|
||||
}
|
||||
else {
|
||||
// We're the menu. Reset the title, in case it's changed.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
aItem->GetParent(*getter_AddRefs(parent));
|
||||
NSMenu* menu = LocateMenu(parent);
|
||||
PRUint32 contentID = 0;
|
||||
aItem->GetContentID(&contentID);
|
||||
NSMenuItem* childItem = [menu itemWithTag: contentID];
|
||||
nsAutoString name;
|
||||
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
|
||||
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
|
||||
[childItem setTitle: title];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
|
|
|
@ -38,9 +38,10 @@ class CHBookmarksButton;
|
|||
|
||||
-(void)initializeToolbar;
|
||||
|
||||
// Called to construct the initial set of personal toolbar buttons.
|
||||
// Called to construct & edit the initial set of personal toolbar buttons.
|
||||
-(void)buildButtonList;
|
||||
-(void)addButton: (nsIDOMElement*)aElt atIndex: (int)aIndex;
|
||||
-(void)editButton: (nsIDOMElement*)aElt;
|
||||
-(void)removeButton: (nsIDOMElement*)aElt;
|
||||
|
||||
// Called to lay out the buttons on the toolbar.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* David Hyatt <hyatt@netscape.com> (Original Author)
|
||||
* Kathy Brade <brade@netscape.com>
|
||||
* David Haas <haasd@cae.wisc.edu>
|
||||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
|
@ -118,6 +119,22 @@
|
|||
[self reflowButtonsStartingAtIndex: aIndex];
|
||||
}
|
||||
|
||||
-(void)editButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
CHBookmarksButton* button = [mButtons objectAtIndex: i];
|
||||
if ([button element] == aElt) {
|
||||
[button setElement: aElt];
|
||||
if (count > i && [self isShown])
|
||||
[self reflowButtonsStartingAtIndex: i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: [self isShown]];
|
||||
}
|
||||
|
||||
-(void)removeButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
if (![mBookmarkItem contentNode])
|
||||
return;
|
||||
|
||||
unsigned int len;
|
||||
|
@ -109,6 +109,7 @@
|
|||
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
|
||||
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
-(void)setBookmark: (BookmarkItem*) aBookmark
|
||||
|
|
|
@ -344,10 +344,10 @@
|
|||
[self deleteBookmark: item];
|
||||
}
|
||||
|
||||
// restore selection to location near last item deleted
|
||||
// restore selection to location near last item deleted or last item
|
||||
int total = [mOutlineView numberOfRows];
|
||||
if (index == total)
|
||||
index--;
|
||||
if (index >= total)
|
||||
index = total - 1;
|
||||
[mOutlineView selectRow: index byExtendingSelection: NO];
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,29 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
|
|||
BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
|
||||
|
||||
if (instance->mDataSource) {
|
||||
// We're a tree view
|
||||
BookmarkItem* item = GetWrapperFor(aItem);
|
||||
[(instance->mDataSource) reloadDataForItem: item reloadChildren: NO];
|
||||
}
|
||||
else if (instance->mToolbar) {
|
||||
// We're a personal toolbar. It'll figure out what to do.
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aItem));
|
||||
[(instance->mToolbar) editButton: elt];
|
||||
}
|
||||
else {
|
||||
// We're the menu. Reset the title, in case it's changed.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
aItem->GetParent(*getter_AddRefs(parent));
|
||||
NSMenu* menu = LocateMenu(parent);
|
||||
PRUint32 contentID = 0;
|
||||
aItem->GetContentID(&contentID);
|
||||
NSMenuItem* childItem = [menu itemWithTag: contentID];
|
||||
nsAutoString name;
|
||||
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
|
||||
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
|
||||
[childItem setTitle: title];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
|
|
|
@ -38,9 +38,10 @@ class CHBookmarksButton;
|
|||
|
||||
-(void)initializeToolbar;
|
||||
|
||||
// Called to construct the initial set of personal toolbar buttons.
|
||||
// Called to construct & edit the initial set of personal toolbar buttons.
|
||||
-(void)buildButtonList;
|
||||
-(void)addButton: (nsIDOMElement*)aElt atIndex: (int)aIndex;
|
||||
-(void)editButton: (nsIDOMElement*)aElt;
|
||||
-(void)removeButton: (nsIDOMElement*)aElt;
|
||||
|
||||
// Called to lay out the buttons on the toolbar.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* David Hyatt <hyatt@netscape.com> (Original Author)
|
||||
* Kathy Brade <brade@netscape.com>
|
||||
* David Haas <haasd@cae.wisc.edu>
|
||||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
|
@ -118,6 +119,22 @@
|
|||
[self reflowButtonsStartingAtIndex: aIndex];
|
||||
}
|
||||
|
||||
-(void)editButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
CHBookmarksButton* button = [mButtons objectAtIndex: i];
|
||||
if ([button element] == aElt) {
|
||||
[button setElement: aElt];
|
||||
if (count > i && [self isShown])
|
||||
[self reflowButtonsStartingAtIndex: i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: [self isShown]];
|
||||
}
|
||||
|
||||
-(void)removeButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
if (![mBookmarkItem contentNode])
|
||||
return;
|
||||
|
||||
unsigned int len;
|
||||
|
@ -109,6 +109,7 @@
|
|||
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
|
||||
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
-(void)setBookmark: (BookmarkItem*) aBookmark
|
||||
|
|
|
@ -344,10 +344,10 @@
|
|||
[self deleteBookmark: item];
|
||||
}
|
||||
|
||||
// restore selection to location near last item deleted
|
||||
// restore selection to location near last item deleted or last item
|
||||
int total = [mOutlineView numberOfRows];
|
||||
if (index == total)
|
||||
index--;
|
||||
if (index >= total)
|
||||
index = total - 1;
|
||||
[mOutlineView selectRow: index byExtendingSelection: NO];
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,29 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
|
|||
BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
|
||||
|
||||
if (instance->mDataSource) {
|
||||
// We're a tree view
|
||||
BookmarkItem* item = GetWrapperFor(aItem);
|
||||
[(instance->mDataSource) reloadDataForItem: item reloadChildren: NO];
|
||||
}
|
||||
else if (instance->mToolbar) {
|
||||
// We're a personal toolbar. It'll figure out what to do.
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aItem));
|
||||
[(instance->mToolbar) editButton: elt];
|
||||
}
|
||||
else {
|
||||
// We're the menu. Reset the title, in case it's changed.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
aItem->GetParent(*getter_AddRefs(parent));
|
||||
NSMenu* menu = LocateMenu(parent);
|
||||
PRUint32 contentID = 0;
|
||||
aItem->GetContentID(&contentID);
|
||||
NSMenuItem* childItem = [menu itemWithTag: contentID];
|
||||
nsAutoString name;
|
||||
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
|
||||
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
|
||||
[childItem setTitle: title];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
|
|
|
@ -38,9 +38,10 @@ class CHBookmarksButton;
|
|||
|
||||
-(void)initializeToolbar;
|
||||
|
||||
// Called to construct the initial set of personal toolbar buttons.
|
||||
// Called to construct & edit the initial set of personal toolbar buttons.
|
||||
-(void)buildButtonList;
|
||||
-(void)addButton: (nsIDOMElement*)aElt atIndex: (int)aIndex;
|
||||
-(void)editButton: (nsIDOMElement*)aElt;
|
||||
-(void)removeButton: (nsIDOMElement*)aElt;
|
||||
|
||||
// Called to lay out the buttons on the toolbar.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* David Hyatt <hyatt@netscape.com> (Original Author)
|
||||
* Kathy Brade <brade@netscape.com>
|
||||
* David Haas <haasd@cae.wisc.edu>
|
||||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
|
@ -118,6 +119,22 @@
|
|||
[self reflowButtonsStartingAtIndex: aIndex];
|
||||
}
|
||||
|
||||
-(void)editButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
CHBookmarksButton* button = [mButtons objectAtIndex: i];
|
||||
if ([button element] == aElt) {
|
||||
[button setElement: aElt];
|
||||
if (count > i && [self isShown])
|
||||
[self reflowButtonsStartingAtIndex: i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: [self isShown]];
|
||||
}
|
||||
|
||||
-(void)removeButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
if (![mBookmarkItem contentNode])
|
||||
return;
|
||||
|
||||
unsigned int len;
|
||||
|
@ -109,6 +109,7 @@
|
|||
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
|
||||
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
-(void)setBookmark: (BookmarkItem*) aBookmark
|
||||
|
|
|
@ -344,10 +344,10 @@
|
|||
[self deleteBookmark: item];
|
||||
}
|
||||
|
||||
// restore selection to location near last item deleted
|
||||
// restore selection to location near last item deleted or last item
|
||||
int total = [mOutlineView numberOfRows];
|
||||
if (index == total)
|
||||
index--;
|
||||
if (index >= total)
|
||||
index = total - 1;
|
||||
[mOutlineView selectRow: index byExtendingSelection: NO];
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,29 @@ BookmarksService::BookmarkChanged(nsIContent* aItem, bool shouldFlush = true)
|
|||
BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
|
||||
|
||||
if (instance->mDataSource) {
|
||||
// We're a tree view
|
||||
BookmarkItem* item = GetWrapperFor(aItem);
|
||||
[(instance->mDataSource) reloadDataForItem: item reloadChildren: NO];
|
||||
}
|
||||
else if (instance->mToolbar) {
|
||||
// We're a personal toolbar. It'll figure out what to do.
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aItem));
|
||||
[(instance->mToolbar) editButton: elt];
|
||||
}
|
||||
else {
|
||||
// We're the menu. Reset the title, in case it's changed.
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
aItem->GetParent(*getter_AddRefs(parent));
|
||||
NSMenu* menu = LocateMenu(parent);
|
||||
PRUint32 contentID = 0;
|
||||
aItem->GetContentID(&contentID);
|
||||
NSMenuItem* childItem = [menu itemWithTag: contentID];
|
||||
nsAutoString name;
|
||||
aItem->GetAttr(kNameSpaceID_None, gNameAtom, name);
|
||||
NSString* title = [NSString stringWithCharacters: name.get() length: name.Length()];
|
||||
[childItem setTitle: title];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
|
|
|
@ -38,9 +38,10 @@ class CHBookmarksButton;
|
|||
|
||||
-(void)initializeToolbar;
|
||||
|
||||
// Called to construct the initial set of personal toolbar buttons.
|
||||
// Called to construct & edit the initial set of personal toolbar buttons.
|
||||
-(void)buildButtonList;
|
||||
-(void)addButton: (nsIDOMElement*)aElt atIndex: (int)aIndex;
|
||||
-(void)editButton: (nsIDOMElement*)aElt;
|
||||
-(void)removeButton: (nsIDOMElement*)aElt;
|
||||
|
||||
// Called to lay out the buttons on the toolbar.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* David Hyatt <hyatt@netscape.com> (Original Author)
|
||||
* Kathy Brade <brade@netscape.com>
|
||||
* David Haas <haasd@cae.wisc.edu>
|
||||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
|
@ -118,6 +119,22 @@
|
|||
[self reflowButtonsStartingAtIndex: aIndex];
|
||||
}
|
||||
|
||||
-(void)editButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
CHBookmarksButton* button = [mButtons objectAtIndex: i];
|
||||
if ([button element] == aElt) {
|
||||
[button setElement: aElt];
|
||||
if (count > i && [self isShown])
|
||||
[self reflowButtonsStartingAtIndex: i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsDisplay: [self isShown]];
|
||||
}
|
||||
|
||||
-(void)removeButton: (nsIDOMElement*)aElt
|
||||
{
|
||||
int count = [mButtons count];
|
||||
|
|
Загрузка…
Ссылка в новой задаче