Fix for bug 158378: fix the bookmark info panel to behave correctly, support Undo, and not crash. Patch from David Hass, hacked on by me.

This commit is contained in:
sfraser%netscape.com 2002-07-25 02:07:43 +00:00
Родитель 8dc07b900d
Коммит d6e26e143a
36 изменённых файлов: 720 добавлений и 460 удалений

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import <AppKit/AppKit.h>
#import "BookmarksService.h"
@ -34,6 +35,7 @@
IBOutlet NSTextField* mDescriptionLabel;
BookmarkItem* mBookmarkItem;
NSTextView* mFieldEditor;
NSOutlineView* mOutlineView;
}
@ -42,7 +44,5 @@
-(void)setBookmark:(BookmarkItem*)aBookmark;
-(void)showUIElementPair: (id)aLabel control: (id) aControl;
-(void)hideUIElementPair: (id)aLabel control: (id) aControl;
@end

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h"
#include "nsINamespaceManager.h"
@interface BookmarkInfoController(Private)
- (void)showUIElementPair: (id)aLabel control: (id) aControl;
- (void)hideUIElementPair: (id)aLabel control: (id) aControl;
- (void)commitChanges:(id)sender;
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom;
@end;
@implementation BookmarkInfoController
-(id) init
{
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self;
}
@ -50,126 +59,120 @@
return [self init];
}
-(void)windowDidLoad
-(void)dealloc
{
[mFieldEditor release];
[super dealloc];
}
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
{
[self commitChanges:[aNotification object]];
[[mFieldEditor undoManager] removeAllActions];
}
-(void)windowDidResignKey:(NSNotification*) aNotification
{
[self commitChanges:nil];
}
// if changedField is nil, commit everything
- (void)commitChanges:(id)changedField
{
if (![mBookmarkItem contentNode])
return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name
len = [[mNameField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
if (!changedField || changedField == mNameField)
[self commitField:mNameField toProperty:BookmarksService::gNameAtom];
// Location
len = [[mLocationField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
if (!changedField || changedField == mLocationField)
[self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
// Keyword
len = [[mKeywordField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
if (!changedField || changedField == mKeywordField)
[self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
// Description
len = [[mDescriptionField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
if (!changedField || changedField == mDescriptionField)
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
}
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom
{
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// we really need a category on NSString for this
len = [[textField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[textField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, propertyAtom, buf, PR_TRUE);
}
-(void)setBookmark: (BookmarkItem*) aBookmark
{
if (aBookmark) {
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// See bug 154081 - don't show this window if Bookmark doesn't exist
// after fix - this should never happen unless disaster strikes.
if (![aBookmark contentNode])
return;
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
mBookmarkItem = aBookmark;
}
@ -198,4 +201,10 @@
}
}
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end

4
camino/BookmarkInfoPanel.nib/info.nib сгенерированный
Просмотреть файл

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
camino/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

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

@ -55,6 +55,8 @@ class BookmarksService;
IBOutlet id mOutlineView;
IBOutlet id mBrowserWindowController;
IBOutlet id mEditBookmarkButton;
IBOutlet id mDeleteBookmarkButton;
NSString* mCachedHref;

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

@ -349,6 +349,9 @@
if (index >= total)
index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO];
// lame, but makes sure we catch all delete events in Info Panel
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSOutlineViewSelectionDidChangeNotification" object:mOutlineView];
}
-(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
}
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{
int index = [mOutlineView selectedRow];
if (index == -1) {
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:NULL];
[mEditBookmarkButton setEnabled:NO];
[mDeleteBookmarkButton setEnabled:NO];
}
else {
BookmarkItem* item = [mOutlineView itemAtRow:index];
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:item];
[mEditBookmarkButton setEnabled:YES];
[mDeleteBookmarkButton setEnabled:YES];
if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
}
}

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

@ -1006,6 +1006,7 @@
};
F50E1BA70207EB8201F281DF = {
children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = {
};
};
F5EA337802EF886D01A96654 = {
children = (
F5EA337902EF889001A96654,
F5EA337A02EF889001A96654,
F5EA337B02EF889001A96654,
F5EA337C02EF889001A96654,
F5EA337D02EF889001A96654,
F5EA337E02EF889001A96654,
);
isa = PBXGroup;
name = widget;
refType = 4;
};
F5EA337902EF889001A96654 = {
isa = PBXFileReference;
name = nsAppShellCocoa.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsAppShellCocoa.mm;
refType = 0;
};
F5EA337A02EF889001A96654 = {
isa = PBXFileReference;
name = nsChildView.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsChildView.mm;
refType = 0;
};
F5EA337B02EF889001A96654 = {
isa = PBXFileReference;
name = nsCocoaWindow.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsCocoaWindow.mm;
refType = 0;
};
F5EA337C02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragHelperService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragHelperService.cpp;
refType = 0;
};
F5EA337D02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragService.cpp;
refType = 0;
};
F5EA337E02EF889001A96654 = {
isa = PBXFileReference;
name = nsToolkit.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsToolkit.mm;
refType = 0;
};
F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference;
name = libwidget.rsrc;

4
camino/English.lproj/BookmarkInfoPanel.nib/info.nib сгенерированный
Просмотреть файл

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
camino/English.lproj/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичные данные
camino/English.lproj/Localizable.strings

Двоичный файл не отображается.

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

@ -1006,6 +1006,7 @@
};
F50E1BA70207EB8201F281DF = {
children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = {
};
};
F5EA337802EF886D01A96654 = {
children = (
F5EA337902EF889001A96654,
F5EA337A02EF889001A96654,
F5EA337B02EF889001A96654,
F5EA337C02EF889001A96654,
F5EA337D02EF889001A96654,
F5EA337E02EF889001A96654,
);
isa = PBXGroup;
name = widget;
refType = 4;
};
F5EA337902EF889001A96654 = {
isa = PBXFileReference;
name = nsAppShellCocoa.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsAppShellCocoa.mm;
refType = 0;
};
F5EA337A02EF889001A96654 = {
isa = PBXFileReference;
name = nsChildView.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsChildView.mm;
refType = 0;
};
F5EA337B02EF889001A96654 = {
isa = PBXFileReference;
name = nsCocoaWindow.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsCocoaWindow.mm;
refType = 0;
};
F5EA337C02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragHelperService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragHelperService.cpp;
refType = 0;
};
F5EA337D02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragService.cpp;
refType = 0;
};
F5EA337E02EF889001A96654 = {
isa = PBXFileReference;
name = nsToolkit.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsToolkit.mm;
refType = 0;
};
F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference;
name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
camino/resources/localized/English.lproj/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичный файл не отображается.

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import <AppKit/AppKit.h>
#import "BookmarksService.h"
@ -34,6 +35,7 @@
IBOutlet NSTextField* mDescriptionLabel;
BookmarkItem* mBookmarkItem;
NSTextView* mFieldEditor;
NSOutlineView* mOutlineView;
}
@ -42,7 +44,5 @@
-(void)setBookmark:(BookmarkItem*)aBookmark;
-(void)showUIElementPair: (id)aLabel control: (id) aControl;
-(void)hideUIElementPair: (id)aLabel control: (id) aControl;
@end

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h"
#include "nsINamespaceManager.h"
@interface BookmarkInfoController(Private)
- (void)showUIElementPair: (id)aLabel control: (id) aControl;
- (void)hideUIElementPair: (id)aLabel control: (id) aControl;
- (void)commitChanges:(id)sender;
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom;
@end;
@implementation BookmarkInfoController
-(id) init
{
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self;
}
@ -50,126 +59,120 @@
return [self init];
}
-(void)windowDidLoad
-(void)dealloc
{
[mFieldEditor release];
[super dealloc];
}
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
{
[self commitChanges:[aNotification object]];
[[mFieldEditor undoManager] removeAllActions];
}
-(void)windowDidResignKey:(NSNotification*) aNotification
{
[self commitChanges:nil];
}
// if changedField is nil, commit everything
- (void)commitChanges:(id)changedField
{
if (![mBookmarkItem contentNode])
return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name
len = [[mNameField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
if (!changedField || changedField == mNameField)
[self commitField:mNameField toProperty:BookmarksService::gNameAtom];
// Location
len = [[mLocationField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
if (!changedField || changedField == mLocationField)
[self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
// Keyword
len = [[mKeywordField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
if (!changedField || changedField == mKeywordField)
[self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
// Description
len = [[mDescriptionField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
if (!changedField || changedField == mDescriptionField)
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
}
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom
{
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// we really need a category on NSString for this
len = [[textField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[textField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, propertyAtom, buf, PR_TRUE);
}
-(void)setBookmark: (BookmarkItem*) aBookmark
{
if (aBookmark) {
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// See bug 154081 - don't show this window if Bookmark doesn't exist
// after fix - this should never happen unless disaster strikes.
if (![aBookmark contentNode])
return;
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
mBookmarkItem = aBookmark;
}
@ -198,4 +201,10 @@
}
}
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end

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

@ -55,6 +55,8 @@ class BookmarksService;
IBOutlet id mOutlineView;
IBOutlet id mBrowserWindowController;
IBOutlet id mEditBookmarkButton;
IBOutlet id mDeleteBookmarkButton;
NSString* mCachedHref;

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

@ -349,6 +349,9 @@
if (index >= total)
index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO];
// lame, but makes sure we catch all delete events in Info Panel
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSOutlineViewSelectionDidChangeNotification" object:mOutlineView];
}
-(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
}
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{
int index = [mOutlineView selectedRow];
if (index == -1) {
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:NULL];
[mEditBookmarkButton setEnabled:NO];
[mDeleteBookmarkButton setEnabled:NO];
}
else {
BookmarkItem* item = [mOutlineView itemAtRow:index];
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:item];
[mEditBookmarkButton setEnabled:YES];
[mDeleteBookmarkButton setEnabled:YES];
if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
}
}

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import <AppKit/AppKit.h>
#import "BookmarksService.h"
@ -34,6 +35,7 @@
IBOutlet NSTextField* mDescriptionLabel;
BookmarkItem* mBookmarkItem;
NSTextView* mFieldEditor;
NSOutlineView* mOutlineView;
}
@ -42,7 +44,5 @@
-(void)setBookmark:(BookmarkItem*)aBookmark;
-(void)showUIElementPair: (id)aLabel control: (id) aControl;
-(void)hideUIElementPair: (id)aLabel control: (id) aControl;
@end

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h"
#include "nsINamespaceManager.h"
@interface BookmarkInfoController(Private)
- (void)showUIElementPair: (id)aLabel control: (id) aControl;
- (void)hideUIElementPair: (id)aLabel control: (id) aControl;
- (void)commitChanges:(id)sender;
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom;
@end;
@implementation BookmarkInfoController
-(id) init
{
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self;
}
@ -50,126 +59,120 @@
return [self init];
}
-(void)windowDidLoad
-(void)dealloc
{
[mFieldEditor release];
[super dealloc];
}
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
{
[self commitChanges:[aNotification object]];
[[mFieldEditor undoManager] removeAllActions];
}
-(void)windowDidResignKey:(NSNotification*) aNotification
{
[self commitChanges:nil];
}
// if changedField is nil, commit everything
- (void)commitChanges:(id)changedField
{
if (![mBookmarkItem contentNode])
return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name
len = [[mNameField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
if (!changedField || changedField == mNameField)
[self commitField:mNameField toProperty:BookmarksService::gNameAtom];
// Location
len = [[mLocationField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
if (!changedField || changedField == mLocationField)
[self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
// Keyword
len = [[mKeywordField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
if (!changedField || changedField == mKeywordField)
[self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
// Description
len = [[mDescriptionField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
if (!changedField || changedField == mDescriptionField)
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
}
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom
{
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// we really need a category on NSString for this
len = [[textField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[textField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, propertyAtom, buf, PR_TRUE);
}
-(void)setBookmark: (BookmarkItem*) aBookmark
{
if (aBookmark) {
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// See bug 154081 - don't show this window if Bookmark doesn't exist
// after fix - this should never happen unless disaster strikes.
if (![aBookmark contentNode])
return;
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
mBookmarkItem = aBookmark;
}
@ -198,4 +201,10 @@
}
}
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end

4
chimera/BookmarkInfoPanel.nib/info.nib сгенерированный
Просмотреть файл

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
chimera/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

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

@ -55,6 +55,8 @@ class BookmarksService;
IBOutlet id mOutlineView;
IBOutlet id mBrowserWindowController;
IBOutlet id mEditBookmarkButton;
IBOutlet id mDeleteBookmarkButton;
NSString* mCachedHref;

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

@ -349,6 +349,9 @@
if (index >= total)
index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO];
// lame, but makes sure we catch all delete events in Info Panel
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSOutlineViewSelectionDidChangeNotification" object:mOutlineView];
}
-(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
}
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{
int index = [mOutlineView selectedRow];
if (index == -1) {
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:NULL];
[mEditBookmarkButton setEnabled:NO];
[mDeleteBookmarkButton setEnabled:NO];
}
else {
BookmarkItem* item = [mOutlineView itemAtRow:index];
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:item];
[mEditBookmarkButton setEnabled:YES];
[mDeleteBookmarkButton setEnabled:YES];
if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
}
}

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

@ -1006,6 +1006,7 @@
};
F50E1BA70207EB8201F281DF = {
children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = {
};
};
F5EA337802EF886D01A96654 = {
children = (
F5EA337902EF889001A96654,
F5EA337A02EF889001A96654,
F5EA337B02EF889001A96654,
F5EA337C02EF889001A96654,
F5EA337D02EF889001A96654,
F5EA337E02EF889001A96654,
);
isa = PBXGroup;
name = widget;
refType = 4;
};
F5EA337902EF889001A96654 = {
isa = PBXFileReference;
name = nsAppShellCocoa.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsAppShellCocoa.mm;
refType = 0;
};
F5EA337A02EF889001A96654 = {
isa = PBXFileReference;
name = nsChildView.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsChildView.mm;
refType = 0;
};
F5EA337B02EF889001A96654 = {
isa = PBXFileReference;
name = nsCocoaWindow.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsCocoaWindow.mm;
refType = 0;
};
F5EA337C02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragHelperService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragHelperService.cpp;
refType = 0;
};
F5EA337D02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragService.cpp;
refType = 0;
};
F5EA337E02EF889001A96654 = {
isa = PBXFileReference;
name = nsToolkit.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsToolkit.mm;
refType = 0;
};
F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference;
name = libwidget.rsrc;

4
chimera/English.lproj/BookmarkInfoPanel.nib/info.nib сгенерированный
Просмотреть файл

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
chimera/English.lproj/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичные данные
chimera/English.lproj/Localizable.strings

Двоичный файл не отображается.

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

@ -1006,6 +1006,7 @@
};
F50E1BA70207EB8201F281DF = {
children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = {
};
};
F5EA337802EF886D01A96654 = {
children = (
F5EA337902EF889001A96654,
F5EA337A02EF889001A96654,
F5EA337B02EF889001A96654,
F5EA337C02EF889001A96654,
F5EA337D02EF889001A96654,
F5EA337E02EF889001A96654,
);
isa = PBXGroup;
name = widget;
refType = 4;
};
F5EA337902EF889001A96654 = {
isa = PBXFileReference;
name = nsAppShellCocoa.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsAppShellCocoa.mm;
refType = 0;
};
F5EA337A02EF889001A96654 = {
isa = PBXFileReference;
name = nsChildView.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsChildView.mm;
refType = 0;
};
F5EA337B02EF889001A96654 = {
isa = PBXFileReference;
name = nsCocoaWindow.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsCocoaWindow.mm;
refType = 0;
};
F5EA337C02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragHelperService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragHelperService.cpp;
refType = 0;
};
F5EA337D02EF889001A96654 = {
isa = PBXFileReference;
name = nsDragService.cpp;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsDragService.cpp;
refType = 0;
};
F5EA337E02EF889001A96654 = {
isa = PBXFileReference;
name = nsToolkit.mm;
path = /Volumes/Development/Trees/Chimera/mozilla/widget/src/cocoa/nsToolkit.mm;
refType = 0;
};
F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference;
name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>158 201 366 258 0 0 1280 1002 </string>
<string>144 74 366 258 0 0 1280 1002 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S60</string>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
chimera/resources/localized/English.lproj/BookmarkInfoPanel.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичный файл не отображается.

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import <AppKit/AppKit.h>
#import "BookmarksService.h"
@ -34,6 +35,7 @@
IBOutlet NSTextField* mDescriptionLabel;
BookmarkItem* mBookmarkItem;
NSTextView* mFieldEditor;
NSOutlineView* mOutlineView;
}
@ -42,7 +44,5 @@
-(void)setBookmark:(BookmarkItem*)aBookmark;
-(void)showUIElementPair: (id)aLabel control: (id) aControl;
-(void)hideUIElementPair: (id)aLabel control: (id) aControl;
@end

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

@ -19,6 +19,7 @@
*
* Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/
#import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h"
#include "nsINamespaceManager.h"
@interface BookmarkInfoController(Private)
- (void)showUIElementPair: (id)aLabel control: (id) aControl;
- (void)hideUIElementPair: (id)aLabel control: (id) aControl;
- (void)commitChanges:(id)sender;
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom;
@end;
@implementation BookmarkInfoController
-(id) init
{
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self;
}
@ -50,126 +59,120 @@
return [self init];
}
-(void)windowDidLoad
-(void)dealloc
{
[mFieldEditor release];
[super dealloc];
}
-(void)controlTextDidEndEditing: (NSNotification*) aNotification
{
[self commitChanges:[aNotification object]];
[[mFieldEditor undoManager] removeAllActions];
}
-(void)windowDidResignKey:(NSNotification*) aNotification
{
[self commitChanges:nil];
}
// if changedField is nil, commit everything
- (void)commitChanges:(id)changedField
{
if (![mBookmarkItem contentNode])
return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name
len = [[mNameField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
if (!changedField || changedField == mNameField)
[self commitField:mNameField toProperty:BookmarksService::gNameAtom];
// Location
len = [[mLocationField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
if (!changedField || changedField == mLocationField)
[self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
// Keyword
len = [[mKeywordField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
if (!changedField || changedField == mKeywordField)
[self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
// Description
len = [[mDescriptionField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
if (!changedField || changedField == mDescriptionField)
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
}
- (void)commitField:(id)textField toProperty:(nsIAtom*)propertyAtom
{
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// we really need a category on NSString for this
len = [[textField stringValue] length];
buffer = new PRUnichar[len + 1];
if (!buffer) return;
[[textField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, propertyAtom, buf, PR_TRUE);
}
-(void)setBookmark: (BookmarkItem*) aBookmark
{
if (aBookmark) {
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// See bug 154081 - don't show this window if Bookmark doesn't exist
// after fix - this should never happen unless disaster strikes.
if (![aBookmark contentNode])
return;
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty();
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
// First, Show/Hide the appropriate UI
if (isGroup) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
else if (isFolder) {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
else {
[self showUIElementPair: mNameLabel control: mNameField];
[self showUIElementPair: mDescriptionLabel control: mDescriptionField];
[self showUIElementPair: mKeywordLabel control: mKeywordField];
[self showUIElementPair: mLocationLabel control: mLocationField];
}
// Then, fill with appropriate values from Bookmarks
nsAutoString value;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: infoForString];
if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
[mLocationField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
if (!isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, value);
[mKeywordField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
mBookmarkItem = aBookmark;
}
@ -198,4 +201,10 @@
}
}
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end

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

@ -55,6 +55,8 @@ class BookmarksService;
IBOutlet id mOutlineView;
IBOutlet id mBrowserWindowController;
IBOutlet id mEditBookmarkButton;
IBOutlet id mDeleteBookmarkButton;
NSString* mCachedHref;

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

@ -349,6 +349,9 @@
if (index >= total)
index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO];
// lame, but makes sure we catch all delete events in Info Panel
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSOutlineViewSelectionDidChangeNotification" object:mOutlineView];
}
-(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
}
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{
int index = [mOutlineView selectedRow];
if (index == -1) {
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:NULL];
[mEditBookmarkButton setEnabled:NO];
[mDeleteBookmarkButton setEnabled:NO];
}
else {
BookmarkItem* item = [mOutlineView itemAtRow:index];
if (mBookmarkInfoController)
[mBookmarkInfoController setBookmark:item];
[mEditBookmarkButton setEnabled:YES];
[mDeleteBookmarkButton setEnabled:YES];
if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
}
}