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

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

@ -19,6 +19,7 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author) * Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/ */
#import "BookmarkInfoController.h" #import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINamespaceManager.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 @implementation BookmarkInfoController
-(id) init -(id) init
{ {
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"]; [super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self; return self;
} }
@ -50,71 +59,74 @@
return [self init]; return [self init];
} }
-(void)windowDidLoad -(void)dealloc
{ {
[mFieldEditor release];
[super dealloc];
} }
-(void)controlTextDidEndEditing: (NSNotification*) aNotification -(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]) if (![mBookmarkItem contentNode])
return; return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name // Name
len = [[mNameField stringValue] length]; if (!changedField || changedField == mNameField)
buffer = new PRUnichar[len + 1]; [self commitField:mNameField toProperty:BookmarksService::gNameAtom];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
// Location // Location
len = [[mLocationField stringValue] length]; if (!changedField || changedField == mLocationField)
buffer = new PRUnichar[len + 1]; [self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
// Keyword // Keyword
len = [[mKeywordField stringValue] length]; if (!changedField || changedField == mKeywordField)
buffer = new PRUnichar[len + 1]; [self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
// Description // Description
len = [[mDescriptionField stringValue] length]; if (!changedField || changedField == mDescriptionField)
buffer = new PRUnichar[len + 1]; [self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO]; [mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE); 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 -(void)setBookmark: (BookmarkItem*) aBookmark
{ {
if (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;
nsAutoString group; nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty(); BOOL isGroup = !group.IsEmpty();
@ -146,8 +158,8 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()]; NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName]; [mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "]; NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]]; [[self window] setTitle: infoForString];
if (!isGroup && !isFolder) { if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
@ -161,15 +173,6 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]]; [mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
mBookmarkItem = aBookmark; mBookmarkItem = aBookmark;
} }
@ -198,4 +201,10 @@
} }
} }
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end @end

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

