screen_blanker signature is at one place

modules tab selection makes the right module selected


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13863 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-08-01 12:53:23 +00:00
parent 9882caaadd
commit 1437c09cb7
6 changed files with 64 additions and 24 deletions

View File

@ -18,12 +18,15 @@ enum arrowDirection {
CENTER
};
#define SCREEN_BLANKER_SIG "application/x-vnd.Be.screenblanker"
class ScreenSaverPrefs
{
public:
ScreenSaverPrefs();
bool LoadSettings();
void Defaults();
BPath & GetPath() { return fSSPath;}
BRect WindowFrame() {return fWindowFrame;}
int32 WindowTab() {return fWindowTab;}
@ -76,7 +79,7 @@ private:
bool fIsNetworkPassword;
BMessage fSettings;
BPath ssPath,networkPath;
BPath fSSPath, fNetworkPath;
};

View File

@ -13,8 +13,6 @@
#include <Debug.h>
#define CALLED() SERIAL_PRINT(("%s\n", __PRETTY_FUNCTION__))
#define SCREEN_BLANKER_SIG "application/x-vnd.Be.screenblanker"
extern "C" _EXPORT BInputServerFilter* instantiate_input_filter();
BInputServerFilter* instantiate_input_filter() { // required C func to build the IS Filter

View File

@ -15,10 +15,10 @@
ScreenSaverPrefs::ScreenSaverPrefs()
{
find_directory(B_USER_SETTINGS_DIRECTORY,&ssPath);
find_directory(B_USER_SETTINGS_DIRECTORY,&networkPath);
ssPath.Append("ScreenSaver_settings",true);
networkPath.Append("network",true);
find_directory(B_USER_SETTINGS_DIRECTORY,&fSSPath);
find_directory(B_USER_SETTINGS_DIRECTORY,&fNetworkPath);
fSSPath.Append("ScreenSaver_settings",true);
fNetworkPath.Append("network",true);
Defaults();
}
@ -28,7 +28,7 @@ ScreenSaverPrefs::ScreenSaverPrefs()
bool
ScreenSaverPrefs::LoadSettings()
{
BFile ssSettings(ssPath.Path(),B_READ_ONLY);
BFile ssSettings(fSSPath.Path(),B_READ_ONLY);
if (B_OK==ssSettings.InitCheck()) { // File exists. Unflatten the message and call the settings parser.
if (fSettings.Unflatten(&ssSettings)!=B_OK)
return false;
@ -61,7 +61,7 @@ ScreenSaverPrefs::LoadSettings()
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")))
if ((networkFile=fopen(fNetworkPath.Path(),"r")))
while (buffer==fgets(buffer,512,networkFile))
if ((start=strstr(buffer,"PASSWORD ="))) {
char password[12];
@ -154,7 +154,7 @@ ScreenSaverPrefs::SaveSettings()
{
BMessage &settings = GetSettings();
settings.PrintToStream();
BFile file(ssPath.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
BFile file(fSSPath.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");
}

View File

@ -46,6 +46,7 @@ PreviewView::~PreviewView()
{
if (fThreadID>=0)
kill_thread(fThreadID);
delete fSst;
}

View File

@ -60,6 +60,37 @@ UnitsToSlider(bigtime_t val)
}
class ModulesTab : public BTab
{
public:
ModulesTab(ScreenSaverWin *win, BView *view = NULL);
virtual ~ModulesTab();
virtual void Select(BView *view);
private:
ScreenSaverWin *fWin;
};
ModulesTab::ModulesTab(ScreenSaverWin *win, BView *view = NULL)
: BTab(view),
fWin(win)
{
}
ModulesTab::~ModulesTab()
{
}
void
ModulesTab::Select(BView *view)
{
BTab::Select(view);
fWin->SelectCurrentModule();
}
ScreenSaverWin::ScreenSaverWin()
: BWindow(BRect(50,50,496,375),"OBOS Screen Saver",
B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) ,
@ -150,7 +181,7 @@ ScreenSaverWin::MessageReceived(BMessage *msg)
case kTest_btn:
{
BMessage &settings = fPrefs.GetSettings();
be_roster->Launch("application/x-vnd.haiku-ScreenSaverApp", &settings);
be_roster->Launch(SCREEN_BLANKER_SIG, &settings);
break;
}
case kAdd_btn:
@ -246,7 +277,7 @@ ScreenSaverWin::SetupForm()
fTabView->AddTab(fTab2, tab);
tab->SetLabel("Fade");
tab = new BTab();
tab = new ModulesTab(this);
fTab1 = new BView(r,"Modules",B_FOLLOW_NONE,0);
fTabView->AddTab(fTab1, tab);
tab->SetLabel("Modules");
@ -270,21 +301,28 @@ ScreenSaverWin::SetupForm()
fFadeNever->setDirection(fPrefs.GetNeverBlankCorner());
fPasswordCheckbox->SetValue(fPrefs.LockEnable());
fPasswordSlider->SetValue(UnitsToSlider(fPrefs.PasswordTime()));
int32 count = fListView1->CountItems();
for (int32 i=0; i<count; i++) {
ScreenSaverItem *item = dynamic_cast<ScreenSaverItem*>(fListView1->ItemAt(i));
if ((strcmp(fPrefs.ModuleName(), item->Text()) == 0)
|| (strcmp(fPrefs.ModuleName(),"") == 0 && strcmp(item->Text(), "Blackness") ==0)) {
fListView1->Select(i);
SaverSelected();
fListView1->ScrollToSelection();
break;
}
}
SelectCurrentModule();
UpdateStatus();
}
void
ScreenSaverWin::SelectCurrentModule()
{
int32 count = fListView1->CountItems();
for (int32 i=0; i<count; i++) {
ScreenSaverItem *item = dynamic_cast<ScreenSaverItem*>(fListView1->ItemAt(i));
if ((strcmp(fPrefs.ModuleName(), item->Text()) == 0)
|| (strcmp(fPrefs.ModuleName(),"") == 0 && strcmp(item->Text(), "Blackness") ==0)) {
fListView1->Select(i);
SaverSelected();
fListView1->ScrollToSelection();
break;
}
}
}
// Set the common Look and Feel stuff for a given control
void
commonLookAndFeel(BView *widget,bool isSlider,bool isControl)

View File

@ -20,7 +20,7 @@ public:
void PopulateScreenSaverList();
void LoadSettings();
virtual ~ScreenSaverWin();
void SelectCurrentModule();
private:
void SetupForm();
void SetupTab1();