* Cleanup of signatures and version infos - this is part of a fix to bug #909.
I've done all preferences apps for now, and some related. * Some other related cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,81 +1,78 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* Jérôme Duval
|
||||
*/
|
||||
|
||||
|
||||
#include "DeskButton.h"
|
||||
|
||||
#include <Dragger.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Dragger.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Roster.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "DeskButton.h"
|
||||
|
||||
#define OPEN_REF 'opre'
|
||||
#define DO_ACTION 'doac'
|
||||
|
||||
extern char *app_signature;
|
||||
extern const char *kAppSignature;
|
||||
// from desklink.cpp
|
||||
|
||||
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),
|
||||
actionList(actions),
|
||||
titleList(titles)
|
||||
|
||||
DeskButton::DeskButton(BRect frame, entry_ref* ref, const char* name,
|
||||
BList& titles, BList& actions, uint32 resizeMask, uint32 flags)
|
||||
: BView(frame, name, resizeMask, flags),
|
||||
fRef(*ref),
|
||||
fActionList(actions),
|
||||
fTitleList(titles)
|
||||
{
|
||||
// Background Color
|
||||
SetViewColor(184,184,184);
|
||||
SetViewColor(184, 184, 184);
|
||||
|
||||
//add dragger
|
||||
BRect rect(Bounds());
|
||||
rect.left = rect.right-7.0;
|
||||
rect.top = rect.bottom-7.0;
|
||||
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);
|
||||
fSegments = new BBitmap(BRect(0,0,15,15), B_CMAP8);
|
||||
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
|
||||
}
|
||||
|
||||
|
||||
DeskButton::DeskButton(BMessage *message)
|
||||
: BView(message)
|
||||
{
|
||||
message->FindRef("ref", &ref);
|
||||
message->FindRef("ref", &fRef);
|
||||
|
||||
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));
|
||||
fTitleList.AddItem(new BString(title));
|
||||
fActionList.AddItem(new BString(action));
|
||||
index++;
|
||||
}
|
||||
|
||||
segments = new BBitmap(BRect(0,0,15,15), B_CMAP8);
|
||||
BNodeInfo::GetTrackerIcon(&ref, segments, B_MINI_ICON);
|
||||
fSegments = new BBitmap(BRect(0,0,15,15), B_CMAP8);
|
||||
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
|
||||
}
|
||||
|
||||
|
||||
DeskButton::~DeskButton()
|
||||
{
|
||||
delete segments;
|
||||
delete fSegments;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +82,7 @@ DeskButton::Instantiate(BMessage *data)
|
||||
{
|
||||
if (!validate_instantiation(data, "DeskButton"))
|
||||
return NULL;
|
||||
|
||||
return new DeskButton(data);
|
||||
}
|
||||
|
||||
@@ -94,19 +92,19 @@ DeskButton::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
BView::Archive(data, deep);
|
||||
|
||||
data->AddRef("ref", &ref);
|
||||
data->AddRef("ref", &fRef);
|
||||
|
||||
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));
|
||||
for (int32 i = 0; i < fTitleList.CountItems()
|
||||
&& i < fActionList.CountItems(); i++) {
|
||||
data->AddString("title", *(BString*)fTitleList.ItemAt(i));
|
||||
data->AddString("action", *(BString*)fActionList.ItemAt(i));
|
||||
}
|
||||
|
||||
data->AddString("add_on", app_signature);
|
||||
data->AddString("add_on", kAppSignature);
|
||||
return B_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
DeskButton::MessageReceived(BMessage *message)
|
||||
{
|
||||
@@ -114,15 +112,15 @@ DeskButton::MessageReceived(BMessage *message)
|
||||
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();
|
||||
"Copyright " B_UTF8_COPYRIGHT "2003-2006, Haiku","OK"))->Go();
|
||||
break;
|
||||
case OPEN_REF:
|
||||
be_roster->Launch(&ref);
|
||||
be_roster->Launch(&fRef);
|
||||
break;
|
||||
case DO_ACTION:
|
||||
{
|
||||
BString action;
|
||||
if(message->FindString("action", &action)==B_OK) {
|
||||
if (message->FindString("action", &action) == B_OK) {
|
||||
action += " &";
|
||||
system(action.String());
|
||||
}
|
||||
@@ -139,33 +137,34 @@ void
|
||||
DeskButton::Draw(BRect rect)
|
||||
{
|
||||
BView::Draw(rect);
|
||||
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
DrawBitmap(segments);
|
||||
DrawBitmap(fSegments);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeskButton::MouseDown(BPoint point)
|
||||
{
|
||||
uint32 mouseButtons;
|
||||
BPoint where;
|
||||
GetMouse(&where, &mouseButtons, true);
|
||||
|
||||
where = ConvertToScreen(point);
|
||||
|
||||
uint32 mouseButtons = 0;
|
||||
if (Window()->CurrentMessage() != NULL)
|
||||
mouseButtons = Window()->CurrentMessage()->FindInt32("buttons");
|
||||
|
||||
BPoint where = ConvertToScreen(point);
|
||||
|
||||
if (mouseButtons & B_SECONDARY_MOUSE_BUTTON) {
|
||||
BString label = "Open ";
|
||||
label += ref.name;
|
||||
label += fRef.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) {
|
||||
if (fTitleList.CountItems() > 0 && fActionList.CountItems() > 0) {
|
||||
menu->AddSeparatorItem();
|
||||
for(int32 i=0; i<titleList.CountItems() && i<actionList.CountItems(); i++) {
|
||||
for (int32 i = 0; i < fTitleList.CountItems()
|
||||
&& i < fActionList.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));
|
||||
message->AddString("action", *(BString*)fActionList.ItemAt(i));
|
||||
menu->AddItem(new BMenuItem(((BString*)fTitleList.ItemAt(i))->String(), message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +172,6 @@ DeskButton::MouseDown(BPoint point)
|
||||
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);
|
||||
be_roster->Launch(&fRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,40 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// 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
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* Jérôme Duval
|
||||
*/
|
||||
#ifndef DESK_BUTTON_H
|
||||
#define DESK_BUTTON_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);
|
||||
|
||||
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;
|
||||
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);
|
||||
DeskButton(BMessage* archive);
|
||||
virtual ~DeskButton();
|
||||
|
||||
// misc BView overrides
|
||||
virtual void MouseDown(BPoint);
|
||||
|
||||
virtual void Draw(BRect );
|
||||
// archiving overrides
|
||||
static DeskButton* Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
|
||||
virtual void MessageReceived(BMessage *);
|
||||
private:
|
||||
BBitmap * segments;
|
||||
entry_ref ref;
|
||||
BList actionList, titleList;
|
||||
// misc BView overrides
|
||||
virtual void MouseDown(BPoint);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
BBitmap* fSegments;
|
||||
entry_ref fRef;
|
||||
BList fActionList, fTitleList;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif // DESK_BUTTON_H
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// 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
|
||||
// Modified by: François Revol, 10/31/2003
|
||||
// Modified by: Marcus Overhagen, 15/08/2004
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* Jérôme Duval
|
||||
* François Revol
|
||||
* Marcus Overhagen
|
||||
*/
|
||||
|
||||
//! VolumeControl and link items in Deskbar
|
||||
|
||||
#include "VolumeSlider.h"
|
||||
#include "DeskButton.h"
|
||||
#include "iconfile.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
@@ -22,8 +20,8 @@
|
||||
#include <Debug.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Dragger.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <List.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
@@ -32,11 +30,9 @@
|
||||
#include <Roster.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include "VolumeSlider.h"
|
||||
#include "DeskButton.h"
|
||||
#include "iconfile.h"
|
||||
|
||||
#define MEDIA_SETTINGS 'mese'
|
||||
#define SOUND_SETTINGS 'sose'
|
||||
@@ -44,13 +40,14 @@
|
||||
#define TOGGLE_DONT_BEEP 'tdbp'
|
||||
#define SET_VOLUME_WHICH 'svwh'
|
||||
|
||||
#define VOLUME_CTL_NAME "MediaReplicant" /* R5 name needed, Media prefs manel removes by name */
|
||||
#define VOLUME_CTL_NAME "MediaReplicant"
|
||||
/* R5 name needed, Media prefs manel removes by name */
|
||||
|
||||
#define SETTINGS_FILE "x-vnd.OBOS.DeskbarVolumeControlSettings"
|
||||
|
||||
const char *app_signature = "application/x-vnd.be.desklink";
|
||||
// the application signature used by the replicant to find the supporting
|
||||
// code
|
||||
const char *kAppSignature = "application/x-vnd.Haiku-desklink";
|
||||
// the application signature used by the replicant to find the
|
||||
// supporting code
|
||||
|
||||
class _EXPORT MediaReplicant;
|
||||
// the dragger part has to be exported
|
||||
@@ -60,7 +57,6 @@ public:
|
||||
MediaReplicant(BRect frame, const char *name,
|
||||
uint32 resizeMask = B_FOLLOW_ALL,
|
||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||
|
||||
MediaReplicant(BMessage *);
|
||||
// BMessage * based constructor needed to support archiving
|
||||
virtual ~MediaReplicant();
|
||||
@@ -69,23 +65,24 @@ public:
|
||||
static MediaReplicant *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 Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual void MessageReceived(BMessage *);
|
||||
private:
|
||||
status_t LaunchByPath(const char *path);
|
||||
status_t LaunchBySig(const char *sig);
|
||||
void LoadSettings();
|
||||
void SaveSettings();
|
||||
BBitmap * segments;
|
||||
VolumeSlider *volumeSlider;
|
||||
bool confDontBeep; /* don't beep on volume change */
|
||||
int32 confVolumeWhich; /* which volume parameter to act on (Mixer/Phys.Output) */
|
||||
|
||||
BBitmap* fSegments;
|
||||
VolumeSlider* fVolumeSlider;
|
||||
bool fDontBeep;
|
||||
/* don't beep on volume change */
|
||||
int32 fVolumeWhich;
|
||||
/* which volume parameter to act on (Mixer/Phys.Output) */
|
||||
};
|
||||
|
||||
//
|
||||
@@ -102,12 +99,13 @@ instantiate_deskbar_item()
|
||||
|
||||
|
||||
MediaReplicant::MediaReplicant(BRect frame, const char *name,
|
||||
uint32 resizeMask, uint32 flags)
|
||||
: BView(frame, name, resizeMask, flags)
|
||||
uint32 resizeMask, uint32 flags)
|
||||
: BView(frame, name, resizeMask, flags),
|
||||
fVolumeSlider(NULL)
|
||||
{
|
||||
// Background Bitmap
|
||||
segments = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), B_CMAP8);
|
||||
segments->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_CMAP8);
|
||||
fSegments = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), B_CMAP8);
|
||||
fSegments->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_CMAP8);
|
||||
// Background Color
|
||||
SetViewColor(184,184,184);
|
||||
|
||||
@@ -123,29 +121,29 @@ MediaReplicant::MediaReplicant(BRect frame, const char *name,
|
||||
|
||||
|
||||
MediaReplicant::MediaReplicant(BMessage *message)
|
||||
: BView(message),
|
||||
volumeSlider(NULL)
|
||||
: BView(message),
|
||||
fVolumeSlider(NULL)
|
||||
{
|
||||
// Background Bitmap
|
||||
segments = new BBitmap(BRect(0, 0, 16 - 1, 16 - 1), B_CMAP8);
|
||||
segments->SetBits(kSpeakerBits, 16*16, 0, B_CMAP8);
|
||||
fSegments = new BBitmap(BRect(0, 0, 16 - 1, 16 - 1), B_CMAP8);
|
||||
fSegments->SetBits(kSpeakerBits, 16*16, 0, B_CMAP8);
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
|
||||
MediaReplicant::~MediaReplicant()
|
||||
{
|
||||
delete segments;
|
||||
delete fSegments;
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
// archiving overrides
|
||||
MediaReplicant *
|
||||
MediaReplicant::Instantiate(BMessage *data)
|
||||
{
|
||||
if (!validate_instantiation(data, VOLUME_CTL_NAME))
|
||||
return NULL;
|
||||
|
||||
return new MediaReplicant(data);
|
||||
}
|
||||
|
||||
@@ -153,10 +151,11 @@ MediaReplicant::Instantiate(BMessage *data)
|
||||
status_t
|
||||
MediaReplicant::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
BView::Archive(data, deep);
|
||||
status_t status = BView::Archive(data, deep);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
data->AddString("add_on", app_signature);
|
||||
return B_NO_ERROR;
|
||||
return data->AddString("add_on", kAppSignature);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,43 +166,40 @@ MediaReplicant::MessageReceived(BMessage *message)
|
||||
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();
|
||||
"Copyright " B_UTF8_COPYRIGHT "2003-2006, Haiku","OK"))->Go();
|
||||
break;
|
||||
case OPEN_MEDIA_PLAYER:
|
||||
// launch the media player app
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Haiku.MediaPlayer"))
|
||||
break;
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Be.MediaPlayer"))
|
||||
break;
|
||||
if (B_OK == LaunchByPath("/boot/beos/apps/MediaPlayer"))
|
||||
if (LaunchBySig("application/x-vnd.Haiku.MediaPlayer") == B_OK
|
||||
|| LaunchBySig("application/x-vnd.Be.MediaPlayer") == B_OK
|
||||
|| LaunchByPath("/boot/beos/apps/MediaPlayer") == B_OK)
|
||||
break;
|
||||
|
||||
(new BAlert("desklink", "Couldn't launch MediaPlayer", "OK"))->Go();
|
||||
break;
|
||||
case MEDIA_SETTINGS:
|
||||
// launch the media prefs app
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Haiku.MediaPrefs"))
|
||||
break;
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Be.MediaPrefs"))
|
||||
break;
|
||||
if (B_OK == LaunchByPath("/boot/home/config/be/Preferences/Media"))
|
||||
if (LaunchBySig("application/x-vnd.Haiku-Media") == B_OK
|
||||
|| LaunchBySig("application/x-vnd.Be.MediaPrefs") == B_OK
|
||||
|| LaunchByPath("/boot/home/config/be/Preferences/Media") == B_OK)
|
||||
break;
|
||||
|
||||
(new BAlert("desklink", "Couldn't launch Media Preferences", "OK"))->Go();
|
||||
break;
|
||||
case SOUND_SETTINGS:
|
||||
// launch the sounds prefs app
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Haiku.SoundsPrefs"))
|
||||
break;
|
||||
if (B_OK == LaunchBySig("application/x-vnd.Be.SoundsPrefs"))
|
||||
break;
|
||||
if (B_OK == LaunchByPath("/boot/home/config/be/Preferences/Sounds"))
|
||||
if (LaunchBySig("application/x-vnd.Haiku-Sounds") == B_OK
|
||||
|| LaunchBySig("application/x-vnd.Be.SoundsPrefs") == B_OK
|
||||
|| LaunchByPath("/boot/home/config/be/Preferences/Sounds") == B_OK)
|
||||
break;
|
||||
|
||||
(new BAlert("desklink", "Couldn't launch Sounds Preferences", "OK"))->Go();
|
||||
break;
|
||||
case TOGGLE_DONT_BEEP:
|
||||
confDontBeep = !confDontBeep;
|
||||
fDontBeep = !fDontBeep;
|
||||
break;
|
||||
case SET_VOLUME_WHICH:
|
||||
message->FindInt32("volwhich", &confVolumeWhich);
|
||||
message->FindInt32("volwhich", &fVolumeWhich);
|
||||
break;
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
@@ -258,7 +254,7 @@ MediaReplicant::Draw(BRect rect)
|
||||
BView::Draw(rect);
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
DrawBitmap(segments);
|
||||
DrawBitmap(fSegments);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,20 +277,20 @@ MediaReplicant::MouseDown(BPoint point)
|
||||
menu->AddSeparatorItem();
|
||||
BMenuItem *tmpItem = new BMenuItem("Don't beep", new BMessage(TOGGLE_DONT_BEEP));
|
||||
menu->AddItem(tmpItem);
|
||||
tmpItem->SetMarked(confDontBeep);
|
||||
tmpItem->SetMarked(fDontBeep);
|
||||
BMenu *volMenu = new BMenu("Act On");
|
||||
volMenu->SetFont(be_plain_font);
|
||||
BMessage *msg;
|
||||
msg = new BMessage(SET_VOLUME_WHICH);
|
||||
msg->AddInt32("volwhich", VOLUME_USE_MIXER);
|
||||
tmpItem = new BMenuItem("System Mixer", msg);
|
||||
tmpItem->SetMarked(confVolumeWhich == VOLUME_USE_MIXER);
|
||||
tmpItem->SetMarked(fVolumeWhich == VOLUME_USE_MIXER);
|
||||
volMenu->AddItem(tmpItem);
|
||||
msg = new BMessage(SET_VOLUME_WHICH);
|
||||
msg->AddInt32("volwhich", VOLUME_USE_PHYS_OUTPUT);
|
||||
tmpItem = new BMenuItem("Physical Output", msg);
|
||||
volMenu->AddItem(tmpItem);
|
||||
tmpItem->SetMarked(confVolumeWhich == VOLUME_USE_PHYS_OUTPUT);
|
||||
tmpItem->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT);
|
||||
menu->AddItem(volMenu);
|
||||
|
||||
menu->SetTargetForItems(this);
|
||||
@@ -303,8 +299,9 @@ MediaReplicant::MouseDown(BPoint point)
|
||||
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), confDontBeep, confVolumeWhich);
|
||||
volumeSlider->Show();
|
||||
fVolumeSlider = new VolumeSlider(BRect(where.x, where.y, where.x + 207, where.y + 19),
|
||||
fDontBeep, fVolumeWhich);
|
||||
fVolumeSlider->Show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,10 +312,13 @@ MediaReplicant::MouseUp(BPoint point)
|
||||
/* don't Quit() ! thanks for FFM users */
|
||||
}
|
||||
|
||||
void MediaReplicant::LoadSettings()
|
||||
|
||||
void
|
||||
MediaReplicant::LoadSettings()
|
||||
{
|
||||
confDontBeep = false;
|
||||
confVolumeWhich = VOLUME_USE_MIXER;
|
||||
fDontBeep = false;
|
||||
fVolumeWhich = VOLUME_USE_MIXER;
|
||||
|
||||
BPath p;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &p, false) < B_OK)
|
||||
return;
|
||||
@@ -329,11 +329,13 @@ void MediaReplicant::LoadSettings()
|
||||
BMessage msg;
|
||||
if (msg.Unflatten(&settings) < B_OK)
|
||||
return;
|
||||
msg.FindInt32("volwhich", &confVolumeWhich);
|
||||
msg.FindBool("dontbeep", &confDontBeep);
|
||||
msg.FindInt32("volwhich", &fVolumeWhich);
|
||||
msg.FindBool("dontbeep", &fDontBeep);
|
||||
}
|
||||
|
||||
void MediaReplicant::SaveSettings()
|
||||
|
||||
void
|
||||
MediaReplicant::SaveSettings()
|
||||
{
|
||||
BPath p;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &p, false) < B_OK)
|
||||
@@ -343,8 +345,8 @@ void MediaReplicant::SaveSettings()
|
||||
if (settings.InitCheck() < B_OK)
|
||||
return;
|
||||
BMessage msg('CNFG');
|
||||
msg.AddInt32("volwhich", confVolumeWhich);
|
||||
msg.AddBool("dontbeep", confDontBeep);
|
||||
msg.AddInt32("volwhich", fVolumeWhich);
|
||||
msg.AddBool("dontbeep", fDontBeep);
|
||||
ssize_t len=0;
|
||||
if (msg.Flatten(&settings, &len) < B_OK)
|
||||
return;
|
||||
@@ -354,13 +356,12 @@ void MediaReplicant::SaveSettings()
|
||||
int
|
||||
main(int, char **argv)
|
||||
{
|
||||
BApplication app(app_signature);
|
||||
BApplication app(kAppSignature);
|
||||
bool atLeastOnePath = false;
|
||||
BList titleList;
|
||||
BList actionList;
|
||||
|
||||
for(int32 i=1; argv[i]!=NULL; i++) {
|
||||
|
||||
for (int32 i = 1; argv[i]!=NULL; i++) {
|
||||
if (strcmp(argv[i], "--list") == 0) {
|
||||
BDeskbar db;
|
||||
int32 i, found = 0, count;
|
||||
@@ -391,11 +392,11 @@ main(int, char **argv)
|
||||
printf("removed %ld items.\n", found);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (strncmp(argv[i], "cmd=", 4) == 0) {
|
||||
BString *title = new BString(argv[i] + 4);
|
||||
int32 index = title->FindFirst(':');
|
||||
if(index<=0) {
|
||||
if (index <= 0) {
|
||||
printf("desklink: usage: cmd=title:action\n");
|
||||
} else {
|
||||
title->Truncate(index);
|
||||
@@ -406,30 +407,28 @@ main(int, char **argv)
|
||||
}
|
||||
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, 15, 15), &ref, "DeskButton",
|
||||
titleList, actionList));
|
||||
|
||||
if(err!=B_OK) {
|
||||
|
||||
status_t err = BDeskbar().AddItem(new DeskButton(BRect(0, 0, 15, 15),
|
||||
&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 { [ --list|--remove|[cmd=title:action ... ] path ] } ...\n"
|
||||
@@ -437,6 +436,6 @@ main(int, char **argv)
|
||||
"--remove: delete all desklink addons.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
|
||||
resource app_signature "application/x-vnd.be.desklink";
|
||||
resource app_signature "application/x-vnd.Haiku-desklink";
|
||||
|
||||
resource file_types message;
|
||||
|
||||
resource app_version
|
||||
{
|
||||
short_info = "Haiku-Desklink",
|
||||
long_info = "Haiku version of Desklink"
|
||||
resource app_version {
|
||||
major = 1,
|
||||
middle = 0,
|
||||
minor = 0,
|
||||
|
||||
/* 0 = development 1 = alpha 2 = beta
|
||||
3 = gamma 4 = golden master 5 = final */
|
||||
variety = 2,
|
||||
|
||||
internal = 0,
|
||||
|
||||
short_info = "desklink",
|
||||
long_info = "desklink ©2003-2006 Haiku"
|
||||
};
|
||||
|
||||
resource app_flags B_MULTIPLE_LAUNCH|B_ARGV_ONLY|B_BACKGROUND_APP ;
|
||||
|
||||
resource app_flags B_MULTIPLE_LAUNCH | B_ARGV_ONLY | B_BACKGROUND_APP ;
|
||||
|
||||
Reference in New Issue
Block a user