Last round of functionality changes.
"Add" and "test" now work. Be warned - without the input server addon running (and maybe even with), testing will cause the ScreenSaver to run but not to turn off. The way out of this is to alt-f# to a different workspace and kill "OpenBeOS ScreenSaver". As far as I know, all functionality now in place and working properly. Needs a good workout. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7257 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
730036e22e
commit
048f424d11
@ -33,6 +33,9 @@ const int SHOW ='SHOW';
|
|||||||
const int POPULATE ='POPU';
|
const int POPULATE ='POPU';
|
||||||
const int UTILIZE ='UTIL';
|
const int UTILIZE ='UTIL';
|
||||||
const int SAVER_SEL ='SSEL';
|
const int SAVER_SEL ='SSEL';
|
||||||
|
const int TEST_BTN ='TEST';
|
||||||
|
const int ADD_BTN ='ADD ';
|
||||||
|
const int UPDATELIST ='UPDL';
|
||||||
|
|
||||||
const rgb_color black = {0,0,0,0};
|
const rgb_color black = {0,0,0,0};
|
||||||
const rgb_color darkGrey = {150,150,150,0};
|
const rgb_color darkGrey = {150,150,150,0};
|
||||||
|
@ -12,7 +12,7 @@ local sources =
|
|||||||
|
|
||||||
Preference ScreenSaver : $(sources) ;
|
Preference ScreenSaver : $(sources) ;
|
||||||
|
|
||||||
LinkSharedOSLibs ScreenSaver : libscreensaver.so be stdc++.r4 ;
|
LinkSharedOSLibs ScreenSaver : tracker libscreensaver.so be stdc++.r4 ;
|
||||||
|
|
||||||
# Ugly hack: Prepend the dir containing Be's ScreenSaver.h to the list of
|
# Ugly hack: Prepend the dir containing Be's ScreenSaver.h to the list of
|
||||||
# include search dirs. Otherwise it won't be found.
|
# include search dirs. Otherwise it won't be found.
|
||||||
|
@ -29,6 +29,8 @@ PreviewView::PreviewView(BRect frame, const char *name,ScreenSaverPrefs *prefp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreviewView::~PreviewView() {
|
PreviewView::~PreviewView() {
|
||||||
|
if (threadID)
|
||||||
|
kill_thread(threadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewView::SetScreenSaver(BString name) {
|
void PreviewView::SetScreenSaver(BString name) {
|
||||||
@ -47,8 +49,10 @@ void PreviewView::SetScreenSaver(BString name) {
|
|||||||
|
|
||||||
sst=new ScreenSaverThread(Window(),configView,prefPtr);
|
sst=new ScreenSaverThread(Window(),configView,prefPtr);
|
||||||
saver=sst->LoadAddOn();
|
saver=sst->LoadAddOn();
|
||||||
|
if (saver) {
|
||||||
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,sst);
|
threadID=spawn_thread(threadFunc,"ScreenSaverRenderer",0,sst);
|
||||||
resume_thread(threadID);
|
resume_thread(threadID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewView::Draw(BRect update) {
|
void PreviewView::Draw(BRect update) {
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
#include "ScreenSaverPrefsApp.h"
|
#include "ScreenSaverPrefsApp.h"
|
||||||
|
|
||||||
@ -12,6 +15,20 @@ ScreenSaverPrefsApp::ScreenSaverPrefsApp(void) : BApplication(APP_SIG) {
|
|||||||
m_MainForm->Show();
|
m_MainForm->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSaverPrefsApp::RefsReceived(BMessage *msg) {
|
||||||
|
entry_ref ref;
|
||||||
|
BEntry e;
|
||||||
|
BPath p;
|
||||||
|
msg->FindRef("refs", &ref);
|
||||||
|
e.SetTo(&ref, true);
|
||||||
|
e.GetPath(&p);
|
||||||
|
|
||||||
|
char temp[2*B_PATH_NAME_LENGTH];
|
||||||
|
sprintf (temp,"cp %s '/boot/home/config/add-ons/Screen Savers/'\n",p.Path());
|
||||||
|
system(temp);
|
||||||
|
m_MainForm->PostMessage(new BMessage(UPDATELIST));
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSaverPrefsApp::MessageReceived(BMessage *message) {
|
void ScreenSaverPrefsApp::MessageReceived(BMessage *message) {
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case B_READY_TO_RUN:
|
case B_READY_TO_RUN:
|
||||||
|
@ -11,6 +11,7 @@ public:
|
|||||||
ScreenSaverPrefsApp(void);
|
ScreenSaverPrefsApp(void);
|
||||||
virtual ~ScreenSaverPrefsApp(void);
|
virtual ~ScreenSaverPrefsApp(void);
|
||||||
virtual void MessageReceived(BMessage *);
|
virtual void MessageReceived(BMessage *);
|
||||||
|
virtual void RefsReceived(BMessage *);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
#include <ScreenSaver.h>
|
#include <ScreenSaver.h>
|
||||||
#include "MouseAreaView.h"
|
#include "MouseAreaView.h"
|
||||||
#include "PreviewView.h"
|
#include "PreviewView.h"
|
||||||
|
#include <Roster.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
const int32 zero=0;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -26,16 +29,9 @@ struct SSListItem {
|
|||||||
BString displayName;
|
BString displayName;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ScreenSaverWin::MessageReceived(BMessage *msg) {
|
void ScreenSaverWin::SaverSelected(void) {
|
||||||
|
if (ListView1->CurrentSelection()>=0) {
|
||||||
SSListItem* listItem;
|
SSListItem* listItem;
|
||||||
switch(msg->what) {
|
|
||||||
case PWBUTTON:
|
|
||||||
pwMessenger->SendMessage(SHOW);
|
|
||||||
break;
|
|
||||||
case B_QUIT_REQUESTED:
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
break;
|
|
||||||
case SAVER_SEL:
|
|
||||||
if (previewDisplay->ScreenSaver())
|
if (previewDisplay->ScreenSaver())
|
||||||
previewDisplay->ScreenSaver()->StopConfig();
|
previewDisplay->ScreenSaver()->StopConfig();
|
||||||
listItem = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()));
|
listItem = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()));
|
||||||
@ -53,6 +49,28 @@ void ScreenSaverWin::MessageReceived(BMessage *msg) {
|
|||||||
|
|
||||||
if (previewDisplay->ScreenSaver())
|
if (previewDisplay->ScreenSaver())
|
||||||
previewDisplay->ScreenSaver()->StartConfig(settingsArea);
|
previewDisplay->ScreenSaver()->StartConfig(settingsArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenSaverWin::MessageReceived(BMessage *msg) {
|
||||||
|
switch(msg->what) {
|
||||||
|
case PWBUTTON:
|
||||||
|
pwMessenger->SendMessage(SHOW);
|
||||||
|
break;
|
||||||
|
case B_QUIT_REQUESTED:
|
||||||
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
break;
|
||||||
|
case SAVER_SEL:
|
||||||
|
SaverSelected();
|
||||||
|
break;
|
||||||
|
case TEST_BTN:
|
||||||
|
be_roster->Launch("application/x-vnd.OBOS-ScreenSaverApp",prefs.GetSettings());
|
||||||
|
break;
|
||||||
|
case ADD_BTN:
|
||||||
|
filePanel->Show();
|
||||||
|
break;
|
||||||
|
case UPDATELIST:
|
||||||
|
populateScreenSaverList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateStatus(); // This could get called sometimes when it doesn't need to. Shouldn't hurt
|
updateStatus(); // This could get called sometimes when it doesn't need to. Shouldn't hurt
|
||||||
@ -98,10 +116,16 @@ void ScreenSaverWin::updateStatus(void) {
|
|||||||
if (selection>=0)
|
if (selection>=0)
|
||||||
prefs.SetModuleName(((BStringItem *)(ListView1->ItemAt(selection)))->Text());
|
prefs.SetModuleName(((BStringItem *)(ListView1->ItemAt(selection)))->Text());
|
||||||
// TODO - Tell the password window to update its stuff
|
// TODO - Tell the password window to update its stuff
|
||||||
|
BMessage ssState;
|
||||||
|
if ((previewDisplay->ScreenSaver()) && (previewDisplay->ScreenSaver()->SaveState(&ssState)==B_OK))
|
||||||
|
prefs.SetState(&ssState);
|
||||||
prefs.SaveSettings();
|
prefs.SaveSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
void ScreenSaverWin::SetupForm(void) {
|
void ScreenSaverWin::SetupForm(void) {
|
||||||
|
|
||||||
|
filePanel=new BFilePanel();
|
||||||
|
|
||||||
BRect r;
|
BRect r;
|
||||||
BView *background;
|
BView *background;
|
||||||
BTab *tab;
|
BTab *tab;
|
||||||
@ -120,6 +144,10 @@ void ScreenSaverWin::SetupForm(void) {
|
|||||||
r.InsetBy(0,4);
|
r.InsetBy(0,4);
|
||||||
r.bottom -= tabView->TabHeight();
|
r.bottom -= tabView->TabHeight();
|
||||||
|
|
||||||
|
// Time to load the settings into a message and implement them...
|
||||||
|
prefs.LoadSettings();
|
||||||
|
prefs.WindowFrame().PrintToStream();
|
||||||
|
|
||||||
tab = new BTab();
|
tab = new BTab();
|
||||||
tabView->AddTab(tab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
|
tabView->AddTab(tab2=new BView(r,"Fade",B_FOLLOW_NONE,0), tab);
|
||||||
tab->SetLabel("Fade");
|
tab->SetLabel("Fade");
|
||||||
@ -137,9 +165,7 @@ void ScreenSaverWin::SetupForm(void) {
|
|||||||
pwWin=new pwWindow;
|
pwWin=new pwWindow;
|
||||||
pwMessenger=new BMessenger (NULL,pwWin);
|
pwMessenger=new BMessenger (NULL,pwWin);
|
||||||
pwWin->Run();
|
pwWin->Run();
|
||||||
// Time to load the settings into a message and implement them...
|
|
||||||
prefs.LoadSettings();
|
|
||||||
prefs.WindowFrame().PrintToStream();
|
|
||||||
MoveTo(prefs.WindowFrame().left,prefs.WindowFrame().top);
|
MoveTo(prefs.WindowFrame().left,prefs.WindowFrame().top);
|
||||||
ResizeTo(prefs.WindowFrame().right-prefs.WindowFrame().left,prefs.WindowFrame().bottom-prefs.WindowFrame().top);
|
ResizeTo(prefs.WindowFrame().right-prefs.WindowFrame().left,prefs.WindowFrame().bottom-prefs.WindowFrame().top);
|
||||||
tabView->Select(prefs.WindowTab());
|
tabView->Select(prefs.WindowTab());
|
||||||
@ -152,10 +178,13 @@ void ScreenSaverWin::SetupForm(void) {
|
|||||||
PasswordSlider->SetValue(secondsToSlider(prefs.PasswordTime()));
|
PasswordSlider->SetValue(secondsToSlider(prefs.PasswordTime()));
|
||||||
const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
|
const BStringItem **ptr = (const BStringItem **)(ListView1->Items());
|
||||||
long count=ListView1->CountItems();
|
long count=ListView1->CountItems();
|
||||||
if (prefs.Password() && ptr)
|
if (prefs.ModuleName() && ptr)
|
||||||
for ( long i = 0; i < count; i++ ) {
|
for ( long i = 0; i < count; i++ ) {
|
||||||
if (BString(prefs.Password())==((*ptr++)->Text()))
|
if (BString(prefs.ModuleName())==((*ptr++)->Text())) {
|
||||||
ListView1->Select(count=i); // Clever bit here - intentional assignment.
|
ListView1->Select(count=i); // Clever bit here - intentional assignment.
|
||||||
|
SaverSelected();
|
||||||
|
ListView1->ScrollToSelection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
@ -218,21 +247,37 @@ int compareSSListItems(const void* left, const void* right) {
|
|||||||
return leftItem->displayName.Compare(rightItem->displayName);
|
return leftItem->displayName.Compare(rightItem->displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the strings in the BList to a BListView
|
void ScreenSaverWin::populateScreenSaverList(void) {
|
||||||
void displayScreenSaversList(BList* list, BListView* view) {
|
if (!AddonList)
|
||||||
list->SortItems(compareSSListItems);
|
AddonList = new BList;
|
||||||
|
else
|
||||||
|
for (void *i=AddonList->RemoveItem(zero);i;i=AddonList->RemoveItem(zero))
|
||||||
|
delete ((SSListItem *)i);
|
||||||
|
|
||||||
int numItems = list->CountItems();
|
SSListItem* tempListItem = new SSListItem;
|
||||||
|
tempListItem->fileName = "";
|
||||||
|
tempListItem->displayName = "Blackness";
|
||||||
|
AddonList->AddItem(tempListItem);
|
||||||
|
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, AddonList );
|
||||||
|
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, AddonList );
|
||||||
|
AddonList->SortItems(compareSSListItems);
|
||||||
|
|
||||||
|
// Add the strings in the BList to a BListView
|
||||||
|
ListView1->DeselectAll();
|
||||||
|
for (void *i=ListView1->RemoveItem(zero);i;i=ListView1->RemoveItem(zero))
|
||||||
|
delete ((BStringItem *)i);
|
||||||
|
|
||||||
|
int numItems = AddonList->CountItems();
|
||||||
for( int i = 0; i < numItems; ++i ) {
|
for( int i = 0; i < numItems; ++i ) {
|
||||||
SSListItem* item = (SSListItem*)(list->ItemAt(i));
|
SSListItem* item = (SSListItem*)(AddonList->ItemAt(i));
|
||||||
view->AddItem( new BStringItem(item->displayName.String()) );
|
ListView1->AddItem( new BStringItem(item->displayName.String()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the controls for the first tab
|
// Create the controls for the first tab
|
||||||
void ScreenSaverWin::setupTab1(void) {
|
void ScreenSaverWin::setupTab1(void) {
|
||||||
int columns[4]={15,150,180,430};
|
int columns[4]={15,150,180,430};
|
||||||
int rows[6]={15,125,135,255,263,276};
|
int rows[6]={15,120,135,255,263,280};
|
||||||
|
|
||||||
{rgb_color clr = {216,216,216,255}; tab1->SetViewColor(clr);}
|
{rgb_color clr = {216,216,216,255}; tab1->SetViewColor(clr);}
|
||||||
tab1->AddChild( ModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
|
tab1->AddChild( ModuleSettingsBox = new BBox(BRect(columns[2],rows[0],columns[3],rows[5]),"ModuleSettingsBox",B_FOLLOW_NONE,B_WILL_DRAW));
|
||||||
@ -248,25 +293,18 @@ void ScreenSaverWin::setupTab1(void) {
|
|||||||
// selection message for screensaver list
|
// selection message for screensaver list
|
||||||
ListView1->SetSelectionMessage( new BMessage( SAVER_SEL ) );
|
ListView1->SetSelectionMessage( new BMessage( SAVER_SEL ) );
|
||||||
|
|
||||||
tab1->AddChild( TestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (TAB1_CHG)));
|
tab1->AddChild( TestButton = new BButton(BRect(columns[0],rows[4],91,rows[5]),"TestButton","Test", new BMessage (TEST_BTN)));
|
||||||
commonLookAndFeel(TestButton,false,true);
|
commonLookAndFeel(TestButton,false,true);
|
||||||
TestButton->SetLabel("Test");
|
TestButton->SetLabel("Test");
|
||||||
|
|
||||||
tab1->AddChild( AddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (TAB1_CHG)));
|
tab1->AddChild( AddButton = new BButton(BRect(97,rows[4],columns[2]-10,rows[5]),"AddButton","Add...", new BMessage (ADD_BTN)));
|
||||||
commonLookAndFeel(AddButton,false,true);
|
commonLookAndFeel(AddButton,false,true);
|
||||||
AddButton->SetLabel("Add...");
|
AddButton->SetLabel("Add...");
|
||||||
|
|
||||||
tab1->AddChild(previewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&prefs));
|
tab1->AddChild(previewDisplay = new PreviewView(BRect(columns[0]+5,rows[0],columns[1],rows[1]),"preview",&prefs));
|
||||||
|
populateScreenSaverList();
|
||||||
AddonList = new BList;
|
|
||||||
|
|
||||||
addScreenSaversToList( B_BEOS_ADDONS_DIRECTORY, AddonList );
|
|
||||||
addScreenSaversToList( B_USER_ADDONS_DIRECTORY, AddonList );
|
|
||||||
|
|
||||||
displayScreenSaversList( AddonList, ListView1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the controls for the second tab
|
// Create the controls for the second tab
|
||||||
void ScreenSaverWin::setupTab2(void) {
|
void ScreenSaverWin::setupTab2(void) {
|
||||||
font_height stdFontHt;
|
font_height stdFontHt;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#ifndef _ScreenSaver_H
|
#ifndef _ScreenSaver_H
|
||||||
#define _ScreenSaver_H
|
#define _ScreenSaver_H
|
||||||
|
#include <FilePanel.h>
|
||||||
#include <Picture.h>
|
#include <Picture.h>
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "passwordWindow.h"
|
#include "passwordWindow.h"
|
||||||
@ -15,27 +16,28 @@ public:
|
|||||||
sampleView(NULL),
|
sampleView(NULL),
|
||||||
tab1(NULL),tab2(NULL),
|
tab1(NULL),tab2(NULL),
|
||||||
tabView(NULL), ModuleSettingsBox(NULL),
|
tabView(NULL), ModuleSettingsBox(NULL),
|
||||||
previewDisplay(NULL), ListView1(NULL),
|
previewDisplay(NULL), ListView1(NULL),
|
||||||
AddonList(NULL), SelectedAddonFileName(NULL),
|
AddonList(NULL), SelectedAddonFileName(NULL),
|
||||||
currentAddon(NULL), TestButton(NULL),
|
currentAddon(NULL), TestButton(NULL),
|
||||||
AddButton(NULL), EnableScreenSaverBox(NULL),
|
AddButton(NULL), EnableScreenSaverBox(NULL),
|
||||||
PasswordSlider(NULL), TurnOffSlider(NULL),
|
PasswordSlider(NULL), TurnOffSlider(NULL),
|
||||||
RunSlider(NULL), StringView1(NULL),
|
RunSlider(NULL), StringView1(NULL),
|
||||||
EnableCheckbox(NULL), PasswordCheckbox(NULL),
|
EnableCheckbox(NULL), PasswordCheckbox(NULL),
|
||||||
TurnOffScreenCheckBox(NULL),
|
TurnOffScreenCheckBox(NULL),
|
||||||
TurnOffMinutes(NULL), RunMinutes(NULL),
|
TurnOffMinutes(NULL), RunMinutes(NULL),
|
||||||
PasswordMinutes(NULL), PasswordButton(NULL),
|
PasswordMinutes(NULL), PasswordButton(NULL),
|
||||||
FadeNowString(NULL),
|
FadeNowString(NULL),
|
||||||
FadeNowString2(NULL),
|
FadeNowString2(NULL),
|
||||||
DontFadeString(NULL), DontFadeString2(NULL),
|
DontFadeString(NULL), DontFadeString2(NULL),
|
||||||
fadeNow(NULL),fadeNever(NULL),
|
fadeNow(NULL),fadeNever(NULL),
|
||||||
pwWin(NULL),
|
pwWin(NULL),
|
||||||
pwMessenger(NULL),
|
pwMessenger(NULL), filePanel(NULL) ,
|
||||||
settingsArea(NULL) {
|
settingsArea(NULL) {
|
||||||
SetupForm();
|
SetupForm();
|
||||||
}
|
}
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual bool QuitRequested(void);
|
virtual bool QuitRequested(void);
|
||||||
|
void populateScreenSaverList(void);
|
||||||
void LoadSettings(void);
|
void LoadSettings(void);
|
||||||
virtual ~ScreenSaverWin(void) {};
|
virtual ~ScreenSaverWin(void) {};
|
||||||
|
|
||||||
@ -44,6 +46,7 @@ private:
|
|||||||
void setupTab1(void);
|
void setupTab1(void);
|
||||||
void setupTab2(void);
|
void setupTab2(void);
|
||||||
void updateStatus(void);
|
void updateStatus(void);
|
||||||
|
void SaverSelected(void);
|
||||||
|
|
||||||
ScreenSaverPrefs prefs;
|
ScreenSaverPrefs prefs;
|
||||||
int fadeState,noFadeState;
|
int fadeState,noFadeState;
|
||||||
@ -83,6 +86,7 @@ private:
|
|||||||
BMessenger *pwMessenger;
|
BMessenger *pwMessenger;
|
||||||
|
|
||||||
BMessage settings;
|
BMessage settings;
|
||||||
|
BFilePanel *filePanel;
|
||||||
BView *settingsArea;
|
BView *settingsArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user