* 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user