зеркало из https://github.com/mozilla/gecko-dev.git
Separating the personal toolbar from the sidebar selection. Bookmarks info
controller is now a singleton that lives forever. Personal toolbar context menus do the right thing. (bug 148932).
This commit is contained in:
Родитель
31c5eb59fb
Коммит
f1e552a3ff
|
@ -36,11 +36,9 @@
|
|||
|
||||
BookmarkItem* mBookmarkItem;
|
||||
NSTextView* mFieldEditor;
|
||||
|
||||
NSOutlineView* mOutlineView;
|
||||
}
|
||||
|
||||
-(id)initWithOutlineView: (id)aOutlineView;
|
||||
+ (id)sharedBookmarkInfoController;
|
||||
|
||||
-(void)setBookmark:(BookmarkItem*)aBookmark;
|
||||
|
||||
|
|
|
@ -40,6 +40,18 @@
|
|||
|
||||
@implementation BookmarkInfoController
|
||||
|
||||
/* BookmarkInfoController singelton */
|
||||
static BookmarkInfoController *sharedBookmarkInfoController = nil;
|
||||
|
||||
+ (id)sharedBookmarkInfoController
|
||||
{
|
||||
if (!sharedBookmarkInfoController) {
|
||||
sharedBookmarkInfoController = [[BookmarkInfoController alloc] init];
|
||||
}
|
||||
|
||||
return sharedBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init
|
||||
{
|
||||
[super initWithWindowNibName:@"BookmarkInfoPanel"];
|
||||
|
@ -52,15 +64,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithOutlineView: (id)aOutlineView
|
||||
{
|
||||
mOutlineView = aOutlineView;
|
||||
|
||||
return [self init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
if (self == sharedBookmarkInfoController)
|
||||
sharedBookmarkInfoController = nil;
|
||||
|
||||
[mFieldEditor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -99,7 +107,6 @@
|
|||
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
|
||||
|
||||
[[mFieldEditor undoManager] removeAllActions];
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
|
@ -130,7 +137,7 @@
|
|||
nsAutoString group;
|
||||
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
|
||||
BOOL isFolder = !isGroup && [aBookmark isFolder];
|
||||
|
||||
// First, Show/Hide the appropriate UI
|
||||
if (isGroup) {
|
||||
|
|
|
@ -59,12 +59,9 @@ class BookmarksService;
|
|||
IBOutlet id mDeleteBookmarkButton;
|
||||
|
||||
NSString* mCachedHref;
|
||||
|
||||
BookmarkInfoController* mBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init;
|
||||
-(void) dealloc;
|
||||
-(void) windowClosing;
|
||||
|
||||
-(void) ensureBookmarks;
|
||||
|
@ -116,6 +113,7 @@ class BookmarksService;
|
|||
- (NSString*)url;
|
||||
- (NSNumber*)contentID;
|
||||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
- (BOOL)isFolder;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[mBookmarkInfoController release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void) windowClosing
|
||||
{
|
||||
if (mBookmarks) {
|
||||
|
@ -431,14 +425,14 @@
|
|||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (!item)
|
||||
mBookmarks->GetRootContent(getter_AddRefs(content));
|
||||
BookmarksService::GetRootContent(getter_AddRefs(content));
|
||||
else
|
||||
content = [item contentNode];
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
content->ChildAt(index, *getter_AddRefs(child));
|
||||
if ( child )
|
||||
return mBookmarks->GetWrapperFor(child);
|
||||
return BookmarksService::GetWrapperFor(child);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
@ -451,11 +445,7 @@
|
|||
if (!item)
|
||||
return YES; // The root node is always open.
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
nsIContent* content = [item contentNode];
|
||||
content->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
BOOL isExpandable = (tagName == BookmarksService::gFolderAtom);
|
||||
BOOL isExpandable = [item isFolder];
|
||||
|
||||
// XXXben - persistence of folder open state
|
||||
// I'm adding this code, turned off, until I can figure out how to refresh the NSOutlineView's
|
||||
|
@ -658,11 +648,50 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView tooltipStringForItem:(id)item
|
||||
{
|
||||
NSString* descStr = nil;
|
||||
NSString* hrefStr = nil;
|
||||
nsIContent* content = [item contentNode];
|
||||
nsAutoString value;
|
||||
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
|
||||
if (value.Length())
|
||||
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
// Only description for folders
|
||||
if ([item isFolder])
|
||||
return descStr;
|
||||
|
||||
// Extract the URL from the item
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
|
||||
if (value.Length())
|
||||
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
if (!hrefStr)
|
||||
return descStr;
|
||||
else if (!descStr)
|
||||
return hrefStr;
|
||||
|
||||
// Display both URL and description
|
||||
return [NSString stringWithFormat:@"%@\n%@", hrefStr, descStr];
|
||||
}
|
||||
|
||||
/*
|
||||
- (NSMenu *)outlineView:(NSOutlineView *)outlineView contextMenuForItem:(id)item
|
||||
{
|
||||
// TODO - return (custom?) context menu for item here.
|
||||
// Note that according to HIG, there should never be disabled items in
|
||||
// a context menu - instead, items that do not apply should be removed.
|
||||
// We could nicely do that here.
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren
|
||||
{
|
||||
if (!item)
|
||||
[mOutlineView reloadData];
|
||||
else if ([mOutlineView isItemExpanded: item])
|
||||
else
|
||||
[mOutlineView reloadItem: item reloadChildren: aReloadChildren];
|
||||
}
|
||||
|
||||
|
@ -696,6 +725,10 @@
|
|||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
@ -703,13 +736,16 @@
|
|||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
if (group.IsEmpty())
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,14 +757,13 @@
|
|||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
if (!mBookmarkInfoController)
|
||||
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
int index = [mOutlineView selectedRow];
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
[mBookmarkInfoController setBookmark:item];
|
||||
|
||||
[mBookmarkInfoController showWindow:mBookmarkInfoController];
|
||||
[bic setBookmark:item];
|
||||
|
||||
[bic showWindow:bic];
|
||||
}
|
||||
|
||||
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
|
||||
|
@ -739,10 +774,12 @@
|
|||
[mDeleteBookmarkButton setEnabled:NO];
|
||||
}
|
||||
else {
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[mEditBookmarkButton setEnabled:YES];
|
||||
[mDeleteBookmarkButton setEnabled:YES];
|
||||
if ([[mBookmarkInfoController window] isVisible])
|
||||
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
|
||||
if ([[bic window] isVisible])
|
||||
[bic setBookmark:[mOutlineView itemAtRow:index]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -828,5 +865,13 @@
|
|||
return copy;
|
||||
}
|
||||
|
||||
- (BOOL)isFolder
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
mContentNode->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
return (tagName == BookmarksService::gFolderAtom);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -176,9 +176,10 @@ BookmarksService::GetWrapperFor(nsIContent* aContent)
|
|||
return item;
|
||||
|
||||
// Create an item.
|
||||
item = [[[BookmarkItem alloc] init] autorelease]; // The dictionary retains us.
|
||||
item = [[BookmarkItem alloc] init]; // The dictionary retains us.
|
||||
[item setContentNode: aContent];
|
||||
[gDictionary setObject: item forKey: [NSNumber numberWithInt: contentID]];
|
||||
[item release];
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
#import <Appkit/Appkit.h>
|
||||
|
||||
class nsIDOMElement;
|
||||
@class BookmarkItem;
|
||||
|
||||
@interface CHBookmarksButton : NSButton {
|
||||
|
||||
nsIDOMElement* mElement;
|
||||
BookmarkItem* mBookmarkItem;
|
||||
BOOL mIsFolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINamespaceManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#import "BookmarkInfoController.h"
|
||||
#import "BookmarksDataSource.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
@implementation CHBookmarksButton
|
||||
|
@ -67,6 +73,73 @@
|
|||
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[[[self window] windowController] openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
if (group.IsEmpty())
|
||||
[[[self window] windowController] openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else
|
||||
[[[self window] windowController] openNewWindowWithGroup: mElement loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[bic showWindow:bic];
|
||||
[bic setBookmark:mBookmarkItem];
|
||||
}
|
||||
|
||||
-(IBAction)deleteBookmarks: (id)aSender
|
||||
{
|
||||
if (mElement == BookmarksService::gToolbarRoot)
|
||||
return; // Don't allow the personal toolbar to be deleted.
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
mElement->GetParentNode(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
if (parent)
|
||||
parent->RemoveChild(mElement, getter_AddRefs(dummy));
|
||||
BookmarksService::BookmarkRemoved(parentContent, content);
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
-(void)drawRect:(NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
|
@ -74,7 +147,36 @@
|
|||
|
||||
-(NSMenu*)menuForEvent:(NSEvent*)aEvent
|
||||
{
|
||||
return [[self superview] menu];
|
||||
// Make a copy of the context menu but change it to target us
|
||||
// FIXME - this will stop to work as soon as we add items to the context menu
|
||||
// that have different targets. In that case, we probably should add code to
|
||||
// CHBookmarksToolbar that manages the context menu for the CHBookmarksButtons.
|
||||
|
||||
NSMenu* myMenu = [[[self superview] menu] copy];
|
||||
[[myMenu itemArray] makeObjectsPerformSelector:@selector(setTarget:) withObject: self];
|
||||
[myMenu update];
|
||||
return [myMenu autorelease];
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
return NO;
|
||||
BOOL isBookmark = [mBookmarkItem isFolder] == NO;
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
|
||||
if (([aMenuItem action] == @selector(openBookmarkInNewWindow:))) {
|
||||
// Bookmarks and Bookmark Groups can be opened in a new window
|
||||
return (isBookmark || isGroup);
|
||||
}
|
||||
else if (([aMenuItem action] == @selector(openBookmarkInNewTab:))) {
|
||||
// Only Bookmarks can be opened in new tabs
|
||||
return isBookmark;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)mouseDown:(NSEvent*)aEvent
|
||||
|
@ -120,6 +222,9 @@
|
|||
nsAutoString name;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
[self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
mBookmarkItem = BookmarksService::GetWrapperFor(content);
|
||||
}
|
||||
|
||||
-(nsIDOMElement*)element
|
||||
|
|
|
@ -36,11 +36,9 @@
|
|||
|
||||
BookmarkItem* mBookmarkItem;
|
||||
NSTextView* mFieldEditor;
|
||||
|
||||
NSOutlineView* mOutlineView;
|
||||
}
|
||||
|
||||
-(id)initWithOutlineView: (id)aOutlineView;
|
||||
+ (id)sharedBookmarkInfoController;
|
||||
|
||||
-(void)setBookmark:(BookmarkItem*)aBookmark;
|
||||
|
||||
|
|
|
@ -40,6 +40,18 @@
|
|||
|
||||
@implementation BookmarkInfoController
|
||||
|
||||
/* BookmarkInfoController singelton */
|
||||
static BookmarkInfoController *sharedBookmarkInfoController = nil;
|
||||
|
||||
+ (id)sharedBookmarkInfoController
|
||||
{
|
||||
if (!sharedBookmarkInfoController) {
|
||||
sharedBookmarkInfoController = [[BookmarkInfoController alloc] init];
|
||||
}
|
||||
|
||||
return sharedBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init
|
||||
{
|
||||
[super initWithWindowNibName:@"BookmarkInfoPanel"];
|
||||
|
@ -52,15 +64,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithOutlineView: (id)aOutlineView
|
||||
{
|
||||
mOutlineView = aOutlineView;
|
||||
|
||||
return [self init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
if (self == sharedBookmarkInfoController)
|
||||
sharedBookmarkInfoController = nil;
|
||||
|
||||
[mFieldEditor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -99,7 +107,6 @@
|
|||
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
|
||||
|
||||
[[mFieldEditor undoManager] removeAllActions];
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
|
@ -130,7 +137,7 @@
|
|||
nsAutoString group;
|
||||
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
|
||||
BOOL isFolder = !isGroup && [aBookmark isFolder];
|
||||
|
||||
// First, Show/Hide the appropriate UI
|
||||
if (isGroup) {
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
#import <Appkit/Appkit.h>
|
||||
|
||||
class nsIDOMElement;
|
||||
@class BookmarkItem;
|
||||
|
||||
@interface CHBookmarksButton : NSButton {
|
||||
|
||||
nsIDOMElement* mElement;
|
||||
BookmarkItem* mBookmarkItem;
|
||||
BOOL mIsFolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINamespaceManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#import "BookmarkInfoController.h"
|
||||
#import "BookmarksDataSource.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
@implementation CHBookmarksButton
|
||||
|
@ -67,6 +73,73 @@
|
|||
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[[[self window] windowController] openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
if (group.IsEmpty())
|
||||
[[[self window] windowController] openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else
|
||||
[[[self window] windowController] openNewWindowWithGroup: mElement loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[bic showWindow:bic];
|
||||
[bic setBookmark:mBookmarkItem];
|
||||
}
|
||||
|
||||
-(IBAction)deleteBookmarks: (id)aSender
|
||||
{
|
||||
if (mElement == BookmarksService::gToolbarRoot)
|
||||
return; // Don't allow the personal toolbar to be deleted.
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
mElement->GetParentNode(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
if (parent)
|
||||
parent->RemoveChild(mElement, getter_AddRefs(dummy));
|
||||
BookmarksService::BookmarkRemoved(parentContent, content);
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
-(void)drawRect:(NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
|
@ -74,7 +147,36 @@
|
|||
|
||||
-(NSMenu*)menuForEvent:(NSEvent*)aEvent
|
||||
{
|
||||
return [[self superview] menu];
|
||||
// Make a copy of the context menu but change it to target us
|
||||
// FIXME - this will stop to work as soon as we add items to the context menu
|
||||
// that have different targets. In that case, we probably should add code to
|
||||
// CHBookmarksToolbar that manages the context menu for the CHBookmarksButtons.
|
||||
|
||||
NSMenu* myMenu = [[[self superview] menu] copy];
|
||||
[[myMenu itemArray] makeObjectsPerformSelector:@selector(setTarget:) withObject: self];
|
||||
[myMenu update];
|
||||
return [myMenu autorelease];
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
return NO;
|
||||
BOOL isBookmark = [mBookmarkItem isFolder] == NO;
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
|
||||
if (([aMenuItem action] == @selector(openBookmarkInNewWindow:))) {
|
||||
// Bookmarks and Bookmark Groups can be opened in a new window
|
||||
return (isBookmark || isGroup);
|
||||
}
|
||||
else if (([aMenuItem action] == @selector(openBookmarkInNewTab:))) {
|
||||
// Only Bookmarks can be opened in new tabs
|
||||
return isBookmark;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)mouseDown:(NSEvent*)aEvent
|
||||
|
@ -120,6 +222,9 @@
|
|||
nsAutoString name;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
[self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
mBookmarkItem = BookmarksService::GetWrapperFor(content);
|
||||
}
|
||||
|
||||
-(nsIDOMElement*)element
|
||||
|
|
|
@ -59,12 +59,9 @@ class BookmarksService;
|
|||
IBOutlet id mDeleteBookmarkButton;
|
||||
|
||||
NSString* mCachedHref;
|
||||
|
||||
BookmarkInfoController* mBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init;
|
||||
-(void) dealloc;
|
||||
-(void) windowClosing;
|
||||
|
||||
-(void) ensureBookmarks;
|
||||
|
@ -116,6 +113,7 @@ class BookmarksService;
|
|||
- (NSString*)url;
|
||||
- (NSNumber*)contentID;
|
||||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
- (BOOL)isFolder;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[mBookmarkInfoController release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void) windowClosing
|
||||
{
|
||||
if (mBookmarks) {
|
||||
|
@ -431,14 +425,14 @@
|
|||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (!item)
|
||||
mBookmarks->GetRootContent(getter_AddRefs(content));
|
||||
BookmarksService::GetRootContent(getter_AddRefs(content));
|
||||
else
|
||||
content = [item contentNode];
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
content->ChildAt(index, *getter_AddRefs(child));
|
||||
if ( child )
|
||||
return mBookmarks->GetWrapperFor(child);
|
||||
return BookmarksService::GetWrapperFor(child);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
@ -451,11 +445,7 @@
|
|||
if (!item)
|
||||
return YES; // The root node is always open.
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
nsIContent* content = [item contentNode];
|
||||
content->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
BOOL isExpandable = (tagName == BookmarksService::gFolderAtom);
|
||||
BOOL isExpandable = [item isFolder];
|
||||
|
||||
// XXXben - persistence of folder open state
|
||||
// I'm adding this code, turned off, until I can figure out how to refresh the NSOutlineView's
|
||||
|
@ -658,11 +648,50 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView tooltipStringForItem:(id)item
|
||||
{
|
||||
NSString* descStr = nil;
|
||||
NSString* hrefStr = nil;
|
||||
nsIContent* content = [item contentNode];
|
||||
nsAutoString value;
|
||||
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
|
||||
if (value.Length())
|
||||
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
// Only description for folders
|
||||
if ([item isFolder])
|
||||
return descStr;
|
||||
|
||||
// Extract the URL from the item
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
|
||||
if (value.Length())
|
||||
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
if (!hrefStr)
|
||||
return descStr;
|
||||
else if (!descStr)
|
||||
return hrefStr;
|
||||
|
||||
// Display both URL and description
|
||||
return [NSString stringWithFormat:@"%@\n%@", hrefStr, descStr];
|
||||
}
|
||||
|
||||
/*
|
||||
- (NSMenu *)outlineView:(NSOutlineView *)outlineView contextMenuForItem:(id)item
|
||||
{
|
||||
// TODO - return (custom?) context menu for item here.
|
||||
// Note that according to HIG, there should never be disabled items in
|
||||
// a context menu - instead, items that do not apply should be removed.
|
||||
// We could nicely do that here.
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren
|
||||
{
|
||||
if (!item)
|
||||
[mOutlineView reloadData];
|
||||
else if ([mOutlineView isItemExpanded: item])
|
||||
else
|
||||
[mOutlineView reloadItem: item reloadChildren: aReloadChildren];
|
||||
}
|
||||
|
||||
|
@ -696,6 +725,10 @@
|
|||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
@ -703,13 +736,16 @@
|
|||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
if (group.IsEmpty())
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,14 +757,13 @@
|
|||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
if (!mBookmarkInfoController)
|
||||
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
int index = [mOutlineView selectedRow];
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
[mBookmarkInfoController setBookmark:item];
|
||||
|
||||
[mBookmarkInfoController showWindow:mBookmarkInfoController];
|
||||
[bic setBookmark:item];
|
||||
|
||||
[bic showWindow:bic];
|
||||
}
|
||||
|
||||
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
|
||||
|
@ -739,10 +774,12 @@
|
|||
[mDeleteBookmarkButton setEnabled:NO];
|
||||
}
|
||||
else {
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[mEditBookmarkButton setEnabled:YES];
|
||||
[mDeleteBookmarkButton setEnabled:YES];
|
||||
if ([[mBookmarkInfoController window] isVisible])
|
||||
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
|
||||
if ([[bic window] isVisible])
|
||||
[bic setBookmark:[mOutlineView itemAtRow:index]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -828,5 +865,13 @@
|
|||
return copy;
|
||||
}
|
||||
|
||||
- (BOOL)isFolder
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
mContentNode->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
return (tagName == BookmarksService::gFolderAtom);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -176,9 +176,10 @@ BookmarksService::GetWrapperFor(nsIContent* aContent)
|
|||
return item;
|
||||
|
||||
// Create an item.
|
||||
item = [[[BookmarkItem alloc] init] autorelease]; // The dictionary retains us.
|
||||
item = [[BookmarkItem alloc] init]; // The dictionary retains us.
|
||||
[item setContentNode: aContent];
|
||||
[gDictionary setObject: item forKey: [NSNumber numberWithInt: contentID]];
|
||||
[item release];
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,9 @@
|
|||
|
||||
BookmarkItem* mBookmarkItem;
|
||||
NSTextView* mFieldEditor;
|
||||
|
||||
NSOutlineView* mOutlineView;
|
||||
}
|
||||
|
||||
-(id)initWithOutlineView: (id)aOutlineView;
|
||||
+ (id)sharedBookmarkInfoController;
|
||||
|
||||
-(void)setBookmark:(BookmarkItem*)aBookmark;
|
||||
|
||||
|
|
|
@ -40,6 +40,18 @@
|
|||
|
||||
@implementation BookmarkInfoController
|
||||
|
||||
/* BookmarkInfoController singelton */
|
||||
static BookmarkInfoController *sharedBookmarkInfoController = nil;
|
||||
|
||||
+ (id)sharedBookmarkInfoController
|
||||
{
|
||||
if (!sharedBookmarkInfoController) {
|
||||
sharedBookmarkInfoController = [[BookmarkInfoController alloc] init];
|
||||
}
|
||||
|
||||
return sharedBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init
|
||||
{
|
||||
[super initWithWindowNibName:@"BookmarkInfoPanel"];
|
||||
|
@ -52,15 +64,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithOutlineView: (id)aOutlineView
|
||||
{
|
||||
mOutlineView = aOutlineView;
|
||||
|
||||
return [self init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
if (self == sharedBookmarkInfoController)
|
||||
sharedBookmarkInfoController = nil;
|
||||
|
||||
[mFieldEditor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -99,7 +107,6 @@
|
|||
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
|
||||
|
||||
[[mFieldEditor undoManager] removeAllActions];
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
|
@ -130,7 +137,7 @@
|
|||
nsAutoString group;
|
||||
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
|
||||
BOOL isFolder = !isGroup && [aBookmark isFolder];
|
||||
|
||||
// First, Show/Hide the appropriate UI
|
||||
if (isGroup) {
|
||||
|
|
|
@ -59,12 +59,9 @@ class BookmarksService;
|
|||
IBOutlet id mDeleteBookmarkButton;
|
||||
|
||||
NSString* mCachedHref;
|
||||
|
||||
BookmarkInfoController* mBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init;
|
||||
-(void) dealloc;
|
||||
-(void) windowClosing;
|
||||
|
||||
-(void) ensureBookmarks;
|
||||
|
@ -116,6 +113,7 @@ class BookmarksService;
|
|||
- (NSString*)url;
|
||||
- (NSNumber*)contentID;
|
||||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
- (BOOL)isFolder;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[mBookmarkInfoController release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void) windowClosing
|
||||
{
|
||||
if (mBookmarks) {
|
||||
|
@ -431,14 +425,14 @@
|
|||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (!item)
|
||||
mBookmarks->GetRootContent(getter_AddRefs(content));
|
||||
BookmarksService::GetRootContent(getter_AddRefs(content));
|
||||
else
|
||||
content = [item contentNode];
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
content->ChildAt(index, *getter_AddRefs(child));
|
||||
if ( child )
|
||||
return mBookmarks->GetWrapperFor(child);
|
||||
return BookmarksService::GetWrapperFor(child);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
@ -451,11 +445,7 @@
|
|||
if (!item)
|
||||
return YES; // The root node is always open.
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
nsIContent* content = [item contentNode];
|
||||
content->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
BOOL isExpandable = (tagName == BookmarksService::gFolderAtom);
|
||||
BOOL isExpandable = [item isFolder];
|
||||
|
||||
// XXXben - persistence of folder open state
|
||||
// I'm adding this code, turned off, until I can figure out how to refresh the NSOutlineView's
|
||||
|
@ -658,11 +648,50 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView tooltipStringForItem:(id)item
|
||||
{
|
||||
NSString* descStr = nil;
|
||||
NSString* hrefStr = nil;
|
||||
nsIContent* content = [item contentNode];
|
||||
nsAutoString value;
|
||||
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
|
||||
if (value.Length())
|
||||
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
// Only description for folders
|
||||
if ([item isFolder])
|
||||
return descStr;
|
||||
|
||||
// Extract the URL from the item
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
|
||||
if (value.Length())
|
||||
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
if (!hrefStr)
|
||||
return descStr;
|
||||
else if (!descStr)
|
||||
return hrefStr;
|
||||
|
||||
// Display both URL and description
|
||||
return [NSString stringWithFormat:@"%@\n%@", hrefStr, descStr];
|
||||
}
|
||||
|
||||
/*
|
||||
- (NSMenu *)outlineView:(NSOutlineView *)outlineView contextMenuForItem:(id)item
|
||||
{
|
||||
// TODO - return (custom?) context menu for item here.
|
||||
// Note that according to HIG, there should never be disabled items in
|
||||
// a context menu - instead, items that do not apply should be removed.
|
||||
// We could nicely do that here.
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren
|
||||
{
|
||||
if (!item)
|
||||
[mOutlineView reloadData];
|
||||
else if ([mOutlineView isItemExpanded: item])
|
||||
else
|
||||
[mOutlineView reloadItem: item reloadChildren: aReloadChildren];
|
||||
}
|
||||
|
||||
|
@ -696,6 +725,10 @@
|
|||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
@ -703,13 +736,16 @@
|
|||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
if (group.IsEmpty())
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,14 +757,13 @@
|
|||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
if (!mBookmarkInfoController)
|
||||
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
int index = [mOutlineView selectedRow];
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
[mBookmarkInfoController setBookmark:item];
|
||||
|
||||
[mBookmarkInfoController showWindow:mBookmarkInfoController];
|
||||
[bic setBookmark:item];
|
||||
|
||||
[bic showWindow:bic];
|
||||
}
|
||||
|
||||
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
|
||||
|
@ -739,10 +774,12 @@
|
|||
[mDeleteBookmarkButton setEnabled:NO];
|
||||
}
|
||||
else {
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[mEditBookmarkButton setEnabled:YES];
|
||||
[mDeleteBookmarkButton setEnabled:YES];
|
||||
if ([[mBookmarkInfoController window] isVisible])
|
||||
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
|
||||
if ([[bic window] isVisible])
|
||||
[bic setBookmark:[mOutlineView itemAtRow:index]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -828,5 +865,13 @@
|
|||
return copy;
|
||||
}
|
||||
|
||||
- (BOOL)isFolder
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
mContentNode->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
return (tagName == BookmarksService::gFolderAtom);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -176,9 +176,10 @@ BookmarksService::GetWrapperFor(nsIContent* aContent)
|
|||
return item;
|
||||
|
||||
// Create an item.
|
||||
item = [[[BookmarkItem alloc] init] autorelease]; // The dictionary retains us.
|
||||
item = [[BookmarkItem alloc] init]; // The dictionary retains us.
|
||||
[item setContentNode: aContent];
|
||||
[gDictionary setObject: item forKey: [NSNumber numberWithInt: contentID]];
|
||||
[item release];
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
#import <Appkit/Appkit.h>
|
||||
|
||||
class nsIDOMElement;
|
||||
@class BookmarkItem;
|
||||
|
||||
@interface CHBookmarksButton : NSButton {
|
||||
|
||||
nsIDOMElement* mElement;
|
||||
BookmarkItem* mBookmarkItem;
|
||||
BOOL mIsFolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINamespaceManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#import "BookmarkInfoController.h"
|
||||
#import "BookmarksDataSource.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
@implementation CHBookmarksButton
|
||||
|
@ -67,6 +73,73 @@
|
|||
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[[[self window] windowController] openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
if (group.IsEmpty())
|
||||
[[[self window] windowController] openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else
|
||||
[[[self window] windowController] openNewWindowWithGroup: mElement loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[bic showWindow:bic];
|
||||
[bic setBookmark:mBookmarkItem];
|
||||
}
|
||||
|
||||
-(IBAction)deleteBookmarks: (id)aSender
|
||||
{
|
||||
if (mElement == BookmarksService::gToolbarRoot)
|
||||
return; // Don't allow the personal toolbar to be deleted.
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
mElement->GetParentNode(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
if (parent)
|
||||
parent->RemoveChild(mElement, getter_AddRefs(dummy));
|
||||
BookmarksService::BookmarkRemoved(parentContent, content);
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
-(void)drawRect:(NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
|
@ -74,7 +147,36 @@
|
|||
|
||||
-(NSMenu*)menuForEvent:(NSEvent*)aEvent
|
||||
{
|
||||
return [[self superview] menu];
|
||||
// Make a copy of the context menu but change it to target us
|
||||
// FIXME - this will stop to work as soon as we add items to the context menu
|
||||
// that have different targets. In that case, we probably should add code to
|
||||
// CHBookmarksToolbar that manages the context menu for the CHBookmarksButtons.
|
||||
|
||||
NSMenu* myMenu = [[[self superview] menu] copy];
|
||||
[[myMenu itemArray] makeObjectsPerformSelector:@selector(setTarget:) withObject: self];
|
||||
[myMenu update];
|
||||
return [myMenu autorelease];
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
return NO;
|
||||
BOOL isBookmark = [mBookmarkItem isFolder] == NO;
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
|
||||
if (([aMenuItem action] == @selector(openBookmarkInNewWindow:))) {
|
||||
// Bookmarks and Bookmark Groups can be opened in a new window
|
||||
return (isBookmark || isGroup);
|
||||
}
|
||||
else if (([aMenuItem action] == @selector(openBookmarkInNewTab:))) {
|
||||
// Only Bookmarks can be opened in new tabs
|
||||
return isBookmark;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)mouseDown:(NSEvent*)aEvent
|
||||
|
@ -120,6 +222,9 @@
|
|||
nsAutoString name;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
[self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
mBookmarkItem = BookmarksService::GetWrapperFor(content);
|
||||
}
|
||||
|
||||
-(nsIDOMElement*)element
|
||||
|
|
|
@ -36,11 +36,9 @@
|
|||
|
||||
BookmarkItem* mBookmarkItem;
|
||||
NSTextView* mFieldEditor;
|
||||
|
||||
NSOutlineView* mOutlineView;
|
||||
}
|
||||
|
||||
-(id)initWithOutlineView: (id)aOutlineView;
|
||||
+ (id)sharedBookmarkInfoController;
|
||||
|
||||
-(void)setBookmark:(BookmarkItem*)aBookmark;
|
||||
|
||||
|
|
|
@ -40,6 +40,18 @@
|
|||
|
||||
@implementation BookmarkInfoController
|
||||
|
||||
/* BookmarkInfoController singelton */
|
||||
static BookmarkInfoController *sharedBookmarkInfoController = nil;
|
||||
|
||||
+ (id)sharedBookmarkInfoController
|
||||
{
|
||||
if (!sharedBookmarkInfoController) {
|
||||
sharedBookmarkInfoController = [[BookmarkInfoController alloc] init];
|
||||
}
|
||||
|
||||
return sharedBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init
|
||||
{
|
||||
[super initWithWindowNibName:@"BookmarkInfoPanel"];
|
||||
|
@ -52,15 +64,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithOutlineView: (id)aOutlineView
|
||||
{
|
||||
mOutlineView = aOutlineView;
|
||||
|
||||
return [self init];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
if (self == sharedBookmarkInfoController)
|
||||
sharedBookmarkInfoController = nil;
|
||||
|
||||
[mFieldEditor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -99,7 +107,6 @@
|
|||
[self commitField:mDescriptionField toProperty:BookmarksService::gDescriptionAtom];
|
||||
|
||||
[[mFieldEditor undoManager] removeAllActions];
|
||||
[mOutlineView reloadItem: mBookmarkItem reloadChildren: NO];
|
||||
BookmarksService::BookmarkChanged([mBookmarkItem contentNode], TRUE);
|
||||
}
|
||||
|
||||
|
@ -130,7 +137,7 @@
|
|||
nsAutoString group;
|
||||
[aBookmark contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
BOOL isFolder = !isGroup && [mOutlineView isExpandable: aBookmark];
|
||||
BOOL isFolder = !isGroup && [aBookmark isFolder];
|
||||
|
||||
// First, Show/Hide the appropriate UI
|
||||
if (isGroup) {
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
#import <Appkit/Appkit.h>
|
||||
|
||||
class nsIDOMElement;
|
||||
@class BookmarkItem;
|
||||
|
||||
@interface CHBookmarksButton : NSButton {
|
||||
|
||||
nsIDOMElement* mElement;
|
||||
BookmarkItem* mBookmarkItem;
|
||||
BOOL mIsFolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
*/
|
||||
|
||||
#import "CHBookmarksButton.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINamespaceManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#import "BookmarkInfoController.h"
|
||||
#import "BookmarksDataSource.h"
|
||||
#import "BookmarksService.h"
|
||||
|
||||
@implementation CHBookmarksButton
|
||||
|
@ -67,6 +73,73 @@
|
|||
[[[[[self window] windowController] getBrowserWrapper] getBrowserView] setActive: YES];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[[[self window] windowController] openNewTabWithURL: hrefStr referrer:nil loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
// Get the href attribute. This is the URL we want to load.
|
||||
nsAutoString hrefAttr;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("href"), hrefAttr);
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
if (group.IsEmpty())
|
||||
[[[self window] windowController] openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else
|
||||
[[[self window] windowController] openNewWindowWithGroup: mElement loadInBackground: loadInBackground];
|
||||
}
|
||||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[bic showWindow:bic];
|
||||
[bic setBookmark:mBookmarkItem];
|
||||
}
|
||||
|
||||
-(IBAction)deleteBookmarks: (id)aSender
|
||||
{
|
||||
if (mElement == BookmarksService::gToolbarRoot)
|
||||
return; // Don't allow the personal toolbar to be deleted.
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
mElement->GetParentNode(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
|
||||
nsCOMPtr<nsIDOMNode> dummy;
|
||||
if (parent)
|
||||
parent->RemoveChild(mElement, getter_AddRefs(dummy));
|
||||
BookmarksService::BookmarkRemoved(parentContent, content);
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
-(void)drawRect:(NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
|
@ -74,7 +147,36 @@
|
|||
|
||||
-(NSMenu*)menuForEvent:(NSEvent*)aEvent
|
||||
{
|
||||
return [[self superview] menu];
|
||||
// Make a copy of the context menu but change it to target us
|
||||
// FIXME - this will stop to work as soon as we add items to the context menu
|
||||
// that have different targets. In that case, we probably should add code to
|
||||
// CHBookmarksToolbar that manages the context menu for the CHBookmarksButtons.
|
||||
|
||||
NSMenu* myMenu = [[[self superview] menu] copy];
|
||||
[[myMenu itemArray] makeObjectsPerformSelector:@selector(setTarget:) withObject: self];
|
||||
[myMenu update];
|
||||
return [myMenu autorelease];
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
|
||||
{
|
||||
if (!mBookmarkItem)
|
||||
return NO;
|
||||
BOOL isBookmark = [mBookmarkItem isFolder] == NO;
|
||||
|
||||
nsAutoString group;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("group"), group);
|
||||
BOOL isGroup = !group.IsEmpty();
|
||||
|
||||
if (([aMenuItem action] == @selector(openBookmarkInNewWindow:))) {
|
||||
// Bookmarks and Bookmark Groups can be opened in a new window
|
||||
return (isBookmark || isGroup);
|
||||
}
|
||||
else if (([aMenuItem action] == @selector(openBookmarkInNewTab:))) {
|
||||
// Only Bookmarks can be opened in new tabs
|
||||
return isBookmark;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)mouseDown:(NSEvent*)aEvent
|
||||
|
@ -120,6 +222,9 @@
|
|||
nsAutoString name;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
[self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
mBookmarkItem = BookmarksService::GetWrapperFor(content);
|
||||
}
|
||||
|
||||
-(nsIDOMElement*)element
|
||||
|
|
|
@ -59,12 +59,9 @@ class BookmarksService;
|
|||
IBOutlet id mDeleteBookmarkButton;
|
||||
|
||||
NSString* mCachedHref;
|
||||
|
||||
BookmarkInfoController* mBookmarkInfoController;
|
||||
}
|
||||
|
||||
-(id) init;
|
||||
-(void) dealloc;
|
||||
-(void) windowClosing;
|
||||
|
||||
-(void) ensureBookmarks;
|
||||
|
@ -116,6 +113,7 @@ class BookmarksService;
|
|||
- (NSString*)url;
|
||||
- (NSNumber*)contentID;
|
||||
- (id)copyWithZone:(NSZone *)aZone;
|
||||
- (BOOL)isFolder;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[mBookmarkInfoController release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void) windowClosing
|
||||
{
|
||||
if (mBookmarks) {
|
||||
|
@ -431,14 +425,14 @@
|
|||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (!item)
|
||||
mBookmarks->GetRootContent(getter_AddRefs(content));
|
||||
BookmarksService::GetRootContent(getter_AddRefs(content));
|
||||
else
|
||||
content = [item contentNode];
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
content->ChildAt(index, *getter_AddRefs(child));
|
||||
if ( child )
|
||||
return mBookmarks->GetWrapperFor(child);
|
||||
return BookmarksService::GetWrapperFor(child);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
@ -451,11 +445,7 @@
|
|||
if (!item)
|
||||
return YES; // The root node is always open.
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
nsIContent* content = [item contentNode];
|
||||
content->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
BOOL isExpandable = (tagName == BookmarksService::gFolderAtom);
|
||||
BOOL isExpandable = [item isFolder];
|
||||
|
||||
// XXXben - persistence of folder open state
|
||||
// I'm adding this code, turned off, until I can figure out how to refresh the NSOutlineView's
|
||||
|
@ -658,11 +648,50 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView:(NSOutlineView *)outlineView tooltipStringForItem:(id)item
|
||||
{
|
||||
NSString* descStr = nil;
|
||||
NSString* hrefStr = nil;
|
||||
nsIContent* content = [item contentNode];
|
||||
nsAutoString value;
|
||||
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gDescriptionAtom, value);
|
||||
if (value.Length())
|
||||
descStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
// Only description for folders
|
||||
if ([item isFolder])
|
||||
return descStr;
|
||||
|
||||
// Extract the URL from the item
|
||||
content->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, value);
|
||||
if (value.Length())
|
||||
hrefStr = [NSString stringWithCharacters:value.get() length:value.Length()];
|
||||
|
||||
if (!hrefStr)
|
||||
return descStr;
|
||||
else if (!descStr)
|
||||
return hrefStr;
|
||||
|
||||
// Display both URL and description
|
||||
return [NSString stringWithFormat:@"%@\n%@", hrefStr, descStr];
|
||||
}
|
||||
|
||||
/*
|
||||
- (NSMenu *)outlineView:(NSOutlineView *)outlineView contextMenuForItem:(id)item
|
||||
{
|
||||
// TODO - return (custom?) context menu for item here.
|
||||
// Note that according to HIG, there should never be disabled items in
|
||||
// a context menu - instead, items that do not apply should be removed.
|
||||
// We could nicely do that here.
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren
|
||||
{
|
||||
if (!item)
|
||||
[mOutlineView reloadData];
|
||||
else if ([mOutlineView isItemExpanded: item])
|
||||
else
|
||||
[mOutlineView reloadItem: item reloadChildren: aReloadChildren];
|
||||
}
|
||||
|
||||
|
@ -696,6 +725,10 @@
|
|||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (!pref)
|
||||
return; // Something bad happened if we can't get prefs.
|
||||
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
@ -703,13 +736,16 @@
|
|||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
nsAutoString group;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gGroupAtom, group);
|
||||
if (group.IsEmpty())
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithURL: hrefStr referrer: nil loadInBackground: loadInBackground];
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface([item contentNode]));
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: NO];
|
||||
[mBrowserWindowController openNewWindowWithGroup: elt loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,14 +757,13 @@
|
|||
|
||||
-(IBAction)showBookmarkInfo:(id)aSender
|
||||
{
|
||||
if (!mBookmarkInfoController)
|
||||
mBookmarkInfoController = [[BookmarkInfoController alloc] initWithOutlineView: mOutlineView];
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
int index = [mOutlineView selectedRow];
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
[mBookmarkInfoController setBookmark:item];
|
||||
|
||||
[mBookmarkInfoController showWindow:mBookmarkInfoController];
|
||||
[bic setBookmark:item];
|
||||
|
||||
[bic showWindow:bic];
|
||||
}
|
||||
|
||||
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
|
||||
|
@ -739,10 +774,12 @@
|
|||
[mDeleteBookmarkButton setEnabled:NO];
|
||||
}
|
||||
else {
|
||||
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
|
||||
|
||||
[mEditBookmarkButton setEnabled:YES];
|
||||
[mDeleteBookmarkButton setEnabled:YES];
|
||||
if ([[mBookmarkInfoController window] isVisible])
|
||||
[mBookmarkInfoController setBookmark:[mOutlineView itemAtRow:index]];
|
||||
if ([[bic window] isVisible])
|
||||
[bic setBookmark:[mOutlineView itemAtRow:index]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -828,5 +865,13 @@
|
|||
return copy;
|
||||
}
|
||||
|
||||
- (BOOL)isFolder
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
mContentNode->GetTag(*getter_AddRefs(tagName));
|
||||
|
||||
return (tagName == BookmarksService::gFolderAtom);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -176,9 +176,10 @@ BookmarksService::GetWrapperFor(nsIContent* aContent)
|
|||
return item;
|
||||
|
||||
// Create an item.
|
||||
item = [[[BookmarkItem alloc] init] autorelease]; // The dictionary retains us.
|
||||
item = [[BookmarkItem alloc] init]; // The dictionary retains us.
|
||||
[item setContentNode: aContent];
|
||||
[gDictionary setObject: item forKey: [NSNumber numberWithInt: contentID]];
|
||||
[item release];
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче