зеркало из https://github.com/mozilla/pjs.git
Hook up "Bookmark this link" context menu item (bug 154856). r=pinkerton.
This commit is contained in:
Родитель
3f9d22bfc4
Коммит
fc7b95f953
|
@ -75,7 +75,7 @@ class BookmarksService;
|
|||
|
||||
-(IBAction)addFolder:(id)aSender;
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder;
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
|
||||
-(NSString*)resolveKeyword:(NSString*)aKeyword;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
|
||||
#import "BookmarksService.h"
|
||||
#import "StringUtils.h"
|
||||
|
||||
@implementation BookmarksDataSource
|
||||
|
||||
|
@ -95,15 +96,15 @@
|
|||
|
||||
-(IBAction)addBookmark:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
if (!mBookmarks)
|
||||
return;
|
||||
|
@ -138,16 +139,22 @@
|
|||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
|
||||
|
||||
// Fetch the title of the current page and the URL.
|
||||
nsAutoString title, href;
|
||||
if (!aIsFolder) {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
|
||||
// If no URL and title were specified, get them from the current page.
|
||||
if (aURL && aTitle) {
|
||||
NSStringTo_nsString(aURL, href);
|
||||
NSStringTo_nsString(aTitle, title);
|
||||
} else {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
}
|
||||
|
||||
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
|
||||
[mCachedHref retain];
|
||||
}
|
||||
else {
|
||||
|
||||
} else { // Folder
|
||||
mCachedHref = nil;
|
||||
title = NS_LITERAL_STRING("New Folder");
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class nsIDOMNode;
|
|||
|
||||
- (BOOL)shouldShowBookmarkToolbar;
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSString*)aURLSpec;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
|
|
@ -735,7 +735,7 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
wrap:inWrap backwards:inBackwards];
|
||||
}
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
[mSidebarBookmarksDataSource ensureBookmarks];
|
||||
BOOL useSel = aIsFromMenu;
|
||||
|
@ -748,19 +748,27 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
useSel = NO;
|
||||
}
|
||||
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder];
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder URL:aURL title:aTitle];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkPage: (id)aSender
|
||||
{
|
||||
[self addBookmarkExtended:YES isFolder:NO];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkLink: (id)aSender
|
||||
{
|
||||
NSLog(@"Bookmark Link not yet implemented");
|
||||
nsCOMPtr<nsIDOMElement> linkContent;
|
||||
nsAutoString href;
|
||||
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
|
||||
(linkContent), href);
|
||||
nsAutoString linkText;
|
||||
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
|
||||
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
|
||||
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
|
||||
}
|
||||
|
||||
- (IBAction)back:(id)aSender
|
||||
|
|
|
@ -376,12 +376,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) addBookmark:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addFolder:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addSeparator:(id)aSender
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2002 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// Utility to convert |NSString|s to unicode |nsString|s to save having
|
||||
// to repeat this set of code each time someone wants to do this...
|
||||
void
|
||||
NSStringTo_nsString(NSString* aNSString, nsString& ansString)
|
||||
{
|
||||
unsigned int len = [aNSString length];
|
||||
PRUnichar* buffer = new PRUnichar[len + 1];
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
[aNSString getCharacters: buffer];
|
||||
buffer[len] = (PRUnichar)'\0';
|
||||
|
||||
ansString.Adopt(buffer);
|
||||
}
|
|
@ -376,12 +376,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) addBookmark:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addFolder:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addSeparator:(id)aSender
|
||||
|
|
|
@ -75,7 +75,7 @@ class BookmarksService;
|
|||
|
||||
-(IBAction)addFolder:(id)aSender;
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder;
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
|
||||
-(NSString*)resolveKeyword:(NSString*)aKeyword;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
|
||||
#import "BookmarksService.h"
|
||||
#import "StringUtils.h"
|
||||
|
||||
@implementation BookmarksDataSource
|
||||
|
||||
|
@ -95,15 +96,15 @@
|
|||
|
||||
-(IBAction)addBookmark:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
if (!mBookmarks)
|
||||
return;
|
||||
|
@ -138,16 +139,22 @@
|
|||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
|
||||
|
||||
// Fetch the title of the current page and the URL.
|
||||
nsAutoString title, href;
|
||||
if (!aIsFolder) {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
|
||||
// If no URL and title were specified, get them from the current page.
|
||||
if (aURL && aTitle) {
|
||||
NSStringTo_nsString(aURL, href);
|
||||
NSStringTo_nsString(aTitle, title);
|
||||
} else {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
}
|
||||
|
||||
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
|
||||
[mCachedHref retain];
|
||||
}
|
||||
else {
|
||||
|
||||
} else { // Folder
|
||||
mCachedHref = nil;
|
||||
title = NS_LITERAL_STRING("New Folder");
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class nsIDOMNode;
|
|||
|
||||
- (BOOL)shouldShowBookmarkToolbar;
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSString*)aURLSpec;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
|
|
@ -735,7 +735,7 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
wrap:inWrap backwards:inBackwards];
|
||||
}
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
[mSidebarBookmarksDataSource ensureBookmarks];
|
||||
BOOL useSel = aIsFromMenu;
|
||||
|
@ -748,19 +748,27 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
useSel = NO;
|
||||
}
|
||||
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder];
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder URL:aURL title:aTitle];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkPage: (id)aSender
|
||||
{
|
||||
[self addBookmarkExtended:YES isFolder:NO];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkLink: (id)aSender
|
||||
{
|
||||
NSLog(@"Bookmark Link not yet implemented");
|
||||
nsCOMPtr<nsIDOMElement> linkContent;
|
||||
nsAutoString href;
|
||||
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
|
||||
(linkContent), href);
|
||||
nsAutoString linkText;
|
||||
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
|
||||
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
|
||||
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
|
||||
}
|
||||
|
||||
- (IBAction)back:(id)aSender
|
||||
|
|
|
@ -75,7 +75,7 @@ class BookmarksService;
|
|||
|
||||
-(IBAction)addFolder:(id)aSender;
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder;
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
|
||||
-(NSString*)resolveKeyword:(NSString*)aKeyword;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
|
||||
#import "BookmarksService.h"
|
||||
#import "StringUtils.h"
|
||||
|
||||
@implementation BookmarksDataSource
|
||||
|
||||
|
@ -95,15 +96,15 @@
|
|||
|
||||
-(IBAction)addBookmark:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
if (!mBookmarks)
|
||||
return;
|
||||
|
@ -138,16 +139,22 @@
|
|||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
|
||||
|
||||
// Fetch the title of the current page and the URL.
|
||||
nsAutoString title, href;
|
||||
if (!aIsFolder) {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
|
||||
// If no URL and title were specified, get them from the current page.
|
||||
if (aURL && aTitle) {
|
||||
NSStringTo_nsString(aURL, href);
|
||||
NSStringTo_nsString(aTitle, title);
|
||||
} else {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
}
|
||||
|
||||
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
|
||||
[mCachedHref retain];
|
||||
}
|
||||
else {
|
||||
|
||||
} else { // Folder
|
||||
mCachedHref = nil;
|
||||
title = NS_LITERAL_STRING("New Folder");
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class nsIDOMNode;
|
|||
|
||||
- (BOOL)shouldShowBookmarkToolbar;
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSString*)aURLSpec;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
|
|
@ -735,7 +735,7 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
wrap:inWrap backwards:inBackwards];
|
||||
}
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
[mSidebarBookmarksDataSource ensureBookmarks];
|
||||
BOOL useSel = aIsFromMenu;
|
||||
|
@ -748,19 +748,27 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
useSel = NO;
|
||||
}
|
||||
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder];
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder URL:aURL title:aTitle];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkPage: (id)aSender
|
||||
{
|
||||
[self addBookmarkExtended:YES isFolder:NO];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkLink: (id)aSender
|
||||
{
|
||||
NSLog(@"Bookmark Link not yet implemented");
|
||||
nsCOMPtr<nsIDOMElement> linkContent;
|
||||
nsAutoString href;
|
||||
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
|
||||
(linkContent), href);
|
||||
nsAutoString linkText;
|
||||
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
|
||||
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
|
||||
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
|
||||
}
|
||||
|
||||
- (IBAction)back:(id)aSender
|
||||
|
|
|
@ -376,12 +376,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) addBookmark:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addFolder:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addSeparator:(id)aSender
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2002 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// Utility to convert |NSString|s to unicode |nsString|s to save having
|
||||
// to repeat this set of code each time someone wants to do this...
|
||||
void
|
||||
NSStringTo_nsString(NSString* aNSString, nsString& ansString)
|
||||
{
|
||||
unsigned int len = [aNSString length];
|
||||
PRUnichar* buffer = new PRUnichar[len + 1];
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
[aNSString getCharacters: buffer];
|
||||
buffer[len] = (PRUnichar)'\0';
|
||||
|
||||
ansString.Adopt(buffer);
|
||||
}
|
|
@ -376,12 +376,12 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
|
||||
-(IBAction) addBookmark:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addFolder:(id)aSender
|
||||
{
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES];
|
||||
[[[mApplication mainWindow] windowController] addBookmarkExtended: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction) addSeparator:(id)aSender
|
||||
|
|
|
@ -75,7 +75,7 @@ class BookmarksService;
|
|||
|
||||
-(IBAction)addFolder:(id)aSender;
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder;
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
|
||||
-(NSString*)resolveKeyword:(NSString*)aKeyword;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
|
||||
#import "BookmarksService.h"
|
||||
#import "StringUtils.h"
|
||||
|
||||
@implementation BookmarksDataSource
|
||||
|
||||
|
@ -95,15 +96,15 @@
|
|||
|
||||
-(IBAction)addBookmark:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(IBAction)addFolder:(id)aSender
|
||||
{
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES];
|
||||
[self addBookmark: aSender useSelection: YES isFolder: YES URL:nil title:nil];
|
||||
}
|
||||
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder
|
||||
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
if (!mBookmarks)
|
||||
return;
|
||||
|
@ -138,16 +139,22 @@
|
|||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
|
||||
|
||||
// Fetch the title of the current page and the URL.
|
||||
nsAutoString title, href;
|
||||
if (!aIsFolder) {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
|
||||
// If no URL and title were specified, get them from the current page.
|
||||
if (aURL && aTitle) {
|
||||
NSStringTo_nsString(aURL, href);
|
||||
NSStringTo_nsString(aTitle, title);
|
||||
} else {
|
||||
BookmarksService::GetTitleAndHrefForBrowserView([[mBrowserWindowController getBrowserWrapper] getBrowserView],
|
||||
title, href);
|
||||
}
|
||||
|
||||
mCachedHref = [NSString stringWithCharacters: href.get() length: href.Length()];
|
||||
[mCachedHref retain];
|
||||
}
|
||||
else {
|
||||
|
||||
} else { // Folder
|
||||
mCachedHref = nil;
|
||||
title = NS_LITERAL_STRING("New Folder");
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class nsIDOMNode;
|
|||
|
||||
- (BOOL)shouldShowBookmarkToolbar;
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder;
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle;
|
||||
- (IBAction)manageBookmarks: (id)aSender;
|
||||
- (void)importBookmarks: (NSString*)aURLSpec;
|
||||
- (IBAction)toggleSidebar:(id)aSender;
|
||||
|
|
|
@ -735,7 +735,7 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
wrap:inWrap backwards:inBackwards];
|
||||
}
|
||||
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder
|
||||
- (void)addBookmarkExtended: (BOOL)aIsFromMenu isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
|
||||
{
|
||||
[mSidebarBookmarksDataSource ensureBookmarks];
|
||||
BOOL useSel = aIsFromMenu;
|
||||
|
@ -748,19 +748,27 @@ static NSString *SearchToolbarItemIdentifier = @"Search Toolbar Item";
|
|||
useSel = NO;
|
||||
}
|
||||
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder];
|
||||
[mSidebarBookmarksDataSource addBookmark: self useSelection: useSel isFolder: aIsFolder URL:aURL title:aTitle];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkPage: (id)aSender
|
||||
{
|
||||
[self addBookmarkExtended:YES isFolder:NO];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:nil title:nil];
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)bookmarkLink: (id)aSender
|
||||
{
|
||||
NSLog(@"Bookmark Link not yet implemented");
|
||||
nsCOMPtr<nsIDOMElement> linkContent;
|
||||
nsAutoString href;
|
||||
CHGeckoUtils::GetEnclosingLinkElementAndHref(mContextMenuNode, getter_AddRefs\
|
||||
(linkContent), href);
|
||||
nsAutoString linkText;
|
||||
CHGeckoUtils::GatherTextUnder(linkContent, linkText);
|
||||
NSString* urlStr = [NSString stringWithCharacters:href.get() length:href.Length()];
|
||||
NSString* titleStr = [NSString stringWithCharacters:linkText.get() length:linkText.Length()];
|
||||
[self addBookmarkExtended:YES isFolder:NO URL:urlStr title:titleStr];
|
||||
}
|
||||
|
||||
- (IBAction)back:(id)aSender
|
||||
|
|
Загрузка…
Ссылка в новой задаче