Unbroke the "Mount Menu in Deskbar" feature. It re-uses the MountMenu code
from libtracker.so. BTW, I like this feature, since it gives mounting volumes more visibility. But this commit does not enable it. Use -SubDirC++Flags -D_SHOW_CALENDAR_MENU_WINDOW=1 ; +SubDirC++Flags -D_SHOW_CALENDAR_MENU_WINDOW=1 -DMOUNT_MENU_IN_DESKBAR=1 ; in the Deskbar Jamfile to enable it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29627 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -43,10 +43,11 @@ All rights reserved.
|
|||||||
#include "BarApp.h"
|
#include "BarApp.h"
|
||||||
#include "BarView.h"
|
#include "BarView.h"
|
||||||
#include "DeskBarUtils.h"
|
#include "DeskBarUtils.h"
|
||||||
|
#include "IconMenuItem.h"
|
||||||
|
#include "MountMenu.h"
|
||||||
#include "PublicCommands.h"
|
#include "PublicCommands.h"
|
||||||
#include "RecentItems.h"
|
#include "RecentItems.h"
|
||||||
#include "StatusView.h"
|
#include "StatusView.h"
|
||||||
#include "IconMenuItem.h"
|
|
||||||
|
|
||||||
#define ROSTER_SIG "application/x-vnd.Be-ROST"
|
#define ROSTER_SIG "application/x-vnd.Be-ROST"
|
||||||
|
|
||||||
@@ -56,24 +57,12 @@ void run_be_about();
|
|||||||
|
|
||||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||||
|
|
||||||
class MountMenu : public BMenu {
|
class DeskbarMountMenu : public BPrivate::MountMenu {
|
||||||
public:
|
public:
|
||||||
MountMenu(const char *name);
|
DeskbarMountMenu(const char *name);
|
||||||
virtual bool AddDynamicItem(add_state s);
|
virtual bool AddDynamicItem(add_state s);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MountMenuItem : public BMenuItem {
|
|
||||||
public:
|
|
||||||
MountMenuItem(const char *label, BMessage *message, BBitmap *icon );
|
|
||||||
virtual ~MountMenuItem();
|
|
||||||
virtual void GetContentSize(float *width, float *height);
|
|
||||||
virtual void DrawContent();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BBitmap *deviceIcon;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define SHOW_RECENT_FIND_ITEMS
|
//#define SHOW_RECENT_FIND_ITEMS
|
||||||
@@ -261,7 +250,7 @@ TBeMenu::AddStandardBeMenuItems()
|
|||||||
AddItem(item);
|
AddItem(item);
|
||||||
|
|
||||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||||
MountMenu *mountMenu = new MountMenu("Mount Disks");
|
DeskbarMountMenu *mountMenu = new DeskbarMountMenu("Mount Disks");
|
||||||
mountMenu->SetEnabled(!dragging);
|
mountMenu->SetEnabled(!dragging);
|
||||||
AddItem(mountMenu);
|
AddItem(mountMenu);
|
||||||
#endif
|
#endif
|
||||||
@@ -731,87 +720,21 @@ TRecentsMenu::ResetTargets()
|
|||||||
|
|
||||||
#ifdef MOUNT_MENU_IN_DESKBAR
|
#ifdef MOUNT_MENU_IN_DESKBAR
|
||||||
|
|
||||||
MountMenu::MountMenu(const char *name)
|
DeskbarMountMenu::DeskbarMountMenu(const char *name)
|
||||||
: BMenu(name)
|
: BPrivate::MountMenu(name)
|
||||||
{
|
{
|
||||||
SetFont(be_plain_font);
|
SetFont(be_plain_font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MountMenu::AddDynamicItem(add_state s)
|
DeskbarMountMenu::AddDynamicItem(add_state s)
|
||||||
{
|
{
|
||||||
RemoveItems(0, CountItems(), true);
|
BPrivate::MountMenu::AddDynamicItem(s);
|
||||||
|
|
||||||
// Send message to tracker to get items.
|
|
||||||
BMessage request('gmtv');
|
|
||||||
BMessage reply;
|
|
||||||
BMessenger(kTrackerSignature).SendMessage(&request,
|
|
||||||
&reply);
|
|
||||||
|
|
||||||
// populate menu
|
|
||||||
type_code code;
|
|
||||||
int32 countFound;
|
|
||||||
reply.GetInfo("DisplayName", &code, &countFound);
|
|
||||||
for (int32 vol = 0; vol < countFound; vol++) {
|
|
||||||
// TODO: get_device_icon version that supports B_RGBA32
|
|
||||||
BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
|
||||||
get_device_icon(reply.FindString("DeviceName", vol), icon->Bits(), B_MINI_ICON);
|
|
||||||
BMessage *invokeMessage = new BMessage;
|
|
||||||
reply.FindMessage("InvokeMessage", vol, invokeMessage);
|
|
||||||
AddItem(new MountMenuItem(reply.FindString("DisplayName", vol),
|
|
||||||
invokeMessage, icon));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (countFound > 0)
|
|
||||||
AddSeparatorItem();
|
|
||||||
|
|
||||||
BMenuItem *mountAll = new BMenuItem("All Disks", new BMessage('mntn'));
|
|
||||||
AddItem(mountAll);
|
|
||||||
mountAll->SetEnabled(countFound > 0);
|
|
||||||
BMenuItem *mountSettings = new BMenuItem("Settings", new BMessage('Tram'));
|
|
||||||
AddItem(mountSettings);
|
|
||||||
|
|
||||||
SetTargetForItems(BMessenger(kTrackerSignature));
|
SetTargetForItems(BMessenger(kTrackerSignature));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MountMenuItem::MountMenuItem(const char *label, BMessage *message, BBitmap *icon)
|
|
||||||
: BMenuItem(label,message),
|
|
||||||
deviceIcon(icon)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MountMenuItem::~MountMenuItem()
|
|
||||||
{
|
|
||||||
delete deviceIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MountMenuItem::GetContentSize(float *width, float *height)
|
|
||||||
{
|
|
||||||
BMenuItem::GetContentSize(width, height);
|
|
||||||
*width += 20;
|
|
||||||
*height += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MountMenuItem::DrawContent()
|
|
||||||
{
|
|
||||||
BPoint loc = ContentLocation();
|
|
||||||
loc.x += 20;
|
|
||||||
Menu()->MovePenTo(loc);
|
|
||||||
BMenuItem::DrawContent();
|
|
||||||
|
|
||||||
BPoint where(ContentLocation());
|
|
||||||
where.y = Frame().top;
|
|
||||||
Menu()->SetDrawingMode(B_OP_OVER);
|
|
||||||
Menu()->DrawBitmapAsync(deviceIcon, where);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user