* Added Tracker Kit NavMenu.h and SlowMenu.h which ought to be removed when
WebPositive is moved into the Haiku repo. * Convert the Bookmarks menu into a BNavMenu, make sure it updates to the current folder contens each time it opens. * Wire everything to complete the bookmark support. Managing bookmarks is fairly nice by re-using Tracker. One can even put anything into the book mark folder and WebPositive will launch the respective app if it doesn't have a META:url attribute. The most immediate benefit is that clicking sub-folders in the Bookmarks folder will also open that folder in Tracker. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@315 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
parent
e509fd60c1
commit
3760e5d868
@ -37,6 +37,7 @@
|
||||
#include "BrowserApp.h"
|
||||
#include "BrowsingHistory.h"
|
||||
#include "IconButton.h"
|
||||
#include "NavMenu.h"
|
||||
#include "TextControlCompleter.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebTabView.h"
|
||||
@ -200,6 +201,31 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class BookmarkMenu : public BNavMenu {
|
||||
public:
|
||||
BookmarkMenu(const char* title, BHandler* target, const entry_ref* navDir)
|
||||
:
|
||||
BNavMenu(title, B_REFS_RECEIVED, target)
|
||||
{
|
||||
SetNavDir(navDir);
|
||||
}
|
||||
|
||||
virtual void AttachedToWindow()
|
||||
{
|
||||
RemoveItems(0, CountItems(), true);
|
||||
ForceRebuild();
|
||||
BNavMenu::AttachedToWindow();
|
||||
if (CountItems() > 0)
|
||||
AddItem(new BSeparatorItem(), 0);
|
||||
AddItem(new BMenuItem("Manage bookmarks",
|
||||
new BMessage(SHOW_BOOKMARKS)), 0);
|
||||
AddItem(new BMenuItem("Bookmark this page",
|
||||
new BMessage(CREATE_BOOKMARK), 'B'), 0);
|
||||
DoLayout();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - BrowserWindow
|
||||
|
||||
|
||||
@ -255,13 +281,14 @@ BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy)
|
||||
fGoMenu = new BMenu("Go");
|
||||
mainMenu->AddItem(fGoMenu);
|
||||
|
||||
fBookmarkMenu = new BMenu("Bookmarks");
|
||||
fBookmarkMenu->AddItem(new BMenuItem("Bookmark this page",
|
||||
new BMessage(CREATE_BOOKMARK), 'B'));
|
||||
fBookmarkMenu->AddItem(new BMenuItem("Manage bookmarks",
|
||||
new BMessage(SHOW_BOOKMARKS)));
|
||||
// fBookmarkMenu->AddSeparatorItem();
|
||||
mainMenu->AddItem(fBookmarkMenu);
|
||||
BPath bookmarkPath;
|
||||
entry_ref bookmarkRef;
|
||||
if (_BookmarkPath(bookmarkPath) == B_OK
|
||||
&& get_ref_for_path(bookmarkPath.Path(), &bookmarkRef) == B_OK) {
|
||||
BMenu* bookmarkMenu
|
||||
= new BookmarkMenu("Bookmarks", this, &bookmarkRef);
|
||||
mainMenu->AddItem(bookmarkMenu);
|
||||
}
|
||||
|
||||
// Back, Forward & Stop
|
||||
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
||||
@ -481,6 +508,31 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
_ShowBookmarks();
|
||||
break;
|
||||
|
||||
case B_REFS_RECEIVED: {
|
||||
// Currently only source of these messages is the bookmarks menu.
|
||||
// Filter refs into urls, this also gets rid of refs for folders.
|
||||
// For clicks on sub-folders in the bookmarks menu, we have Tracker
|
||||
// open the corresponding folder.
|
||||
entry_ref ref;
|
||||
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
bool isURL = false;
|
||||
if (file.InitCheck() == B_OK) {
|
||||
BString url;
|
||||
if (file.ReadAttrString("META:url", &url) == B_OK) {
|
||||
message->AddString("url", url.String());
|
||||
isURL = true;
|
||||
}
|
||||
}
|
||||
if (!isURL) {
|
||||
// Must be a folder or something else, have the system open it.
|
||||
be_roster->Launch(&ref);
|
||||
}
|
||||
}
|
||||
message->RemoveName("refs");
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
case B_SIMPLE_DATA: {
|
||||
// User possibly dropped files on this window.
|
||||
// If there is more than one entry_ref, let the app handle it (open one
|
||||
|
@ -126,7 +126,6 @@ private:
|
||||
|
||||
private:
|
||||
BMenu* fGoMenu;
|
||||
BMenu* fBookmarkMenu;
|
||||
IconButton* fBackButton;
|
||||
IconButton* fForwardButton;
|
||||
IconButton* fStopButton;
|
||||
|
168
src/apps/webpositive/support/NavMenu.h
Normal file
168
src/apps/webpositive/support/NavMenu.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
of Be Incorporated in the United States and other countries. Other brand product
|
||||
names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
// NavMenu is a hierarchical menu of volumes, folders, files and queries
|
||||
// displays icons, uses the SlowMenu API for full interruptability
|
||||
|
||||
#ifndef NAV_MENU_H
|
||||
#define NAV_MENU_H
|
||||
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <Entry.h>
|
||||
|
||||
#include "SlowMenu.h"
|
||||
|
||||
|
||||
template<class T> class BObjectList;
|
||||
class BMenuItem;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class Model;
|
||||
class BContainerWindow;
|
||||
class ModelMenuItem;
|
||||
class EntryListBase;
|
||||
|
||||
|
||||
class TrackingHookData {
|
||||
public:
|
||||
TrackingHookData()
|
||||
:
|
||||
fTrackingHook(NULL),
|
||||
fDragMessage(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
bool (*fTrackingHook)(BMenu *, void *);
|
||||
BMessenger fTarget;
|
||||
const BMessage *fDragMessage;
|
||||
};
|
||||
|
||||
|
||||
class BNavMenu : public BSlowMenu {
|
||||
public:
|
||||
BNavMenu(const char* title, uint32 message, const BHandler *,
|
||||
BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL);
|
||||
BNavMenu(const char* title, uint32 message, const BMessenger &,
|
||||
BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL);
|
||||
// parentWindow, if specified, will be closed if nav menu item invoked
|
||||
// with option held down
|
||||
|
||||
virtual ~BNavMenu();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
|
||||
void SetNavDir(const entry_ref *);
|
||||
void ForceRebuild();
|
||||
bool NeedsToRebuild() const;
|
||||
// will cause menu to get rebuilt next time it is shown
|
||||
|
||||
virtual void ResetTargets();
|
||||
void SetTarget(const BMessenger &);
|
||||
BMessenger Target();
|
||||
|
||||
void SetTypesList(const BObjectList<BString> *list);
|
||||
const BObjectList<BString> *TypesList() const;
|
||||
|
||||
void AddNavDir(const Model *model, uint32 what, BHandler *target,
|
||||
bool populateSubmenu);
|
||||
|
||||
void AddNavParentDir(const char *name, const Model *model, uint32 what, BHandler *target);
|
||||
void AddNavParentDir(const Model *model, uint32 what, BHandler *target);
|
||||
void SetShowParent(bool show);
|
||||
|
||||
static int32 GetMaxMenuWidth();
|
||||
|
||||
static int CompareFolderNamesFirstOne(const BMenuItem *, const BMenuItem *);
|
||||
static int CompareOne(const BMenuItem *, const BMenuItem *);
|
||||
|
||||
static ModelMenuItem *NewModelItem(Model *, const BMessage *, const BMessenger &,
|
||||
bool suppressFolderHierarchy=false, BContainerWindow * = NULL,
|
||||
const BObjectList<BString> *typeslist = NULL,
|
||||
TrackingHookData *hook = NULL);
|
||||
|
||||
TrackingHookData *InitTrackingHook(bool (*hookfunction)(BMenu *, void *),
|
||||
const BMessenger *target, const BMessage *dragMessage);
|
||||
|
||||
protected:
|
||||
virtual bool StartBuildingItemList();
|
||||
virtual bool AddNextItem();
|
||||
virtual void DoneBuildingItemList();
|
||||
virtual void ClearMenuBuildingState();
|
||||
|
||||
void BuildVolumeMenu();
|
||||
|
||||
void AddOneItem(Model *);
|
||||
void AddRootItemsIfNeeded();
|
||||
void AddTrashItem();
|
||||
static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *);
|
||||
|
||||
entry_ref fNavDir;
|
||||
BMessage fMessage;
|
||||
BMessenger fMessenger;
|
||||
BWindow *fParentWindow;
|
||||
|
||||
// menu building state
|
||||
uint8 fFlags;
|
||||
BObjectList<BMenuItem> *fItemList;
|
||||
EntryListBase *fContainer;
|
||||
bool fIteratingDesktop;
|
||||
|
||||
const BObjectList<BString> *fTypesList;
|
||||
|
||||
TrackingHookData fTrackingHook;
|
||||
};
|
||||
|
||||
// Spring Loaded Folder convenience routines
|
||||
// used in both Tracker and Deskbar
|
||||
#ifndef _IMPEXP_TRACKER
|
||||
# define _IMPEXP_TRACKER
|
||||
#endif
|
||||
_IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming,
|
||||
const BMessage *dragmessage);
|
||||
_IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu,
|
||||
const BObjectList<BString> *typeslist);
|
||||
_IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref,
|
||||
BObjectList<BString> *typeslist);
|
||||
_IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming,
|
||||
BMessage **, BObjectList<BString> **typeslist);
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
#endif // NAV_MENU_H
|
76
src/apps/webpositive/support/SlowMenu.h
Normal file
76
src/apps/webpositive/support/SlowMenu.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Open Tracker License
|
||||
|
||||
Terms and Conditions
|
||||
|
||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice applies to all licensees
|
||||
and shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||
this Software without prior written authorization from Be Incorporated.
|
||||
|
||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||
of Be Incorporated in the United States and other countries. Other brand product
|
||||
names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __SLOW_MENU__
|
||||
#define __SLOW_MENU__
|
||||
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Debug.h>
|
||||
|
||||
// SlowMenu is a convenience class that makes it easier to
|
||||
// use the AddDynamicItem callback to implement a menu that can
|
||||
// checks periodically between creating new items and quits
|
||||
// early if needed
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class BSlowMenu : public BMenu {
|
||||
public:
|
||||
BSlowMenu(const char *title, menu_layout layout = B_ITEMS_IN_COLUMN);
|
||||
|
||||
protected:
|
||||
virtual bool StartBuildingItemList();
|
||||
// set up state to start building the item list
|
||||
// returns false if setup failed
|
||||
virtual bool AddNextItem() = 0;
|
||||
// returns false if done
|
||||
virtual void DoneBuildingItemList() = 0;
|
||||
// default version adds items from itemList to menu and deletes
|
||||
// the list; override to sort items first, etc.
|
||||
|
||||
virtual void ClearMenuBuildingState() = 0;
|
||||
|
||||
protected:
|
||||
virtual bool AddDynamicItem(add_state state);
|
||||
// this is the callback from BMenu, you shouldn't need to override this
|
||||
|
||||
bool fMenuBuilt;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
#endif /* __SLOW_MENU__ */
|
Loading…
x
Reference in New Issue
Block a user