diff --git a/mozilla/camino/BrowserWindow.nib/classes.nib b/mozilla/camino/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/camino/BrowserWindow.nib/classes.nib +++ b/mozilla/camino/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/camino/BrowserWindow.nib/info.nib b/mozilla/camino/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/camino/BrowserWindow.nib/info.nib +++ b/mozilla/camino/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/camino/BrowserWindow.nib/objects.nib b/mozilla/camino/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/camino/BrowserWindow.nib/objects.nib and b/mozilla/camino/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/camino/BrowserWindowController.mm b/mozilla/camino/BrowserWindowController.mm index a9781ab23bb..a52c9f3ab5a 100644 --- a/mozilla/camino/BrowserWindowController.mm +++ b/mozilla/camino/BrowserWindowController.mm @@ -967,8 +967,10 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [panelsItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:3] view]]; #endif + // remove default tab from nib [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:0]]; + // insert the tabs we want [mSidebarTabView insertTabViewItem:bookItem atIndex:0]; [mSidebarTabView insertTabViewItem:histItem atIndex:1]; #if USE_SEARCH_ITEM @@ -978,6 +980,17 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [mSidebarTabView insertTabViewItem:panelsItem atIndex:3]; #endif + BOOL showHistory = NO; + nsCOMPtr pref(do_GetService("@mozilla.org/preferences-service;1")); + if (pref) { + PRBool historyPref = PR_FALSE; + if (NS_SUCCEEDED(pref->GetBoolPref("chimera.show_history", &historyPref))) + showHistory = historyPref ? YES : NO; + } + + if (!showHistory) + [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:1]]; + [mSidebarTabView selectFirstTabViewItem:self]; } diff --git a/mozilla/camino/CHHistoryDataSource.h b/mozilla/camino/CHHistoryDataSource.h index eb883d8340a..cad776e0291 100644 --- a/mozilla/camino/CHHistoryDataSource.h +++ b/mozilla/camino/CHHistoryDataSource.h @@ -10,8 +10,13 @@ #import "CHRDFOutlineViewDataSource.h" -@interface CHHistoryDataSource : CHRDFOutlineViewDataSource { +@interface CHHistoryDataSource : CHRDFOutlineViewDataSource +{ + + IBOutlet id mBrowserWindowController; } +-(IBAction)openHistoryItem: (id)aSender; + @end diff --git a/mozilla/camino/CHHistoryDataSource.mm b/mozilla/camino/CHHistoryDataSource.mm index 2edda3125a4..8682fc2ca47 100644 --- a/mozilla/camino/CHHistoryDataSource.mm +++ b/mozilla/camino/CHHistoryDataSource.mm @@ -7,11 +7,15 @@ // #import "CHHistoryDataSource.h" +#import "CHBrowserView.h" #include "nsIRDFService.h" #include "nsIRDFDataSource.h" #include "nsIRDFResource.h" +#include "nsXPIDLString.h" +#include "nsString.h" + #include "nsComponentManagerUtils.h" @implementation CHHistoryDataSource @@ -26,7 +30,123 @@ mRDFService->GetResource("NC:HistoryByDate", &mRootResource); [mOutlineView setTarget: self]; + [mOutlineView setDoubleAction: @selector(openHistoryItem:)]; + [mOutlineView reloadData]; } +- (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn + byItem: (id) aItem +{ + NSMutableAttributedString *cellValue = [[NSMutableAttributedString alloc] init]; + + if (!mDataSource || !aItem) + return nil; + + // The table column's identifier is the RDF Resource URI of the property being displayed in + // that column, e.g. "http://home.netscape.com/NC-rdf#Name" + NSString* columnPropertyURI = [aTableColumn identifier]; + + nsCOMPtr propertyResource; + mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([aItem resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return nil; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return nil; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + //Set cell's textual contents + [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]]; + + if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"]) + { + NSMutableAttributedString *attachmentAttrString = nil; + NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil]; + NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper]; + NSCell *attachmentAttrStringCell; + + //Create an attributed string to hold the empty attachment, then release the components. + attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain]; + [textAttachment release]; + [fileWrapper release]; + + //Get the cell of the text attachment. + attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute: + NSAttachmentAttributeName atIndex:0 effectiveRange:nil] attachmentCell]; + + if ([self outlineView:mOutlineView isItemExpandable:aItem]) { + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]]; + } + else + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]]; + + //Insert the image + [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString]; + + //Tweak the baseline to vertically center the text. + [cellValue addAttribute:NSBaselineOffsetAttributeName + value:[NSNumber numberWithFloat:-5.0] + range:NSMakeRange(0, 1)]; + } + + return cellValue; +} + +-(IBAction)openHistoryItem: (id)aSender +{ + int index = [mOutlineView selectedRow]; + if (index == -1) + return; + + id item = [mOutlineView itemAtRow: index]; + if (!item) + return; + + // expand if collapsed and double click + if ([mOutlineView isExpandable: item]) { + if ([mOutlineView isItemExpanded: item]) + [mOutlineView collapseItem: item]; + else + [mOutlineView expandItem: item]; + + return; + } + + // get uri + nsCOMPtr propertyResource; + mRDFService->GetResource("http://home.netscape.com/NC-rdf#URL", getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([item resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()]; + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone]; + // Focus and activate our content area. + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES]; +} + @end diff --git a/mozilla/camino/CHRDFOutlineViewDataSource.h b/mozilla/camino/CHRDFOutlineViewDataSource.h index 5d08e5d8df6..2d66e0ef490 100644 --- a/mozilla/camino/CHRDFOutlineViewDataSource.h +++ b/mozilla/camino/CHRDFOutlineViewDataSource.h @@ -50,9 +50,11 @@ class nsIRDFService; nsIRDFContainer* mContainer; nsIRDFContainerUtils* mContainerUtils; nsIRDFResource* mRootResource; - nsIRDFService* mRDFService; + nsIRDFService* mRDFService; IBOutlet id mOutlineView; + + NSMutableDictionary* mDictionary; } // Initialization Methods diff --git a/mozilla/camino/CHRDFOutlineViewDataSource.mm b/mozilla/camino/CHRDFOutlineViewDataSource.mm index 1cd6d5c8826..8eb331fa9f8 100644 --- a/mozilla/camino/CHRDFOutlineViewDataSource.mm +++ b/mozilla/camino/CHRDFOutlineViewDataSource.mm @@ -69,6 +69,8 @@ mDataSource = nsnull; mRootResource = nsnull; + + mDictionary = [[NSMutableDictionary alloc] initWithCapacity: 30]; } - (void) dealloc @@ -80,29 +82,35 @@ NS_IF_RELEASE(mDataSource); NS_IF_RELEASE(mRootResource); + [mDictionary release]; + [super dealloc]; } - (nsIRDFDataSource*) dataSource { + NS_IF_ADDREF(mDataSource); return mDataSource; } - (nsIRDFResource*) rootResource { + NS_IF_ADDREF(mRootResource); return mRootResource; } - (void) setDataSource: (nsIRDFDataSource*) aDataSource { - NS_IF_RELEASE(mDataSource); + nsIRDFDataSource* oldDataSource = mDataSource; NS_IF_ADDREF(mDataSource = aDataSource); + NS_IF_RELEASE(oldDataSource); } - (void) setRootResource: (nsIRDFResource*) aResource { - NS_IF_RELEASE(mRootResource); + nsIRDFResource* oldResource = mRootResource; NS_IF_ADDREF(mRootResource = aResource); + NS_IF_RELEASE(oldResource); } // @@ -123,7 +131,7 @@ if (!aItem) return YES; // The root is always open - nsCOMPtr itemResource = [aItem resource]; + nsCOMPtr itemResource = dont_AddRef([aItem resource]); PRBool isSeq = PR_FALSE; mContainerUtils->IsSeq(mDataSource, itemResource, &isSeq); @@ -145,7 +153,7 @@ if (!mDataSource) return nil; - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + nsCOMPtr resource = !aItem ? dont_AddRef([self rootResource]) : dont_AddRef([aItem resource]); nsCOMPtr ordinalResource; mContainerUtils->IndexToOrdinalResource(aIndex + 1, getter_AddRefs(ordinalResource)); @@ -159,55 +167,43 @@ if (childResource) return [self MakeWrapperFor:childResource]; } -#if 0 - else { + else + { // Oh well, not a regular container. We need to count, dagnabbit. nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); - NSLog(@"1"); nsCOMPtr childNodes; mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); - NSLog(@"2"); - PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - - PRInt32 count = 0; - - NSLog(@"3"); nsCOMPtr supp; - while (hasMore && count < aIndex) { + PRInt32 count = 0; + + PRBool hasMore = PR_FALSE; + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { childNodes->GetNext(getter_AddRefs(supp)); - - NSLog(@"4"); - ++count; - - childNodes->HasMoreElements(&hasMore); - NSLog(@"5"); + if (count == aIndex) + break; + count ++; } + nsCOMPtr childResource(do_QueryInterface(supp)); - NSLog(@"6"); if (childResource) { - NSLog(@"6.5"); - RDFOutlineViewItem* thing = [self MakeWrapperFor:childResource]; - - NSLog(@"thing = %@", thing); - return thing; + return [self MakeWrapperFor:childResource]; } } - NSLog(@"7"); -#endif + return nil; } - (int) outlineView: (NSOutlineView*) aOutlineView numberOfChildrenOfItem: (id) aItem; { if (!mDataSource) - return nil; - - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + return 0; + nsCOMPtr resource = dont_AddRef(aItem ? [aItem resource] : [self rootResource]); + // XXX just assume NC:child is the only containment arc for now nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); @@ -216,20 +212,16 @@ mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - PRInt32 count = 0; - - while (hasMore) { + + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { nsCOMPtr supp; childNodes->GetNext(getter_AddRefs(supp)); - - ++count; - - childNodes->HasMoreElements(&hasMore); + count ++; } - if (!count) { + if (count == 0) { nsresult rv = mContainer->Init(mDataSource, resource); if (NS_FAILED(rv)) return 0; @@ -243,27 +235,18 @@ - (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn byItem: (id) aItem { - NSLog(@"*** aItem = %@", aItem); if (!mDataSource || !aItem) return nil; - NSLog(@"1"); - // The table column's identifier is the RDF Resource URI of the property being displayed in // that column, e.g. "http://home.netscape.com/NC-rdf#Name" NSString* columnPropertyURI = [aTableColumn identifier]; - NSLog(@"2"); - nsCOMPtr propertyResource; mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); - - NSLog(@"3"); - - nsCOMPtr resource = [aItem resource]; - - NSLog(@"4"); - + + nsCOMPtr resource = dont_AddRef([aItem resource]); + nsCOMPtr valueNode; mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); if (!valueNode) { @@ -272,19 +255,13 @@ } nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); - nsXPIDLString str3; - valueLiteral->GetValue(getter_Copies(str3)); - nsCAutoString str2; str2.AssignWithConversion(str3); - NSLog(@"Value = %@", [NSString stringWithCString: str2.get()]); - if (!valueLiteral) return nil; nsXPIDLString literalValue; valueLiteral->GetValue(getter_Copies(literalValue)); - - nsCAutoString str; str.AssignWithConversion(literalValue); - return [NSString stringWithCString: str.get()]; + + return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]; } - (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject @@ -306,6 +283,11 @@ { RDFOutlineViewItem* item = [[[RDFOutlineViewItem alloc] init] autorelease]; [item setResource: aRDFResource]; + // keep a copy around + const char* resourceValue; + aRDFResource->GetValueConst(&resourceValue); + + [mDictionary setObject:item forKey:[NSString stringWithCString:resourceValue]]; return item; } @@ -314,14 +296,23 @@ @implementation RDFOutlineViewItem +- (void) dealloc +{ + NS_IF_RELEASE(mResource); + [super dealloc]; +} + - (nsIRDFResource*) resource { + NS_IF_ADDREF(mResource); return mResource; } - (void) setResource: (nsIRDFResource*) aResource { - mResource = aResource; + nsIRDFResource* oldResource = mResource; + NS_IF_ADDREF(mResource = aResource); + NS_IF_RELEASE(oldResource); } @end diff --git a/mozilla/camino/English.lproj/BrowserWindow.nib/classes.nib b/mozilla/camino/English.lproj/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/camino/English.lproj/BrowserWindow.nib/classes.nib +++ b/mozilla/camino/English.lproj/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/camino/English.lproj/BrowserWindow.nib/info.nib b/mozilla/camino/English.lproj/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/camino/English.lproj/BrowserWindow.nib/info.nib +++ b/mozilla/camino/English.lproj/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/camino/English.lproj/BrowserWindow.nib/objects.nib b/mozilla/camino/English.lproj/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/camino/English.lproj/BrowserWindow.nib/objects.nib and b/mozilla/camino/English.lproj/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/camino/FindDlgController.mm b/mozilla/camino/FindDlgController.mm index e3bea8ac6c5..7e4e0d0d182 100644 --- a/mozilla/camino/FindDlgController.mm +++ b/mozilla/camino/FindDlgController.mm @@ -40,6 +40,7 @@ #import "CHFind.h" #include "nsCOMPtr.h" + @implementation FindDlgController - (id)initWithWindowNibName:(NSString *)windowNibName diff --git a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/classes.nib b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/classes.nib +++ b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/info.nib b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/info.nib +++ b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib and b/mozilla/camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/camino/src/browser/BrowserWindowController.mm b/mozilla/camino/src/browser/BrowserWindowController.mm index a9781ab23bb..a52c9f3ab5a 100644 --- a/mozilla/camino/src/browser/BrowserWindowController.mm +++ b/mozilla/camino/src/browser/BrowserWindowController.mm @@ -967,8 +967,10 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [panelsItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:3] view]]; #endif + // remove default tab from nib [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:0]]; + // insert the tabs we want [mSidebarTabView insertTabViewItem:bookItem atIndex:0]; [mSidebarTabView insertTabViewItem:histItem atIndex:1]; #if USE_SEARCH_ITEM @@ -978,6 +980,17 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [mSidebarTabView insertTabViewItem:panelsItem atIndex:3]; #endif + BOOL showHistory = NO; + nsCOMPtr pref(do_GetService("@mozilla.org/preferences-service;1")); + if (pref) { + PRBool historyPref = PR_FALSE; + if (NS_SUCCEEDED(pref->GetBoolPref("chimera.show_history", &historyPref))) + showHistory = historyPref ? YES : NO; + } + + if (!showHistory) + [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:1]]; + [mSidebarTabView selectFirstTabViewItem:self]; } diff --git a/mozilla/camino/src/extensions/RDFOutlineViewDataSource.h b/mozilla/camino/src/extensions/RDFOutlineViewDataSource.h index 5d08e5d8df6..2d66e0ef490 100644 --- a/mozilla/camino/src/extensions/RDFOutlineViewDataSource.h +++ b/mozilla/camino/src/extensions/RDFOutlineViewDataSource.h @@ -50,9 +50,11 @@ class nsIRDFService; nsIRDFContainer* mContainer; nsIRDFContainerUtils* mContainerUtils; nsIRDFResource* mRootResource; - nsIRDFService* mRDFService; + nsIRDFService* mRDFService; IBOutlet id mOutlineView; + + NSMutableDictionary* mDictionary; } // Initialization Methods diff --git a/mozilla/camino/src/extensions/RDFOutlineViewDataSource.mm b/mozilla/camino/src/extensions/RDFOutlineViewDataSource.mm index 1cd6d5c8826..8eb331fa9f8 100644 --- a/mozilla/camino/src/extensions/RDFOutlineViewDataSource.mm +++ b/mozilla/camino/src/extensions/RDFOutlineViewDataSource.mm @@ -69,6 +69,8 @@ mDataSource = nsnull; mRootResource = nsnull; + + mDictionary = [[NSMutableDictionary alloc] initWithCapacity: 30]; } - (void) dealloc @@ -80,29 +82,35 @@ NS_IF_RELEASE(mDataSource); NS_IF_RELEASE(mRootResource); + [mDictionary release]; + [super dealloc]; } - (nsIRDFDataSource*) dataSource { + NS_IF_ADDREF(mDataSource); return mDataSource; } - (nsIRDFResource*) rootResource { + NS_IF_ADDREF(mRootResource); return mRootResource; } - (void) setDataSource: (nsIRDFDataSource*) aDataSource { - NS_IF_RELEASE(mDataSource); + nsIRDFDataSource* oldDataSource = mDataSource; NS_IF_ADDREF(mDataSource = aDataSource); + NS_IF_RELEASE(oldDataSource); } - (void) setRootResource: (nsIRDFResource*) aResource { - NS_IF_RELEASE(mRootResource); + nsIRDFResource* oldResource = mRootResource; NS_IF_ADDREF(mRootResource = aResource); + NS_IF_RELEASE(oldResource); } // @@ -123,7 +131,7 @@ if (!aItem) return YES; // The root is always open - nsCOMPtr itemResource = [aItem resource]; + nsCOMPtr itemResource = dont_AddRef([aItem resource]); PRBool isSeq = PR_FALSE; mContainerUtils->IsSeq(mDataSource, itemResource, &isSeq); @@ -145,7 +153,7 @@ if (!mDataSource) return nil; - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + nsCOMPtr resource = !aItem ? dont_AddRef([self rootResource]) : dont_AddRef([aItem resource]); nsCOMPtr ordinalResource; mContainerUtils->IndexToOrdinalResource(aIndex + 1, getter_AddRefs(ordinalResource)); @@ -159,55 +167,43 @@ if (childResource) return [self MakeWrapperFor:childResource]; } -#if 0 - else { + else + { // Oh well, not a regular container. We need to count, dagnabbit. nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); - NSLog(@"1"); nsCOMPtr childNodes; mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); - NSLog(@"2"); - PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - - PRInt32 count = 0; - - NSLog(@"3"); nsCOMPtr supp; - while (hasMore && count < aIndex) { + PRInt32 count = 0; + + PRBool hasMore = PR_FALSE; + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { childNodes->GetNext(getter_AddRefs(supp)); - - NSLog(@"4"); - ++count; - - childNodes->HasMoreElements(&hasMore); - NSLog(@"5"); + if (count == aIndex) + break; + count ++; } + nsCOMPtr childResource(do_QueryInterface(supp)); - NSLog(@"6"); if (childResource) { - NSLog(@"6.5"); - RDFOutlineViewItem* thing = [self MakeWrapperFor:childResource]; - - NSLog(@"thing = %@", thing); - return thing; + return [self MakeWrapperFor:childResource]; } } - NSLog(@"7"); -#endif + return nil; } - (int) outlineView: (NSOutlineView*) aOutlineView numberOfChildrenOfItem: (id) aItem; { if (!mDataSource) - return nil; - - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + return 0; + nsCOMPtr resource = dont_AddRef(aItem ? [aItem resource] : [self rootResource]); + // XXX just assume NC:child is the only containment arc for now nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); @@ -216,20 +212,16 @@ mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - PRInt32 count = 0; - - while (hasMore) { + + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { nsCOMPtr supp; childNodes->GetNext(getter_AddRefs(supp)); - - ++count; - - childNodes->HasMoreElements(&hasMore); + count ++; } - if (!count) { + if (count == 0) { nsresult rv = mContainer->Init(mDataSource, resource); if (NS_FAILED(rv)) return 0; @@ -243,27 +235,18 @@ - (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn byItem: (id) aItem { - NSLog(@"*** aItem = %@", aItem); if (!mDataSource || !aItem) return nil; - NSLog(@"1"); - // The table column's identifier is the RDF Resource URI of the property being displayed in // that column, e.g. "http://home.netscape.com/NC-rdf#Name" NSString* columnPropertyURI = [aTableColumn identifier]; - NSLog(@"2"); - nsCOMPtr propertyResource; mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); - - NSLog(@"3"); - - nsCOMPtr resource = [aItem resource]; - - NSLog(@"4"); - + + nsCOMPtr resource = dont_AddRef([aItem resource]); + nsCOMPtr valueNode; mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); if (!valueNode) { @@ -272,19 +255,13 @@ } nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); - nsXPIDLString str3; - valueLiteral->GetValue(getter_Copies(str3)); - nsCAutoString str2; str2.AssignWithConversion(str3); - NSLog(@"Value = %@", [NSString stringWithCString: str2.get()]); - if (!valueLiteral) return nil; nsXPIDLString literalValue; valueLiteral->GetValue(getter_Copies(literalValue)); - - nsCAutoString str; str.AssignWithConversion(literalValue); - return [NSString stringWithCString: str.get()]; + + return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]; } - (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject @@ -306,6 +283,11 @@ { RDFOutlineViewItem* item = [[[RDFOutlineViewItem alloc] init] autorelease]; [item setResource: aRDFResource]; + // keep a copy around + const char* resourceValue; + aRDFResource->GetValueConst(&resourceValue); + + [mDictionary setObject:item forKey:[NSString stringWithCString:resourceValue]]; return item; } @@ -314,14 +296,23 @@ @implementation RDFOutlineViewItem +- (void) dealloc +{ + NS_IF_RELEASE(mResource); + [super dealloc]; +} + - (nsIRDFResource*) resource { + NS_IF_ADDREF(mResource); return mResource; } - (void) setResource: (nsIRDFResource*) aResource { - mResource = aResource; + nsIRDFResource* oldResource = mResource; + NS_IF_ADDREF(mResource = aResource); + NS_IF_RELEASE(oldResource); } @end diff --git a/mozilla/camino/src/find/FindDlgController.mm b/mozilla/camino/src/find/FindDlgController.mm index e3bea8ac6c5..7e4e0d0d182 100644 --- a/mozilla/camino/src/find/FindDlgController.mm +++ b/mozilla/camino/src/find/FindDlgController.mm @@ -40,6 +40,7 @@ #import "CHFind.h" #include "nsCOMPtr.h" + @implementation FindDlgController - (id)initWithWindowNibName:(NSString *)windowNibName diff --git a/mozilla/camino/src/history/HistoryDataSource.h b/mozilla/camino/src/history/HistoryDataSource.h index eb883d8340a..cad776e0291 100644 --- a/mozilla/camino/src/history/HistoryDataSource.h +++ b/mozilla/camino/src/history/HistoryDataSource.h @@ -10,8 +10,13 @@ #import "CHRDFOutlineViewDataSource.h" -@interface CHHistoryDataSource : CHRDFOutlineViewDataSource { +@interface CHHistoryDataSource : CHRDFOutlineViewDataSource +{ + + IBOutlet id mBrowserWindowController; } +-(IBAction)openHistoryItem: (id)aSender; + @end diff --git a/mozilla/camino/src/history/HistoryDataSource.mm b/mozilla/camino/src/history/HistoryDataSource.mm index 2edda3125a4..8682fc2ca47 100644 --- a/mozilla/camino/src/history/HistoryDataSource.mm +++ b/mozilla/camino/src/history/HistoryDataSource.mm @@ -7,11 +7,15 @@ // #import "CHHistoryDataSource.h" +#import "CHBrowserView.h" #include "nsIRDFService.h" #include "nsIRDFDataSource.h" #include "nsIRDFResource.h" +#include "nsXPIDLString.h" +#include "nsString.h" + #include "nsComponentManagerUtils.h" @implementation CHHistoryDataSource @@ -26,7 +30,123 @@ mRDFService->GetResource("NC:HistoryByDate", &mRootResource); [mOutlineView setTarget: self]; + [mOutlineView setDoubleAction: @selector(openHistoryItem:)]; + [mOutlineView reloadData]; } +- (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn + byItem: (id) aItem +{ + NSMutableAttributedString *cellValue = [[NSMutableAttributedString alloc] init]; + + if (!mDataSource || !aItem) + return nil; + + // The table column's identifier is the RDF Resource URI of the property being displayed in + // that column, e.g. "http://home.netscape.com/NC-rdf#Name" + NSString* columnPropertyURI = [aTableColumn identifier]; + + nsCOMPtr propertyResource; + mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([aItem resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return nil; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return nil; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + //Set cell's textual contents + [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]]; + + if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"]) + { + NSMutableAttributedString *attachmentAttrString = nil; + NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil]; + NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper]; + NSCell *attachmentAttrStringCell; + + //Create an attributed string to hold the empty attachment, then release the components. + attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain]; + [textAttachment release]; + [fileWrapper release]; + + //Get the cell of the text attachment. + attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute: + NSAttachmentAttributeName atIndex:0 effectiveRange:nil] attachmentCell]; + + if ([self outlineView:mOutlineView isItemExpandable:aItem]) { + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]]; + } + else + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]]; + + //Insert the image + [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString]; + + //Tweak the baseline to vertically center the text. + [cellValue addAttribute:NSBaselineOffsetAttributeName + value:[NSNumber numberWithFloat:-5.0] + range:NSMakeRange(0, 1)]; + } + + return cellValue; +} + +-(IBAction)openHistoryItem: (id)aSender +{ + int index = [mOutlineView selectedRow]; + if (index == -1) + return; + + id item = [mOutlineView itemAtRow: index]; + if (!item) + return; + + // expand if collapsed and double click + if ([mOutlineView isExpandable: item]) { + if ([mOutlineView isItemExpanded: item]) + [mOutlineView collapseItem: item]; + else + [mOutlineView expandItem: item]; + + return; + } + + // get uri + nsCOMPtr propertyResource; + mRDFService->GetResource("http://home.netscape.com/NC-rdf#URL", getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([item resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()]; + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone]; + // Focus and activate our content area. + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES]; +} + @end diff --git a/mozilla/chimera/BrowserWindow.nib/classes.nib b/mozilla/chimera/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/chimera/BrowserWindow.nib/classes.nib +++ b/mozilla/chimera/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/chimera/BrowserWindow.nib/info.nib b/mozilla/chimera/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/chimera/BrowserWindow.nib/info.nib +++ b/mozilla/chimera/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/chimera/BrowserWindow.nib/objects.nib b/mozilla/chimera/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/chimera/BrowserWindow.nib/objects.nib and b/mozilla/chimera/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/chimera/BrowserWindowController.mm b/mozilla/chimera/BrowserWindowController.mm index a9781ab23bb..a52c9f3ab5a 100644 --- a/mozilla/chimera/BrowserWindowController.mm +++ b/mozilla/chimera/BrowserWindowController.mm @@ -967,8 +967,10 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [panelsItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:3] view]]; #endif + // remove default tab from nib [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:0]]; + // insert the tabs we want [mSidebarTabView insertTabViewItem:bookItem atIndex:0]; [mSidebarTabView insertTabViewItem:histItem atIndex:1]; #if USE_SEARCH_ITEM @@ -978,6 +980,17 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [mSidebarTabView insertTabViewItem:panelsItem atIndex:3]; #endif + BOOL showHistory = NO; + nsCOMPtr pref(do_GetService("@mozilla.org/preferences-service;1")); + if (pref) { + PRBool historyPref = PR_FALSE; + if (NS_SUCCEEDED(pref->GetBoolPref("chimera.show_history", &historyPref))) + showHistory = historyPref ? YES : NO; + } + + if (!showHistory) + [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:1]]; + [mSidebarTabView selectFirstTabViewItem:self]; } diff --git a/mozilla/chimera/CHHistoryDataSource.h b/mozilla/chimera/CHHistoryDataSource.h index eb883d8340a..cad776e0291 100644 --- a/mozilla/chimera/CHHistoryDataSource.h +++ b/mozilla/chimera/CHHistoryDataSource.h @@ -10,8 +10,13 @@ #import "CHRDFOutlineViewDataSource.h" -@interface CHHistoryDataSource : CHRDFOutlineViewDataSource { +@interface CHHistoryDataSource : CHRDFOutlineViewDataSource +{ + + IBOutlet id mBrowserWindowController; } +-(IBAction)openHistoryItem: (id)aSender; + @end diff --git a/mozilla/chimera/CHHistoryDataSource.mm b/mozilla/chimera/CHHistoryDataSource.mm index 2edda3125a4..8682fc2ca47 100644 --- a/mozilla/chimera/CHHistoryDataSource.mm +++ b/mozilla/chimera/CHHistoryDataSource.mm @@ -7,11 +7,15 @@ // #import "CHHistoryDataSource.h" +#import "CHBrowserView.h" #include "nsIRDFService.h" #include "nsIRDFDataSource.h" #include "nsIRDFResource.h" +#include "nsXPIDLString.h" +#include "nsString.h" + #include "nsComponentManagerUtils.h" @implementation CHHistoryDataSource @@ -26,7 +30,123 @@ mRDFService->GetResource("NC:HistoryByDate", &mRootResource); [mOutlineView setTarget: self]; + [mOutlineView setDoubleAction: @selector(openHistoryItem:)]; + [mOutlineView reloadData]; } +- (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn + byItem: (id) aItem +{ + NSMutableAttributedString *cellValue = [[NSMutableAttributedString alloc] init]; + + if (!mDataSource || !aItem) + return nil; + + // The table column's identifier is the RDF Resource URI of the property being displayed in + // that column, e.g. "http://home.netscape.com/NC-rdf#Name" + NSString* columnPropertyURI = [aTableColumn identifier]; + + nsCOMPtr propertyResource; + mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([aItem resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return nil; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return nil; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + //Set cell's textual contents + [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]]; + + if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"]) + { + NSMutableAttributedString *attachmentAttrString = nil; + NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil]; + NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper]; + NSCell *attachmentAttrStringCell; + + //Create an attributed string to hold the empty attachment, then release the components. + attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain]; + [textAttachment release]; + [fileWrapper release]; + + //Get the cell of the text attachment. + attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute: + NSAttachmentAttributeName atIndex:0 effectiveRange:nil] attachmentCell]; + + if ([self outlineView:mOutlineView isItemExpandable:aItem]) { + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]]; + } + else + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]]; + + //Insert the image + [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString]; + + //Tweak the baseline to vertically center the text. + [cellValue addAttribute:NSBaselineOffsetAttributeName + value:[NSNumber numberWithFloat:-5.0] + range:NSMakeRange(0, 1)]; + } + + return cellValue; +} + +-(IBAction)openHistoryItem: (id)aSender +{ + int index = [mOutlineView selectedRow]; + if (index == -1) + return; + + id item = [mOutlineView itemAtRow: index]; + if (!item) + return; + + // expand if collapsed and double click + if ([mOutlineView isExpandable: item]) { + if ([mOutlineView isItemExpanded: item]) + [mOutlineView collapseItem: item]; + else + [mOutlineView expandItem: item]; + + return; + } + + // get uri + nsCOMPtr propertyResource; + mRDFService->GetResource("http://home.netscape.com/NC-rdf#URL", getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([item resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()]; + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone]; + // Focus and activate our content area. + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES]; +} + @end diff --git a/mozilla/chimera/CHRDFOutlineViewDataSource.h b/mozilla/chimera/CHRDFOutlineViewDataSource.h index 5d08e5d8df6..2d66e0ef490 100644 --- a/mozilla/chimera/CHRDFOutlineViewDataSource.h +++ b/mozilla/chimera/CHRDFOutlineViewDataSource.h @@ -50,9 +50,11 @@ class nsIRDFService; nsIRDFContainer* mContainer; nsIRDFContainerUtils* mContainerUtils; nsIRDFResource* mRootResource; - nsIRDFService* mRDFService; + nsIRDFService* mRDFService; IBOutlet id mOutlineView; + + NSMutableDictionary* mDictionary; } // Initialization Methods diff --git a/mozilla/chimera/CHRDFOutlineViewDataSource.mm b/mozilla/chimera/CHRDFOutlineViewDataSource.mm index 1cd6d5c8826..8eb331fa9f8 100644 --- a/mozilla/chimera/CHRDFOutlineViewDataSource.mm +++ b/mozilla/chimera/CHRDFOutlineViewDataSource.mm @@ -69,6 +69,8 @@ mDataSource = nsnull; mRootResource = nsnull; + + mDictionary = [[NSMutableDictionary alloc] initWithCapacity: 30]; } - (void) dealloc @@ -80,29 +82,35 @@ NS_IF_RELEASE(mDataSource); NS_IF_RELEASE(mRootResource); + [mDictionary release]; + [super dealloc]; } - (nsIRDFDataSource*) dataSource { + NS_IF_ADDREF(mDataSource); return mDataSource; } - (nsIRDFResource*) rootResource { + NS_IF_ADDREF(mRootResource); return mRootResource; } - (void) setDataSource: (nsIRDFDataSource*) aDataSource { - NS_IF_RELEASE(mDataSource); + nsIRDFDataSource* oldDataSource = mDataSource; NS_IF_ADDREF(mDataSource = aDataSource); + NS_IF_RELEASE(oldDataSource); } - (void) setRootResource: (nsIRDFResource*) aResource { - NS_IF_RELEASE(mRootResource); + nsIRDFResource* oldResource = mRootResource; NS_IF_ADDREF(mRootResource = aResource); + NS_IF_RELEASE(oldResource); } // @@ -123,7 +131,7 @@ if (!aItem) return YES; // The root is always open - nsCOMPtr itemResource = [aItem resource]; + nsCOMPtr itemResource = dont_AddRef([aItem resource]); PRBool isSeq = PR_FALSE; mContainerUtils->IsSeq(mDataSource, itemResource, &isSeq); @@ -145,7 +153,7 @@ if (!mDataSource) return nil; - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + nsCOMPtr resource = !aItem ? dont_AddRef([self rootResource]) : dont_AddRef([aItem resource]); nsCOMPtr ordinalResource; mContainerUtils->IndexToOrdinalResource(aIndex + 1, getter_AddRefs(ordinalResource)); @@ -159,55 +167,43 @@ if (childResource) return [self MakeWrapperFor:childResource]; } -#if 0 - else { + else + { // Oh well, not a regular container. We need to count, dagnabbit. nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); - NSLog(@"1"); nsCOMPtr childNodes; mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); - NSLog(@"2"); - PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - - PRInt32 count = 0; - - NSLog(@"3"); nsCOMPtr supp; - while (hasMore && count < aIndex) { + PRInt32 count = 0; + + PRBool hasMore = PR_FALSE; + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { childNodes->GetNext(getter_AddRefs(supp)); - - NSLog(@"4"); - ++count; - - childNodes->HasMoreElements(&hasMore); - NSLog(@"5"); + if (count == aIndex) + break; + count ++; } + nsCOMPtr childResource(do_QueryInterface(supp)); - NSLog(@"6"); if (childResource) { - NSLog(@"6.5"); - RDFOutlineViewItem* thing = [self MakeWrapperFor:childResource]; - - NSLog(@"thing = %@", thing); - return thing; + return [self MakeWrapperFor:childResource]; } } - NSLog(@"7"); -#endif + return nil; } - (int) outlineView: (NSOutlineView*) aOutlineView numberOfChildrenOfItem: (id) aItem; { if (!mDataSource) - return nil; - - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + return 0; + nsCOMPtr resource = dont_AddRef(aItem ? [aItem resource] : [self rootResource]); + // XXX just assume NC:child is the only containment arc for now nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); @@ -216,20 +212,16 @@ mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - PRInt32 count = 0; - - while (hasMore) { + + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { nsCOMPtr supp; childNodes->GetNext(getter_AddRefs(supp)); - - ++count; - - childNodes->HasMoreElements(&hasMore); + count ++; } - if (!count) { + if (count == 0) { nsresult rv = mContainer->Init(mDataSource, resource); if (NS_FAILED(rv)) return 0; @@ -243,27 +235,18 @@ - (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn byItem: (id) aItem { - NSLog(@"*** aItem = %@", aItem); if (!mDataSource || !aItem) return nil; - NSLog(@"1"); - // The table column's identifier is the RDF Resource URI of the property being displayed in // that column, e.g. "http://home.netscape.com/NC-rdf#Name" NSString* columnPropertyURI = [aTableColumn identifier]; - NSLog(@"2"); - nsCOMPtr propertyResource; mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); - - NSLog(@"3"); - - nsCOMPtr resource = [aItem resource]; - - NSLog(@"4"); - + + nsCOMPtr resource = dont_AddRef([aItem resource]); + nsCOMPtr valueNode; mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); if (!valueNode) { @@ -272,19 +255,13 @@ } nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); - nsXPIDLString str3; - valueLiteral->GetValue(getter_Copies(str3)); - nsCAutoString str2; str2.AssignWithConversion(str3); - NSLog(@"Value = %@", [NSString stringWithCString: str2.get()]); - if (!valueLiteral) return nil; nsXPIDLString literalValue; valueLiteral->GetValue(getter_Copies(literalValue)); - - nsCAutoString str; str.AssignWithConversion(literalValue); - return [NSString stringWithCString: str.get()]; + + return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]; } - (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject @@ -306,6 +283,11 @@ { RDFOutlineViewItem* item = [[[RDFOutlineViewItem alloc] init] autorelease]; [item setResource: aRDFResource]; + // keep a copy around + const char* resourceValue; + aRDFResource->GetValueConst(&resourceValue); + + [mDictionary setObject:item forKey:[NSString stringWithCString:resourceValue]]; return item; } @@ -314,14 +296,23 @@ @implementation RDFOutlineViewItem +- (void) dealloc +{ + NS_IF_RELEASE(mResource); + [super dealloc]; +} + - (nsIRDFResource*) resource { + NS_IF_ADDREF(mResource); return mResource; } - (void) setResource: (nsIRDFResource*) aResource { - mResource = aResource; + nsIRDFResource* oldResource = mResource; + NS_IF_ADDREF(mResource = aResource); + NS_IF_RELEASE(oldResource); } @end diff --git a/mozilla/chimera/English.lproj/BrowserWindow.nib/classes.nib b/mozilla/chimera/English.lproj/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/chimera/English.lproj/BrowserWindow.nib/classes.nib +++ b/mozilla/chimera/English.lproj/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/chimera/English.lproj/BrowserWindow.nib/info.nib b/mozilla/chimera/English.lproj/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/chimera/English.lproj/BrowserWindow.nib/info.nib +++ b/mozilla/chimera/English.lproj/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/chimera/English.lproj/BrowserWindow.nib/objects.nib b/mozilla/chimera/English.lproj/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/chimera/English.lproj/BrowserWindow.nib/objects.nib and b/mozilla/chimera/English.lproj/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/chimera/FindDlgController.mm b/mozilla/chimera/FindDlgController.mm index e3bea8ac6c5..7e4e0d0d182 100644 --- a/mozilla/chimera/FindDlgController.mm +++ b/mozilla/chimera/FindDlgController.mm @@ -40,6 +40,7 @@ #import "CHFind.h" #include "nsCOMPtr.h" + @implementation FindDlgController - (id)initWithWindowNibName:(NSString *)windowNibName diff --git a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/classes.nib b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/classes.nib index 97dfc30f872..97f22639098 100644 --- a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/classes.nib +++ b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/classes.nib @@ -112,6 +112,7 @@ { CLASS = CHHistoryDataSource; LANGUAGE = ObjC; + OUTLETS = {mBrowserWindowController = id; }; SUPERCLASS = CHRDFOutlineViewDataSource; }, {CLASS = CHLocationBar; LANGUAGE = ObjC; SUPERCLASS = NSView; }, diff --git a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/info.nib b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/info.nib index f7881c3a983..dcd5f099040 100644 --- a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/info.nib +++ b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/info.nib @@ -3,15 +3,15 @@ IBDocumentLocation - 41 39 480 309 0 0 1152 746 + 31 46 632 495 0 0 1280 1002 IBEditorPositions 124 305 659 170 144 0 0 1152 848 160 - 478 172 195 666 0 0 1152 848 + 523 326 195 666 0 0 1280 1002 28 - 478 351 195 457 0 0 1152 848 + 523 439 195 457 0 0 1280 1002 297 233 646 176 162 0 0 1152 848 314 @@ -41,6 +41,10 @@ 497 + IBOpenObjects + + 160 + IBSystem Version 5S66 diff --git a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib index df273de93a7..f8f0e7211a0 100644 Binary files a/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib and b/mozilla/chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib differ diff --git a/mozilla/chimera/src/browser/BrowserWindowController.mm b/mozilla/chimera/src/browser/BrowserWindowController.mm index a9781ab23bb..a52c9f3ab5a 100644 --- a/mozilla/chimera/src/browser/BrowserWindowController.mm +++ b/mozilla/chimera/src/browser/BrowserWindowController.mm @@ -967,8 +967,10 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [panelsItem setView:[[mSidebarSourceTabView tabViewItemAtIndex:3] view]]; #endif + // remove default tab from nib [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:0]]; + // insert the tabs we want [mSidebarTabView insertTabViewItem:bookItem atIndex:0]; [mSidebarTabView insertTabViewItem:histItem atIndex:1]; #if USE_SEARCH_ITEM @@ -978,6 +980,17 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item"; [mSidebarTabView insertTabViewItem:panelsItem atIndex:3]; #endif + BOOL showHistory = NO; + nsCOMPtr pref(do_GetService("@mozilla.org/preferences-service;1")); + if (pref) { + PRBool historyPref = PR_FALSE; + if (NS_SUCCEEDED(pref->GetBoolPref("chimera.show_history", &historyPref))) + showHistory = historyPref ? YES : NO; + } + + if (!showHistory) + [mSidebarTabView removeTabViewItem:[mSidebarTabView tabViewItemAtIndex:1]]; + [mSidebarTabView selectFirstTabViewItem:self]; } diff --git a/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.h b/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.h index 5d08e5d8df6..2d66e0ef490 100644 --- a/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.h +++ b/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.h @@ -50,9 +50,11 @@ class nsIRDFService; nsIRDFContainer* mContainer; nsIRDFContainerUtils* mContainerUtils; nsIRDFResource* mRootResource; - nsIRDFService* mRDFService; + nsIRDFService* mRDFService; IBOutlet id mOutlineView; + + NSMutableDictionary* mDictionary; } // Initialization Methods diff --git a/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.mm b/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.mm index 1cd6d5c8826..8eb331fa9f8 100644 --- a/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.mm +++ b/mozilla/chimera/src/extensions/RDFOutlineViewDataSource.mm @@ -69,6 +69,8 @@ mDataSource = nsnull; mRootResource = nsnull; + + mDictionary = [[NSMutableDictionary alloc] initWithCapacity: 30]; } - (void) dealloc @@ -80,29 +82,35 @@ NS_IF_RELEASE(mDataSource); NS_IF_RELEASE(mRootResource); + [mDictionary release]; + [super dealloc]; } - (nsIRDFDataSource*) dataSource { + NS_IF_ADDREF(mDataSource); return mDataSource; } - (nsIRDFResource*) rootResource { + NS_IF_ADDREF(mRootResource); return mRootResource; } - (void) setDataSource: (nsIRDFDataSource*) aDataSource { - NS_IF_RELEASE(mDataSource); + nsIRDFDataSource* oldDataSource = mDataSource; NS_IF_ADDREF(mDataSource = aDataSource); + NS_IF_RELEASE(oldDataSource); } - (void) setRootResource: (nsIRDFResource*) aResource { - NS_IF_RELEASE(mRootResource); + nsIRDFResource* oldResource = mRootResource; NS_IF_ADDREF(mRootResource = aResource); + NS_IF_RELEASE(oldResource); } // @@ -123,7 +131,7 @@ if (!aItem) return YES; // The root is always open - nsCOMPtr itemResource = [aItem resource]; + nsCOMPtr itemResource = dont_AddRef([aItem resource]); PRBool isSeq = PR_FALSE; mContainerUtils->IsSeq(mDataSource, itemResource, &isSeq); @@ -145,7 +153,7 @@ if (!mDataSource) return nil; - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + nsCOMPtr resource = !aItem ? dont_AddRef([self rootResource]) : dont_AddRef([aItem resource]); nsCOMPtr ordinalResource; mContainerUtils->IndexToOrdinalResource(aIndex + 1, getter_AddRefs(ordinalResource)); @@ -159,55 +167,43 @@ if (childResource) return [self MakeWrapperFor:childResource]; } -#if 0 - else { + else + { // Oh well, not a regular container. We need to count, dagnabbit. nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); - NSLog(@"1"); nsCOMPtr childNodes; mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); - NSLog(@"2"); - PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - - PRInt32 count = 0; - - NSLog(@"3"); nsCOMPtr supp; - while (hasMore && count < aIndex) { + PRInt32 count = 0; + + PRBool hasMore = PR_FALSE; + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { childNodes->GetNext(getter_AddRefs(supp)); - - NSLog(@"4"); - ++count; - - childNodes->HasMoreElements(&hasMore); - NSLog(@"5"); + if (count == aIndex) + break; + count ++; } + nsCOMPtr childResource(do_QueryInterface(supp)); - NSLog(@"6"); if (childResource) { - NSLog(@"6.5"); - RDFOutlineViewItem* thing = [self MakeWrapperFor:childResource]; - - NSLog(@"thing = %@", thing); - return thing; + return [self MakeWrapperFor:childResource]; } } - NSLog(@"7"); -#endif + return nil; } - (int) outlineView: (NSOutlineView*) aOutlineView numberOfChildrenOfItem: (id) aItem; { if (!mDataSource) - return nil; - - nsCOMPtr resource = !aItem ? mRootResource : [aItem resource]; + return 0; + nsCOMPtr resource = dont_AddRef(aItem ? [aItem resource] : [self rootResource]); + // XXX just assume NC:child is the only containment arc for now nsCOMPtr childProperty; mRDFService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(childProperty)); @@ -216,20 +212,16 @@ mDataSource->GetTargets(resource, childProperty, PR_TRUE, getter_AddRefs(childNodes)); PRBool hasMore = PR_FALSE; - childNodes->HasMoreElements(&hasMore); - PRInt32 count = 0; - - while (hasMore) { + + while (NS_SUCCEEDED(childNodes->HasMoreElements(&hasMore)) && hasMore) + { nsCOMPtr supp; childNodes->GetNext(getter_AddRefs(supp)); - - ++count; - - childNodes->HasMoreElements(&hasMore); + count ++; } - if (!count) { + if (count == 0) { nsresult rv = mContainer->Init(mDataSource, resource); if (NS_FAILED(rv)) return 0; @@ -243,27 +235,18 @@ - (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn byItem: (id) aItem { - NSLog(@"*** aItem = %@", aItem); if (!mDataSource || !aItem) return nil; - NSLog(@"1"); - // The table column's identifier is the RDF Resource URI of the property being displayed in // that column, e.g. "http://home.netscape.com/NC-rdf#Name" NSString* columnPropertyURI = [aTableColumn identifier]; - NSLog(@"2"); - nsCOMPtr propertyResource; mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); - - NSLog(@"3"); - - nsCOMPtr resource = [aItem resource]; - - NSLog(@"4"); - + + nsCOMPtr resource = dont_AddRef([aItem resource]); + nsCOMPtr valueNode; mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); if (!valueNode) { @@ -272,19 +255,13 @@ } nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); - nsXPIDLString str3; - valueLiteral->GetValue(getter_Copies(str3)); - nsCAutoString str2; str2.AssignWithConversion(str3); - NSLog(@"Value = %@", [NSString stringWithCString: str2.get()]); - if (!valueLiteral) return nil; nsXPIDLString literalValue; valueLiteral->GetValue(getter_Copies(literalValue)); - - nsCAutoString str; str.AssignWithConversion(literalValue); - return [NSString stringWithCString: str.get()]; + + return [NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]; } - (void) outlineView: (NSOutlineView*) aOutlineView setObjectValue: (id) aObject @@ -306,6 +283,11 @@ { RDFOutlineViewItem* item = [[[RDFOutlineViewItem alloc] init] autorelease]; [item setResource: aRDFResource]; + // keep a copy around + const char* resourceValue; + aRDFResource->GetValueConst(&resourceValue); + + [mDictionary setObject:item forKey:[NSString stringWithCString:resourceValue]]; return item; } @@ -314,14 +296,23 @@ @implementation RDFOutlineViewItem +- (void) dealloc +{ + NS_IF_RELEASE(mResource); + [super dealloc]; +} + - (nsIRDFResource*) resource { + NS_IF_ADDREF(mResource); return mResource; } - (void) setResource: (nsIRDFResource*) aResource { - mResource = aResource; + nsIRDFResource* oldResource = mResource; + NS_IF_ADDREF(mResource = aResource); + NS_IF_RELEASE(oldResource); } @end diff --git a/mozilla/chimera/src/find/FindDlgController.mm b/mozilla/chimera/src/find/FindDlgController.mm index e3bea8ac6c5..7e4e0d0d182 100644 --- a/mozilla/chimera/src/find/FindDlgController.mm +++ b/mozilla/chimera/src/find/FindDlgController.mm @@ -40,6 +40,7 @@ #import "CHFind.h" #include "nsCOMPtr.h" + @implementation FindDlgController - (id)initWithWindowNibName:(NSString *)windowNibName diff --git a/mozilla/chimera/src/history/HistoryDataSource.h b/mozilla/chimera/src/history/HistoryDataSource.h index eb883d8340a..cad776e0291 100644 --- a/mozilla/chimera/src/history/HistoryDataSource.h +++ b/mozilla/chimera/src/history/HistoryDataSource.h @@ -10,8 +10,13 @@ #import "CHRDFOutlineViewDataSource.h" -@interface CHHistoryDataSource : CHRDFOutlineViewDataSource { +@interface CHHistoryDataSource : CHRDFOutlineViewDataSource +{ + + IBOutlet id mBrowserWindowController; } +-(IBAction)openHistoryItem: (id)aSender; + @end diff --git a/mozilla/chimera/src/history/HistoryDataSource.mm b/mozilla/chimera/src/history/HistoryDataSource.mm index 2edda3125a4..8682fc2ca47 100644 --- a/mozilla/chimera/src/history/HistoryDataSource.mm +++ b/mozilla/chimera/src/history/HistoryDataSource.mm @@ -7,11 +7,15 @@ // #import "CHHistoryDataSource.h" +#import "CHBrowserView.h" #include "nsIRDFService.h" #include "nsIRDFDataSource.h" #include "nsIRDFResource.h" +#include "nsXPIDLString.h" +#include "nsString.h" + #include "nsComponentManagerUtils.h" @implementation CHHistoryDataSource @@ -26,7 +30,123 @@ mRDFService->GetResource("NC:HistoryByDate", &mRootResource); [mOutlineView setTarget: self]; + [mOutlineView setDoubleAction: @selector(openHistoryItem:)]; + [mOutlineView reloadData]; } +- (id) outlineView: (NSOutlineView*) aOutlineView objectValueForTableColumn: (NSTableColumn*) aTableColumn + byItem: (id) aItem +{ + NSMutableAttributedString *cellValue = [[NSMutableAttributedString alloc] init]; + + if (!mDataSource || !aItem) + return nil; + + // The table column's identifier is the RDF Resource URI of the property being displayed in + // that column, e.g. "http://home.netscape.com/NC-rdf#Name" + NSString* columnPropertyURI = [aTableColumn identifier]; + + nsCOMPtr propertyResource; + mRDFService->GetResource([columnPropertyURI cString], getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([aItem resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return nil; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return nil; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + //Set cell's textual contents + [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length]) withString:[NSString stringWithCharacters: literalValue.get() length:literalValue.Length()]]; + + if ([columnPropertyURI isEqualToString: @"http://home.netscape.com/NC-rdf#Name"]) + { + NSMutableAttributedString *attachmentAttrString = nil; + NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil]; + NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper]; + NSCell *attachmentAttrStringCell; + + //Create an attributed string to hold the empty attachment, then release the components. + attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain]; + [textAttachment release]; + [fileWrapper release]; + + //Get the cell of the text attachment. + attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute: + NSAttachmentAttributeName atIndex:0 effectiveRange:nil] attachmentCell]; + + if ([self outlineView:mOutlineView isItemExpandable:aItem]) { + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]]; + } + else + [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]]; + + //Insert the image + [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString]; + + //Tweak the baseline to vertically center the text. + [cellValue addAttribute:NSBaselineOffsetAttributeName + value:[NSNumber numberWithFloat:-5.0] + range:NSMakeRange(0, 1)]; + } + + return cellValue; +} + +-(IBAction)openHistoryItem: (id)aSender +{ + int index = [mOutlineView selectedRow]; + if (index == -1) + return; + + id item = [mOutlineView itemAtRow: index]; + if (!item) + return; + + // expand if collapsed and double click + if ([mOutlineView isExpandable: item]) { + if ([mOutlineView isItemExpanded: item]) + [mOutlineView collapseItem: item]; + else + [mOutlineView expandItem: item]; + + return; + } + + // get uri + nsCOMPtr propertyResource; + mRDFService->GetResource("http://home.netscape.com/NC-rdf#URL", getter_AddRefs(propertyResource)); + + nsCOMPtr resource = dont_AddRef([item resource]); + + nsCOMPtr valueNode; + mDataSource->GetTarget(resource, propertyResource, PR_TRUE, getter_AddRefs(valueNode)); + if (!valueNode) { + NSLog(@"ValueNode is null!"); + return; + } + + nsCOMPtr valueLiteral(do_QueryInterface(valueNode)); + if (!valueLiteral) + return; + + nsXPIDLString literalValue; + valueLiteral->GetValue(getter_Copies(literalValue)); + + NSString* url = [NSString stringWithCharacters: literalValue.get() length: literalValue.Length()]; + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] loadURI: url flags: NSLoadFlagsNone]; + // Focus and activate our content area. + [[[mBrowserWindowController getBrowserWrapper] getBrowserView] setActive: YES]; +} + @end