@ -349,6 +349,9 @@
if (index >= total) if (index >= total)
index = total - 1; index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO]; [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 -(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController) if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView]; mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index]; BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item]; [mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
} }
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification -(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{ {
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
if (index == -1) { if (index == -1) {
if (mBookmarkInfoController) [mEditBookmarkButton setEnabled:NO];
[mBookmarkInfoController setBookmark:NULL]; [mDeleteBookmarkButton setEnabled:NO];
} }
else { else {
BookmarkItem* item = [mOutlineView itemAtRow:index]; [mEditBookmarkButton setEnabled:YES];
if (mBookmarkInfoController) [mDeleteBookmarkButton setEnabled:YES];
[mBookmarkInfoController setBookmark:item]; if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
} }
} }

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

@ -1006,6 +1006,7 @@
}; };
F50E1BA70207EB8201F281DF = { F50E1BA70207EB8201F281DF = {
children = ( children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102, F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF, F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF, F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = { 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 = { F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference; isa = PBXFileReference;
name = libwidget.rsrc; name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

@ -1006,6 +1006,7 @@
}; };
F50E1BA70207EB8201F281DF = { F50E1BA70207EB8201F281DF = {
children = ( children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102, F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF, F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF, F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = { 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 = { F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference; isa = PBXFileReference;
name = libwidget.rsrc; name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

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

@ -19,6 +19,7 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author) * Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/ */
#import "BookmarkInfoController.h" #import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINamespaceManager.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 @implementation BookmarkInfoController
-(id) init -(id) init
{ {
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"]; [super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self; return self;
} }
@ -50,71 +59,74 @@
return [self init]; return [self init];
} }
-(void)windowDidLoad -(void)dealloc
{ {
[mFieldEditor release];
[super dealloc];
} }
-(void)controlTextDidEndEditing: (NSNotification*) aNotification -(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]) if (![mBookmarkItem contentNode])
return; return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name // Name
len = [[mNameField stringValue] length]; if (!changedField || changedField == mNameField)
buffer = new PRUnichar[len + 1]; [self commitField:mNameField toProperty:BookmarksService::gNameAtom];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
// Location // Location
len = [[mLocationField stringValue] length]; if (!changedField || changedField == mLocationField)
buffer = new PRUnichar[len + 1]; [self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
// Keyword // Keyword
len = [[mKeywordField stringValue] length]; if (!changedField || changedField == mKeywordField)
buffer = new PRUnichar[len + 1]; [self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
// Description // Description
len = [[mDescriptionField stringValue] length]; if (!changedField || changedField == mDescriptionField)
buffer = new PRUnichar[len + 1]; [self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO]; [mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE); 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 -(void)setBookmark: (BookmarkItem*) aBookmark
{ {
if (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;
nsAutoString group; nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty(); BOOL isGroup = !group.IsEmpty();
@ -146,8 +158,8 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()]; NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName]; [mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "]; NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]]; [[self window] setTitle: infoForString];
if (!isGroup && !isFolder) { if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
@ -161,15 +173,6 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]]; [mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
mBookmarkItem = aBookmark; mBookmarkItem = aBookmark;
} }
@ -198,4 +201,10 @@
} }
} }
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end @end

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

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

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

@ -349,6 +349,9 @@
if (index >= total) if (index >= total)
index = total - 1; index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO]; [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 -(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController) if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView]; mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index]; BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item]; [mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
} }
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification -(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{ {
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
if (index == -1) { if (index == -1) {
if (mBookmarkInfoController) [mEditBookmarkButton setEnabled:NO];
[mBookmarkInfoController setBookmark:NULL]; [mDeleteBookmarkButton setEnabled:NO];
} }
else { else {
BookmarkItem* item = [mOutlineView itemAtRow:index]; [mEditBookmarkButton setEnabled:YES];
if (mBookmarkInfoController) [mDeleteBookmarkButton setEnabled:YES];
[mBookmarkInfoController setBookmark:item]; if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
} }
} }

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

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

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

@ -19,6 +19,7 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author) * Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/ */
#import "BookmarkInfoController.h" #import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINamespaceManager.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 @implementation BookmarkInfoController
-(id) init -(id) init
{ {
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"]; [super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self; return self;
} }
@ -50,71 +59,74 @@
return [self init]; return [self init];
} }
-(void)windowDidLoad -(void)dealloc
{ {
[mFieldEditor release];
[super dealloc];
} }
-(void)controlTextDidEndEditing: (NSNotification*) aNotification -(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]) if (![mBookmarkItem contentNode])
return; return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name // Name
len = [[mNameField stringValue] length]; if (!changedField || changedField == mNameField)
buffer = new PRUnichar[len + 1]; [self commitField:mNameField toProperty:BookmarksService::gNameAtom];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
// Location // Location
len = [[mLocationField stringValue] length]; if (!changedField || changedField == mLocationField)
buffer = new PRUnichar[len + 1]; [self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
// Keyword // Keyword
len = [[mKeywordField stringValue] length]; if (!changedField || changedField == mKeywordField)
buffer = new PRUnichar[len + 1]; [self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
// Description // Description
len = [[mDescriptionField stringValue] length]; if (!changedField || changedField == mDescriptionField)
buffer = new PRUnichar[len + 1]; [self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO]; [mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE); 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 -(void)setBookmark: (BookmarkItem*) aBookmark
{ {
if (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;
nsAutoString group; nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty(); BOOL isGroup = !group.IsEmpty();
@ -146,8 +158,8 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()]; NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName]; [mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "]; NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]]; [[self window] setTitle: infoForString];
if (!isGroup && !isFolder) { if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
@ -161,15 +173,6 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]]; [mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
mBookmarkItem = aBookmark; mBookmarkItem = aBookmark;
} }
@ -198,4 +201,10 @@
} }
} }
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end @end

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

