Partially implement ticket #4916:

- Rename "Configure Favorites..." to "Edit Favorites...".
	- Remove the old-style Configure Favorites dialog in favor of simply
	  opening the favorites folder (~/config/settings/Tracker/go) in a
	  Tracker window for the user to manipulate.
	- Rename the "Favorite Folders" section to simply "Favorites" as files
 	  are also allowed (i.e. to easily open a template document).
 	- Removed completely arbitrary (and silent) 20 item limit to favorites
 	  list.
 	- Automatic whitespace cleanup
Still to do: Grab the ref filter from the file panel (if any) and run the
favorites through it as well, since we want to filter out any non-folder
favorites that the app is incapable of handling. Also, the setting for
the favorites menu to show recent documents needs a new home, as it was
previously in the no longer existing Configure Favorites window. Suggestions
welcome, as I'm not currently seeing a spot in the Tracker prefs that would
make good sense.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34071 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2009-11-16 01:07:40 +00:00
parent 7dd65803e7
commit f4dc59983b
7 changed files with 131 additions and 2773 deletions

View File

@ -1,275 +0,0 @@
/*
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 FAVORITES_CONFIG_H
#define FAVORITES_CONFIG_H
#include <Control.h>
#include <Window.h>
#include "Model.h"
class BBox;
class BButton;
class BCheckBox;
class BFilePanel;
class BMenuField;
class BPopUpMenu;
class BTextControl;
class BMessageRunner;
namespace BPrivate {
const uint32 kConfigShow = 'show';
const uint32 kConfigClose = 'canc';
//
// your app will get one of these messages when
// the count has changed
// FindInt32("count", &count)
//
const uint32 kUpdateAppsCount = 'upac';
const uint32 kUpdateDocsCount = 'updc';
const uint32 kUpdateFolderCount = 'upfl';
class NameItemPanel : public BWindow {
public:
NameItemPanel(BWindow *parent, const char *initialText);
virtual ~NameItemPanel();
virtual void MessageReceived(BMessage *);
private:
void AddParts(const char *initialText);
BWindow *fParent;
BBox *fBG;
BTextControl *fNameFld;
BButton *fCancelBtn;
BButton *fDoneBtn;
};
class TDraggableIconButton : public BControl {
public:
TDraggableIconButton(BRect , const char *label, BMessage *,
uint32 resizemask, uint32 flags);
virtual ~TDraggableIconButton();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect);
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint);
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
virtual void GetPreferredSize(float *, float *);
virtual void ResizeToPreferred();
private:
bool fDragging;
BRect fInitialClickRect;
BBitmap *fIcon;
BRect fIconRect;
BRect fLabelRect;
};
class TScrollerButton : public BControl {
public:
TScrollerButton(BRect , BMessage *, bool direction);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect);
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint);
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
private:
bool fDirection;
rgb_color fSelectedColor;
BRect fHiliteFrame;
BMessageRunner *fTicker;
};
class TContentsMenu : public BControl {
public:
TContentsMenu(BRect , BMessage *singleClick, BMessage *doubleClick,
int32 visibleItemCount, const entry_ref *startRef);
virtual ~TContentsMenu();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect );
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MessageReceived(BMessage *);
virtual void MouseDown(BPoint );
virtual void MouseUp(BPoint );
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
virtual void GetPreferredSize(float *, float *);
virtual void ResizeToPreferred();
void StartTracking(BPoint);
void StopTracking();
#ifdef ITEM_EDIT
void BeginItemEdit(BPoint);
void StopItemEdit();
#endif
void SetStartRef(const entry_ref *);
void FillMenu(const entry_ref *);
void EmptyMenu();
bool ItemFrame(int32 index, BRect *iconFrame, BRect *textFrame, BRect *itemFrame) const;
void InvalidateItem(int32 index);
void InvalidateAbsoluteItem(int32 index);
int32 ItemAt(BPoint, BRect *textFrame, BRect *itemFrame, BRect *iconFrame);
const Model *ItemAt(int32) const;
void SelectItemAt(BPoint where);
void Select(const entry_ref *);
void OpenItem(int32);
int32 ItemCount() const;
void RemoveItem(int32);
void AddTempItem(BPoint where);
private:
void UpdateScrollers();
void Scroll(bool);
BMessage *fDoubleClickMessage;
int32 fVisibleItemCount;
entry_ref fStartRef;
BFont *fMenuFont;
float fFontHeight;
float fItemHeight;
rgb_color fHiliteColor;
BRect fInitialClickRect;
bigtime_t fInitialClickTime;
#ifdef ITEM_EDIT
BPoint fInitialClickLoc;
bool fEditingItem;
BTextView *fEditingFld;
int32 fItemIndex;
#endif
int32 fFirstItem;
BObjectList<Model> *fContentsList;
BBitmap *fSmallGroupIcon;
BBitmap *fSymlinkIcon;
TScrollerButton *fUpBtn;
TScrollerButton *fDownBtn;
};
// pass -1 to max apps/docs/folders to not have it show
class TFavoritesConfigWindow : public BWindow {
public:
TFavoritesConfigWindow(BRect frame, const char *title,
bool modal, uint32 filePanelNodeFlavors,
BMessenger parent, const entry_ref *startRef,
int32 maxApps = -1, int32 maxDocs = -1, int32 maxFolders = -1);
~TFavoritesConfigWindow();
void MessageReceived(BMessage *);
bool QuitRequested();
void AddNewGroup();
void AddRefs(BMessage *);
private:
void AddParts(int32 maxApps, int32 maxDocs, int32 maxFolders);
void AddBeMenuPane(int32 maxApps, int32 maxDocs, int32 maxFolders);
void OpenGroup(const entry_ref *);
void ShowGroup(const entry_ref *);
void PromptForAdd();
void UpdateButtons();
void UpdateFoldersCount(int32 = -1, bool notifyTracker = true);
void UpdateDocsCount(int32 = -1, bool notifyTracker = true);
void UpdateAppsCount(int32 = -1, bool notifyTracker = true);
static void BuildCommon(BRect *frame, int32 count, const char *string, uint32 btnWhat,
uint32 fldWhat, BCheckBox **button, BTextControl **field, BBox *parent);
static void AddNewGroup(entry_ref *, entry_ref *);
static void AddSymLink(const entry_ref *, const entry_ref *);
uint32 fFilePanelNodeFlavors;
BMessenger fParent;
entry_ref fCurrentRef;
BFilePanel *fAddPanel;
// Favorites Menu Config controls
BBox *fBeMenuPaneBG;
BPopUpMenu *fGroupMenu;
BMenuField *fGroupBtn;
BPopUpMenu *fSortMenu;
BMenuField *fSortBtn;
TDraggableIconButton *fNewGroupBtn;
BCheckBox *fRecentAppsBtn;
BTextControl *fRecentAppsFld;
BCheckBox *fRecentFoldersBtn;
BTextControl *fRecentFoldersFld;
BCheckBox *fRecentDocsBtn;
BTextControl *fRecentDocsFld;
TContentsMenu *fMenuThing;
BButton *fAddBtn;
BButton *fRemoveBtn;
BButton *fEditBtn;
BButton *fOpenBtn;
};
} // namespace BPrivate
using namespace BPrivate;
#endif

View File

@ -100,6 +100,7 @@ const uint32 kPasteAttributes = 'Tpat';
const uint32 kAttributeItem = 'Tatr';
const uint32 kMIMETypeItem = 'Tmim';
const uint32 kAddCurrentDir = 'Tadd';
const uint32 kEditFavorites = 'Tedf';
const uint32 kSwitchDirectory = 'Tswd';
const uint32 kQuitTracker = 'Tqit';

File diff suppressed because it is too large Load Diff

View File

@ -74,18 +74,18 @@ FavoritesMenu::~FavoritesMenu()
}
bool
bool
FavoritesMenu::StartBuildingItemList()
{
// initialize the menu building state
if (!fInitialItemCount)
fInitialItemCount = CountItems();
else {
// strip the old items so we can add new fresh ones
int32 count = CountItems() - fInitialItemCount;
// keep the items that were added by the FavoritesMenu creator
while (count--)
while (count--)
delete RemoveItem(fInitialItemCount);
}
@ -95,11 +95,11 @@ FavoritesMenu::StartBuildingItemList()
}
bool
bool
FavoritesMenu::AddNextItem()
{
// run the next chunk of code for a given item adding state
if (fState == kStart) {
fState = kAddingFavorites;
fSectionItemCount = 0;
@ -118,13 +118,13 @@ FavoritesMenu::AddNextItem()
if (!startModel.IsContainer())
throw B_ERROR;
if (startModel.IsQuery())
if (startModel.IsQuery())
fContainer = new QueryEntryListCollection(&startModel);
else
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory *>
(startModel.Node()));
ThrowOnInitCheckError(fContainer);
ThrowOnError( fContainer->Rewind() );
@ -133,13 +133,11 @@ FavoritesMenu::AddNextItem()
fContainer = NULL;
}
}
if (fState == kAddingFavorites) {
if (fState == kAddingFavorites) {
entry_ref ref;
// limit nav menus to 20 items only
if (fContainer
&& fSectionItemCount < 20
&& fContainer->GetNextRef(&ref) == B_OK) {
Model model(&ref, true);
if (model.InitCheck() != B_OK)
@ -153,19 +151,19 @@ FavoritesMenu::AddNextItem()
if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true;
AddItem(new TitledSeparatorItem("Favorite Folders"));
AddItem(new TitledSeparatorItem("Favorites"));
}
fUniqueRefCheck.push_back(*model.EntryRef());
AddItem(item);
fSectionItemCount++;
return true;
}
// done with favorites, set up for adding recent files
fState = kAddingFiles;
fAddedSeparatorForSection = false;
app_info info;
be_app->GetAppInfo(&info);
fItems.MakeEmpty();
@ -177,7 +175,7 @@ FavoritesMenu::AddNextItem()
fIndex = 0;
fSectionItemCount = 0;
}
if (fState == kAddingFiles) {
// if this is a Save panel, not an Open panel
// then don't add the recent documents
@ -189,7 +187,7 @@ FavoritesMenu::AddNextItem()
Model model(&ref, true);
if (model.InitCheck() != B_OK)
return true;
BMenuItem *item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget);
if (item) {
if (!fAddedSeparatorForSection) {
@ -202,10 +200,10 @@ FavoritesMenu::AddNextItem()
}
}
}
// done with recent files, set up for adding recent folders
fState = kAddingFolders;
fAddedSeparatorForSection = false;
app_info info;
@ -218,16 +216,16 @@ FavoritesMenu::AddNextItem()
BRoster().GetRecentFolders(&fItems, folders, info.signature);
fIndex = 0;
}
if (fState == kAddingFolders) {
for (;;) {
entry_ref ref;
if (fItems.FindRef("refs", fIndex++, &ref) != B_OK)
break;
// don't add folders that are already in the GoTo section
if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(),
bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end())
bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end())
continue;
Model model(&ref, true);
@ -253,14 +251,14 @@ FavoritesMenu::AddNextItem()
}
void
void
FavoritesMenu::DoneBuildingItemList()
{
SetTargetForItems(fTarget);
}
void
void
FavoritesMenu::ClearMenuBuildingState()
{
delete fContainer;
@ -300,12 +298,12 @@ RecentsMenu::DetachedFromWindow()
{
//
// BNavMenu::DetachedFromWindow sets the TypesList to NULL
//
//
BMenu::DetachedFromWindow();
}
bool
bool
RecentsMenu::StartBuildingItemList()
{
int32 count = CountItems()-1;
@ -327,7 +325,7 @@ RecentsMenu::StartBuildingItemList()
}
bool
bool
RecentsMenu::AddNextItem()
{
if (fRecentsCount > 0 && AddRecents(fRecentsCount))
@ -344,7 +342,7 @@ RecentsMenu::AddRecents(int32 count)
if (fItemIndex == 0) {
fRecentList.MakeEmpty();
BRoster roster;
switch(fWhich) {
case 0:
roster.GetRecentDocuments(&fRecentList, count);
@ -388,7 +386,7 @@ RecentsMenu::AddRecents(int32 count)
}
void
void
RecentsMenu::DoneBuildingItemList()
{
//
@ -407,7 +405,7 @@ RecentsMenu::DoneBuildingItemList()
}
void
void
RecentsMenu::ClearMenuBuildingState()
{
fMenuBuilt = false;

View File

@ -39,7 +39,6 @@ All rights reserved.
#include "Commands.h"
#include "DesktopPoseView.h"
#include "DirMenu.h"
#include "FavoritesConfig.h"
#include "FavoritesMenu.h"
#include "FilePanelPriv.h"
#include "FSUtils.h"
@ -90,7 +89,7 @@ GetLinkFlavor(const Model *model, bool resolve = true)
}
if (!model)
return 0;
if (model->IsDirectory())
return B_DIRECTORY_NODE;
@ -146,8 +145,7 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target,
fSelectionIterator(0),
fMessage(NULL),
fHideWhenDone(hideWhenDone),
fIsTrackingMenu(false),
fConfigWindow(NULL)
fIsTrackingMenu(false)
{
InitIconPreloader();
@ -176,7 +174,7 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target,
bool useRoot = true;
if (startDir) {
if (model->SetTo(startDir) == B_OK && model->IsDirectory())
if (model->SetTo(startDir) == B_OK && model->IsDirectory())
useRoot = false;
else {
delete model;
@ -199,7 +197,7 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target,
BVolumeRoster volumeRoster;
volumeRoster.GetBootVolume(&volume);
volume.GetRootDirectory(&root);
BEntry entry;
root.GetEntry(&entry);
model->SetTo(&entry);
@ -229,16 +227,6 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target,
TFilePanel::~TFilePanel()
{
// regardless of the hide/close method
// always get rid of the config window
if (fConfigWindow) {
// moved from QuitRequested to ensure that
// if the config window is showing that
// it gets closed as well
fConfigWindow->Lock();
fConfigWindow->Quit();
}
BMessenger tracker(kTrackerSignature);
BHandler::StopWatching(tracker, kDesktopFilePanelRootChanged);
@ -302,7 +290,7 @@ TFilePanel::MessageDropFilter(BMessage *message, BHandler **, BMessageFilter *fi
panel->fTaskLoop->RunLater(NewMemberFunctionObjectWithResult
(&TFilePanel::SelectChildInParent, panel,
const_cast<const entry_ref *>(&ref),
const_cast<const node_ref *>(&child)),
const_cast<const node_ref *>(&child)),
ref == *panel->TargetModel()->EntryRef() ? 0 : 100000, 200000, 5000000);
// if the target directory is already current, we won't
// delay the initial selection try
@ -327,7 +315,7 @@ TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter)
node_ref itemNode;
node_ref dirNode;
TFilePanel *panel = dynamic_cast<TFilePanel *>(filter->Looper());
message->FindInt32("device", &dirNode.device);
itemNode.device = dirNode.device;
message->FindInt64("to directory", (int64 *)&dirNode.node);
@ -335,8 +323,8 @@ TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter)
const char *name;
if (message->FindString("name", &name) != B_OK)
break;
// if current directory moved, update entry ref and menu
// if current directory moved, update entry ref and menu
// but not wind title
if (*(panel->TargetModel()->NodeRef()) == itemNode) {
panel->TargetModel()->UpdateEntryRef(&dirNode, name);
@ -351,7 +339,7 @@ TFilePanel::FSFilter(BMessage *message, BHandler **, BMessageFilter *filter)
TFilePanel *panel = dynamic_cast<TFilePanel *>(filter->Looper());
message->FindInt32("device", &itemNode.device);
message->FindInt64("node", (int64 *)&itemNode.node);
// if folder we're watching is deleted, switch to root
// or Desktop
if (*(panel->TargetModel()->NodeRef()) == itemNode) {
@ -438,7 +426,7 @@ TFilePanel::SetTarget(BMessenger target)
void
TFilePanel::SetMessage(BMessage *message)
{
{
delete fMessage;
fMessage = new BMessage(*message);
}
@ -449,7 +437,7 @@ TFilePanel::SetRefFilter(BRefFilter *filter)
{
if (!filter)
return;
fPoseView->SetRefFilter(filter);
fPoseView->CommitActivePose();
fPoseView->Refresh();
@ -542,7 +530,7 @@ TFilePanel::AdjustButton()
// selection mode then we don't disable button ever
if ((modelFlavor == B_DIRECTORY_NODE
|| linkFlavor == B_DIRECTORY_NODE)
&& count == 1)
&& count == 1)
break;
if ((fNodeFlavors & modelFlavor) == 0
@ -554,7 +542,7 @@ TFilePanel::AdjustButton()
}
}
button->SetLabel(buttonText);
button->SetLabel(buttonText);
button->SetEnabled(enabled);
}
@ -576,7 +564,7 @@ TFilePanel::GetNextEntryRef(entry_ref *ref)
return B_ERROR;
BPose *pose = fPoseView->SelectionList()->ItemAt(fSelectionIterator++);
if (!pose)
if (!pose)
return B_ERROR;
*ref = *pose->TargetModel()->EntryRef();
@ -610,9 +598,9 @@ TFilePanel::Init(const BMessage *)
BMessenger(this), IsSavePanel());
favorites->AddItem(new BMenuItem("Add Current Folder",
new BMessage(kAddCurrentDir)));
favorites->AddItem(new BMenuItem("Configure Favorites"B_UTF8_ELLIPSIS,
new BMessage(kConfigShow)));
favorites->AddItem(new BMenuItem("Edit Favorites"B_UTF8_ELLIPSIS,
new BMessage(kEditFavorites)));
fMenuBar->AddItem(favorites);
// configure menus
@ -695,7 +683,7 @@ TFilePanel::Init(const BMessage *)
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
DisallowMetaKeys(fTextControl->TextView());
DisallowFilenameKeys(fTextControl->TextView());
fBackView->AddChild(fTextControl);
fBackView->AddChild(fTextControl);
fTextControl->SetDivider(0.0f);
fTextControl->TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);
@ -743,24 +731,24 @@ TFilePanel::Init(const BMessage *)
rect.right -= 25;
float default_width = be_plain_font->StringWidth(fButtonText.String()) + 20;
rect.left = (default_width > 75) ? (rect.right - default_width) : (rect.right - 75);
BButton *default_button = new BButton(rect, "default button", fButtonText.String(),
new BMessage(kDefaultButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
fBackView->AddChild(default_button);
rect.right = rect.left -= 10;
float cancel_width = be_plain_font->StringWidth("Cancel") + 20;
rect.left = (cancel_width > 75) ? (rect.right - cancel_width) : (rect.right - 75);
BButton *cancel_button = new BButton(rect, "cancel button", "Cancel",
new BMessage(kCancelButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
fBackView->AddChild(cancel_button);
if (!fIsSavePanel)
default_button->SetEnabled(false);
default_button->MakeDefault(true);
RestoreState();
PoseView()->ScrollTo(B_ORIGIN);
@ -768,16 +756,16 @@ TFilePanel::Init(const BMessage *)
PoseView()->ScrollTo(B_ORIGIN);
if (fTextControl) {
fTextControl->MakeFocus();
fTextControl->MakeFocus();
fTextControl->TextView()->SelectAll();
} else
PoseView()->MakeFocus();
app_info info;
app_info info;
BString title;
if (be_app->GetAppInfo(&info) == B_OK)
title << info.ref.name << ": ";
title << fButtonText; // Open or Save
SetTitle(title.String());
@ -786,7 +774,7 @@ TFilePanel::Init(const BMessage *)
}
void
void
TFilePanel::RestoreState()
{
BNode defaultingNode;
@ -801,7 +789,7 @@ TFilePanel::RestoreState()
}
void
void
TFilePanel::SaveState(bool)
{
BNode defaultingNode;
@ -817,21 +805,21 @@ TFilePanel::SaveState(bool)
void
TFilePanel::SaveState(BMessage &message) const
{
_inherited::SaveState(message);
_inherited::SaveState(message);
}
void
void
TFilePanel::RestoreWindowState(AttributeStreamNode *node)
{
SetSizeLimits(360, 10000, 200, 10000);
if (!node)
return;
const char *rectAttributeName = kAttrWindowFrame;
const char *rectAttributeName = kAttrWindowFrame;
BRect frame(Frame());
if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame)
== sizeof(BRect)) {
== sizeof(BRect)) {
MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height());
}
@ -841,18 +829,18 @@ TFilePanel::RestoreWindowState(AttributeStreamNode *node)
void
TFilePanel::RestoreState(const BMessage &message)
{
_inherited::RestoreState(message);
_inherited::RestoreState(message);
}
void
TFilePanel::RestoreWindowState(const BMessage &message)
{
_inherited::RestoreWindowState(message);
_inherited::RestoreWindowState(message);
}
void
void
TFilePanel::AddFileContextMenus(BMenu *menu)
{
menu->AddItem(new BMenuItem("Get Info", new BMessage(kGetInfo), 'I'));
@ -869,9 +857,9 @@ TFilePanel::AddFileContextMenus(BMenu *menu)
}
void
void
TFilePanel::AddVolumeContextMenus(BMenu *menu)
{
{
menu->AddItem(new BMenuItem("Open", new BMessage(kOpenSelection), 'O'));
menu->AddItem(new BMenuItem("Get Info", new BMessage(kGetInfo), 'I'));
menu->AddItem(new BMenuItem("Edit Name", new BMessage(kEditItem), 'E'));
@ -916,7 +904,7 @@ TFilePanel::AddWindowContextMenus(BMenu *menu)
}
void
void
TFilePanel::AddDropContextMenus(BMenu *)
{
}
@ -940,7 +928,7 @@ TFilePanel::MenusBeginning()
}
void
void
TFilePanel::MenusEnded()
{
fIsTrackingMenu = false;
@ -974,7 +962,7 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char *text)
BButton *button = dynamic_cast<BButton *>(FindView("cancel button"));
if (!button)
break;
float old_width = button->StringWidth(button->Label());
button->SetLabel(text);
float delta = old_width - button->StringWidth(text);
@ -999,7 +987,7 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char *text)
button->ResizeBy(-delta, 0);
}
}
// now must move cancel button
button = dynamic_cast<BButton *>(FindView("cancel button"));
if (button)
@ -1045,7 +1033,7 @@ TFilePanel::MessageReceived(BMessage *message)
PoseView()->SwitchDir(&ref);
SwitchDirMenuTo(&ref);
} else {
// Otherwise, we have a file or a link to a file.
// Otherwise, we have a file or a link to a file.
// AdjustButton has already tested the flavor;
// all we have to do is see if the button is enabled.
BButton *button = dynamic_cast<BButton *>(FindView("default button"));
@ -1056,7 +1044,7 @@ TFilePanel::MessageReceived(BMessage *message)
int32 count = 0;
type_code type;
message->GetInfo("refs", &type, &count);
// Don't allow saves of multiple files
if (count > 1) {
ShowCenteredAlert("Sorry, saving of more than one item is not allowed.",
@ -1074,15 +1062,15 @@ TFilePanel::MessageReceived(BMessage *message)
HandleSaveButton();
}
break;
}
}
// send handler a message and close
BMessage openMessage(*fMessage);
for (int32 index = 0; ; index++) {
if (message->FindRef("refs", index, &ref) != B_OK)
break;
openMessage.AddRef("refs", &ref);
}
openMessage.AddRef("refs", &ref);
}
OpenSelectionCommon(&openMessage);
}
}
@ -1108,7 +1096,7 @@ TFilePanel::MessageReceived(BMessage *message)
if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK
|| get_ref_for_path(homePath.Path(), &ref) != B_OK)
break;
SetTo(&ref);
break;
}
@ -1132,77 +1120,21 @@ TFilePanel::MessageReceived(BMessage *message)
break;
}
case kConfigShow:
case kEditFavorites:
{
if (fConfigWindow) {
fConfigWindow->Activate();
break;
}
BPath path;
if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
break;
path.Append(kGoDirectory);
BDirectory goDirectory(path.Path());
if (goDirectory.InitCheck() == B_OK) {
entry_ref startref;
BEntry entry;
goDirectory.GetEntry(&entry);
entry.GetRef(&startref);
int32 apps, docs, folders;
TrackerSettings().RecentCounts(&apps, &docs, &folders);
// if this is a save panel
// then don't show recent docs controls
if (fIsSavePanel)
docs = -1;
fConfigWindow = new TFavoritesConfigWindow(BRect(0, 0, 320, 24),
"Configure Favorites", Feel() == B_MODAL_APP_WINDOW_FEEL,
B_DIRECTORY_NODE, BMessenger(this), &startref, -1, docs, folders);
}
break;
}
case kConfigClose:
{
int32 count = 0;
TrackerSettings settings;
// save off whatever was last in the fields
// do this just in case someone didn't tab out
if (message->FindInt32("applications", &count) == B_OK)
settings.SetRecentApplicationsCount(count);
if (message->FindInt32("folders", &count) == B_OK)
settings.SetRecentFoldersCount(count);
if (message->FindInt32("documents", &count) == B_OK)
settings.SetRecentDocumentsCount(count);
settings.SaveSettings(false);
fConfigWindow = NULL;
break;
}
case kUpdateAppsCount:
case kUpdateDocsCount:
case kUpdateFolderCount:
{
// messages sent when the user changes the count
int32 count;
TrackerSettings settings;
if (message->FindInt32("count", &count) == B_OK) {
if (message->what == kUpdateAppsCount)
settings.SetRecentApplicationsCount(count);
else if (message->what == kUpdateDocsCount)
settings.SetRecentDocumentsCount(count);
else if (message->what == kUpdateFolderCount)
settings.SetRecentFoldersCount(count);
settings.SaveSettings(false);
BMessenger msgr(kTrackerSignature);
if (msgr.IsValid()) {
BMessage message(B_REFS_RECEIVED);
entry_ref ref;
if (get_ref_for_path(path.Path(), &ref) == B_OK) {
message.AddRef("refs", &ref);
msgr.SendMessage(&message);
}
}
break;
}
@ -1250,7 +1182,7 @@ TFilePanel::MessageReceived(BMessage *message)
break;
}
}
}
}
break;
}
@ -1260,7 +1192,7 @@ TFilePanel::MessageReceived(BMessage *message)
}
void
void
TFilePanel::OpenDirectory()
{
BObjectList<BPose> *list = PoseView()->SelectionList();
@ -1276,7 +1208,7 @@ TFilePanel::OpenDirectory()
}
void
void
TFilePanel::OpenParent()
{
if (!CanOpenParent())
@ -1287,15 +1219,15 @@ TFilePanel::OpenParent()
Model oldModel(*PoseView()->TargetModel());
BEntry entry(oldModel.EntryRef());
if (entry.InitCheck() == B_OK
&& entry.GetParent(&dir) == B_OK
&& dir.GetEntry(&parentEntry) == B_OK
&& entry != parentEntry) {
entry_ref ref;
parentEntry.GetRef(&ref);
PoseView()->SetIsDesktop(SwitchDirToDesktopIfNeeded(ref));
PoseView()->SwitchDir(&ref);
SwitchDirMenuTo(&ref);
@ -1310,7 +1242,7 @@ TFilePanel::OpenParent()
}
bool
bool
TFilePanel::CanOpenParent() const
{
if (TrackerSettings().DesktopFilePanelRoot()) {
@ -1318,7 +1250,7 @@ TFilePanel::CanOpenParent() const
BEntry entry(TargetModel()->EntryRef());
if (FSIsDeskDir(&entry, TargetModel()->NodeRef()->device))
return false;
}
}
// block on "/"
BEntry root("/");
@ -1329,7 +1261,7 @@ TFilePanel::CanOpenParent() const
}
bool
bool
TFilePanel::SwitchDirToDesktopIfNeeded(entry_ref &ref)
{
// support showing Desktop as root of everything
@ -1339,7 +1271,7 @@ TFilePanel::SwitchDirToDesktopIfNeeded(entry_ref &ref)
if (!settings.DesktopFilePanelRoot())
// Tracker isn't set up that way, just let Disks show
return false;
BEntry entry(&ref);
BEntry root("/");
@ -1361,7 +1293,7 @@ TFilePanel::SwitchDirToDesktopIfNeeded(entry_ref &ref)
}
bool
bool
TFilePanel::SelectChildInParent(const entry_ref *, const node_ref *child)
{
AutoLock<TFilePanel> lock(this);
@ -1371,7 +1303,7 @@ TFilePanel::SelectChildInParent(const entry_ref *, const node_ref *child)
int32 index;
BPose *pose = PoseView()->FindPose(child, &index);
if (!pose)
if (!pose)
return false;
PoseView()->UpdateScrollRange();
@ -1396,7 +1328,7 @@ TFilePanel::ShowCenteredAlert(const char *text, const char *button1,
else if (button2 != NULL && !strncmp(button2, "Cancel", 7))
alert->SetShortcut(1, B_ESCAPE);
else if (button3 != NULL && !strncmp(button3, "Cancel", 7))
alert->SetShortcut(2, B_ESCAPE);
alert->SetShortcut(2, B_ESCAPE);
#endif
return alert->Go();
@ -1450,7 +1382,7 @@ TFilePanel::HandleSaveButton()
// user selected "Replace" - let app deal with it
}
}
BMessage message(*fMessage);
message.AddRef("directory", TargetModel()->EntryRef());
message.AddString("name", fTextControl->Text());
@ -1485,9 +1417,9 @@ TFilePanel::OpenSelectionCommon(BMessage *openMessage)
BRoster().AddToRecentDocuments(&ref);
}
}
BRoster().AddToRecentFolders(TargetModel()->EntryRef());
if (fClientObject)
fClientObject->SendMessage(&fTarget, openMessage);
else
@ -1513,7 +1445,7 @@ TFilePanel::HandleOpenButton()
if (model->IsDirectory()
|| (model->IsSymLink() && !(fNodeFlavors & B_SYMLINK_NODE)
&& model->ResolveIfLink()->IsDirectory())) {
BMessage message(B_REFS_RECEIVED);
message.AddRef("refs", model->EntryRef());
PostMessage(&message);
@ -1524,11 +1456,11 @@ TFilePanel::HandleOpenButton()
// don't do anything unless there are items selected
// message->fMessage->message from here to end
if (selection->CountItems()) {
BMessage message(*fMessage);
BMessage message(*fMessage);
// go through selection and add appropriate items
for (int32 index = 0; index < selection->CountItems(); index++) {
Model *model = selection->ItemAt(index)->TargetModel();
if (((fNodeFlavors & B_DIRECTORY_NODE) != 0
&& model->ResolveIfLink()->IsDirectory())
|| ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink())
@ -1558,11 +1490,11 @@ TFilePanel::SwitchDirMenuTo(const entry_ref *ref)
}
void
void
TFilePanel::WindowActivated(bool active)
{
// force focus to update properly
fBackView->Invalidate();
fBackView->Invalidate();
_inherited::WindowActivated(active);
}
@ -1579,7 +1511,7 @@ BFilePanelPoseView::BFilePanelPoseView(Model *model, BRect frame, uint32 resizeM
}
void
void
BFilePanelPoseView::StartWatching()
{
TTracker::WatchNode(0, B_WATCH_MOUNT, this);
@ -1591,7 +1523,7 @@ BFilePanelPoseView::StartWatching()
}
void
void
BFilePanelPoseView::StopWatching()
{
stop_watching(this);
@ -1639,7 +1571,7 @@ BFilePanelPoseView::FSNotification(const BMessage *message)
&& otherDesktop.GetEntry(&entry) == B_OK) {
// place desktop items from the mounted volume onto the desktop
Model model(&entry);
if (model.InitCheck() == B_OK)
if (model.InitCheck() == B_OK)
AddPoses(&model);
}
}
@ -1650,7 +1582,7 @@ BFilePanelPoseView::FSNotification(const BMessage *message)
}
void
void
BFilePanelPoseView::RestoreState(AttributeStreamNode *node)
{
_inherited::RestoreState(node);
@ -1658,14 +1590,14 @@ BFilePanelPoseView::RestoreState(AttributeStreamNode *node)
}
void
void
BFilePanelPoseView::RestoreState(const BMessage &message)
{
_inherited::RestoreState(message);
}
void
void
BFilePanelPoseView::SavePoseLocations(BRect *)
{
}
@ -1674,14 +1606,14 @@ BFilePanelPoseView::SavePoseLocations(BRect *)
EntryListBase *
BFilePanelPoseView::InitDirentIterator(const entry_ref *ref)
{
if (IsDesktopView())
if (IsDesktopView())
return DesktopPoseView::InitDesktopDirentIterator(this, ref);
return _inherited::InitDirentIterator(ref);
}
bool
bool
BFilePanelPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo)
{
if (IsDesktopView() && !ShouldShowDesktopPose(TargetModel()->NodeRef()->device,
@ -1699,7 +1631,7 @@ BFilePanelPoseView::SetIsDesktop(bool on)
}
bool
bool
BFilePanelPoseView::IsDesktopView() const
{
return fIsDesktop;
@ -1713,10 +1645,10 @@ BFilePanelPoseView::ShowVolumes(bool visible, bool showShared)
if (!visible)
RemoveRootPoses();
else
AddRootPoses(true, showShared);
AddRootPoses(true, showShared);
}
TFilePanel *filepanel = dynamic_cast<TFilePanel*>(Window());
if (filepanel)
filepanel->SetTo(TargetModel()->EntryRef());
@ -1739,7 +1671,7 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage *message)
if (model.InitCheck() == B_OK) {
BMessage monitorMsg;
monitorMsg.what = B_NODE_MONITOR;
if (showDisksIcon)
monitorMsg.AddInt32("opcode", B_ENTRY_CREATED);
else
@ -1753,7 +1685,7 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage *message)
if (Window())
Window()->PostMessage(&monitorMsg, this);
}
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
}

View File

@ -53,7 +53,6 @@ class BackgroundView;
class BDirMenu;
class AttributeStreamNode;
class BFilePanelPoseView;
class TFavoritesConfigWindow;
class TFilePanel : public BContainerWindow {
public:
@ -67,7 +66,7 @@ public:
bool hideWhenDone = true);
virtual ~TFilePanel();
BFilePanelPoseView *PoseView() const;
virtual bool QuitRequested();
@ -89,13 +88,13 @@ public:
void Refresh();
const BMessenger *Target() const;
BRefFilter *Filter() const;
void SetTarget(BMessenger);
void SetMessage(BMessage *message);
virtual status_t GetNextEntryRef(entry_ref *);
virtual void MessageReceived(BMessage *);
void SetHideWhenDone(bool);
bool HidesWhenDone(void);
@ -125,8 +124,8 @@ protected:
static filter_result MessageDropFilter(BMessage *, BHandler **, BMessageFilter *);
int32 ShowCenteredAlert(const char *text, const char *button1, const char *button2 = NULL,
const char *button3 = NULL);
private:
bool SwitchDirToDesktopIfNeeded(entry_ref &ref);
bool CanOpenParent() const;
@ -145,11 +144,10 @@ private:
BMessenger fTarget;
BFilePanel *fClientObject;
int32 fSelectionIterator;
BMessage *fMessage;
BMessage *fMessage;
BString fButtonText;
bool fHideWhenDone;
bool fIsTrackingMenu;
TFavoritesConfigWindow *fConfigWindow;
typedef BContainerWindow _inherited;
@ -163,7 +161,7 @@ public:
virtual bool IsFilePanel() const;
virtual bool FSNotification(const BMessage *);
void SetIsDesktop(bool);
protected:
@ -189,7 +187,7 @@ private:
// this flags makes the distinction between the Desktop as the Root of
// the world and "/boot/home/Desktop" to which we might have navigated
// from the home dir
typedef BPoseView _inherited;
};

View File

@ -38,7 +38,6 @@ SharedLibrary libtracker.so :
FSClipboard.cpp
FSUndoRedo.cpp
FSUtils.cpp
FavoritesConfig.cpp
FavoritesMenu.cpp
FilePanel.cpp
FilePanelPriv.cpp