Added desklink

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5213 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2003-10-30 15:10:18 +00:00
parent 7206521bed
commit f7d9ae3667
9 changed files with 989 additions and 0 deletions

View File

@ -52,6 +52,7 @@ StdBinCommands
#SubInclude OBOS_TOP src apps bin gnu ;
SubInclude OBOS_TOP src apps bin addattr ;
SubInclude OBOS_TOP src apps bin chkbfs ;
SubInclude OBOS_TOP src apps bin desklink ;
SubInclude OBOS_TOP src apps bin listdev ;
SubInclude OBOS_TOP src apps bin mkdos ;
SubInclude OBOS_TOP src apps bin pc ;

View File

@ -0,0 +1,178 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <Dragger.h>
#include <Bitmap.h>
#include <Message.h>
#include <String.h>
#include <Alert.h>
#include <NodeInfo.h>
#include <PopUpMenu.h>
#include <MenuItem.h>
#include <Roster.h>
#include <stdlib.h>
#include "DeskButton.h"
#define OPEN_REF 'opre'
#define DO_ACTION 'doac'
extern char *app_signature;
DeskButton::DeskButton(BRect frame, entry_ref *entry_ref, const char *name, BList &titles, BList &actions,
uint32 resizeMask, uint32 flags)
: BView(frame, name, resizeMask, flags),
ref(*entry_ref),
titleList(titles),
actionList(actions)
{
// Background Color
SetViewColor(184,184,184);
//add dragger
BRect rect(Bounds());
rect.left = rect.right-7.0;
rect.top = rect.bottom-7.0;
BDragger *dragger = new BDragger(rect, this, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
AddChild(dragger);
dragger->SetViewColor(B_TRANSPARENT_32_BIT);
segments = new BBitmap(BRect(0,0,15,15), B_CMAP8);
BNodeInfo::GetTrackerIcon(&ref, segments, B_MINI_ICON);
}
DeskButton::DeskButton(BMessage *message)
: BView(message)
{
message->FindRef("ref", &ref);
BString title, action;
int32 index = 0;
while(message->FindString("title", index, &title)==B_OK
&& message->FindString("action", index, &action)==B_OK) {
titleList.AddItem(new BString(title));
actionList.AddItem(new BString(action));
index++;
}
segments = new BBitmap(BRect(0,0,15,15), B_CMAP8);
BNodeInfo::GetTrackerIcon(&ref, segments, B_MINI_ICON);
}
DeskButton::~DeskButton()
{
delete segments;
}
// archiving overrides
DeskButton *
DeskButton::Instantiate(BMessage *data)
{
if (!validate_instantiation(data, "DeskButton"))
return NULL;
return new DeskButton(data);
}
status_t
DeskButton::Archive(BMessage *data, bool deep) const
{
BView::Archive(data, deep);
data->AddRef("ref", &ref);
for(int32 i=0; i<titleList.CountItems() &&
i<actionList.CountItems(); i++) {
data->AddString("title", *(BString*)titleList.ItemAt(i));
data->AddString("action", *(BString*)actionList.ItemAt(i));
}
data->AddString("add_on", app_signature);
return B_NO_ERROR;
}
void
DeskButton::MessageReceived(BMessage *message)
{
switch (message->what) {
case B_ABOUT_REQUESTED:
(new BAlert("About Desklink", "Desklink (Replicant)\n"
" Brought to you by Jérôme DUVAL.\n\n"
"OpenBeOS, 2003","OK"))->Go();
break;
case OPEN_REF:
be_roster->Launch(&ref);
break;
case DO_ACTION:
{
BString action;
if(message->FindString("action", &action)==B_OK) {
action += " &";
system(action.String());
}
break;
}
default:
BView::MessageReceived(message);
break;
}
}
void
DeskButton::Draw(BRect rect)
{
BView::Draw(rect);
SetDrawingMode(B_OP_OVER);
DrawBitmap(segments);
}
void
DeskButton::MouseDown(BPoint point)
{
uint32 mouseButtons;
BPoint where;
GetMouse(&where, &mouseButtons, true);
where = ConvertToScreen(point);
if (mouseButtons & B_SECONDARY_MOUSE_BUTTON) {
BString label = "Open ";
label += ref.name;
BPopUpMenu *menu = new BPopUpMenu("", false, false);
menu->SetFont(be_plain_font);
menu->AddItem(new BMenuItem(label.String(), new BMessage(OPEN_REF)));
if(titleList.CountItems()>0 && actionList.CountItems()>0) {
menu->AddSeparatorItem();
for(int32 i=0; i<titleList.CountItems() && i<actionList.CountItems(); i++) {
BMessage *message = new BMessage(DO_ACTION);
message->AddString("action", *(BString*)actionList.ItemAt(i));
menu->AddItem(new BMenuItem(((BString*)titleList.ItemAt(i))->String(), message));
}
}
menu->SetTargetForItems(this);
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
where + BPoint(4, 4)));
} else if (mouseButtons & B_PRIMARY_MOUSE_BUTTON) {
be_roster->Launch(&ref);
}
}

