Merge branch 'master' into sam460ex

This commit is contained in:
François Revol
2012-12-31 17:17:38 +01:00
47 changed files with 830 additions and 803 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ SYSTEM_ADD_ONS_PRINT_TRANSPORT = HP\ JetDirect IPP LPR
SYSTEM_ADD_ONS_SCREENSAVERS = [ FFilterByBuildFeatures
Butterfly DebugNow Flurry@x86
GLife@x86 $(HAIKU_INCLUDE_TRADEMARKS)Haiku Icons IFS Leaves
Message Spider
Message Spider Gravity@x86
] ;
SYSTEM_ADD_ONS_DRIVERS_AUDIO = auich auvia echo3g emuxki hda ice1712 sis7018 ;
SYSTEM_ADD_ONS_DRIVERS_AUDIO_OLD = ; #cmedia usb_audio ;
+16 -7
View File
@@ -1134,9 +1134,7 @@ if [ IsOptionalHaikuImagePackageAdded GetText ] {
# Git
if [ IsOptionalHaikuImagePackageAdded Git ] {
if $(TARGET_ARCH) != x86 {
Echo "No optional package Git available for $(TARGET_ARCH)" ;
} else {
if $(TARGET_ARCH) = x86 {
if $(HAIKU_GCC_VERSION[1]) >= 4 {
InstallOptionalHaikuImagePackage
git-1.7.10.2-r1a4-x86-gcc4-2012-08-30.zip
@@ -1148,6 +1146,13 @@ if [ IsOptionalHaikuImagePackageAdded Git ] {
: $(baseURL)/git-1.7.10.2-r1a4-x86-gcc2-2012-08-28.zip
: : true ;
}
} else if $(TARGET_ARCH) = x86_64 {
InstallOptionalHaikuImagePackage
git-1.8.0-x86_64-2012-12-29.zip
: $(baseURL)/git-1.8.0-x86_64-2012-12-29.zip
: : true ;
} else {
Echo "No optional package Git available for $(TARGET_ARCH)" ;
}
}
@@ -1695,15 +1700,17 @@ if [ IsOptionalHaikuImagePackageAdded OpenSound ] {
# OpenSSH
if [ IsOptionalHaikuImagePackageAdded OpenSSH ] {
if $(TARGET_ARCH) != x86 {
Echo "No optional package OpenSSH available for $(TARGET_ARCH)" ;
} else {
if $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 {
if ! $(HAIKU_IMAGE_HOST_NAME) && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) {
Exit "Optional package OpenSSH requires the HAIKU_IMAGE_HOST_NAME"
"variable to be set!" ;
}
if $(HAIKU_GCC_VERSION[1]) >= 4 {
if $(TARGET_ARCH) = x86_64 {
InstallOptionalHaikuImagePackage
openssh-6.0p1-x86_64-2012-12-29.zip
: $(baseURL)/openssh-6.0p1-x86_64-2012-12-29.zip ;
} else if $(HAIKU_GCC_VERSION[1]) >= 4 {
InstallOptionalHaikuImagePackage
openssh-6.0p1-r1a4-x86-gcc4-2012-09-29.zip
: $(baseURL)/openssh-6.0p1-r1a4-x86-gcc4-2012-09-29.zip ;
@@ -1715,6 +1722,8 @@ if [ IsOptionalHaikuImagePackageAdded OpenSSH ] {
AddUserToHaikuImage sshd : 1001 : 100 : /var/empty : /bin/true
: "sshd user" ;
} else {
Echo "No optional package OpenSSH available for $(TARGET_ARCH)" ;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,104 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "ConfigView.h"
#include "Constants.h"
#include "Gravity.h"
#include <GroupLayoutBuilder.h>
#include <ListView.h>
#include <ScrollView.h>
#include <Slider.h>
#include <StringView.h>
#include <View.h>
ConfigView::ConfigView(Gravity* parent, BRect rect)
:
BView(rect, B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
{
fParent = parent;
SetLayout(new BGroupLayout(B_HORIZONTAL));
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fTitleString = new BStringView(RECT_0, B_EMPTY_STRING,
"OpenGL Gravity Effect", B_FOLLOW_LEFT);
fAuthorString = new BStringView(RECT_0, B_EMPTY_STRING,
"by Tri-Edge AI", B_FOLLOW_LEFT);
fCountSlider = new BSlider(RECT_0, B_EMPTY_STRING, "Particle Count: ",
new BMessage(MSG_COUNT), 0, 4, B_BLOCK_THUMB);
fShadeString = new BStringView(RECT_0, B_EMPTY_STRING, "Shade: ",
B_FOLLOW_LEFT);
fShadeList = new BListView(RECT_0, B_EMPTY_STRING, B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL);
fShadeList->SetSelectionMessage(new BMessage(MSG_SHADE));
fShadeList->AddItem(new BStringItem("Red"));
fShadeList->AddItem(new BStringItem("Green"));
fShadeList->AddItem(new BStringItem("Blue"));
fShadeList->AddItem(new BStringItem("Orange"));
fShadeList->AddItem(new BStringItem("Purple"));
fShadeList->AddItem(new BStringItem("White"));
fShadeList->AddItem(new BStringItem("Rainbow"));
fShadeList->Select(parent->Config.ShadeID);
fShadeScroll = new BScrollView(B_EMPTY_STRING, fShadeList,
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
fCountSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fCountSlider->SetHashMarkCount(5);
fCountSlider->SetLimitLabels("128", "2048");
fCountSlider->SetValue(parent->Config.ParticleCount);
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fTitleString)
.Add(fAuthorString)
)
.Add(fShadeString)
.Add(fShadeScroll)
.Add(fCountSlider)
.SetInsets(B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING)
);
}
void
ConfigView::AttachedToWindow()
{
fShadeList->SetTarget(this);
fCountSlider->SetTarget(this);
}
void
ConfigView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case MSG_COUNT:
fParent->Config.ParticleCount = fCountSlider->Value();
break;
case MSG_SHADE:
fParent->Config.ShadeID = fShadeList->CurrentSelection();
break;
default:
BView::MessageReceived(msg);
}
}
@@ -0,0 +1,41 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef GRAVITY_CONFIG_VIEW_H
#define GRAVITY_CONFIG_VIEW_H
#include <View.h>
class Gravity;
class BListView;
class BScrollView;
class BSlider;
class BStringView;
class ConfigView : public BView
{
public:
ConfigView(Gravity* parent, BRect rect);
void AttachedToWindow();
void MessageReceived(BMessage* pbmMessage);
private:
Gravity* fParent;
BStringView* fTitleString;
BStringView* fAuthorString;
BListView* fShadeList;
BStringView* fShadeString;
BScrollView* fShadeScroll;
BSlider* fCountSlider;
};
#endif
@@ -0,0 +1,15 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef CONSTANTS_H
#define CONSTANTS_H
#define MSG_SHADE 'm000'
#define MSG_COUNT 'm001'
#define RECT_0 BRect(0, 0, 0, 0)
#endif
+87 -13
View File
@@ -1,17 +1,91 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#include "GravityScreenSaver.hpp"
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
extern "C" _EXPORT BScreenSaver*
instantiate_screen_saver(BMessage* pbmPrefs, image_id iidImage)
#include "Gravity.h"
#include "ConfigView.h"
#include "GravityView.h"
#include <ScreenSaver.h>
#include <View.h>
#include <stdlib.h>
Gravity::Gravity(BMessage* prefs, image_id imageID)
:
BScreenSaver(prefs, imageID)
{
return new GravityScreenSaver(pbmPrefs, iidImage);
srand(time(NULL));
if (prefs->IsEmpty()) {
Config.ParticleCount = 1;
Config.ShadeID = 2;
} else {
if (prefs->FindInt32("ParticleCount", &Config.ParticleCount) != B_OK)
Config.ParticleCount = 1;
if (prefs->FindInt32("ShadeID", &Config.ShadeID) != B_OK)
Config.ShadeID = 2;
}
}
status_t
Gravity::SaveState(BMessage* prefs) const
{
prefs->AddInt32("ParticleCount", Config.ParticleCount);
prefs->AddInt32("ShadeID", Config.ShadeID);
return B_OK;
}
void
Gravity::StartConfig(BView* view)
{
view->AddChild(new ConfigView(this, view->Bounds()));
}
status_t
Gravity::StartSaver(BView* view, bool preview)
{
if (preview) {
fView = NULL;
return B_ERROR;
} else {
SetTickSize((1000 / 20) * 1000);
// ~20 FPS
fView = new GravityView(this, view->Bounds());
view->AddChild(fView);
return B_OK;
}
}
void
Gravity::StopSaver()
{
if (fView != NULL)
fView->EnableDirectMode(false);
}
void
Gravity::DirectConnected(direct_buffer_info* info)
{
if (fView != NULL) {
// TODO: Find out why I had to uncomment this.
// view->DirectConnected(pdbiInfo);
// view->EnableDirectMode(true);
}
}
void
Gravity::DirectDraw(int32 frame)
{
fView->DirectDraw();
}
@@ -0,0 +1,43 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef GRAVITY_SCREEN_SAVER_H
#define GRAVITY_SCREEN_SAVER_H
#include <ScreenSaver.h>
class GravityView;
class BMessage;
class BView;
class Gravity : public BScreenSaver
{
public:
struct
{
int32 ShadeID;
int32 ParticleCount;
} Config;
Gravity(BMessage* prefs, image_id imageID);
status_t SaveState(BMessage* prefs) const;
void StartConfig(BView* view);
status_t StartSaver(BView* view, bool preview);
void StopSaver();
void DirectConnected(direct_buffer_info* info);
void DirectDraw(int32 frame);
private:
GravityView* fView;
};
#endif
@@ -1,94 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#include "GravityConfigView.hpp"
class GravityScreenSaver;
GravityConfigView::GravityConfigView(GravityScreenSaver* parent, BRect frame)
:
BView(frame, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
{
this->parent = parent;
SetLayout(new BGroupLayout(B_HORIZONTAL));
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BStringView* pbsvTitle = new BStringView(frame, B_EMPTY_STRING,
"OpenGL Gravity Effect", B_FOLLOW_LEFT);
BStringView* pbsvAuthor = new BStringView(frame, B_EMPTY_STRING,
"by Tri-Edge AI", B_FOLLOW_LEFT);
pbsParticleCount = new BSlider(frame, B_EMPTY_STRING, "Particle Count: ",
new BMessage('pcnt'), 0, 4, B_BLOCK_THUMB);
pbsvShadeText = new BStringView(frame, B_EMPTY_STRING, "Shade: ",
B_FOLLOW_LEFT);
pblvShade = new BListView(frame, B_EMPTY_STRING, B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL);
pblvShade->SetSelectionMessage(new BMessage('shds'));
pblvShade->AddItem(new BStringItem("Red"));
pblvShade->AddItem(new BStringItem("Green"));
pblvShade->AddItem(new BStringItem("Blue"));
pblvShade->AddItem(new BStringItem("Orange"));
pblvShade->AddItem(new BStringItem("Purple"));
pblvShade->AddItem(new BStringItem("White"));
pblvShade->AddItem(new BStringItem("Rainbow"));
pblvShade->Select(parent->Config.ShadeID);
BScrollView* scroll = new BScrollView(B_EMPTY_STRING, pblvShade,
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
pbsParticleCount->SetHashMarks(B_HASH_MARKS_BOTTOM);
pbsParticleCount->SetHashMarkCount(5);
pbsParticleCount->SetLimitLabels("128", "2048");
pbsParticleCount->SetValue(parent->Config.ParticleCount);
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(pbsvTitle)
.Add(pbsvAuthor)
)
.Add(pbsvShadeText)
.Add(scroll)
.Add(pbsParticleCount)
.SetInsets(B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING)
);
}
void
GravityConfigView::AttachedToWindow()
{
pblvShade->SetTarget(this);
pbsParticleCount->SetTarget(this);
}
void
GravityConfigView::MessageReceived(BMessage* pbmMessage)
{
if (pbmMessage->what == 'pcnt') {
parent->Config.ParticleCount = pbsParticleCount->Value();
} else if (pbmMessage->what == 'shds') {
parent->Config.ShadeID = pblvShade->CurrentSelection();
} else {
BView::MessageReceived(pbmMessage);
}
}
@@ -1,42 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#ifndef _GRAVITY_CONFIG_VIEW_HPP_
#define _GRAVITY_CONFIG_VIEW_HPP_
#include "GravityScreenSaver.hpp"
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <ListView.h>
#include <ScrollView.h>
#include <Slider.h>
#include <StringItem.h>
#include <StringView.h>
#include <View.h>
class GravityScreenSaver;
class GravityConfigView : public BView
{
public:
GravityConfigView(GravityScreenSaver* parent, BRect frame);
void AttachedToWindow();
void MessageReceived(BMessage* pbmMessage);
private:
GravityScreenSaver* parent;
BListView* pblvShade;
BStringView* pbsvShadeText;
BSlider* pbsParticleCount;
};
#endif /* _GRAVITY_CONFIG_VIEW_HPP_ */
@@ -1,79 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#include "Particle.hpp"
#include "GravityHole.hpp"
#include <math.h>
#include <stdlib.h>
#define frand() ((float)rand() / (float)RAND_MAX)
GravityHole::GravityHole()
{
x = 0.0f;
y = 0.0f;
z = 0.0f;
vx = 0.0f;
vy = 0.0f;
vz = 0.0f;
ax = frand() * 30.0f - 15.0f;
ay = frand() * 30.0f - 15.0f;
az = frand() * 10.0f - 5.0f;
}
void
GravityHole::Run()
{
float dx = ax - x;
float dy = ay - y;
float dz = az - z;
float d = dx * dx + dy * dy + dz * dz;
vx += dx * 0.005f;
vy += dy * 0.005f;
vz += dz * 0.005f;
x += vx;
y += vy;
z += vz;
vx *= 0.95f;
vy *= 0.95f;
vz *= 0.95f;
if (dx * dx + dy * dy + dz * dz < 10.0f) {
ax = frand() * 30.0f - 15.0f;
ay = frand() * 30.0f - 15.0f;
az = frand() * 10.0f - 5.0f;
}
for (uint32 i = 0; i < Particle::list.size(); i++) {
dx = x - Particle::list[i]->x;
dy = y - Particle::list[i]->y;
dz = z - Particle::list[i]->z;
d = dx * dx + dy * dy + dz * dz;
Particle::list[i]->vx += dx / d * 0.5f;
Particle::list[i]->vy += dy / d * 0.5f;
Particle::list[i]->vz += dz / d * 0.5f;
Particle::list[i]->vr += 1.0f / d;
}
}
void
GravityHole::Draw()
{
//...
}
@@ -1,35 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#ifndef _GRAVITY_HOLE_HPP_
#define _GRAVITY_HOLE_HPP_
#include <GLView.h>
class GravityHole
{
public:
float x;
float y;
float z;
float vx;
float vy;
float vz;
float ax;
float ay;
float az;
GravityHole();
void Run();
void Draw();
};
#endif /* _GRAVITY_HOLE_HPP */
@@ -1,95 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#include <View.h>
#include <StringView.h>
#include "GravityScreenSaver.hpp"
GravityScreenSaver::GravityScreenSaver(BMessage* pbmPrefs, image_id iidImage)
:
BScreenSaver(pbmPrefs, iidImage)
{
srand(time(NULL));
if (pbmPrefs->IsEmpty()) {
Config.ParticleCount = 1;
Config.ShadeID = 2;
} else {
if (pbmPrefs->FindInt32("ParticleCount", &Config.ParticleCount) != B_OK)
Config.ParticleCount = 1;
if (pbmPrefs->FindInt32("ShadeID", &Config.ShadeID) != B_OK)
Config.ShadeID = 2;
}
}
status_t
GravityScreenSaver::SaveState(BMessage* pbmPrefs) const
{
pbmPrefs->AddInt32("ParticleCount", Config.ParticleCount);
pbmPrefs->AddInt32("ShadeID", Config.ShadeID);
return B_OK;
}
void
GravityScreenSaver::StartConfig(BView* pbvView)
{
pbvView->AddChild(new GravityConfigView(this, pbvView->Bounds()));
}
status_t
GravityScreenSaver::StartSaver(BView* pbvView, bool bPreview)
{
if (bPreview) {
view = NULL;
return B_ERROR;
} else {
SetTickSize((1000 / 30) * 1000); // ~30 FPS
view = new GravityView(this, pbvView->Bounds());
pbvView->AddChild(view);
return B_OK;
}
}
void
GravityScreenSaver::StopSaver()
{
if (view != NULL) {
view->EnableDirectMode(false);
}
}
void
GravityScreenSaver::DirectConnected(direct_buffer_info* pdbiInfo)
{
if (view != NULL) {
// TODO: Find out why I had to uncomment this.
// view->DirectConnected(pdbiInfo);
// view->EnableDirectMode(true);
}
}
void
GravityScreenSaver::DirectDraw(int32 iFrame)
{
view->Run();
// Dummy rect
BRect rect;
view->Draw(rect);
}
@@ -1,53 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#ifndef _GRAVITY_SCREEN_SAVER_HPP_
#define _GRAVITY_SCREEN_SAVER_HPP_
#include "GravityConfigView.hpp"
#include "GravityView.hpp"
#include <OS.h>
#include <ScreenSaver.h>
#include <View.h>
#include <GLView.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
class GravityView;
class GravityScreenSaver : public BScreenSaver
{
public:
struct
{
int32 ShadeID;
int32 ParticleCount;
} Config;
GravityScreenSaver(BMessage* pbmPrefs, image_id iidImage);
status_t SaveState(BMessage* pbmPrefs) const;
void StartConfig(BView* pbvView);
status_t StartSaver(BView* pbvView, bool bPreview);
void StopSaver();
void DirectConnected(direct_buffer_info* pdbiInfo);
void DirectDraw(int32 iFrame);
private:
GravityView* view;
};
#endif /* _GRAVITY_SCREEN_SAVER_HPP_ */
@@ -0,0 +1,74 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "GravitySource.h"
#include "Particle.h"
#include <stdlib.h>
#define frand() ((float)rand() / (float)RAND_MAX)
GravitySource::GravitySource()
{
x = 0.0f;
y = 0.0f;
z = 0.0f;
r = 0.0f;
vx = 0.0f;
vy = 0.0f;
vz = 0.0f;
tx = frand() * 30.0f - 15.0f;
ty = frand() * 30.0f - 15.0f;
tz = frand() * 10.0f - 5.0f;
}
void
GravitySource::Tick()
{
float dx = tx - x;
float dy = ty - y;
float dz = tz - z;
float d = dx * dx + dy * dy + dz * dz;
vx += dx * 0.003f;
vy += dy * 0.003f;
vz += dz * 0.003f;
x += vx;
y += vy;
z += vz;
vx *= 0.98f;
vy *= 0.98f;
vz *= 0.98f;
if (dx * dx + dy * dy + dz * dz < 1.0f) {
tx = frand() * 20.0f - 10.0f;
ty = frand() * 20.0f - 10.0f;
tz = frand() * 10.0f - 5.0f;
}
for (int32 i = 0; i < Particle::list->CountItems(); i++) {
Particle* p = (Particle*)Particle::list->ItemAt(i);
dx = x - p->x;
dy = y - p->y;
dz = z - p->z;
d = dx * dx + dy * dy + dz * dz;
p->vx += dx / d * 0.25f;
p->vy += dy / d * 0.25f;
p->vz += dz / d * 0.25f;
p->vr += 1.0f / d;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef GRAVITY_SOURCE_H
#define GRAVITY_SOURCE_H
class GravitySource
{
public:
float x;
float y;
float z;
float r;
float vx;
float vy;
float vz;
float tx;
float ty;
float tz;
GravitySource();
void Tick();
private:
};
#endif
@@ -1,70 +1,69 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "GravityView.hpp"
#include "GravityView.h"
#include "Gravity.h"
#include "GravitySource.h"
#include "Particle.h"
#include <GL/glu.h>
GravityView::GravityView(GravityScreenSaver* parent, BRect rect)
GravityView::GravityView(Gravity* parent, BRect rect)
:
BGLView(rect, B_EMPTY_STRING, B_FOLLOW_NONE, 0,
BGL_RGB | BGL_DEPTH | BGL_DOUBLE),
fRect(rect)
BGLView(rect, B_EMPTY_STRING, B_FOLLOW_NONE, 0,
BGL_RGB | BGL_DEPTH | BGL_DOUBLE)
{
this->parent = parent;
fParent = parent;
int realCount;
if (parent->Config.ParticleCount == 0)
realCount = 128;
else if (parent->Config.ParticleCount == 1)
realCount = 256;
realCount = 256;
else if (parent->Config.ParticleCount == 2)
realCount = 512;
realCount = 512;
else if (parent->Config.ParticleCount == 3)
realCount = 1024;
realCount = 1024;
else if (parent->Config.ParticleCount == 4)
realCount = 2048;
realCount = 2048;
else
realCount = 128; // This shouldn't be happening either.
realCount = 128;
Particle::Initialize(realCount, parent->Config.ShadeID);
LockGL();
glClearDepth(1.0f);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, rect.Width() / rect.Height(), 2.0f, 20000.0f);
glTranslatef(0.0f, 0.0f, -30.0f);
glDepthMask(GL_FALSE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -30.0f);
glDepthMask(GL_FALSE);
UnlockGL();
ghole = new GravityHole();
fGravSource = new GravitySource();
}
GravityView::~GravityView()
{
delete ghole;
Particle::Terminate();
delete fGravSource;
}
@@ -78,24 +77,18 @@ GravityView::AttachedToWindow()
void
GravityView::Draw(BRect rect)
GravityView::DirectDraw()
{
LockGL();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Particle::DrawAll();
ghole->Draw();
Particle::Tick();
fGravSource->Tick();
SwapBuffers();
UnlockGL();
}
void
GravityView::Run()
{
Particle::RunAll();
ghole->Run();
}
@@ -0,0 +1,32 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef GRAVITY_VIEW_H
#define GRAVITY_VIEW_H
#include <GLView.h>
class Gravity;
class GravitySource;
class GravityView : public BGLView
{
public:
GravityView(Gravity* parent, BRect rect);
~GravityView();
void AttachedToWindow();
void DirectDraw();
private:
Gravity* fParent;
GravitySource* fGravSource;
};
#endif
@@ -1,40 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#ifndef _GRAVITY_VIEW_HPP_
#define _GRAVITY_VIEW_HPP_
#include <GLView.h>
#include "Particle.hpp"
#include "GravityHole.hpp"
#include "GravityScreenSaver.hpp"
class GravityScreenSaver;
class GravityView : public BGLView
{
public:
GravityView(GravityScreenSaver* parent, BRect rect);
~GravityView();
void AttachedToWindow();
void Draw(BRect rect);
void Run();
private:
BRect fRect;
GravityScreenSaver* parent;
GravityHole* ghole;
};
#endif /* _GRAVITY_VIEW_HPP_ */
+9 -4
View File
@@ -2,15 +2,20 @@ SubDir HAIKU_TOP src add-ons screen_savers gravity ;
SubDirSysHdrs $(HAIKU_GLU_HEADERS) ;
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
AddResources Leaves : Gravity.rdef ;
# For GCC2
if $(HAIKU_GCC_VERSION[1]) < 3 {
SubDirC++Flags --no-warnings ;
}
AddResources Gravity : Gravity.rdef ;
local sources =
ConfigView.cpp
Gravity.cpp
GravityConfigView.cpp
GravityHole.cpp
GravityScreenSaver.cpp
GravitySource.cpp
GravityView.cpp
Particle.cpp
main.cpp
;
Includes [ FGristFiles $(sources) ] : $(HAIKU_MESA_HEADERS_DEPENDENCY) ;
+61 -57
View File
@@ -1,66 +1,81 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "Particle.hpp"
#include "Particle.h"
#include <List.h>
#include <stdlib.h>
#define frand() ((float)rand() / (float)RAND_MAX)
vector<Particle*> Particle::list;
BList* Particle::list;
void
Particle::Initialize(int32 size, int32 shade)
{
{
list = new BList();
for (int32 i = 0; i < size; i++) {
Particle* p = new Particle(frand() * 30.0f - 15.0f,
frand() * 30.0f - 15.0f, frand() * 5.0f, frand() * 360.0f);
Particle* p = new Particle();
p->x = frand() * 30.0f - 15.0f;
p->y = frand() * 30.0f - 15.0f;
p->z = frand() * 5.0f;
p->r = frand() * 360.0f;
p->vx = frand() - 0.5f;
p->vy = frand() - 0.5f;
p->vz = frand() - 0.5f;
p->vr = (frand() - 0.5f) * 180.0f;
if (shade == 0) { // Red
if (shade == 0) {
// Red
p->red = 0.1f + frand() * 0.2f;
p->green = 0.0f;
p->blue = frand() * 0.05f;
} else if (shade == 1) { // Green
p->blue = frand() * 0.05f;
} else if (shade == 1) {
// Green
p->red = 0;
p->green = 0.1f + frand() * 0.2f;
p->blue = frand() * 0.05f;
} else if (shade == 2) { // Blue
} else if (shade == 2) {
// Blue
p->red = 0;
p->green = frand() * 0.05f;
p->blue = 0.1f + frand() * 0.2f;
} else if (shade == 3) { // Orange
} else if (shade == 3) {
// Orange
p->red = 0.1f + frand() * 0.1f;
p->green = 0.05f + frand() * 0.1f;
p->blue = 0.0f;
} else if (shade == 4) { // Purple
} else if (shade == 4) {
// Purple
p->red = 0.1f + frand() * 0.2f;
p->green = 0.0f;
p->blue = 0.1f + frand() * 0.2f;
} else if (shade == 5) { // White
} else if (shade == 5) {
// White
p->red = p->green = p->blue = 0.1f + frand() * 0.2f;
} else if (shade == 6) { // Rainbow
} else if (shade == 6) {
// Rainbow
p->red = 0.1f + frand() * 0.2f;
p->green = 0.1f + frand() * 0.2f;
p->blue = 0.1f + frand() * 0.2f;
} else {
// Man, this shouldn't even happen.. Blue.
// Man, this shouldn't even happen.. Blue.
p->red = 0;
p->green = frand() * 0.05f;
p->blue = 0.1f + frand() * 0.2f;
}
list.push_back(p);
list->AddItem(p);
}
}
@@ -68,46 +83,35 @@ Particle::Initialize(int32 size, int32 shade)
void
Particle::Terminate()
{
for (uint32 i = 0; i < list.size(); i++)
delete list[i];
list.clear();
for (int32 i = 0; i < list->CountItems(); i++)
delete (Particle*)list->ItemAt(i);
list->MakeEmpty();
delete list;
}
void
Particle::RunAll()
Particle::Tick()
{
for (uint32 i = 0; i < list.size(); i++)
list[i]->Run();
for (int32 i = 0; i < list->CountItems(); i++) {
Particle* p = (Particle*)list->ItemAt(i);
p->_Logic();
p->_Render();
}
}
void
Particle::DrawAll()
{
for (uint32 i = 0; i < list.size(); i++)
list[i]->Draw();
}
Particle::Particle(float x, float y, float z, float r)
{
this->x = x;
this->y = y;
this->z = z;
this->r = r;
}
void
Particle::Run()
Particle::_Logic()
{
// Motion
x += vx;
y += vy;
z += vz;
r += vr;
// Friction
vx *= 0.98f;
vy *= 0.98f;
vz *= 0.98f;
@@ -116,17 +120,17 @@ Particle::Run()
void
Particle::Draw() const
Particle::_Render() const
{
glPushMatrix();
glTranslatef(x, y, z);
glRotatef(r, 0.0f, 0.0f, 1.0f);
glBegin(GL_QUADS);
glColor3f(red, green, blue);
glVertex3f(-0.5f, 0.5f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.0f);
glBegin(GL_QUADS);
glVertex3f(-0.25f, 0.25f, 0.0f);
glVertex3f(-0.25f, -0.25f, 0.0f);
glVertex3f( 0.25f, -0.25f, 0.0f);
glVertex3f( 0.25f, 0.25f, 0.0f);
glEnd();
glPopMatrix();
}
@@ -0,0 +1,44 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef PARTICLE_H
#define PARTICLE_H
#include <GLView.h>
class BList;
class Particle
{
public:
static BList* list;
static void Initialize(int32 size, int32 shade);
static void Terminate();
static void Tick();
float x;
float y;
float z;
float r;
float vx;
float vy;
float vz;
float vr;
float red;
float green;
float blue;
private:
void _Logic();
void _Render() const;
};
#endif
@@ -1,54 +0,0 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Tri-Edge AI <[email protected]>
*/
#ifndef _PARTICLE_HPP_
#define _PARTICLE_HPP_
#include <GLView.h>
#include <math.h>
#include <vector>
#include <cstdlib>
using namespace std;
class Particle
{
public:
static vector<Particle*> list;
static void Initialize(int32 size, int32 shade);
static void Terminate();
static void RunAll();
static void DrawAll();
float x;
float y;
float z;
float r;
float vx;
float vy;
float vz;
float vr;
float red;
float green;
float blue;
Particle(float x, float y, float z, float r);
private:
void Run();
void Draw() const;
};
#endif /* _PARTICLE_HPP_ */
@@ -0,0 +1,14 @@
/*
* Copyright 2012-2013 Tri-Edge AI <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "Gravity.h"
extern "C" _EXPORT BScreenSaver*
instantiate_screen_saver(BMessage* prefs, image_id imageID)
{
return new Gravity(prefs, imageID);
}
+6 -2
View File
@@ -6,12 +6,16 @@
#include "ConfigView.h"
#include "ICNSTranslator.h"
#include <Catalog.h>
#include <StringView.h>
#include <SpaceLayoutItem.h>
#include <ControlLook.h>
#include <stdio.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ICNSConfig"
extern "C" {
#include <openjpeg.h>
};
@@ -23,7 +27,7 @@ ConfigView::ConfigView(TranslatorSettings *settings)
fSettings = settings;
BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
BStringView *stringView = new BStringView("title", "Apple icon translator");
BStringView *stringView = new BStringView("title", B_TRANSLATE("Apple icon translator"));
stringView->SetFont(be_bold_font);
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
@@ -32,7 +36,7 @@ ConfigView::ConfigView(TranslatorSettings *settings)
AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
char version[256];
sprintf(version, "Version %d.%d.%d, %s",
sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
int(B_TRANSLATION_MAJOR_VERSION(ICNS_TRANSLATOR_VERSION)),
int(B_TRANSLATION_MINOR_VERSION(ICNS_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(ICNS_TRANSLATOR_VERSION)),
@@ -13,6 +13,11 @@
#include "ConfigView.h"
#include "ICNSLoader.h"
#include <Catalog.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ICNSTranslator"
extern "C" {
#include "icns.h"
}
@@ -78,8 +83,8 @@ const uint32 kNumDefaultSettings = sizeof(sDefaultSettings)
ICNSTranslator::ICNSTranslator()
: BaseTranslator("Apple icons",
"Apple icon translator",
: BaseTranslator(B_TRANSLATE("Apple icons"),
B_TRANSLATE("Apple icon translator"),
ICNS_TRANSLATOR_VERSION,
sInputFormats, kNumInputFormats,
sOutputFormats, kNumOutputFormats,
+1
View File
@@ -80,6 +80,7 @@ Translator ICNSTranslator :
DoCatalogs ICNSTranslator :
x-vnd.Haiku-ICNSTranslator
:
ConfigView.cpp
ICNSTranslator.h
ICNSTranslator.cpp
;
+8 -6
View File
@@ -1888,16 +1888,18 @@ ProbeView::QuitRequested()
return true;
BAlert* alert = new BAlert(B_TRANSLATE("DiskProbe request"),
B_TRANSLATE("Save changes before closing?"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Save"), B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE);
B_TRANSLATE("Save changes before closing?"), B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't save"), B_TRANSLATE("Save"), B_WIDTH_AS_USUAL,
B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
int32 chosen = alert->Go();
if (chosen == 0)
return true;
if (chosen == 1)
return false;
if (chosen == 1)
return true;
return _Save() == B_OK;
}
+9 -5
View File
@@ -1274,17 +1274,21 @@ MainWindow::_CheckSaveIcon(const BMessage* currentMessage)
Activate();
BAlert* alert = new BAlert("save",
B_TRANSLATE("Save changes to current icon?"), B_TRANSLATE("Discard"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Save"));
B_TRANSLATE("Save changes to current icon before closing?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
int32 choice = alert->Go();
switch (choice) {
case 0:
// discard
return true;
case 1:
// cancel
return false;
case 1:
// don't save
return true;
case 2:
default:
// cancel (save first) but pick up what we were doing before
+16 -15
View File
@@ -1697,40 +1697,41 @@ TMailWindow::QuitRequested()
&& fEnclosuresView->fList->CountItems()))) {
if (fResending) {
BAlert *alert = new BAlert("", B_TRANSLATE(
"Do you wish to send this message before closing?"),
B_TRANSLATE("Discard"),
"Send this message before closing?"),
B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't send"),
B_TRANSLATE("Send"),
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, 'd');
alert->SetShortcut(1, B_ESCAPE);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
result = alert->Go();
switch (result) {
case 0: // Discard
break;
case 1: // Cancel
case 0: // Cancel
return false;
case 1: // Don't send
break;
case 2: // Send
Send(true);
break;
}
} else {
BAlert *alert = new BAlert("",
B_TRANSLATE("Do you wish to save this message as a draft "
"before closing?"),
B_TRANSLATE("Don't save"),
B_TRANSLATE("Save this message as a draft before closing?"),
B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"),
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, 'd');
alert->SetShortcut(1, B_ESCAPE);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
result = alert->Go();
switch (result) {
case 0: // Don't Save
break;
case 1: // Cancel
case 0: // Cancel
return false;
case 1: // Don't Save
break;
case 2: // Save
Send(false);
break;
+6 -5
View File
@@ -296,14 +296,15 @@ TSignatureWindow::Clear()
beep();
BAlert *alert = new BAlert("",
B_TRANSLATE("Save changes to this signature?"),
B_TRANSLATE("Don't save"),
B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"),
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, 'd');
alert->SetShortcut(1, B_ESCAPE);
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
result = alert->Go();
if (result == 1)
if (result == 0)
return false;
if (result == 2)
Save();
+6 -3
View File
@@ -296,10 +296,13 @@ PersonWindow::QuitRequested()
status_t result;
if (!fView->IsSaved()) {
BAlert* alert = new BAlert("", B_TRANSLATE("Save changes before quitting?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Quit"),
B_TRANSLATE("Save"));
BAlert* alert = new BAlert("",
B_TRANSLATE("Save changes before closing?"), B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't save"), B_TRANSLATE("Save"),
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
result = alert->Go();
if (result == 2) {
+6 -3
View File
@@ -34,10 +34,13 @@ bool
ResWindow::QuitRequested(void)
{
if (fView->GetSaveStatus() == FILE_DIRTY) {
BAlert *alert = new BAlert("ResEdit", "Save your changes?", "Cancel",
"Don't Save", "Save");
BAlert *alert = new BAlert("ResEdit", "Save changes before closing?",
"Cancel", "Don't save", "Save",
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
switch (alert->Go()) {
case 0:
return false;
+1 -1
View File
@@ -751,7 +751,7 @@ StyledEditWindow::Save(BMessage* message)
|| (S_IWOTH & st.st_mode))) {
BString alertText;
bs_printf(&alertText, B_TRANSLATE("This file is marked "
"Read-Only. Save changes to the document \"%s\"? "), name);
"read-only. Save changes to the document \"%s\"? "), name);
switch (_ShowAlert(alertText, B_TRANSLATE("Cancel"),
B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"), B_WARNING_ALERT)) {
+18 -37
View File
@@ -245,26 +245,15 @@ resource vector_icon {
};
resource(201, "kActionBack") #'VICN' array {
$"6E636966070500020006023B2FA63AC896BCCBD33D335A4A6980490D0B00ACE2"
$"FFFF6ECDFF0200060236D841374D6EBD38553CC6154AA9DF4607770026A8EBFF"
$"0694DE020006023729EA388C8FBC29073AAE614A51AF4A729A00035E8CFF0585"
$"C70200060238E8A83647FBBA8E2D3D42294AF6F7496CE200047BB8FF0694DE02"
$"0006023957BB3923F0BC39AC3C5E604AA873475AB1000592DAFD67CBFF04FF49"
$"080A092E3C3A53424C484F5047503A4435442B3A300A072E3C3A533A48484F48"
$"403A3A3A300A043A303A3A4435442B0A033A483A53424C0A044840484F504750"
$"3A0A043A3A4435503A48400803C125B7D43AB99FB8D3BE0E08023A3A4840070A"
$"0001001001178400040A010101000A020102000A030103000A040104000A0501"
$"05000A06020607100117812004"
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
$"A0000080FF80FF00B300010A0722353622362C482C483E363E3648030A000100"
$"302C2C01178322040A010100302A2A01178322040A020100202A2A"
};
resource(202, "kActionForward") #'VICN' array {
$"6E636966050500020006023B2FA63AC896BCCBD33D335A4A6980490D0B00ACE2"
$"FFFF6ECDFF0200060239AF2C39E19BBC89D83C68DC4AFA1247CFA20006A5F7FF"
$"069EEC02000602B8EEBEB986C33C7FB4BC13FB46FA0C49FBDD000592DAFD3EBD"
$"FF04FF49050A0A2E423A483A524847503F432A3A2F3A3136302E350A0748473A"
$"2F3A392E352E423A483A520A043A2F4847503F432A0A042E3536303A313A3908"
$"0536B9932FBB773B3A3BB939C0E5B755050A0001001001178400040A01010100"
$"0A020102000A030103000A040104100117812004"
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
$"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
$"302C2C01178322040A010100302A2A01178322040A020100202A2A"
};
resource(203, "kActionForward2") #'VICN' array {
@@ -281,29 +270,21 @@ resource(203, "kActionForward2") #'VICN' array {
};
resource(204, "kActionStop") #'VICN' array {
$"6E63696606050102000602393D323BB602BEA28F3C4CC64B601449439F00FF3E"
$"3EFFF70606020006033B27153C10C7BDF9893D088A4B2F634882C500C805057D"
$"9D0404FFB4040403750303020006023B06EB3B5469BC08EB3BB31F4AB15D4478"
$"7700FF9090FFFF757504FF440A0A0C2E4C364E3C4742524A5440434A3842353C"
$"BE1B36312E2E38400A0636313C3C40434A54504E402E0A03364E3E483C470A04"
$"483FC712BADE4A3840430A042E2E3631402E382C0A0442354A38C712BADE4AB9"
$"EC0A0E2E4C364EBEB6C37042524A54504E483FC712BADE4AB9EC4335402E382C"
$"2E2E384008022FB8A0BCC3B80708033C3C42364ABA120802BCA9BFF3B8D3C47B"
$"060A0001061001178400040A020101000A03020302000A010100000A04020504"
$"000A0503070809100117810004"
$"6E6369660304006603800000020006020000003C2000C000000000004C000048"
$"E00000FFABABFFD90000010A0C482A4022352D2A22222A2D3522402A48353D40"
$"4848403D35030A000100302C2C01178322040A010100302A2A01178322040A02"
$"0100202A2A"
};
resource(206, "kActionGoStart") #'VICN' array {
$"6E63696605050002001602B53D77BAF2653D77A7B7CFFC460F874A2D7700F0FF"
$"D50200160236FB2637191CBC57873C40E14B0E7149D82700A2FFBB0200060239"
$"FB483A6DC2BDAC713D02DB4B384746086300EA0606FFD005050200060238B0C7"
$"397C47BD2A963C71B74A82C348B2B700FF4444FFF106060A0A06304942525044"
$"50383E32303D0A09303B3049324A32C0723643364C4252424036320A04503650"
$"44425242400A082D3E3535434645455439462C35312B3C0A062B3C2D3E353543"
$"46454535310A0445455439462C35310A0432C072324A364C36430A043A453A4A"
$"3E4C3EC2630A044645464A484848430A044C3F4C444E424E3D070A0001001001"
$"178400040A010101000A020102000A000406070809000A000103100117840004"
$"0A030105000A04010400"
$"6E6369660804006603800000020006020000003A8000C000000000004C000047"
$"000000FFABABFFD900000554020016020000003AC000C000000000004BE00048"
$"A00000FFFFE50300590002000602000000370000C000000000004C00004A5000"
$"0080FF80FF00B20003806040040A064836483035222230223635280A04484848"
$"42224222480A0542404234352A283428400A042C342C4032403234080A030102"
$"302A2A01178400040A040102202A2A0A010100302A2A01178402040A02010020"
$"2A2A0A050101302A2A01178402040A060101202A2A0A070103202A2A0A070103"
$"0240AAAA0000000000003E0000480000488000"
};
resource(205, "kActionGo") archive BBitmap {
-4
View File
@@ -100,10 +100,6 @@ struct sockaddr;
struct tm;
struct addrinfo;
#ifndef __HAIKU__
typedef int sa_family_t;
#endif
void abort_remote(FILE *);
void abort_squared(int);
void abortpt(int);
@@ -1022,17 +1022,20 @@ ApplicationTypeWindow::QuitRequested()
{
if (_NeedsSaving(CHECK_ALL) != 0) {
BAlert* alert = new BAlert(B_TRANSLATE("Save request"),
B_TRANSLATE("Do you want to save the changes?"),
B_TRANSLATE("Quit, don't save"), B_TRANSLATE("Cancel"),
B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE);
B_TRANSLATE("Save changes before closing?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
int32 choice = alert->Go();
switch (choice) {
case 0:
break;
case 1:
return false;
case 1:
break;
case 2:
_Save();
break;
+10 -7
View File
@@ -283,15 +283,21 @@ ShortcutsWindow::QuitRequested()
if (fKeySetModified) {
BAlert* alert = new BAlert(WARNING,
B_TRANSLATE("Really quit without saving your changes?"),
B_TRANSLATE("Don't save"), B_TRANSLATE("Cancel"),
B_TRANSLATE("Save changes before closing?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"));
alert->SetShortcut(1, B_ESCAPE);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
switch(alert->Go()) {
case 1:
case 0:
ret = false;
break;
case 1:
ret = true;
break;
case 2:
// Save: automatically if possible, otherwise go back and open
// up the file requester
@@ -310,9 +316,6 @@ ShortcutsWindow::QuitRequested()
ret = false;
}
break;
default:
ret = true;
break;
}
}
+30 -19
View File
@@ -29,14 +29,16 @@
#include <SupportDefs.h>
SpoolFolder::SpoolFolder(BLocker*locker, BLooper* looper, const BDirectory& spoolDir)
SpoolFolder::SpoolFolder(BLocker* locker, BLooper* looper,
const BDirectory& spoolDir)
: Folder(locker, looper, spoolDir)
{
}
// Notify print_server that there is a job file waiting for printing
void SpoolFolder::Notify(Job* job, int kind)
void
SpoolFolder::Notify(Job* job, int kind)
{
if ((kind == kJobAdded || kind == kJobAttrChanged)
&& job->IsValid() && job->IsWaiting()) {
@@ -61,10 +63,11 @@ BObjectList<Printer> Printer::sPrinters;
// Returns:
// Pointer to Printer object, or NULL if not found.
// ---------------------------------------------------------------
Printer* Printer::Find(const BString& name)
Printer*
Printer::Find(const BString& name)
{
// Look in list to find printer definition
for (int32 idx=0; idx < sPrinters.CountItems(); idx++) {
// Look in list to find printer definition
for (int32 idx = 0; idx < sPrinters.CountItems(); idx++) {
if (name == sPrinters.ItemAt(idx)->Name())
return sPrinters.ItemAt(idx);
}
@@ -72,10 +75,11 @@ Printer* Printer::Find(const BString& name)
}
Printer* Printer::Find(node_ref* node)
Printer*
Printer::Find(node_ref* node)
{
node_ref n;
// Look in list to find printer definition
// Look in list to find printer definition
for (int32 idx = 0; idx < sPrinters.CountItems(); idx++) {
Printer* printer = sPrinters.ItemAt(idx);
printer->SpoolDir()->GetNodeRef(&n);
@@ -83,23 +87,27 @@ Printer* Printer::Find(node_ref* node)
return printer;
}
// None found, so return NULL
// None found, so return NULL
return NULL;
}
Printer* Printer::At(int32 idx)
Printer*
Printer::At(int32 idx)
{
return sPrinters.ItemAt(idx);
}
void Printer::Remove(Printer* printer)
void
Printer::Remove(Printer* printer)
{
sPrinters.RemoveItem(printer);
}
int32 Printer::CountPrinters()
int32
Printer::CountPrinters()
{
return sPrinters.CountItems();
}
@@ -144,7 +152,8 @@ Printer::~Printer()
}
void Printer::MessageReceived(BMessage* msg)
void
Printer::MessageReceived(BMessage* msg)
{
switch(msg->what) {
case B_GET_PROPERTY:
@@ -163,12 +172,13 @@ void Printer::MessageReceived(BMessage* msg)
// Remove printer spooler directory
status_t Printer::Remove()
status_t
Printer::Remove()
{
status_t rc = B_OK;
BPath path;
if ((rc=::find_directory(B_USER_PRINTERS_DIRECTORY, &path)) == B_OK) {
if ((rc = ::find_directory(B_USER_PRINTERS_DIRECTORY, &path)) == B_OK) {
path.Append(Name());
rc = rmdir(path.Path());
}
@@ -196,7 +206,8 @@ Printer::FindPathToDriver(const char* driverName, BPath* path)
// Returns:
// B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t Printer::ConfigurePrinter(const char* driverName,
status_t
Printer::ConfigurePrinter(const char* driverName,
const char* printerName)
{
PrintAddOnServer addOn(driverName);
@@ -257,9 +268,9 @@ Printer::ConfigureJob(BMessage& settings)
PrintAddOnServer addOn(driver.String());
result = addOn.ConfigJob(SpoolDir(), &settings);
if (result == B_OK) {
if (result == B_OK)
AddCurrentPrinter(settings);
}
return result;
}
@@ -301,9 +312,9 @@ Printer::GetDefaultSettings(BMessage& settings)
PrintAddOnServer addOn(driver.String());
result = addOn.DefaultSettings(SpoolDir(), &settings);
if (result == B_OK) {
if (result == B_OK)
AddCurrentPrinter(settings);
}
return result;
}
+60 -44
View File
@@ -15,23 +15,27 @@
AppSettings::AppSettings(const char* mimetype, const char* printer)
: fMimeType(mimetype)
{
if (printer) fPrinter = printer;
if (printer != NULL)
fPrinter = printer;
}
// Implementation of PrinterSettings
PrinterSettings::PrinterSettings(const char* printer, BMessage* pageSettings, BMessage* jobSettings)
PrinterSettings::PrinterSettings(const char* printer,
BMessage* pageSettings, BMessage* jobSettings)
: fPrinter(printer)
{
if (pageSettings) fPageSettings = *pageSettings;
if (jobSettings) fJobSettings = *jobSettings;
if (pageSettings != NULL)
fPageSettings = *pageSettings;
if (jobSettings != NULL)
fJobSettings = *jobSettings;
}
// Implementation of Settings
Settings* Settings::fSingleton = NULL;
Settings* Settings::sSingleton = NULL;
static const BRect kConfigWindowFrame(30, 30, 220, 120);
@@ -44,33 +48,39 @@ Settings::Settings()
}
Settings::~Settings() {
fSingleton = NULL;
Settings::~Settings()
{
sSingleton = NULL;
}
Settings*
Settings::GetSettings() {
if (fSingleton == NULL) fSingleton = new Settings();
return fSingleton;
Settings::GetSettings()
{
if (sSingleton == NULL)
sSingleton = new Settings();
return sSingleton;
}
void
Settings::RemoveAppSettings(int i) {
Settings::RemoveAppSettings(int i)
{
delete fApps.RemoveItemAt(i);
}
void
Settings::RemovePrinterSettings(int i) {
Settings::RemovePrinterSettings(int i)
{
delete fPrinters.RemoveItemAt(i);
}
AppSettings*
Settings::FindAppSettings(const char* mimeType) {
for (int i = AppSettingsCount()-1; i >= 0; i --) {
Settings::FindAppSettings(const char* mimeType)
{
for (int i = AppSettingsCount() - 1; i >= 0; i --) {
if (strcmp(AppSettingsAt(i)->GetMimeType(), mimeType) == 0)
return AppSettingsAt(i);
}
@@ -79,8 +89,9 @@ Settings::FindAppSettings(const char* mimeType) {
PrinterSettings*
Settings::FindPrinterSettings(const char* printer) {
for (int i = PrinterSettingsCount()-1; i >= 0; i --) {
Settings::FindPrinterSettings(const char* printer)
{
for (int i = PrinterSettingsCount() - 1; i >= 0; i --) {
if (strcmp(PrinterSettingsAt(i)->GetPrinter(), printer) == 0)
return PrinterSettingsAt(i);
}
@@ -89,54 +100,59 @@ Settings::FindPrinterSettings(const char* printer) {
void
Settings::Save(BFile* file) {
BMessage m;
// store application settings
Settings::Save(BFile* file)
{
BMessage message;
// store application settings
for (int i = 0; i < AppSettingsCount(); i++) {
AppSettings* app = AppSettingsAt(i);
m.AddString("m", app->GetMimeType());
m.AddString("p", app->GetPrinter());
message.AddString("message", app->GetMimeType());
message.AddString("p", app->GetPrinter());
}
// store printer settings
// store printer settings
for (int i = 0; i < PrinterSettingsCount(); i++) {
PrinterSettings* p = PrinterSettingsAt(i);
m.AddString("P", p->GetPrinter());
m.AddMessage("S", p->GetPageSettings());
m.AddMessage("J", p->GetJobSettings());
message.AddString("P", p->GetPrinter());
message.AddMessage("S", p->GetPageSettings());
message.AddMessage("J", p->GetJobSettings());
}
m.AddBool("UseConfigWindow", fUseConfigWindow);
m.AddRect("ConfigWindowFrame", fConfigWindowFrame);
m.AddString("DefaultPrinter", fDefaultPrinter);
m.Flatten(file);
message.AddBool("UseConfigWindow", fUseConfigWindow);
message.AddRect("ConfigWindowFrame", fConfigWindowFrame);
message.AddString("DefaultPrinter", fDefaultPrinter);
message.Flatten(file);
}
void
Settings::Load(BFile* file) {
BMessage m;
if (m.Unflatten(file) == B_OK) {
// restore application settings
BString mimetype, printer;
for (int i = 0; m.FindString("m", i, &mimetype) == B_OK &&
m.FindString("p", i, &printer ) == B_OK; i ++) {
Settings::Load(BFile* file)
{
BMessage message;
if (message.Unflatten(file) == B_OK) {
// restore application settings
BString mimetype;
BString printer;
for (int i = 0; message.FindString("message", i, &mimetype) == B_OK &&
message.FindString("p", i, &printer ) == B_OK; i ++) {
AddAppSettings(new AppSettings(mimetype.String(), printer.String()));
}
// restore printer settings
BMessage page, job;
for (int i = 0; m.FindString("P", i, &printer) == B_OK &&
m.FindMessage("S", i, &page) == B_OK &&
m.FindMessage("J", i, &job) == B_OK; i ++) {
// restore printer settings
BMessage page;
BMessage job;
for (int i = 0; message.FindString("P", i, &printer) == B_OK &&
message.FindMessage("S", i, &page) == B_OK &&
message.FindMessage("J", i, &job) == B_OK; i ++) {
AddPrinterSettings(new PrinterSettings(printer.String(), &page, &job));
}
if (m.FindBool("UseConfigWindow", &fUseConfigWindow) != B_OK)
if (message.FindBool("UseConfigWindow", &fUseConfigWindow) != B_OK)
fUseConfigWindow = true;
if (m.FindRect("ConfigWindowFrame", &fConfigWindowFrame) != B_OK)
if (message.FindRect("ConfigWindowFrame", &fConfigWindowFrame) != B_OK)
fConfigWindowFrame = BRect(kConfigWindowFrame);
if (m.FindString("DefaultPrinter", &fDefaultPrinter) != B_OK)
if (message.FindString("DefaultPrinter", &fDefaultPrinter) != B_OK)
fDefaultPrinter = "";
}
}
+1 -1
View File
@@ -55,7 +55,7 @@ private:
BRect fConfigWindowFrame;
BString fDefaultPrinter;
static Settings* fSingleton;
static Settings* sSingleton;
Settings();
public:
+22 -23
View File
@@ -34,10 +34,9 @@ Transport*
Transport::Find(const BString& name)
{
// Look in list to find printer definition
for (int32 idx=0; idx < sTransports.CountItems(); idx++) {
if (name == sTransports.ItemAt(idx)->Name()) {
return sTransports.ItemAt(idx);
}
for (int32 index = 0; index < sTransports.CountItems(); index++) {
if (name == sTransports.ItemAt(index)->Name())
return sTransports.ItemAt(index);
}
// None found, so return NULL
@@ -46,9 +45,9 @@ Transport::Find(const BString& name)
Transport*
Transport::At(int32 idx)
Transport::At(int32 index)
{
return sTransports.ItemAt(idx);
return sTransports.ItemAt(index);
}
@@ -69,19 +68,19 @@ Transport::CountTransports()
status_t
Transport::Scan(directory_which which)
{
BDirectory dir;
status_t rc;
status_t result;
BPath path;
// Try to find specified transport addon directory
if ((rc=find_directory(which,&path)) != B_OK)
return rc;
if ((result = find_directory(which, &path)) != B_OK)
return result;
if ((rc=path.Append("Print/transport")) != B_OK)
return rc;
if ((result = path.Append("Print/transport")) != B_OK)
return result;
if ((rc=dir.SetTo(path.Path())) != B_OK)
return rc;
BDirectory dir;
if ((result = dir.SetTo(path.Path())) != B_OK)
return result;
// Walk over all entries in directory
BEntry entry;
@@ -101,7 +100,6 @@ Transport::Scan(directory_which which)
}
return B_OK;
}
@@ -130,19 +128,20 @@ Transport::Transport(const BPath& path)
// Find transport_features symbol, to determine if we need to keep
// this transport loaded
int* transport_features_ptr;
int* transportFeaturesPointer;
if (get_image_symbol(id, B_TRANSPORT_FEATURES_SYMBOL,
B_SYMBOL_TYPE_DATA, (void**)&transport_features_ptr) != B_OK) {
B_SYMBOL_TYPE_DATA, (void**)&transportFeaturesPointer) != B_OK) {
unload_add_on(id);
} else {
fFeatures = *transport_features_ptr;
fFeatures = *transportFeaturesPointer;
if (*transport_features_ptr & B_TRANSPORT_IS_HOTPLUG) {
if (fFeatures & B_TRANSPORT_IS_HOTPLUG) {
// We are hotpluggable; so keep us loaded!
fImageID = id;
}
else // No extended Transport support; so no need to keep loaded
} else {
// No extended Transport support; so no need to keep loaded
::unload_add_on(id);
}
}
sTransports.AddItem(this);
@@ -163,11 +162,11 @@ Transport::ListAvailablePorts(BMessage* msg)
status_t rc = B_OK;
// Load image if not loaded yet
if (id == -1 && (id=load_add_on(fPath.Path())) < 0)
if (id == -1 && (id = load_add_on(fPath.Path())) < 0)
return id;
// Get pointer to addon function
if ((rc=get_image_symbol(id, B_TRANSPORT_LIST_PORTS_SYMBOL,
if ((rc = get_image_symbol(id, B_TRANSPORT_LIST_PORTS_SYMBOL,
B_SYMBOL_TYPE_TEXT, (void**)&list_ports)) != B_OK)
goto done;