mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Hook up bookmarks context menu items for the sidebar view. The behaviour is a little broken in that you need to actually have selected something before any of these work, but it was like that before I touched it, and we can fix that. I'm just hooking up functionality. More specifically:
- Delete - Open in New Window - Open in New Tab - New Folde
This commit is contained in:
parent
724a445970
commit
181ca4c488
@ -81,6 +81,9 @@ class nsIAtom;
|
||||
-(IBAction)cancelRenameBookmarkSheet:(id)sender;
|
||||
-(IBAction)doRenameBookmarkSheet:(id)sender;
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender;
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender;
|
||||
|
||||
// Datasource methods.
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFile.h"
|
||||
@ -635,6 +636,49 @@
|
||||
mBookmarks->BookmarkChanged([item contentNode]);
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
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);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[mBrowserWindowController openNewTabWithURL: urlToLoad loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
[mBrowserWindowController openNewWindowWithURL: urlToLoad loadInBackground: NO];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BookmarkItem
|
||||
|
2
camino/BrowserWindow.nib/classes.nib
generated
2
camino/BrowserWindow.nib/classes.nib
generated
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
8
camino/BrowserWindow.nib/info.nib
generated
8
camino/BrowserWindow.nib/info.nib
generated
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
BIN
camino/BrowserWindow.nib/objects.nib
generated
BIN
camino/BrowserWindow.nib/objects.nib
generated
Binary file not shown.
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
8
camino/English.lproj/BrowserWindow.nib/info.nib
generated
8
camino/English.lproj/BrowserWindow.nib/info.nib
generated
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
BIN
camino/English.lproj/BrowserWindow.nib/objects.nib
generated
BIN
camino/English.lproj/BrowserWindow.nib/objects.nib
generated
Binary file not shown.
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
Binary file not shown.
@ -81,6 +81,9 @@ class nsIAtom;
|
||||
-(IBAction)cancelRenameBookmarkSheet:(id)sender;
|
||||
-(IBAction)doRenameBookmarkSheet:(id)sender;
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender;
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender;
|
||||
|
||||
// Datasource methods.
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFile.h"
|
||||
@ -635,6 +636,49 @@
|
||||
mBookmarks->BookmarkChanged([item contentNode]);
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
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);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[mBrowserWindowController openNewTabWithURL: urlToLoad loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
[mBrowserWindowController openNewWindowWithURL: urlToLoad loadInBackground: NO];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BookmarkItem
|
||||
|
@ -81,6 +81,9 @@ class nsIAtom;
|
||||
-(IBAction)cancelRenameBookmarkSheet:(id)sender;
|
||||
-(IBAction)doRenameBookmarkSheet:(id)sender;
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender;
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender;
|
||||
|
||||
// Datasource methods.
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFile.h"
|
||||
@ -635,6 +636,49 @@
|
||||
mBookmarks->BookmarkChanged([item contentNode]);
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
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);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[mBrowserWindowController openNewTabWithURL: urlToLoad loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
[mBrowserWindowController openNewWindowWithURL: urlToLoad loadInBackground: NO];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BookmarkItem
|
||||
|
2
chimera/BrowserWindow.nib/classes.nib
generated
2
chimera/BrowserWindow.nib/classes.nib
generated
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
8
chimera/BrowserWindow.nib/info.nib
generated
8
chimera/BrowserWindow.nib/info.nib
generated
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
BIN
chimera/BrowserWindow.nib/objects.nib
generated
BIN
chimera/BrowserWindow.nib/objects.nib
generated
Binary file not shown.
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
8
chimera/English.lproj/BrowserWindow.nib/info.nib
generated
8
chimera/English.lproj/BrowserWindow.nib/info.nib
generated
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
BIN
chimera/English.lproj/BrowserWindow.nib/objects.nib
generated
BIN
chimera/English.lproj/BrowserWindow.nib/objects.nib
generated
Binary file not shown.
@ -9,6 +9,8 @@
|
||||
cancelRenameBookmarkSheet = id;
|
||||
deleteBookmarks = id;
|
||||
doRenameBookmarkSheet = id;
|
||||
openBookmarkInNewTab = id;
|
||||
openBookmarkInNewWindow = id;
|
||||
};
|
||||
CLASS = BookmarksDataSource;
|
||||
LANGUAGE = ObjC;
|
||||
|
@ -7,9 +7,9 @@
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>124</key>
|
||||
<string>305 656 170 180 0 0 1152 848 </string>
|
||||
<string>345 807 170 180 0 0 1280 1002 </string>
|
||||
<key>160</key>
|
||||
<string>478 172 195 666 0 0 1152 848 </string>
|
||||
<string>564 326 195 666 0 0 1280 1002 </string>
|
||||
<key>28</key>
|
||||
<string>478 351 195 457 0 0 1152 848 </string>
|
||||
<key>297</key>
|
||||
@ -17,7 +17,7 @@
|
||||
<key>314</key>
|
||||
<string>218 602 139 66 0 0 1152 848 </string>
|
||||
<key>336</key>
|
||||
<string>630 666 200 132 0 0 1152 848 </string>
|
||||
<string>715 809 200 132 0 0 1280 1002 </string>
|
||||
<key>365</key>
|
||||
<string>22 587 93 162 0 0 1152 848 </string>
|
||||
<key>463</key>
|
||||
@ -43,7 +43,9 @@
|
||||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>336</integer>
|
||||
<integer>160</integer>
|
||||
<integer>124</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q125</string>
|
||||
|
Binary file not shown.
@ -81,6 +81,9 @@ class nsIAtom;
|
||||
-(IBAction)cancelRenameBookmarkSheet:(id)sender;
|
||||
-(IBAction)doRenameBookmarkSheet:(id)sender;
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender;
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender;
|
||||
|
||||
// Datasource methods.
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFile.h"
|
||||
@ -635,6 +636,49 @@
|
||||
mBookmarks->BookmarkChanged([item contentNode]);
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewTab:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
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);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
PRBool loadInBackground;
|
||||
pref->GetBoolPref("browser.tabs.loadInBackground", &loadInBackground);
|
||||
|
||||
[mBrowserWindowController openNewTabWithURL: urlToLoad loadInBackground: loadInBackground];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)openBookmarkInNewWindow:(id)aSender
|
||||
{
|
||||
int index = [mOutlineView selectedRow];
|
||||
if (index == -1)
|
||||
return;
|
||||
if ([mOutlineView numberOfSelectedRows] == 1) {
|
||||
BookmarkItem* item = [mOutlineView itemAtRow: index];
|
||||
nsAutoString hrefAttr;
|
||||
[item contentNode]->GetAttr(kNameSpaceID_None, BookmarksService::gHrefAtom, hrefAttr);
|
||||
|
||||
// stuff it into the string
|
||||
NSString* hrefStr = [NSString stringWithCharacters:hrefAttr.get() length:hrefAttr.Length()];
|
||||
NSURL* urlToLoad = [NSURL URLWithString: hrefStr];
|
||||
|
||||
[mBrowserWindowController openNewWindowWithURL: urlToLoad loadInBackground: NO];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BookmarkItem
|
||||
|
Loading…
Reference in New Issue
Block a user