diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 1fa3d68406..fb77abdbe6 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -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 ; diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index dff94f745f..59bcdc68db 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -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)" ; } } diff --git a/data/artwork/icons/Action_GoBack_3 b/data/artwork/icons/Action_GoBack_3 new file mode 100644 index 0000000000..9ebbc4c6a3 Binary files /dev/null and b/data/artwork/icons/Action_GoBack_3 differ diff --git a/data/artwork/icons/Action_GoForward_3 b/data/artwork/icons/Action_GoForward_3 new file mode 100644 index 0000000000..974dfc0c7e Binary files /dev/null and b/data/artwork/icons/Action_GoForward_3 differ diff --git a/data/artwork/icons/Action_GoHome_4 b/data/artwork/icons/Action_GoHome_4 new file mode 100644 index 0000000000..4d6820e89f Binary files /dev/null and b/data/artwork/icons/Action_GoHome_4 differ diff --git a/data/artwork/icons/Action_Stop_1 b/data/artwork/icons/Action_Stop_1 new file mode 100644 index 0000000000..f606af87b3 Binary files /dev/null and b/data/artwork/icons/Action_Stop_1 differ diff --git a/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf b/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf index 97fe927610..46e1b9063e 100644 Binary files a/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf and b/data/system/data/fonts/ttfonts/VL-Gothic-Regular.ttf differ diff --git a/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf b/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf index d4790cba6c..64f8934268 100644 Binary files a/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf and b/data/system/data/fonts/ttfonts/VL-PGothic-Regular.ttf differ diff --git a/src/add-ons/screen_savers/gravity/ConfigView.cpp b/src/add-ons/screen_savers/gravity/ConfigView.cpp new file mode 100644 index 0000000000..3a4fe18b5d --- /dev/null +++ b/src/add-ons/screen_savers/gravity/ConfigView.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ + + +#include "ConfigView.h" + +#include "Constants.h" +#include "Gravity.h" + +#include +#include +#include +#include +#include +#include + + +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); + } +} diff --git a/src/add-ons/screen_savers/gravity/ConfigView.h b/src/add-ons/screen_savers/gravity/ConfigView.h new file mode 100644 index 0000000000..adfa77cc74 --- /dev/null +++ b/src/add-ons/screen_savers/gravity/ConfigView.h @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef GRAVITY_CONFIG_VIEW_H +#define GRAVITY_CONFIG_VIEW_H + + +#include + +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 diff --git a/src/add-ons/screen_savers/gravity/Constants.h b/src/add-ons/screen_savers/gravity/Constants.h new file mode 100644 index 0000000000..15df98d7fc --- /dev/null +++ b/src/add-ons/screen_savers/gravity/Constants.h @@ -0,0 +1,15 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * 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 diff --git a/src/add-ons/screen_savers/gravity/Gravity.cpp b/src/add-ons/screen_savers/gravity/Gravity.cpp index 5010f5c089..afef0fef14 100644 --- a/src/add-ons/screen_savers/gravity/Gravity.cpp +++ b/src/add-ons/screen_savers/gravity/Gravity.cpp @@ -1,17 +1,91 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ - - -#include "GravityScreenSaver.hpp" +/* + * Copyright 2012-2013 Tri-Edge AI + * 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 +#include + +#include + +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(); } diff --git a/src/add-ons/screen_savers/gravity/Gravity.h b/src/add-ons/screen_savers/gravity/Gravity.h new file mode 100644 index 0000000000..6fc25f60ad --- /dev/null +++ b/src/add-ons/screen_savers/gravity/Gravity.h @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef GRAVITY_SCREEN_SAVER_H +#define GRAVITY_SCREEN_SAVER_H + + +#include + +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 diff --git a/src/add-ons/screen_savers/gravity/GravityConfigView.cpp b/src/add-ons/screen_savers/gravity/GravityConfigView.cpp deleted file mode 100644 index 1a12fa9d94..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityConfigView.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ - - -#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); - } -} diff --git a/src/add-ons/screen_savers/gravity/GravityConfigView.hpp b/src/add-ons/screen_savers/gravity/GravityConfigView.hpp deleted file mode 100644 index b8f63faead..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityConfigView.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ -#ifndef _GRAVITY_CONFIG_VIEW_HPP_ -#define _GRAVITY_CONFIG_VIEW_HPP_ - - -#include "GravityScreenSaver.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include - - -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_ */ diff --git a/src/add-ons/screen_savers/gravity/GravityHole.cpp b/src/add-ons/screen_savers/gravity/GravityHole.cpp deleted file mode 100644 index e71a0b7d85..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityHole.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ - -#include "Particle.hpp" -#include "GravityHole.hpp" - -#include -#include - -#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() -{ - //... -} diff --git a/src/add-ons/screen_savers/gravity/GravityHole.hpp b/src/add-ons/screen_savers/gravity/GravityHole.hpp deleted file mode 100644 index 9ede10fc57..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityHole.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ - -#ifndef _GRAVITY_HOLE_HPP_ -#define _GRAVITY_HOLE_HPP_ - -#include - -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 */ diff --git a/src/add-ons/screen_savers/gravity/GravityScreenSaver.cpp b/src/add-ons/screen_savers/gravity/GravityScreenSaver.cpp deleted file mode 100644 index 1524b0addb..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityScreenSaver.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ - - -#include -#include - -#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); -} diff --git a/src/add-ons/screen_savers/gravity/GravityScreenSaver.hpp b/src/add-ons/screen_savers/gravity/GravityScreenSaver.hpp deleted file mode 100644 index 40900e2c53..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityScreenSaver.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ -#ifndef _GRAVITY_SCREEN_SAVER_HPP_ -#define _GRAVITY_SCREEN_SAVER_HPP_ - - -#include "GravityConfigView.hpp" -#include "GravityView.hpp" - -#include -#include -#include -#include - -#include -#include -#include - - -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_ */ diff --git a/src/add-ons/screen_savers/gravity/GravitySource.cpp b/src/add-ons/screen_savers/gravity/GravitySource.cpp new file mode 100644 index 0000000000..034876855c --- /dev/null +++ b/src/add-ons/screen_savers/gravity/GravitySource.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ + + +#include "GravitySource.h" + +#include "Particle.h" + +#include + + +#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; + } +} diff --git a/src/add-ons/screen_savers/gravity/GravitySource.h b/src/add-ons/screen_savers/gravity/GravitySource.h new file mode 100644 index 0000000000..0a44ef71e9 --- /dev/null +++ b/src/add-ons/screen_savers/gravity/GravitySource.h @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * 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 diff --git a/src/add-ons/screen_savers/gravity/GravityView.cpp b/src/add-ons/screen_savers/gravity/GravityView.cpp index 880ecf1133..3ae454daa0 100644 --- a/src/add-ons/screen_savers/gravity/GravityView.cpp +++ b/src/add-ons/screen_savers/gravity/GravityView.cpp @@ -1,70 +1,69 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ +/* + * Copyright 2012-2013 Tri-Edge AI + * 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 -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(); -} diff --git a/src/add-ons/screen_savers/gravity/GravityView.h b/src/add-ons/screen_savers/gravity/GravityView.h new file mode 100644 index 0000000000..4557b60a63 --- /dev/null +++ b/src/add-ons/screen_savers/gravity/GravityView.h @@ -0,0 +1,32 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef GRAVITY_VIEW_H +#define GRAVITY_VIEW_H + + +#include + + +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 diff --git a/src/add-ons/screen_savers/gravity/GravityView.hpp b/src/add-ons/screen_savers/gravity/GravityView.hpp deleted file mode 100644 index 49384374d1..0000000000 --- a/src/add-ons/screen_savers/gravity/GravityView.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ -#ifndef _GRAVITY_VIEW_HPP_ -#define _GRAVITY_VIEW_HPP_ - - -#include - -#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_ */ diff --git a/src/add-ons/screen_savers/gravity/Jamfile b/src/add-ons/screen_savers/gravity/Jamfile index 228a392f59..426435bf47 100644 --- a/src/add-ons/screen_savers/gravity/Jamfile +++ b/src/add-ons/screen_savers/gravity/Jamfile @@ -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) ; diff --git a/src/add-ons/screen_savers/gravity/Particle.cpp b/src/add-ons/screen_savers/gravity/Particle.cpp index f5d3e62690..93cea677e4 100644 --- a/src/add-ons/screen_savers/gravity/Particle.cpp +++ b/src/add-ons/screen_savers/gravity/Particle.cpp @@ -1,66 +1,81 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ -#include "Particle.hpp" +#include "Particle.h" + +#include + +#include #define frand() ((float)rand() / (float)RAND_MAX) -vector 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(); } diff --git a/src/add-ons/screen_savers/gravity/Particle.h b/src/add-ons/screen_savers/gravity/Particle.h new file mode 100644 index 0000000000..1d7be18718 --- /dev/null +++ b/src/add-ons/screen_savers/gravity/Particle.h @@ -0,0 +1,44 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef PARTICLE_H +#define PARTICLE_H + + +#include + +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 diff --git a/src/add-ons/screen_savers/gravity/Particle.hpp b/src/add-ons/screen_savers/gravity/Particle.hpp deleted file mode 100644 index bc8f2047cf..0000000000 --- a/src/add-ons/screen_savers/gravity/Particle.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Tri-Edge AI - */ -#ifndef _PARTICLE_HPP_ -#define _PARTICLE_HPP_ - - -#include - -#include -#include -#include - - -using namespace std; - - -class Particle -{ -public: - static vector 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_ */ diff --git a/src/add-ons/screen_savers/gravity/main.cpp b/src/add-ons/screen_savers/gravity/main.cpp new file mode 100644 index 0000000000..9b93e9120f --- /dev/null +++ b/src/add-ons/screen_savers/gravity/main.cpp @@ -0,0 +1,14 @@ +/* + * Copyright 2012-2013 Tri-Edge AI + * 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); +} diff --git a/src/add-ons/translators/icns/ConfigView.cpp b/src/add-ons/translators/icns/ConfigView.cpp index 69c3f5336a..289d2d82c0 100644 --- a/src/add-ons/translators/icns/ConfigView.cpp +++ b/src/add-ons/translators/icns/ConfigView.cpp @@ -6,12 +6,16 @@ #include "ConfigView.h" #include "ICNSTranslator.h" +#include #include #include #include #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "ICNSConfig" + extern "C" { #include }; @@ -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)), diff --git a/src/add-ons/translators/icns/ICNSTranslator.cpp b/src/add-ons/translators/icns/ICNSTranslator.cpp index c4cf42d868..c70b5bdb33 100644 --- a/src/add-ons/translators/icns/ICNSTranslator.cpp +++ b/src/add-ons/translators/icns/ICNSTranslator.cpp @@ -13,6 +13,11 @@ #include "ConfigView.h" #include "ICNSLoader.h" +#include + +#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, diff --git a/src/add-ons/translators/icns/Jamfile b/src/add-ons/translators/icns/Jamfile index 23b3e44942..68ab239ba9 100644 --- a/src/add-ons/translators/icns/Jamfile +++ b/src/add-ons/translators/icns/Jamfile @@ -80,6 +80,7 @@ Translator ICNSTranslator : DoCatalogs ICNSTranslator : x-vnd.Haiku-ICNSTranslator : + ConfigView.cpp ICNSTranslator.h ICNSTranslator.cpp ; diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 4072057a8a..2aef09dcaa 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -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; } diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index 5d7c015a6f..d8ac569860 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -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 diff --git a/src/apps/mail/MailWindow.cpp b/src/apps/mail/MailWindow.cpp index 0537456fbc..8a81cba786 100644 --- a/src/apps/mail/MailWindow.cpp +++ b/src/apps/mail/MailWindow.cpp @@ -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; diff --git a/src/apps/mail/Signature.cpp b/src/apps/mail/Signature.cpp index 7fd5ea867e..48a02034f1 100644 --- a/src/apps/mail/Signature.cpp +++ b/src/apps/mail/Signature.cpp @@ -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(); diff --git a/src/apps/people/PersonWindow.cpp b/src/apps/people/PersonWindow.cpp index 8c5511e92c..728482aa69 100644 --- a/src/apps/people/PersonWindow.cpp +++ b/src/apps/people/PersonWindow.cpp @@ -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) { diff --git a/src/apps/resedit/ResWindow.cpp b/src/apps/resedit/ResWindow.cpp index 4f5fea524a..83d1c925e8 100644 --- a/src/apps/resedit/ResWindow.cpp +++ b/src/apps/resedit/ResWindow.cpp @@ -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; diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 0dfd0c9ea0..3193bcfc85 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -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)) { diff --git a/src/apps/webpositive/WebPositive.rdef b/src/apps/webpositive/WebPositive.rdef index 15d1b92913..b382c9559b 100644 --- a/src/apps/webpositive/WebPositive.rdef +++ b/src/apps/webpositive/WebPositive.rdef @@ -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 { diff --git a/src/bin/network/ftp/extern.h b/src/bin/network/ftp/extern.h index 9be2b20c6a..f2b802ac5b 100644 --- a/src/bin/network/ftp/extern.h +++ b/src/bin/network/ftp/extern.h @@ -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); diff --git a/src/preferences/filetypes/ApplicationTypeWindow.cpp b/src/preferences/filetypes/ApplicationTypeWindow.cpp index d556cd6dd2..df1e7a48e2 100644 --- a/src/preferences/filetypes/ApplicationTypeWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypeWindow.cpp @@ -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; diff --git a/src/preferences/shortcuts/ShortcutsWindow.cpp b/src/preferences/shortcuts/ShortcutsWindow.cpp index e389a4df94..5a5c6785e6 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.cpp +++ b/src/preferences/shortcuts/ShortcutsWindow.cpp @@ -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; } } diff --git a/src/servers/print/Printer.cpp b/src/servers/print/Printer.cpp index bf94c76618..a085949803 100644 --- a/src/servers/print/Printer.cpp +++ b/src/servers/print/Printer.cpp @@ -29,14 +29,16 @@ #include -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::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; } diff --git a/src/servers/print/Settings.cpp b/src/servers/print/Settings.cpp index f05e29a002..79944e21a5 100644 --- a/src/servers/print/Settings.cpp +++ b/src/servers/print/Settings.cpp @@ -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 = ""; } } diff --git a/src/servers/print/Settings.h b/src/servers/print/Settings.h index 477f1a988a..2ba6752aec 100644 --- a/src/servers/print/Settings.h +++ b/src/servers/print/Settings.h @@ -55,7 +55,7 @@ private: BRect fConfigWindowFrame; BString fDefaultPrinter; - static Settings* fSingleton; + static Settings* sSingleton; Settings(); public: diff --git a/src/servers/print/Transport.cpp b/src/servers/print/Transport.cpp index 9ccd09ea2e..3b59cefec0 100644 --- a/src/servers/print/Transport.cpp +++ b/src/servers/print/Transport.cpp @@ -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;