@ -349,6 +349,9 @@
if (index >= total) if (index >= total)
index = total - 1; index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO]; [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 -(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController) if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView]; mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index]; BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item]; [mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
} }
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification -(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{ {
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
if (index == -1) { if (index == -1) {
if (mBookmarkInfoController) [mEditBookmarkButton setEnabled:NO];
[mBookmarkInfoController setBookmark:NULL]; [mDeleteBookmarkButton setEnabled:NO];
} }
else { else {
BookmarkItem* item = [mOutlineView itemAtRow:index]; [mEditBookmarkButton setEnabled:YES];
if (mBookmarkInfoController) [mDeleteBookmarkButton setEnabled:YES];
[mBookmarkInfoController setBookmark:item]; if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
} }
} }

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

@ -1006,6 +1006,7 @@
}; };
F50E1BA70207EB8201F281DF = { F50E1BA70207EB8201F281DF = {
children = ( children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102, F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF, F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF, F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = { 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 = { F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference; isa = PBXFileReference;
name = libwidget.rsrc; name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

@ -1006,6 +1006,7 @@
}; };
F50E1BA70207EB8201F281DF = { F50E1BA70207EB8201F281DF = {
children = ( children = (
F5EA337802EF886D01A96654,
F5948A48029EB9C801000102, F5948A48029EB9C801000102,
F50E1BC90207F99201F281DF, F50E1BC90207F99201F281DF,
F50E1BBC0207F27B01F281DF, F50E1BBC0207F27B01F281DF,
@ -7333,6 +7334,55 @@
settings = { 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 = { F5F14E9602A5A43A01A967F3 = {
isa = PBXFileReference; isa = PBXFileReference;
name = libwidget.rsrc; name = libwidget.rsrc;

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

@ -3,10 +3,10 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>248.0</string> <string>248.0</string>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5S60</string> <string>5S66</string>
</dict> </dict>
</plist> </plist>

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

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

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

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

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

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

@ -19,6 +19,7 @@
* *
* Contributor(s): * Contributor(s):
* Ben Goodger <ben@netscape.com> (Original Author) * Ben Goodger <ben@netscape.com> (Original Author)
* David Haas <haasd@cae.wisc.edu>
*/ */
#import "BookmarkInfoController.h" #import "BookmarkInfoController.h"
@ -27,19 +28,27 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINamespaceManager.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 @implementation BookmarkInfoController
-(id) init -(id) init
{ {
#if 0
[mNameField setDelegate: self];
[mLocationField setDelegate: self];
[mKeywordField setDelegate: self];
[mDescriptionField setDelegate: self];
#endif
[super initWithWindowNibName:@"BookmarkInfoPanel"]; [super initWithWindowNibName:@"BookmarkInfoPanel"];
//custom field editor lets us undo our changes
mFieldEditor = [[NSTextView alloc] init];
[mFieldEditor setAllowsUndo:YES];
[mFieldEditor setFieldEditor:YES];
return self; return self;
} }
@ -50,71 +59,74 @@
return [self init]; return [self init];
} }
-(void)windowDidLoad -(void)dealloc
{ {
[mFieldEditor release];
[super dealloc];
} }
-(void)controlTextDidEndEditing: (NSNotification*) aNotification -(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]) if (![mBookmarkItem contentNode])
return; return;
unsigned int len;
PRUnichar* buffer;
nsXPIDLString buf;
// Name // Name
len = [[mNameField stringValue] length]; if (!changedField || changedField == mNameField)
buffer = new PRUnichar[len + 1]; [self commitField:mNameField toProperty:BookmarksService::gNameAtom];
if (!buffer) return;
[[mNameField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, buf, PR_TRUE);
// Location // Location
len = [[mLocationField stringValue] length]; if (!changedField || changedField == mLocationField)
buffer = new PRUnichar[len + 1]; [self commitField:mLocationField toProperty:BookmarksService::gHrefAtom];
if (!buffer) return;
[[mLocationField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, buf, PR_TRUE);
// Keyword // Keyword
len = [[mKeywordField stringValue] length]; if (!changedField || changedField == mKeywordField)
buffer = new PRUnichar[len + 1]; [self commitField:mKeywordField toProperty:BookmarksService::gKeywordAtom];
if (!buffer) return;
[[mKeywordField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gKeywordAtom, buf, PR_TRUE);
// Description // Description
len = [[mDescriptionField stringValue] length]; if (!changedField || changedField == mDescriptionField)
buffer = new PRUnichar[len + 1]; [self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
if (!buffer) return;
[[mDescriptionField stringValue] getCharacters:buffer];
buffer[len] = (PRUnichar)'\0';
buf.Adopt(buffer);
[mBookmarkItem contentNode]->SetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, buf, PR_TRUE);
[[mFieldEditor undoManager] removeAllActions];
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO]; [mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE); 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 -(void)setBookmark: (BookmarkItem*) aBookmark
{ {
if (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;
nsAutoString group; nsAutoString group;
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
BOOL isGroup = !group.IsEmpty(); BOOL isGroup = !group.IsEmpty();
@ -146,8 +158,8 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, value);
NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()]; NSString* bookmarkName = [NSString stringWithCharacters: value.get() length: value.Length()];
[mNameField setStringValue: bookmarkName]; [mNameField setStringValue: bookmarkName];
NSString* infoForString = [NSString stringWithCString: "Info for "]; NSString* infoForString = [NSString stringWithFormat:NSLocalizedString(@"BookmarkInfoTitle",@"Info for "), bookmarkName];
[[self window] setTitle: [infoForString stringByAppendingString: bookmarkName]]; [[self window] setTitle: infoForString];
if (!isGroup && !isFolder) { if (!isGroup && !isFolder) {
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
@ -161,15 +173,6 @@
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value); [aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
[mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]]; [mDescriptionField setStringValue: [NSString stringWithCharacters: value.get() length: value.Length()]];
}
else {
[[self window] setTitle: [NSString stringWithCString: "Bookmark Info"]];
[self hideUIElementPair: mNameLabel control: mNameField];
[self hideUIElementPair: mDescriptionLabel control: mDescriptionField];
[self hideUIElementPair: mKeywordLabel control: mKeywordField];
[self hideUIElementPair: mLocationLabel control: mLocationField];
}
mBookmarkItem = aBookmark; mBookmarkItem = aBookmark;
} }
@ -198,4 +201,10 @@
} }
} }
-(NSText *)windowWillReturnFieldEditor:(NSWindow *)aPanel toObject:(id)aObject
{
return mFieldEditor;
}
@end @end

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

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

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

@ -349,6 +349,9 @@
if (index >= total) if (index >= total)
index = total - 1; index = total - 1;
[mOutlineView selectRow: index byExtendingSelection: NO]; [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 -(void)deleteBookmark:(id)aItem
@ -720,24 +723,25 @@
if (!mBookmarkInfoController) if (!mBookmarkInfoController)
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView]; mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
BookmarkItem* item = [mOutlineView itemAtRow: index]; BookmarkItem* item = [mOutlineView itemAtRow: index];
[mBookmarkInfoController setBookmark:item]; [mBookmarkInfoController setBookmark:item];
[mBookmarkInfoController showWindow:mBookmarkInfoController];
} }
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification -(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{ {
int index = [mOutlineView selectedRow]; int index = [mOutlineView selectedRow];
if (index == -1) { if (index == -1) {
if (mBookmarkInfoController) [mEditBookmarkButton setEnabled:NO];
[mBookmarkInfoController setBookmark:NULL]; [mDeleteBookmarkButton setEnabled:NO];
} }
else { else {
BookmarkItem* item = [mOutlineView itemAtRow:index]; [mEditBookmarkButton setEnabled:YES];
if (mBookmarkInfoController) [mDeleteBookmarkButton setEnabled:YES];
[mBookmarkInfoController setBookmark:item]; if ([[mBookmarkInfoController window] isVisible])
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
} }
} }