Skip to content

Commit

Permalink
LaunchBox: add Open containing folder option.
Browse files Browse the repository at this point in the history
Contributed by abhiin1947. Fixes #7951.
  • Loading branch information
mmadia committed Feb 17, 2013
1 parent c4d175c commit ac966d5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/apps/launchbox/LaunchButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum {
MSG_CLEAR_SLOT = 'clsl',
MSG_REMOVE_SLOT = 'rmsl',
MSG_LAUNCH = 'lnch',
MSG_OPEN_CONTAINING_FOLDER = 'opcf',
};


Expand Down
33 changes: 27 additions & 6 deletions src/apps/launchbox/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ void
MainWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_LAUNCH: {
case MSG_LAUNCH:
{
BView* pointer;
if (message->FindPointer("be:source", (void**)&pointer) < B_OK)
break;
Expand Down Expand Up @@ -180,29 +181,33 @@ MainWindow::MessageReceived(BMessage* message)
}
break;
}
case MSG_ADD_SLOT: {
case MSG_ADD_SLOT:
{
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
fPadView->AddButton(new LaunchButton("launch button",
NULL, new BMessage(MSG_LAUNCH)), button);
}
break;
}
case MSG_CLEAR_SLOT: {
case MSG_CLEAR_SLOT:
{
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK)
button->SetTo((entry_ref*)NULL);
break;
}
case MSG_REMOVE_SLOT: {
case MSG_REMOVE_SLOT:
{
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
if (fPadView->RemoveButton(button))
delete button;
}
break;
}
case MSG_SET_DESCRIPTION: {
case MSG_SET_DESCRIPTION:
{
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
const char* name;
Expand Down Expand Up @@ -260,7 +265,8 @@ MainWindow::MessageReceived(BMessage* message)
}
break;
}
case MSG_ADD_WINDOW: {
case MSG_ADD_WINDOW:
{
BMessage settings('sett');
SaveSettings(&settings);
message->AddMessage("window", &settings);
Expand All @@ -283,6 +289,21 @@ MainWindow::MessageReceived(BMessage* message)
else
SetWorkspaces(1L << current_workspace());
break;
case MSG_OPEN_CONTAINING_FOLDER:
{
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) == B_OK && button->Ref() != NULL) {
entry_ref target = *button->Ref();
BEntry openTarget(&target);
BMessage openMsg(B_REFS_RECEIVED);
BMessenger tracker("application/x-vnd.Be-TRAK");
openTarget.GetParent(&openTarget);
openTarget.GetRef(&target);
openMsg.AddRef("refs",&target);
tracker.SendMessage(&openMsg);
}
}
break;
case B_SIMPLE_DATA:
case B_REFS_RECEIVED:
case B_PASTE:
Expand Down
8 changes: 8 additions & 0 deletions src/apps/launchbox/PadView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ PadView::DisplayMenu(BPoint where, LaunchButton* button) const
item = new BMenuItem(B_TRANSLATE("Remove button"), message);
item->SetTarget(window);
menu->AddItem(item);
// Open containing folder button
if (button->Ref() != NULL) {
message = new BMessage(MSG_OPEN_CONTAINING_FOLDER);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Open containing folder"), message);
item->SetTarget(window);
menu->AddItem(item);
}
// set button description
if (button->Ref()) {
message = new BMessage(MSG_SET_DESCRIPTION);
Expand Down

0 comments on commit ac966d5

Please sign in to comment.