View File

@ -0,0 +1,50 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef DESKBUTTON_H
#define DESKBUTTON_H
#include <View.h>
#include <List.h>
#include <Entry.h>
class DeskButton : public BView {
public:
DeskButton(BRect frame, entry_ref *ref, const char *name, BList &titleList, BList &actionList,
uint32 resizeMask = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED);
DeskButton(BMessage *);
// BMessage * based constructor needed to support archiving
virtual ~DeskButton();
// archiving overrides
static DeskButton *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
// misc BView overrides
virtual void MouseDown(BPoint);
virtual void Draw(BRect );
virtual void MessageReceived(BMessage *);
private:
BBitmap * segments;
entry_ref ref;
BList actionList, titleList;
};
#endif

View File

@ -0,0 +1,11 @@
SubDir OBOS_TOP src apps bin desklink ;
AddResources desklink : desklink.rsrc ;
BinCommand desklink :
desklink.cpp
VolumeSlider.cpp
DeskButton.cpp
: be media
;

View File

@ -0,0 +1,316 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <MediaRoster.h>
#include <MediaTheme.h>
#include <MultiChannelControl.h>
#include <Screen.h>
#include <Beep.h>
#include <Box.h>
#include <stdio.h>
#include <Debug.h>
#include "VolumeSlider.h"
#include "iconfile.h"
#define VOLUME_CHANGED 'vlcg'
VolumeSlider::VolumeSlider(BRect frame)
: BWindow(frame, "VolumeSlider", B_BORDERED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK, 0),
aOutNode(NULL),
paramWeb(NULL),
mixerParam(NULL)
{
//Make sure it's not outside the screen.
const int32 kMargin = 3;
BRect windowRect=ConvertToScreen(Bounds());
BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
if (screenFrame.right < windowRect.right + kMargin)
MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
if (screenFrame.bottom < windowRect.bottom + kMargin)
MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom);
if (screenFrame.left > windowRect.left - kMargin)
MoveBy(kMargin + screenFrame.left - windowRect.left, 0);
if (screenFrame.top > windowRect.top - kMargin)
MoveBy(0, kMargin + screenFrame.top - windowRect.top);
float value = 0.0;
aOutNode = new media_node();
status_t err;
BMediaRoster* roster = BMediaRoster::Roster(&err);
if(roster && (err==B_OK)) {
if((err = roster->GetAudioOutput(aOutNode)) == B_OK) {
if((err = roster->GetParameterWebFor(*aOutNode, &paramWeb)) == B_OK) {
//Finding the Mixer slider in the audio output ParameterWeb
int32 numParams = paramWeb->CountParameters();
BParameter* p = NULL;
for (int i = 0; i < numParams; i++) {
p = paramWeb->ParameterAt(i);
printf("%i %s\n", i, p->Name());
if (!strcmp(p->Name(), "Master")) {
for (; i < numParams; i++) {
p = paramWeb->ParameterAt(i);
if (strcmp(p->Kind(), B_MASTER_GAIN)) p=NULL;
else break;
}
break;
} else p = NULL;
}
if (p==NULL) {
printf("Could not find the mixer.\n");
exit(1);
} else if(p->Type()!=BParameter::B_CONTINUOUS_PARAMETER) {
printf("Mixer is unknown.\n");
exit(2);
}
mixerParam= dynamic_cast<BContinuousParameter*>(p);
min = mixerParam->MinValue();
max = mixerParam->MaxValue();
step = mixerParam->ValueStep();
float chanData[2];
bigtime_t lastChange;
size_t size = sizeof(chanData);
mixerParam->GetValue( &chanData, &size, &lastChange );
value = (chanData[0]-min)*100/(max-min);
} else {
printf("No parameter web\n");
}
} else {
printf("No Audio output\n");
}
} else {
printf("No Media Roster\n");
}
if(err!=B_OK) {
delete aOutNode;
aOutNode = NULL;
}
BBox *box = new BBox(Bounds(), "sliderbox", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
AddChild(box);
slider = new SliderView(box->Bounds().InsetByCopy(1, 1), new BMessage(VOLUME_CHANGED),
mixerParam ? "Volume" : "No Media Server", B_FOLLOW_LEFT | B_FOLLOW_TOP, value);
box->AddChild(slider);
slider->SetTarget(this);
SetPulseRate(100);
}
VolumeSlider::~VolumeSlider()
{
delete paramWeb;
BMediaRoster* roster = BMediaRoster::CurrentRoster();
if(roster && aOutNode)
roster->ReleaseNode(*aOutNode);
}
void
VolumeSlider::WindowActivated(bool active)
{
if (!active) {
Lock();
Quit();
}
}
void
VolumeSlider::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case VOLUME_CHANGED:
{
printf("VOLUME_CHANGED\n");
if(mixerParam) {
float chanData[2];
bigtime_t lastChange;
size_t size = sizeof(chanData);
mixerParam->GetValue( &chanData, &size, &lastChange );
for( int i=0; i<2; i++) {
chanData[i] = (slider->Value() * (max - min) / 100) / step * step + min;
}
PRINT(("Min value: %f Max Value: %f\nData: %f %f\n", mixerParam->MinValue(), mixerParam->MaxValue(), chanData[0], chanData[1]));
mixerParam->SetValue(&chanData, sizeof(chanData), 0);
beep();
}
Quit();
break;
}
default:
BWindow::MessageReceived(msg); // not a slider message, not our problem
}
}
#define REDZONESTART 151
SliderView::SliderView(BRect rect, BMessage *msg, const char *title, uint32 resizeFlags, int32 value)
: BControl(rect, "slider", NULL, msg, resizeFlags, B_WILL_DRAW | B_PULSE_NEEDED),
leftBitmap(BRect(0, 0, kLeftWidth - 1, kLeftHeight - 1), B_CMAP8),
rightBitmap(BRect(0, 0, kRightWidth - 1, kRightHeight - 1), B_CMAP8),
buttonBitmap(BRect(0, 0, kButtonWidth - 1, kButtonHeight - 1), B_CMAP8),
fTrackingX(11 + (192-11) * value / 100),
fTitle(title)
{
leftBitmap.SetBits(kLeftBits, kLeftWidth * kLeftHeight, 0, B_CMAP8);
rightBitmap.SetBits(kRightBits, kRightWidth * kRightHeight, 0, B_CMAP8);
buttonBitmap.SetBits(kButtonBits, kButtonWidth * kButtonHeight, 0, B_CMAP8);
SetTracking(true);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
SetValue(value);
}
SliderView::~SliderView()
{
}
void
SliderView::Pulse()
{
uint32 mouseButtons;
BPoint where;
GetMouse(&where, &mouseButtons, true);
// button not pressed, exit
if (! (mouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
SetTracking(false);
SetValue( (fTrackingX - 11) / (192-11) * 100 );
Invoke();
}
}
void
SliderView::Draw(BRect updateRect)
{
SetHighColor(189,186,189);
StrokeLine(BPoint(11,1), BPoint(192,1));
SetHighColor(0,0,0);
StrokeLine(BPoint(11,2), BPoint(192,2));
SetHighColor(255,255,255);
StrokeLine(BPoint(11,14), BPoint(192,14));
SetHighColor(231,227,231);
StrokeLine(BPoint(11,15), BPoint(192,15));
SetLowColor(ViewColor());
SetDrawingMode(B_OP_OVER);
DrawBitmapAsync(&leftBitmap, BPoint(5,1));
DrawBitmapAsync(&rightBitmap, BPoint(193,1));
float right = (fTrackingX < REDZONESTART) ? fTrackingX : REDZONESTART;
SetHighColor(99,151,99);
FillRect(BRect(11,3,right,4));
SetHighColor(156,203,156);
FillRect(BRect(11,5,right,13));
if(right == REDZONESTART) {
SetHighColor(156,101,99);
FillRect(BRect(REDZONESTART,3,fTrackingX,4));
SetHighColor(255,154,156);
FillRect(BRect(REDZONESTART,5,fTrackingX,13));
}
SetHighColor(156,154,156);
FillRect(BRect(fTrackingX,3,192,13));
BFont font;
float width = font.StringWidth(fTitle);
SetHighColor(49,154,49);
DrawString(fTitle, BPoint(11 + (192-11-width)/2, 12));
DrawBitmapAsync(&buttonBitmap, BPoint(fTrackingX-5,3));
Sync();
SetDrawingMode(B_OP_COPY);
}
void
SliderView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
{
if (!IsTracking())
return;
uint32 mouseButtons;
BPoint where;
GetMouse(&where, &mouseButtons, true);
// button not pressed, exit
if (! (mouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
Invoke();
SetTracking(false);
}
if (!Bounds().InsetBySelf(2,2).Contains(point))
return;
fTrackingX = point.x;
if(fTrackingX < 11)
fTrackingX = 11;
if(fTrackingX > 192)
fTrackingX = 192;
Draw(Bounds());
Flush();
}
void
SliderView::MouseUp(BPoint point)
{
if (!IsTracking())
return;
SetValue( (point.x - 11) / (192-11) * 100 );
if(Value()<0)
SetValue(0);
if(Value()>100)
SetValue(100);
Invoke();
SetTracking(false);
fTrackingX = point.x;
if(fTrackingX < 11)
fTrackingX = 11;
if(fTrackingX > 192)
fTrackingX = 192;
Draw(Bounds());
Flush();
}

View File

@ -0,0 +1,55 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef VOLUMESLIDER_H
#define VOLUMESLIDER_H
#include <Window.h>
#include <Control.h>
#include <Bitmap.h>
#include <ParameterWeb.h>
class SliderView : public BControl
{
public:
SliderView(BRect rect, BMessage *msg, const char* title, uint32 resizeFlags, int32 value);
~SliderView();
virtual void Draw(BRect);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void MouseUp(BPoint point);
virtual void Pulse();
private:
BBitmap leftBitmap, rightBitmap, buttonBitmap;
float fTrackingX;
const char* fTitle;
};
class VolumeSlider : public BWindow
{
public:
VolumeSlider(BRect frame);
~VolumeSlider();
void MessageReceived(BMessage*);
void WindowActivated(bool active);
private:
media_node *aOutNode;
BParameterWeb* paramWeb;
BContinuousParameter* mixerParam;
float min, max, step;
SliderView *slider;
};
#endif

View File

@ -0,0 +1,277 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <View.h>
#include <Dragger.h>
#include <Message.h>
#include <Alert.h>
#include <Bitmap.h>
#include <stdio.h>
#include <Application.h>
#include <PopUpMenu.h>
#include <MenuItem.h>
#include <Roster.h>
#include <Deskbar.h>
#include <strings.h>
#include <List.h>
#include <String.h>
#include "VolumeSlider.h"
#include "DeskButton.h"
#include "iconfile.h"
#define MEDIA_SETTINGS 'mese'
#define SOUND_SETTINGS 'sose'
#define OPEN_MEDIA_PLAYER 'omep'
const char *app_signature = "application/x-vnd.be.desklink";
// the application signature used by the replicant to find the supporting
// code
class _EXPORT VCButton;
// the dragger part has to be exported
class VCButton : public BView {
public:
VCButton(BRect frame, const char *name,
uint32 resizeMask = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED);
VCButton(BMessage *);
// BMessage * based constructor needed to support archiving
virtual ~VCButton();
// archiving overrides
static VCButton *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
// misc BView overrides
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint);
virtual void Draw(BRect );
virtual void MessageReceived(BMessage *);
private:
BBitmap * segments;
VolumeSlider *volumeSlider;
};
//
// This is the exported function that will be used by Deskbar
// to create and add the replicant
//
extern "C" _EXPORT BView* instantiate_deskbar_item();
BView *
instantiate_deskbar_item()
{
return new VCButton(BRect(0, 0, 16, 16), "VCButton");
}
VCButton::VCButton(BRect frame, const char *name,
uint32 resizeMask, uint32 flags)
: BView(frame, name, resizeMask, flags)
{
// Background Bitmap
segments = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), B_COLOR_8_BIT);
segments->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_COLOR_8_BIT);
// Background Color
SetViewColor(184,184,184);
//add dragger
BRect rect(Bounds());
rect.left = rect.right-7.0;
rect.top = rect.bottom-7.0;
BDragger *dragger = new BDragger(rect, this, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
AddChild(dragger);
dragger->SetViewColor(B_TRANSPARENT_32_BIT);
}
VCButton::VCButton(BMessage *message)
: BView(message),
volumeSlider(NULL)
{
// Background Bitmap
segments = new BBitmap(BRect(0, 0, 16 - 1, 16 - 1), B_COLOR_8_BIT);
segments->SetBits(kSpeakerBits, 16*16, 0, B_COLOR_8_BIT);
}
VCButton::~VCButton()
{
delete segments;
}
// archiving overrides
VCButton *
VCButton::Instantiate(BMessage *data)
{
if (!validate_instantiation(data, "VCButton"))
return NULL;
return new VCButton(data);
}
status_t
VCButton::Archive(BMessage *data, bool deep) const
{
BView::Archive(data, deep);
data->AddString("add_on", app_signature);
return B_NO_ERROR;
}
void
VCButton::MessageReceived(BMessage *message)
{
switch (message->what) {
case B_ABOUT_REQUESTED:
(new BAlert("About Volume Control", "Volume Control (Replicant)\n"
" Brought to you by Jérôme DUVAL.\n\n"
"OpenBeOS, 2003","OK"))->Go();
break;
case OPEN_MEDIA_PLAYER:
// launch the media player app
be_roster->Launch("application/x-vnd.Be.MediaPlayer");
break;
case MEDIA_SETTINGS:
// launch the media prefs app
be_roster->Launch("application/x-vnd.Be.MediaPrefs");
break;
case SOUND_SETTINGS:
// launch the sounds prefs app
be_roster->Launch("application/x-vnd.Be.SoundsPrefs");
break;
default:
BView::MessageReceived(message);
break;
}
}
void
VCButton::Draw(BRect rect)
{
BView::Draw(rect);
SetDrawingMode(B_OP_OVER);
DrawBitmap(segments);
}
void
VCButton::MouseDown(BPoint point)
{
uint32 mouseButtons;
BPoint where;
GetMouse(&where, &mouseButtons, true);
where = ConvertToScreen(point);
if (mouseButtons & B_SECONDARY_MOUSE_BUTTON) {
BPopUpMenu *menu = new BPopUpMenu("", false, false);
menu->SetFont(be_plain_font);
menu->AddItem(new BMenuItem("Media Settings...", new BMessage(MEDIA_SETTINGS)));
menu->AddItem(new BMenuItem("Sound Settings...", new BMessage(SOUND_SETTINGS)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Open MediaPlayer", new BMessage(OPEN_MEDIA_PLAYER)));
menu->SetTargetForItems(this);
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
where + BPoint(4, 4)));
} else if (mouseButtons & B_PRIMARY_MOUSE_BUTTON) {
// Show VolumeSlider
volumeSlider = new VolumeSlider(BRect(where.x,where.y,where.x+207,where.y+19));
volumeSlider->Show();
}
}
void
VCButton::MouseUp(BPoint point)
{
if(volumeSlider) {
volumeSlider->Lock();
volumeSlider->Quit();
delete volumeSlider;
volumeSlider = NULL;
}
}
int
main(int, char **argv)
{
BApplication app(app_signature);
bool atLeastOnePath = false;
BList titleList;
BList actionList;
for(int32 i=1; argv[i]!=NULL; i++) {
if (strncmp(argv[i], "cmd=", 4) == 0) {
BString *title = new BString(argv[i] + 4);
int32 index = title->FindFirst(':');
if(index<=0) {
printf("desklink: usage: cmd=title:action\n");
} else {
title->Truncate(index);
BString *action = new BString(argv[i] + 4);
action->Remove(0, index+1);
titleList.AddItem(title);
actionList.AddItem(action);
}
continue;
}
atLeastOnePath = true;
BEntry entry(argv[i], true);
if(!entry.Exists()) {
printf("desklink: cannot find '%s'\n", argv[i]);
return 1;
}
entry_ref ref;
entry.GetRef(&ref);
status_t err;
err = BDeskbar().AddItem(new DeskButton(BRect(0, 0, 16, 16), &ref, "DeskButton",
titleList, actionList));
if(err!=B_OK) {
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));
}
titleList.MakeEmpty();
actionList.MakeEmpty();
}
if (!atLeastOnePath) {
// print a simple usage string
printf( "usage: desklink { [ cmd=title:action ... ] path } ...\n");
return 1;
}
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,101 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2003, OpenBeOS
//
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
//
// Program: desklink
// Author: Jérôme DUVAL
// Description: VolumeControl and link items in Deskbar
// Created : October 20, 2003
// Modified by: Jérome Duval
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
const int32 kSpeakerWidth = 16;
const int32 kSpeakerHeight = 16;
const color_space kSpeakerColorSpace = B_CMAP8;
const unsigned char kSpeakerBits [] = {
0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0x00,0x3f,0x1c,0x1c,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x00,0x3f,0x1c,0x1c,0x1c,0x1c,0x1c,0x00,0x00,0xff,0xff,0xff,0xff,
0xff,0xff,0x00,0x3f,0x3f,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x11,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x17,0x18,0x3f,0x3f,0x1c,0x1c,0x1c,0x11,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x17,0x17,0x18,0x17,0x3f,0x3f,0x11,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x11,0x00,0x00,0x00,0x17,0x11,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x00,0x08,0x09,0x00,0x11,0x11,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x00,0x08,0x0f,0x0b,0x08,0x11,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x11,0x00,0x0a,0x0f,0x09,0x11,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x17,0x11,0x08,0x09,0x11,0x11,0x0f,0x0f,0x0f,0x00,0xff,0xff,0xff,
0xff,0xff,0x00,0x17,0x17,0x17,0x17,0x17,0x11,0x0f,0x0f,0x0f,0x00,0x0f,0xff,0xff,
0xff,0xff,0x00,0x00,0x17,0x17,0x2d,0x18,0x11,0x0f,0x0f,0x00,0x0f,0x0f,0xff,0xff,
0xff,0xff,0xff,0xff,0x00,0x00,0x17,0x17,0x11,0x0f,0x00,0x0f,0x0f,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x11,0x00,0x0f,0x0f,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x0f,0x0f,0xff,0xff,0xff,0xff,0xff
};
const int32 kButtonWidth = 16;
const int32 kButtonHeight = 11;
const color_space kButtonColorSpace = B_CMAP8;
const unsigned char kButtonBits [] = {
0xff,0xff,0xff,0x18,0x1d,0x3f,0x1d,0x19,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x15,0x1d,0x1e,0x1e,0x1d,0x1e,0x1b,0x19,0x12,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x1e,0x1e,0x1d,0x1d,0x3f,0x1d,0x1d,0x1b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1a,0x1e,0x1d,0x1d,0x1d,0xff,0x1d,0x1d,0x1d,0x19,0x12,0xff,0xff,0xff,0xff,0xff,
0x1e,0x1e,0x1d,0x1d,0x1d,0x3f,0x1d,0x1d,0x1d,0x19,0x11,0xff,0xff,0xff,0xff,0xff,
0x3f,0x1d,0x1d,0x1d,0x1d,0xff,0x1d,0x1d,0x1d,0x1c,0x0e,0xff,0xff,0xff,0xff,0xff,
0x1e,0x1e,0x1d,0x1d,0x1d,0x3f,0x1d,0x1d,0x1d,0x19,0x11,0xff,0xff,0xff,0xff,0xff,
0x1a,0x1d,0x1d,0x1d,0x1d,0xff,0x1d,0x1d,0x1d,0x15,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x1a,0x19,0x1d,0x1d,0x1d,0x1d,0x1d,0x17,0x12,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x16,0xff,0x15,0x19,0x1c,0x19,0x15,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x14,0x11,0x0e,0x11,0x14,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
const int32 kLeftWidth = 16;
const int32 kLeftHeight = 15;
const color_space kLeftColorSpace = B_CMAP8;
const unsigned char kLeftBits [] = {
0xff,0xff,0xff,0xff,0x19,0x19,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x1a,0x18,0x11,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x19,0x15,0x0b,0x06,0x0a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1a,0x15,0x09,0x09,0xb6,0x8f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x18,0x0b,0x09,0x8f,0x8f,0x8f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x11,0x07,0xb6,0x8f,0x8f,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x0c,0x0c,0x8f,0x8f,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x07,0x10,0x8f,0x68,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x16,0x12,0x8f,0x68,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1a,0x16,0x11,0x68,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x1a,0x18,0x68,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x1c,0x19,0x68,0x68,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x1d,0x1c,0x19,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0x1d,0x1e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
const int32 kRightWidth = 16;
const int32 kRightHeight = 15;
const color_space kRightColorSpace = B_CMAP8;
const unsigned char kRightBits [] = {
0x19,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x11,0x18,0x1a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x08,0x0d,0x16,0x1a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x11,0x0c,0x0f,0x17,0x1a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x10,0x14,0x19,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x13,0x15,0x19,0x1a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x13,0x16,0x1a,0x1a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x13,0x15,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x13,0x19,0x1e,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x13,0x15,0x1d,0x1d,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x13,0x14,0x1a,0x1e,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x15,0xff,0x3f,0x1d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1d,0x1e,0x1d,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1d,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};