added license headers
changed the way prefs is stored, so that we have default settings general cleanup time sliders are now linked together as on R5 password window is centered onscreen git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13849 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,83 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003, Michael Phipps. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef SCREEN_SAVER_PREFS_H
|
#ifndef SCREEN_SAVER_PREFS_H
|
||||||
#define SCREEN_SAVER_PREFS_H
|
#define SCREEN_SAVER_PREFS_H
|
||||||
#include "Message.h"
|
#include <Message.h>
|
||||||
#include "Path.h"
|
#include <Path.h>
|
||||||
#include <string.h>
|
#include <String.h>
|
||||||
|
|
||||||
enum arrowDirection {NONE=-1,UPLEFT,UPRIGHT,DOWNRIGHT,DOWNLEFT,CENTER};
|
enum arrowDirection {
|
||||||
|
NONE = -1,
|
||||||
|
UPLEFT,
|
||||||
|
UPRIGHT,
|
||||||
|
DOWNRIGHT,
|
||||||
|
DOWNLEFT,
|
||||||
|
CENTER
|
||||||
|
};
|
||||||
|
|
||||||
class ScreenSaverPrefs
|
class ScreenSaverPrefs
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScreenSaverPrefs(void);
|
ScreenSaverPrefs();
|
||||||
bool LoadSettings(void);
|
bool LoadSettings();
|
||||||
|
void Defaults();
|
||||||
|
|
||||||
BRect WindowFrame(void) {return getRect("windowframe");}
|
BRect WindowFrame() {return fWindowFrame;}
|
||||||
int WindowTab(void) {return getInt("windowtab");}
|
int32 WindowTab() {return fWindowTab;}
|
||||||
int TimeFlags(void) {return getInt("timeflags");}
|
int32 TimeFlags() {return fTimeFlags;}
|
||||||
int BlankTime(void) {return getInt("timefade");}
|
bigtime_t BlankTime() {return fBlankTime;}
|
||||||
int StandbyTime(void) {return getInt("timestandby");}
|
bigtime_t StandbyTime() {return fStandByTime;}
|
||||||
int SuspendTime(void) {return getInt("timesuspend");}
|
bigtime_t SuspendTime() {return fSuspendTime;}
|
||||||
int OffTime(void) {return getInt("timeoff");}
|
bigtime_t OffTime() {return fOffTime;}
|
||||||
arrowDirection GetBlankCorner(void) {return (arrowDirection)(getInt("cornernow"));}
|
arrowDirection GetBlankCorner() {return fBlankCorner;}
|
||||||
arrowDirection GetNeverBlankCorner(void) {return (arrowDirection)(getInt("cornerNever"));}
|
arrowDirection GetNeverBlankCorner() {return fNeverBlankCorner;}
|
||||||
bool LockEnable(void) {return getBool("lockenable");}
|
bool LockEnable() {return fLockEnabled;}
|
||||||
int PasswordTime(void) {return getInt("lockdelay");}
|
bigtime_t PasswordTime() {return fPasswordTime;}
|
||||||
const char *Password(void);
|
const char *Password() { return fPassword.String(); }
|
||||||
bool IsNetworkPassword(void) {return (0==strcmp("custom",getString("lockmethod")));}
|
bool IsNetworkPassword() {return fIsNetworkPassword;}
|
||||||
const char *ModuleName(void) {
|
const char *ModuleName() {return fModuleName.String();}
|
||||||
const char *name=getString("modulename");
|
|
||||||
return ((name)?name:"Blackness");
|
|
||||||
}
|
|
||||||
BMessage *GetState(const char *name);
|
BMessage *GetState(const char *name);
|
||||||
BMessage *GetSettings(void) {return ¤tMessage;}
|
|
||||||
|
|
||||||
void SetWindowFrame(const BRect &fr) {setRect("windowframe",fr);}
|
void SetWindowFrame(const BRect &fr) { fWindowFrame = fr;}
|
||||||
void SetWindowTab(int tab) {setInt("windowtab",tab);}
|
void SetWindowTab(int32 tab) { fWindowTab = tab;}
|
||||||
void SetTimeFlags(int tf) {setInt("timeflags",tf);}
|
void SetTimeFlags(int32 tf) {fTimeFlags = tf;}
|
||||||
void SetBlankTime(int bt) {setInt("timefade",bt);}
|
void SetBlankTime(bigtime_t bt) {fBlankTime = bt;}
|
||||||
void SetStandbyTime(int time) {setInt("timestandby",time);}
|
void SetStandbyTime(bigtime_t time) {fStandByTime = time;}
|
||||||
void SetSuspendTime(int time) {setInt("timesuspend",time);}
|
void SetSuspendTime(bigtime_t time) {fSuspendTime = time;}
|
||||||
void SetOffTime(int intime) {setInt("timeoff",intime);}
|
void SetOffTime(bigtime_t intime) {fOffTime = intime;}
|
||||||
void SetBlankCorner(arrowDirection in) {setInt("cornernow",(int)in);}
|
void SetBlankCorner(arrowDirection in) {fBlankCorner = in;}
|
||||||
void SetNeverBlankCorner(arrowDirection in){setInt("cornernever",(int)in);}
|
void SetNeverBlankCorner(arrowDirection in) {fNeverBlankCorner = in;}
|
||||||
void SetLockEnable(bool en) {setBool("lockenable",en);}
|
void SetLockEnable(bool en) {fLockEnabled = en;}
|
||||||
void SetPasswordTime(int pt) {setInt("lockdelay",pt);}
|
void SetPasswordTime(bigtime_t pt) {fPasswordTime = pt;}
|
||||||
void SetPassword(char *pw){setString("lockpassword",pw);} // Can not set network password from here.
|
void SetPassword(char *pw) {fPassword = pw;} // Can not set network password from here.
|
||||||
void SetModuleName(const char *mn) {setString("modulename",mn);}
|
void SetModuleName(const char *mn) {fModuleName = mn;}
|
||||||
void SetState(const char *name,BMessage *in);
|
void SetState(const char *name,BMessage *in);
|
||||||
void SaveSettings (void);
|
void SaveSettings();
|
||||||
|
BMessage * GetSettings();
|
||||||
private:
|
private:
|
||||||
bool parseSettings(BMessage *newSSMessage);
|
BRect fWindowFrame;
|
||||||
|
int32 fWindowTab;
|
||||||
|
int32 fTimeFlags;
|
||||||
|
bigtime_t fBlankTime;
|
||||||
|
bigtime_t fStandByTime;
|
||||||
|
bigtime_t fSuspendTime;
|
||||||
|
bigtime_t fOffTime;
|
||||||
|
arrowDirection fBlankCorner;
|
||||||
|
arrowDirection fNeverBlankCorner;
|
||||||
|
bool fLockEnabled;
|
||||||
|
bigtime_t fPasswordTime;
|
||||||
|
BString fPassword;
|
||||||
|
BString fModuleName;
|
||||||
|
BString fLockMethod;
|
||||||
|
|
||||||
bool getBool(const char *name) {bool b;currentMessage.FindBool(name,&b);return b;}
|
bool fIsNetworkPassword;
|
||||||
int32 getInt(const char *name){int32 b;currentMessage.FindInt32(name,&b);return b;}
|
|
||||||
const char *getString(const char *name){const char *b;currentMessage.FindString(name,&b);return b;}
|
|
||||||
BRect getRect(const char *name){BRect b;currentMessage.FindRect(name,&b);return b;}
|
|
||||||
|
|
||||||
void setBool(const char *name,bool value) {
|
BMessage stateMsg, currentMessage;
|
||||||
if (B_NAME_NOT_FOUND == currentMessage.ReplaceBool(name,value))
|
|
||||||
currentMessage.AddBool(name,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setInt(const char *name,int value) {
|
|
||||||
if (B_NAME_NOT_FOUND == currentMessage.ReplaceInt32(name,value))
|
|
||||||
currentMessage.AddInt32(name,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setString(const char *name,const char *value) {
|
|
||||||
if (B_NAME_NOT_FOUND == currentMessage.ReplaceString(name,value))
|
|
||||||
currentMessage.AddString(name,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRect(const char *name,BRect value) {
|
|
||||||
if (B_NAME_NOT_FOUND == currentMessage.ReplaceRect(name,value))
|
|
||||||
currentMessage.AddRect(name,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
BMessage currentMessage,stateMsg;
|
|
||||||
BPath ssPath,networkPath;
|
BPath ssPath,networkPath;
|
||||||
char password[512];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003, Michael Phipps. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef SCREEN_SAVER_THREAD_H
|
#ifndef SCREEN_SAVER_THREAD_H
|
||||||
#define SCREEN_SAVER_THREAD_H
|
#define SCREEN_SAVER_THREAD_H
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003, Michael Phipps. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
@@ -8,12 +13,14 @@
|
|||||||
|
|
||||||
#include "ScreenSaverPrefs.h"
|
#include "ScreenSaverPrefs.h"
|
||||||
|
|
||||||
ScreenSaverPrefs::ScreenSaverPrefs()
|
ScreenSaverPrefs::ScreenSaverPrefs()
|
||||||
{
|
{
|
||||||
find_directory(B_USER_SETTINGS_DIRECTORY,&ssPath);
|
find_directory(B_USER_SETTINGS_DIRECTORY,&ssPath);
|
||||||
find_directory(B_USER_SETTINGS_DIRECTORY,&networkPath);
|
find_directory(B_USER_SETTINGS_DIRECTORY,&networkPath);
|
||||||
ssPath.Append("ScreenSaver_settings",true);
|
ssPath.Append("ScreenSaver_settings",true);
|
||||||
networkPath.Append("network",true);
|
networkPath.Append("network",true);
|
||||||
|
|
||||||
|
Defaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -24,47 +31,120 @@ ScreenSaverPrefs::LoadSettings()
|
|||||||
BFile ssSettings(ssPath.Path(),B_READ_ONLY);
|
BFile ssSettings(ssPath.Path(),B_READ_ONLY);
|
||||||
if (B_OK==ssSettings.InitCheck()) { // File exists. Unflatten the message and call the settings parser.
|
if (B_OK==ssSettings.InitCheck()) { // File exists. Unflatten the message and call the settings parser.
|
||||||
BMessage settings;
|
BMessage settings;
|
||||||
settings.Unflatten(&ssSettings);
|
if (settings.Unflatten(&ssSettings)!=B_OK)
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
|
settings.PrintToStream();
|
||||||
|
|
||||||
|
settings.FindRect("windowframe", &fWindowFrame);
|
||||||
|
settings.FindInt32("windowtab", &fWindowTab);
|
||||||
|
settings.FindInt32("timeflags", &fTimeFlags);
|
||||||
|
|
||||||
|
int32 blank_time, standByTime, suspendTime, offTime, passwordTime;
|
||||||
|
if (settings.FindInt32("timefade", &blank_time) == B_OK)
|
||||||
|
fBlankTime = blank_time * 1000000;
|
||||||
|
if (settings.FindInt32("timestandby", &standByTime) == B_OK)
|
||||||
|
fStandByTime = standByTime * 1000000;
|
||||||
|
if (settings.FindInt32("timesuspend", &suspendTime) == B_OK)
|
||||||
|
fSuspendTime = suspendTime * 1000000;
|
||||||
|
if (settings.FindInt32("timeoff", &offTime) == B_OK)
|
||||||
|
fOffTime = offTime * 1000000;
|
||||||
|
settings.FindInt32("cornernow", (int32*)&fBlankCorner);
|
||||||
|
settings.FindInt32("cornernever", (int32*)&fNeverBlankCorner);
|
||||||
|
settings.FindBool("lockenable", &fLockEnabled);
|
||||||
|
if (settings.FindInt32("lockdelay", &passwordTime) == B_OK)
|
||||||
|
fPasswordTime = passwordTime * 1000000;
|
||||||
|
settings.FindString("lockpassword", &fPassword);
|
||||||
|
settings.FindString("lockmethod", &fLockMethod);
|
||||||
|
settings.FindString("modulename", &fModuleName);
|
||||||
|
|
||||||
|
if (IsNetworkPassword()) {
|
||||||
|
FILE *networkFile=NULL;
|
||||||
|
char buffer[512],*start;
|
||||||
|
// This ugly piece opens the networking file and reads the password, if it exists.
|
||||||
|
if ((networkFile=fopen(networkPath.Path(),"r")))
|
||||||
|
while (buffer==fgets(buffer,512,networkFile))
|
||||||
|
if ((start=strstr(buffer,"PASSWORD ="))) {
|
||||||
|
char password[12];
|
||||||
|
strncpy(password, start+10,strlen(start-11));
|
||||||
|
fPassword = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
|
||||||
ScreenSaverPrefs::Password() {
|
void
|
||||||
if (IsNetworkPassword()) {
|
ScreenSaverPrefs::Defaults()
|
||||||
FILE *networkFile=NULL;
|
{
|
||||||
char buffer[512],*start;
|
fWindowFrame = BRect(96.5, 77.0, 542.5, 402);
|
||||||
// This ugly piece opens the networking file and reads the password, if it exists.
|
fWindowTab = 0;
|
||||||
if ((networkFile=fopen(networkPath.Path(),"r")))
|
fTimeFlags = 0;
|
||||||
while (buffer==fgets(buffer,512,networkFile))
|
fBlankTime = 120;
|
||||||
if ((start=strstr(buffer,"PASSWORD ="))) {
|
fStandByTime = 120;
|
||||||
strncpy(password, start+10,strlen(start-11));
|
fSuspendTime = 120;
|
||||||
return password;
|
fOffTime = 120;
|
||||||
}
|
fBlankCorner = NONE;
|
||||||
}
|
fNeverBlankCorner = NONE;
|
||||||
return getString("lockpassword");
|
fLockEnabled = false;
|
||||||
|
fPasswordTime = 120;
|
||||||
|
fPassword = "";
|
||||||
|
fLockMethod = "custom";
|
||||||
|
fModuleName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMessage *
|
BMessage *
|
||||||
ScreenSaverPrefs::GetState(const char *name) {
|
ScreenSaverPrefs::GetSettings()
|
||||||
|
{
|
||||||
|
BMessage *msg = new BMessage();
|
||||||
|
msg->AddRect("windowframe", fWindowFrame);
|
||||||
|
msg->AddInt32("windowtab", fWindowTab);
|
||||||
|
msg->AddInt32("timeflags", fTimeFlags);
|
||||||
|
msg->AddInt32("timefade", fBlankTime/1000000);
|
||||||
|
msg->AddInt32("timestandby", fStandByTime/1000000);
|
||||||
|
msg->AddInt32("timesuspend", fSuspendTime/1000000);
|
||||||
|
msg->AddInt32("timeoff", fOffTime/1000000);
|
||||||
|
msg->AddInt32("cornernow", fBlankCorner);
|
||||||
|
msg->AddInt32("cornernever", fNeverBlankCorner);
|
||||||
|
msg->AddBool("lockenable", fLockEnabled);
|
||||||
|
msg->AddInt32("lockdelay", fPasswordTime/1000000);
|
||||||
|
msg->AddString("lockpassword", fPassword);
|
||||||
|
msg->AddString("lockmethod", fLockMethod);
|
||||||
|
msg->AddString("modulename", fModuleName);
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMessage *
|
||||||
|
ScreenSaverPrefs::GetState(const char *name)
|
||||||
|
{
|
||||||
BString stateMsgName("modulesettings_");
|
BString stateMsgName("modulesettings_");
|
||||||
stateMsgName+=name;
|
stateMsgName+=name;
|
||||||
currentMessage.FindMessage(stateMsgName.String(),&stateMsg);
|
currentMessage.FindMessage(stateMsgName.String(),&stateMsg);
|
||||||
return &stateMsg;
|
return &stateMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverPrefs::SetState(const char *name,BMessage *msg) {
|
ScreenSaverPrefs::SetState(const char *name,BMessage *msg)
|
||||||
|
{
|
||||||
BString stateMsgName("modulesettings_");
|
BString stateMsgName("modulesettings_");
|
||||||
stateMsgName+=name;
|
stateMsgName+=name;
|
||||||
if (B_NAME_NOT_FOUND == currentMessage.ReplaceMessage(stateMsgName.String(),msg))
|
if (B_NAME_NOT_FOUND == currentMessage.ReplaceMessage(stateMsgName.String(),msg))
|
||||||
currentMessage.AddMessage(stateMsgName.String(),msg);
|
currentMessage.AddMessage(stateMsgName.String(),msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverPrefs::SaveSettings (void) {
|
ScreenSaverPrefs::SaveSettings()
|
||||||
BFile file(ssPath.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
{
|
||||||
if ((file.InitCheck()!=B_OK) || (currentMessage.Flatten(&file)!=B_OK))
|
BMessage *settings = GetSettings();
|
||||||
printf ("Problem with saving preferences file!\n");
|
settings->PrintToStream();
|
||||||
|
BFile file(ssPath.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
|
if ((file.InitCheck()!=B_OK) || (settings->Flatten(&file)!=B_OK))
|
||||||
|
fprintf(stderr, "Problem while saving screensaver preferences file!\n");
|
||||||
|
delete settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003, Michael Phipps. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScreenSaver.h>
|
#include <ScreenSaver.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
|||||||
@@ -43,19 +43,23 @@ scale3(int x, int y,BRect area,bool invertX,bool invertY)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int kTab1_chg ='TAB1';
|
const int32 kTab1_chg ='TAB1';
|
||||||
const int kTab2_chg ='TAB2';
|
const int32 kTab2_chg ='TAB2';
|
||||||
const int kPwbutton ='PWBT';
|
const int32 kPwbutton ='PWBT';
|
||||||
const int kDone_clicked ='DONE';
|
const int32 kDone_clicked ='DONE';
|
||||||
const int kCancel_clicked ='CNCL';
|
const int32 kCancel_clicked ='CNCL';
|
||||||
const int kButton_changed ='BTNC';
|
const int32 kButton_changed ='BTNC';
|
||||||
const int kShow ='SHOW';
|
const int32 kShow ='SHOW';
|
||||||
const int kPopulate ='POPU';
|
const int32 kPopulate ='POPU';
|
||||||
const int kUtilize ='UTIL';
|
const int32 kUtilize ='UTIL';
|
||||||
const int kSaver_sel ='SSEL';
|
const int32 kSaver_sel ='SSEL';
|
||||||
const int kTest_btn ='TEST';
|
const int32 kTest_btn ='TEST';
|
||||||
const int kAdd_btn ='ADD ';
|
const int32 kAdd_btn ='ADD ';
|
||||||
const int kUpdatelist ='UPDL';
|
const int32 kUpdatelist ='UPDL';
|
||||||
|
const int32 kPasswordCheckbox = 'PWCB';
|
||||||
|
const int32 kRunSliderChanged = 'RSCG';
|
||||||
|
const int32 kPasswordSliderChanged = 'PWCG';
|
||||||
|
const int32 kTurnOffSliderChanged = 'TUCG';
|
||||||
|
|
||||||
const rgb_color kBlack = {0,0,0,0};
|
const rgb_color kBlack = {0,0,0,0};
|
||||||
const rgb_color kDarkGrey = {150,150,150,0};
|
const rgb_color kDarkGrey = {150,150,150,0};
|
||||||
|
|||||||
@@ -5,14 +5,22 @@
|
|||||||
|
|
||||||
#include "PasswordWindow.h"
|
#include "PasswordWindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <RadioButton.h>
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <RadioButton.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
|
||||||
|
|
||||||
PasswordWindow::PasswordWindow()
|
PasswordWindow::PasswordWindow()
|
||||||
: BWindow(BRect(100,100,380,250),"",B_MODAL_WINDOW_LOOK,B_MODAL_APP_WINDOW_FEEL,B_NOT_RESIZABLE)
|
: BWindow(BRect(100,100,380,250),"",B_MODAL_WINDOW_LOOK,B_MODAL_APP_WINDOW_FEEL,B_NOT_RESIZABLE)
|
||||||
{
|
{
|
||||||
Setup();
|
Setup();
|
||||||
|
BRect screenFrame = BScreen(B_MAIN_SCREEN_ID).Frame();
|
||||||
|
BPoint point;
|
||||||
|
point.x = (screenFrame.Width() - Bounds().Width()) / 2;
|
||||||
|
point.y = (screenFrame.Height() - Bounds().Height()) / 2;
|
||||||
|
|
||||||
|
if (screenFrame.Contains(point))
|
||||||
|
MoveTo(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -105,7 +113,7 @@ PasswordWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2005, Haiku
|
||||||
|
//
|
||||||
|
// This software is part of the Haiku distribution and is covered
|
||||||
|
// by the Haiku license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: ScreenSaverItem.h
|
||||||
|
// Author: Jérôme Duval
|
||||||
|
// Description: ScreenSaver Preferences
|
||||||
|
// Created : July 28, 2005
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
|
#ifndef __SCREENSAVERITEM_H__
|
||||||
|
#define __SCREENSAVERITEM_H__
|
||||||
|
|
||||||
|
#include <StringItem.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenSaverItem : public BStringItem {
|
||||||
|
public:
|
||||||
|
ScreenSaverItem(const char* event_name,const char* path)
|
||||||
|
: BStringItem(event_name), fPath(path) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Path() const { return fPath.String();}
|
||||||
|
private:
|
||||||
|
BString fPath;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -22,9 +22,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ScreenSaverWindow.h"
|
#include "ScreenSaverWindow.h"
|
||||||
|
#include "ScreenSaverItem.h"
|
||||||
#include "MouseAreaView.h"
|
#include "MouseAreaView.h"
|
||||||
#include "PreviewView.h"
|
#include "PreviewView.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
#define CALLED() PRINT(("%s\n", __PRETTY_FUNCTION__))
|
||||||
|
|
||||||
static const char *kTimes[]={"30 seconds", "1 minute", "1 minute 30 seconds",
|
static const char *kTimes[]={"30 seconds", "1 minute", "1 minute 30 seconds",
|
||||||
"2 minutes", "2 minutes 30 seconds", "3 minutes",
|
"2 minutes", "2 minutes 30 seconds", "3 minutes",
|
||||||
"4 minutes", "5 minutes", "6 minutes",
|
"4 minutes", "5 minutes", "6 minutes",
|
||||||
@@ -35,7 +39,7 @@ static const char *kTimes[]={"30 seconds", "1 minute", "1 minute 30
|
|||||||
"2 hours", "2 hours 30 minutes", "3 hours",
|
"2 hours", "2 hours 30 minutes", "3 hours",
|
||||||
"4 hours", "5 hours"};
|
"4 hours", "5 hours"};
|
||||||
|
|
||||||
static const int kTimeInSeconds[]={ 30, 60, 90,
|
static const int32 kTimeInUnits[]={ 30, 60, 90,
|
||||||
120, 150, 180,
|
120, 150, 180,
|
||||||
240, 300, 360,
|
240, 300, 360,
|
||||||
420, 480, 540,
|
420, 480, 540,
|
||||||
@@ -45,53 +49,35 @@ static const int kTimeInSeconds[]={ 30, 60, 90,
|
|||||||
7200, 9000, 10800,
|
7200, 9000, 10800,
|
||||||
14400, 18000};
|
14400, 18000};
|
||||||
|
|
||||||
const int32 zero=0;
|
const int32 PASSWORD_CHECKBOX = 'psCB';
|
||||||
|
|
||||||
void drawPositionalMonitor(BView *view,BRect areaToDrawIn,int state);
|
void drawPositionalMonitor(BView *view,BRect areaToDrawIn,int state);
|
||||||
BView *drawSampleMonitor(BView *view, BRect area);
|
BView *drawSampleMonitor(BView *view, BRect area);
|
||||||
|
|
||||||
|
int32
|
||||||
int
|
UnitsToSlider(bigtime_t val)
|
||||||
secondsToSlider(int val)
|
|
||||||
{
|
{
|
||||||
int count=sizeof(kTimeInSeconds)/sizeof(int);
|
int count = sizeof(kTimeInUnits)/sizeof(int);
|
||||||
for (int t=0;t<count;t++)
|
for (int t=0; t<count; t++)
|
||||||
if (kTimeInSeconds[t]==val)
|
if (kTimeInUnits[t]*1000000LL == val)
|
||||||
return t;
|
return t;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct SSListItem {
|
|
||||||
BString fileName;
|
|
||||||
BString displayName;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ScreenSaverWin::ScreenSaverWin()
|
ScreenSaverWin::ScreenSaverWin()
|
||||||
: BWindow(BRect(50,50,500,385),"OBOS Screen Saver Preferences",
|
: BWindow(BRect(50,50,496,375),"OBOS Screen Saver",
|
||||||
B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) ,
|
B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) ,
|
||||||
fFadeState(0),fNoFadeState(0),
|
fFadeState(0),fNoFadeState(0),
|
||||||
fSampleView(NULL),
|
fSelectedAddonFileName(NULL),
|
||||||
fTab1(NULL),fTab2(NULL),
|
|
||||||
fTabView(NULL), fModuleSettingsBox(NULL),
|
|
||||||
fPreviewDisplay(NULL), fListView1(NULL),
|
|
||||||
fAddonList(NULL), fSelectedAddonFileName(NULL),
|
|
||||||
fCurrentAddon(NULL), fTestButton(NULL),
|
fCurrentAddon(NULL), fTestButton(NULL),
|
||||||
fAddButton(NULL), fEnableScreenSaverBox(NULL),
|
|
||||||
fPasswordSlider(NULL), fTurnOffSlider(NULL),
|
|
||||||
fRunSlider(NULL), fStringView1(NULL),
|
|
||||||
fEnableCheckbox(NULL), fPasswordCheckbox(NULL),
|
|
||||||
fTurnOffScreenCheckBox(NULL),
|
|
||||||
fTurnOffMinutes(NULL), fRunMinutes(NULL),
|
fTurnOffMinutes(NULL), fRunMinutes(NULL),
|
||||||
fPasswordMinutes(NULL), fPasswordButton(NULL),
|
fPasswordMinutes(NULL), fPasswordButton(NULL),
|
||||||
fFadeNowString(NULL),
|
fFadeNowString(NULL),
|
||||||
fFadeNowString2(NULL),
|
fFadeNowString2(NULL),
|
||||||
fDontFadeString(NULL), fDontFadeString2(NULL),
|
fDontFadeString(NULL), fDontFadeString2(NULL),
|
||||||
fFadeNow(NULL),fFadeNever(NULL),
|
fFadeNow(NULL),fFadeNever(NULL),
|
||||||
fPwWin(NULL),
|
fPwMessenger(NULL),
|
||||||
fPwMessenger(NULL), fFilePanel(NULL) ,
|
|
||||||
fSettingsArea(NULL)
|
fSettingsArea(NULL)
|
||||||
{
|
{
|
||||||
SetupForm();
|
SetupForm();
|
||||||
@@ -104,22 +90,23 @@ ScreenSaverWin::~ScreenSaverWin()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverWin::SaverSelected(void)
|
ScreenSaverWin::SaverSelected()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
UpdateStatus();
|
||||||
if (fListView1->CurrentSelection()>=0) {
|
if (fListView1->CurrentSelection()>=0) {
|
||||||
SSListItem* listItem;
|
|
||||||
if (fPreviewDisplay->ScreenSaver())
|
if (fPreviewDisplay->ScreenSaver())
|
||||||
fPreviewDisplay->ScreenSaver()->StopConfig();
|
fPreviewDisplay->ScreenSaver()->StopConfig();
|
||||||
listItem = reinterpret_cast<SSListItem*>(fAddonList->ItemAt(fListView1->CurrentSelection()));
|
ScreenSaverItem* item = reinterpret_cast<ScreenSaverItem*>(fListView1->ItemAt(fListView1->CurrentSelection()));
|
||||||
BString settingsMsgName(listItem->fileName);
|
BString settingsMsgName(item->Path());
|
||||||
fPreviewDisplay->SetScreenSaver(settingsMsgName);
|
fPreviewDisplay->SetScreenSaver(settingsMsgName);
|
||||||
if (fSettingsArea) {
|
if (fSettingsArea) {
|
||||||
fModuleSettingsBox->RemoveChild(fSettingsArea);
|
fModuleSettingsBox->RemoveChild(fSettingsArea);
|
||||||
delete fSettingsArea;
|
delete fSettingsArea;
|
||||||
}
|
}
|
||||||
BRect bnds=fModuleSettingsBox->Bounds();
|
BRect bnds = fModuleSettingsBox->Bounds();
|
||||||
bnds.InsetBy(5,10);
|
bnds.InsetBy(5,10);
|
||||||
fSettingsArea=new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
fSettingsArea = new BView(bnds,"settingsArea",B_FOLLOW_NONE,B_WILL_DRAW);
|
||||||
fSettingsArea->SetViewColor(216,216,216);
|
fSettingsArea->SetViewColor(216,216,216);
|
||||||
fModuleSettingsBox->AddChild(fSettingsArea);
|
fModuleSettingsBox->AddChild(fSettingsArea);
|
||||||
|
|
||||||
@@ -133,9 +120,31 @@ void
|
|||||||
ScreenSaverWin::MessageReceived(BMessage *msg)
|
ScreenSaverWin::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
|
case kPasswordCheckbox:
|
||||||
|
fPasswordSlider->SetEnabled(fPasswordCheckbox->Value()==B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
case kRunSliderChanged:
|
||||||
|
fRunSlider->SetLabel(kTimes[fRunSlider->Value()]);
|
||||||
|
if (fRunSlider->Value()>fPasswordSlider->Value()) {
|
||||||
|
fTurnOffSlider->SetValue(fRunSlider->Value());
|
||||||
|
fTurnOffSlider->SetLabel(kTimes[fTurnOffSlider->Value()]);
|
||||||
|
fPasswordSlider->SetValue(fRunSlider->Value());
|
||||||
|
fPasswordSlider->SetLabel(kTimes[fPasswordSlider->Value()]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kTurnOffSliderChanged:
|
||||||
|
fTurnOffSlider->SetLabel(kTimes[fTurnOffSlider->Value()]);
|
||||||
|
break;
|
||||||
|
case kPasswordSliderChanged:
|
||||||
|
fPasswordSlider->SetLabel(kTimes[fPasswordSlider->Value()]);
|
||||||
|
if (fPasswordSlider->Value()<fRunSlider->Value()) {
|
||||||
|
fRunSlider->SetValue(fPasswordSlider->Value());
|
||||||
|
fRunSlider->SetLabel(kTimes[fRunSlider->Value()]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case kPwbutton:
|
case kPwbutton:
|
||||||
fPwMessenger->SendMessage(kShow);
|
fPwMessenger->SendMessage(kShow);
|
||||||
break;
|
break;
|
||||||
case B_QUIT_REQUESTED:
|
case B_QUIT_REQUESTED:
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
@@ -143,8 +152,12 @@ ScreenSaverWin::MessageReceived(BMessage *msg)
|
|||||||
SaverSelected();
|
SaverSelected();
|
||||||
break;
|
break;
|
||||||
case kTest_btn:
|
case kTest_btn:
|
||||||
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",fPrefs.GetSettings());
|
{
|
||||||
|
BMessage *settings = fPrefs.GetSettings();
|
||||||
|
be_roster->Launch("application/x-vnd.haiku-ScreenSaverApp", settings);
|
||||||
|
delete settings;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case kAdd_btn:
|
case kAdd_btn:
|
||||||
fFilePanel->Show();
|
fFilePanel->Show();
|
||||||
break;
|
break;
|
||||||
@@ -152,7 +165,6 @@ ScreenSaverWin::MessageReceived(BMessage *msg)
|
|||||||
PopulateScreenSaverList();
|
PopulateScreenSaverList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UpdateStatus(); // This could get called sometimes when it doesn't need to. Shouldn't hurt
|
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +173,7 @@ bool
|
|||||||
ScreenSaverWin::QuitRequested()
|
ScreenSaverWin::QuitRequested()
|
||||||
{
|
{
|
||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
|
fPrefs.SaveSettings();
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@@ -188,22 +201,24 @@ ScreenSaverWin::UpdateStatus(void)
|
|||||||
fPrefs.SetWindowFrame(Frame());
|
fPrefs.SetWindowFrame(Frame());
|
||||||
fPrefs.SetWindowTab(fTabView->Selection());
|
fPrefs.SetWindowTab(fTabView->Selection());
|
||||||
fPrefs.SetTimeFlags(fEnableCheckbox->Value());
|
fPrefs.SetTimeFlags(fEnableCheckbox->Value());
|
||||||
fPrefs.SetBlankTime(kTimeInSeconds[fRunSlider->Value()]);
|
fPrefs.SetBlankTime(1000000LL* kTimeInUnits[fRunSlider->Value()]);
|
||||||
fPrefs.SetOffTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
fPrefs.SetOffTime(1000000LL* kTimeInUnits[fTurnOffSlider->Value()]);
|
||||||
fPrefs.SetSuspendTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
fPrefs.SetSuspendTime(1000000LL* kTimeInUnits[fTurnOffSlider->Value()]);
|
||||||
fPrefs.SetStandbyTime(kTimeInSeconds[fTurnOffSlider->Value()]);
|
fPrefs.SetStandbyTime(1000000LL* kTimeInUnits[fTurnOffSlider->Value()]);
|
||||||
fPrefs.SetBlankCorner(fFadeNow->getDirection());
|
fPrefs.SetBlankCorner(fFadeNow->getDirection());
|
||||||
fPrefs.SetNeverBlankCorner(fFadeNever->getDirection());
|
fPrefs.SetNeverBlankCorner(fFadeNever->getDirection());
|
||||||
fPrefs.SetLockEnable(fPasswordCheckbox->Value());
|
fPrefs.SetLockEnable(fPasswordCheckbox->Value());
|
||||||
fPrefs.SetPasswordTime(kTimeInSeconds[fPasswordSlider->Value()]);
|
fPrefs.SetPasswordTime(1000000LL* kTimeInUnits[fPasswordSlider->Value()]);
|
||||||
int selection=fListView1->CurrentSelection(0);
|
int selection = fListView1->CurrentSelection();
|
||||||
if (selection>=0)
|
if (selection >= 0) {
|
||||||
fPrefs.SetModuleName(((BStringItem *)(fListView1->ItemAt(selection)))->Text());
|
fPrefs.SetModuleName(((ScreenSaverItem *)(fListView1->ItemAt(selection)))->Text());
|
||||||
|
if (strcmp(fPrefs.ModuleName(), "Blackness") == 0)
|
||||||
|
fPrefs.SetModuleName("");
|
||||||
|
}
|
||||||
// TODO - Tell the password window to update its stuff
|
// TODO - Tell the password window to update its stuff
|
||||||
BMessage ssState;
|
BMessage ssState;
|
||||||
if ((fPreviewDisplay->ScreenSaver()) && (fPreviewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
|
if ((fPreviewDisplay->ScreenSaver()) && (fPreviewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
|
||||||
fPrefs.SetState(fPrefs.ModuleName(), &ssState);
|
fPrefs.SetState(fPrefs.ModuleName(), &ssState);
|
||||||
fPrefs.SaveSettings();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -221,7 +236,7 @@ ScreenSaverWin::SetupForm()
|
|||||||
AddChild(background);
|
AddChild(background);
|
||||||
|
|
||||||
// Add the tab view to the background
|
// Add the tab view to the background
|
||||||
r.InsetBy(0,3);
|
r.top += 4;
|
||||||
fTabView = new BTabView(r, "tab_view");
|
fTabView = new BTabView(r, "tab_view");
|
||||||
fTabView->SetViewColor(216,216,216,0);
|
fTabView->SetViewColor(216,216,216,0);
|
||||||
r = fTabView->Bounds();
|
r = fTabView->Bounds();
|
||||||
@@ -232,11 +247,13 @@ ScreenSaverWin::SetupForm()
|
|||||||
fPrefs.LoadSettings();
|
fPrefs.LoadSettings();
|
||||||
|
|
||||||
tab = new BTab();
|
tab = new BTab();
|
||||||
fTabView->AddTab(fTab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
|
fTab2 = new BView(r,"Fade",B_FOLLOW_NONE,0);
|
||||||
|
fTabView->AddTab(fTab2, tab);
|
||||||
tab->SetLabel("Fade");
|
tab->SetLabel("Fade");
|
||||||
|
|
||||||
tab = new BTab();
|
tab = new BTab();
|
||||||
fTabView->AddTab(fTab1=new BView(r,"Modules",B_FOLLOW_NONE,0), tab);
|
fTab1 = new BView(r,"Modules",B_FOLLOW_NONE,0);
|
||||||
|
fTabView->AddTab(fTab1, tab);
|
||||||
tab->SetLabel("Modules");
|
tab->SetLabel("Modules");
|
||||||
background->AddChild(fTabView);
|
background->AddChild(fTabView);
|
||||||
|
|
||||||
@@ -253,22 +270,24 @@ ScreenSaverWin::SetupForm()
|
|||||||
//ResizeTo(fPrefs.WindowFrame().right-fPrefs.WindowFrame().left,fPrefs.WindowFrame().bottom-fPrefs.WindowFrame().top);
|
//ResizeTo(fPrefs.WindowFrame().right-fPrefs.WindowFrame().left,fPrefs.WindowFrame().bottom-fPrefs.WindowFrame().top);
|
||||||
fTabView->Select(fPrefs.WindowTab());
|
fTabView->Select(fPrefs.WindowTab());
|
||||||
fEnableCheckbox->SetValue(fPrefs.TimeFlags());
|
fEnableCheckbox->SetValue(fPrefs.TimeFlags());
|
||||||
fRunSlider->SetValue(secondsToSlider(fPrefs.BlankTime()));
|
fRunSlider->SetValue(UnitsToSlider(fPrefs.BlankTime()));
|
||||||
fTurnOffSlider->SetValue(secondsToSlider(fPrefs.OffTime()));
|
fTurnOffSlider->SetValue(UnitsToSlider(fPrefs.OffTime()));
|
||||||
fFadeNow->setDirection(fPrefs.GetBlankCorner());
|
fFadeNow->setDirection(fPrefs.GetBlankCorner());
|
||||||
fFadeNever->setDirection(fPrefs.GetNeverBlankCorner());
|
fFadeNever->setDirection(fPrefs.GetNeverBlankCorner());
|
||||||
fPasswordCheckbox->SetValue(fPrefs.LockEnable());
|
fPasswordCheckbox->SetValue(fPrefs.LockEnable());
|
||||||
fPasswordSlider->SetValue(secondsToSlider(fPrefs.PasswordTime()));
|
fPasswordSlider->SetValue(UnitsToSlider(fPrefs.PasswordTime()));
|
||||||
const BStringItem **ptr = (const BStringItem **)(fListView1->Items());
|
int32 count = fListView1->CountItems();
|
||||||
long count=fListView1->CountItems();
|
for (int32 i=0; i<count; i++) {
|
||||||
if (fPrefs.ModuleName() && ptr)
|
ScreenSaverItem *item = dynamic_cast<ScreenSaverItem*>(fListView1->ItemAt(i));
|
||||||
for ( long i = 0; i < count; i++ ) {
|
printf("modulename %s-%s\n", fPrefs.ModuleName(), item->Text());
|
||||||
if (BString(fPrefs.ModuleName())==((*ptr++)->Text())) {
|
if ((strcmp(fPrefs.ModuleName(), item->Text()) == 0)
|
||||||
fListView1->Select(count=i); // Clever bit here - intentional assignment.
|
|| (strcmp(fPrefs.ModuleName(),"") == 0 && strcmp(item->Text(), "Blackness") ==0)) {
|
||||||
SaverSelected();
|
fListView1->Select(i);
|
||||||
fListView1->ScrollToSelection();
|
SaverSelected();
|
||||||
}
|
fListView1->ScrollToSelection();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,69 +323,49 @@ commonLookAndFeel(BView *widget,bool isSlider,bool isControl)
|
|||||||
|
|
||||||
// Iterate over a directory, adding the directories files to the list
|
// Iterate over a directory, adding the directories files to the list
|
||||||
void
|
void
|
||||||
addScreenSaversToList (directory_which dir, BList *list)
|
addScreenSaversToList (directory_which dir, BListView *list)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
find_directory(dir,&path);
|
find_directory(dir,&path);
|
||||||
path.Append("Screen Savers",true);
|
path.Append("Screen Savers",true);
|
||||||
|
|
||||||
const char* pathName = path.Path();
|
BDirectory ssDir(path.Path());
|
||||||
|
|
||||||
BDirectory ssDir(pathName);
|
|
||||||
BEntry thisSS;
|
BEntry thisSS;
|
||||||
char thisName[B_FILE_NAME_LENGTH];
|
char thisName[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
while (B_OK==ssDir.GetNextEntry(&thisSS,true)) {
|
while (B_OK==ssDir.GetNextEntry(&thisSS,true)) {
|
||||||
thisSS.GetName(thisName);
|
thisSS.GetName(thisName);
|
||||||
SSListItem* tempListItem = new SSListItem;
|
BString pathname = path.Path();
|
||||||
tempListItem->fileName = pathName;
|
pathname += "/";
|
||||||
tempListItem->fileName += "/";
|
pathname += thisName;
|
||||||
tempListItem->fileName += thisName;
|
list->AddItem(new ScreenSaverItem(thisName, pathname.String()));
|
||||||
tempListItem->displayName = thisName;
|
|
||||||
|
|
||||||
list->AddItem(tempListItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// sorting function for SSListItems
|
// sorting function for ScreenSaverItems
|
||||||
int
|
int
|
||||||
ScreenSaverWin::CompareSSListItems(const void* left, const void* right)
|
ScreenSaverWin::CompareScreenSaverItems(const void* left, const void* right)
|
||||||
{
|
{
|
||||||
SSListItem* leftItem = *(SSListItem **)left;
|
ScreenSaverItem* leftItem = *(ScreenSaverItem **)left;
|
||||||
SSListItem* rightItem = *(SSListItem **)right;
|
ScreenSaverItem* rightItem = *(ScreenSaverItem **)right;
|
||||||
|
|
||||||
return leftItem->displayName.Compare(rightItem->displayName);
|
return strcmp(leftItem->Text(),rightItem->Text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverWin::PopulateScreenSaverList(void)
|
ScreenSaverWin::PopulateScreenSaverList(void)
|
||||||
{
|
{
|
||||||
if (!fAddonList)
|
|
||||||
fAddonList = new BList;
|
|
||||||
else
|
|
||||||
for (void *i=fAddonList->RemoveItem(zero);i;i=fAddonList->RemoveItem(zero))
|
|
||||||
delete ((SSListItem *)i);
|
|
||||||
|
|
||||||
SSListItem* tempListItem = new SSListItem;
|
|
||||||
tempListItem->fileName = "";
|
|
||||||
tempListItem->displayName = "Blackness";
|
|
||||||
fAddonList->AddItem(tempListItem);
|
|
||||||
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, fAddonList );
|
|
||||||
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, fAddonList );
|
|
||||||
fAddonList->SortItems(CompareSSListItems);
|
|
||||||
|
|
||||||
// Add the strings in the BList to a BListView
|
|
||||||
fListView1->DeselectAll();
|
fListView1->DeselectAll();
|
||||||
for (void *i=fListView1->RemoveItem(zero);i;i=fListView1->RemoveItem(zero))
|
while (void *i=fListView1->RemoveItem((int32)0))
|
||||||
delete ((BStringItem *)i);
|
delete ((ScreenSaverItem *)i);
|
||||||
|
|
||||||
int numItems = fAddonList->CountItems();
|
fListView1->AddItem(new ScreenSaverItem("Blackness", ""));
|
||||||
for( int i = 0; i < numItems; ++i ) {
|
addScreenSaversToList(B_BEOS_ADDONS_DIRECTORY, fListView1);
|
||||||
SSListItem* item = (SSListItem*)(fAddonList->ItemAt(i));
|
addScreenSaversToList(B_USER_ADDONS_DIRECTORY, fListView1);
|
||||||
fListView1->AddItem( new BStringItem(item->displayName.String()) );
|
|
||||||
}
|
fListView1->SortItems(CompareScreenSaverItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -413,7 +412,7 @@ ScreenSaverWin::SetupTab2()
|
|||||||
int stringHeight=(int)(stdFontHt.ascent+stdFontHt.descent),sliderHeight=30;
|
int stringHeight=(int)(stdFontHt.ascent+stdFontHt.descent),sliderHeight=30;
|
||||||
int topEdge;
|
int topEdge;
|
||||||
{rgb_color clr = {216,216,216,255}; fTab2->SetViewColor(clr);}
|
{rgb_color clr = {216,216,216,255}; fTab2->SetViewColor(clr);}
|
||||||
fTab2->AddChild( fEnableScreenSaverBox = new BBox(BRect(11,13,437,280),"EnableScreenSaverBox"));
|
fTab2->AddChild( fEnableScreenSaverBox = new BBox(BRect(8,6,436,280),"EnableScreenSaverBox"));
|
||||||
commonLookAndFeel(fEnableScreenSaverBox,false,false);
|
commonLookAndFeel(fEnableScreenSaverBox,false,false);
|
||||||
|
|
||||||
fEnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (kTab2_chg));
|
fEnableCheckbox = new BCheckBox(BRect(0,0,90,stringHeight),"EnableCheckBox","Enable Screen Saver", new BMessage (kTab2_chg));
|
||||||
@@ -427,8 +426,8 @@ ScreenSaverWin::SetupTab2()
|
|||||||
fStringView1->SetText("Run module");
|
fStringView1->SetText("Run module");
|
||||||
fStringView1->SetAlignment(B_ALIGN_LEFT);
|
fStringView1->SetAlignment(B_ALIGN_LEFT);
|
||||||
|
|
||||||
fEnableScreenSaverBox->AddChild( fRunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(kTab2_chg), 0, 25));
|
fEnableScreenSaverBox->AddChild( fRunSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"RunSlider","minutes", new BMessage(kRunSliderChanged), 0, 25));
|
||||||
fRunSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
fRunSlider->SetModificationMessage(new BMessage(kRunSliderChanged));
|
||||||
commonLookAndFeel(fRunSlider,true,true);
|
commonLookAndFeel(fRunSlider,true,true);
|
||||||
float w,h;
|
float w,h;
|
||||||
fRunSlider->GetPreferredSize(&w,&h);
|
fRunSlider->GetPreferredSize(&w,&h);
|
||||||
@@ -441,18 +440,18 @@ ScreenSaverWin::SetupTab2()
|
|||||||
fTurnOffScreenCheckBox->SetLabel("Turn off screen");
|
fTurnOffScreenCheckBox->SetLabel("Turn off screen");
|
||||||
fTurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
|
fTurnOffScreenCheckBox->SetResizingMode(B_FOLLOW_NONE);
|
||||||
|
|
||||||
fEnableScreenSaverBox->AddChild( fTurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(kTab2_chg), 0, 25));
|
fEnableScreenSaverBox->AddChild( fTurnOffSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"TurnOffSlider","", new BMessage(kTurnOffSliderChanged), 0, 25));
|
||||||
fTurnOffSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
fTurnOffSlider->SetModificationMessage(new BMessage(kTurnOffSliderChanged));
|
||||||
commonLookAndFeel(fTurnOffSlider,true,true);
|
commonLookAndFeel(fTurnOffSlider,true,true);
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
topEdge+=sliderHeight;
|
topEdge+=sliderHeight;
|
||||||
fEnableScreenSaverBox->AddChild( fPasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (kTab2_chg)));
|
fEnableScreenSaverBox->AddChild( fPasswordCheckbox = new BCheckBox(BRect(9,topEdge,108,topEdge+stringHeight),"PasswordCheckbox","Password lock", new BMessage (kPasswordCheckbox)));
|
||||||
commonLookAndFeel(fPasswordCheckbox,false,true);
|
commonLookAndFeel(fPasswordCheckbox,false,true);
|
||||||
fPasswordCheckbox->SetLabel("Password lock");
|
fPasswordCheckbox->SetLabel("Password lock");
|
||||||
|
|
||||||
fEnableScreenSaverBox->AddChild( fPasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(kTab2_chg), 0, 25));
|
fEnableScreenSaverBox->AddChild( fPasswordSlider = new BSlider(BRect(132,topEdge,415,topEdge+sliderHeight),"PasswordSlider","", new BMessage(kPasswordSliderChanged), 0, 25));
|
||||||
fPasswordSlider->SetModificationMessage(new BMessage(kTab2_chg));
|
fPasswordSlider->SetModificationMessage(new BMessage(kPasswordSliderChanged));
|
||||||
commonLookAndFeel(fPasswordSlider,true,true);
|
commonLookAndFeel(fPasswordSlider,true,true);
|
||||||
|
|
||||||
topEdge+=sliderHeight;
|
topEdge+=sliderHeight;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ private:
|
|||||||
void UpdateStatus();
|
void UpdateStatus();
|
||||||
void SaverSelected();
|
void SaverSelected();
|
||||||
|
|
||||||
static int CompareSSListItems(const void* left, const void* right);
|
static int CompareScreenSaverItems(const void* left, const void* right);
|
||||||
|
|
||||||
ScreenSaverPrefs fPrefs;
|
ScreenSaverPrefs fPrefs;
|
||||||
int fFadeState,fNoFadeState;
|
int fFadeState,fNoFadeState;
|
||||||
@@ -41,7 +41,6 @@ private:
|
|||||||
|
|
||||||
PreviewView *fPreviewDisplay;
|
PreviewView *fPreviewDisplay;
|
||||||
BListView *fListView1;
|
BListView *fListView1;
|
||||||
BList *fAddonList;
|
|
||||||
BString fSelectedAddonFileName;
|
BString fSelectedAddonFileName;
|
||||||
image_id fCurrentAddon;
|
image_id fCurrentAddon;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user