Removed support for setting the app_server's cache configuration.

We doesn't support that API anyway, and I really don't think this belongs there - the
app_server should handle this by itself alone.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14745 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-07 13:26:34 +00:00
parent 1663fe079b
commit 7a0b14b7ab
6 changed files with 39 additions and 280 deletions
-166
View File
@@ -1,166 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
*/
#include "CacheView.h"
#include <String.h>
#include <stdio.h>
#include "MainWindow.h"
#include "Pref_Utils.h"
#define PRINT_FCS_UPDATE_MSG 'pfum'
#define SCREEN_FCS_UPDATE_MSG 'sfum'
#define PRINT_FCS_MODIFICATION_MSG 'pfmm'
#define SCREEN_FCS_MODIFICATION_MSG 'sfmm'
CacheView::CacheView(const BRect &frame, const int32 &sliderMin,
const int32 &sliderMax, const int32 &printVal,
const int32 &screenVal)
: BView(frame, "Cache", B_FOLLOW_ALL, B_WILL_DRAW),
fSavedPrintValue(printVal),
fSavedScreenValue(screenVal)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
rgb_color fillColor = { 102, 152, 203, 255 };
BString minLabel(B_EMPTY_STRING);
BString maxLabel(B_EMPTY_STRING);
float fontheight = FontHeight(true);
BRect rect( Bounds().InsetByCopy(5.0,3.0) );
rect.top += fontheight;
rect.bottom = rect.top +(fontheight *2.0);
BString labels(B_EMPTY_STRING);
labels << "Screen font cache size: " << screenVal << " kB";
fScreenSlider = new BSlider(rect, "screenslider", labels.String(),
new BMessage(SCREEN_FCS_UPDATE_MSG),
sliderMin, sliderMax, B_TRIANGLE_THUMB);
fScreenSlider->SetModificationMessage(new BMessage(SCREEN_FCS_MODIFICATION_MSG));
AddChild(fScreenSlider);
minLabel << sliderMin << " kB";
maxLabel << sliderMax << " kB";
fScreenSlider->SetLimitLabels(minLabel.String(), maxLabel.String());
fScreenSlider->UseFillColor(TRUE, &fillColor);
fScreenSlider->SetValue(screenVal);
rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5));
labels = "";
labels << "Printing font cache size: " << printVal << " kB";
fPrintSlider = new BSlider(rect, "printFontCache", labels.String(),
new BMessage(PRINT_FCS_UPDATE_MSG),
sliderMin, sliderMax, B_TRIANGLE_THUMB);
AddChild(fPrintSlider);
fPrintSlider->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG));
fPrintSlider->SetLimitLabels(minLabel.String(), maxLabel.String());
fPrintSlider->UseFillColor(TRUE, &fillColor);
fPrintSlider->SetValue(printVal);
rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0));
rect.right = rect.left +86.0;
rect.bottom = rect.top +24.0;
// TODO: figure out what to do with 'Save Cache' on R5. According to the
// BeOS Bible, it allocates a block of memory to disk, which is loaded on
// next boot. FreeType does better than this.
fSaveCache = new BButton(rect, "saveCache", "Save Cache",
NULL, B_FOLLOW_LEFT, B_WILL_DRAW);
AddChild(fSaveCache);
fSaveCache->SetEnabled(false);
}
void
CacheView::AttachedToWindow(void)
{
fScreenSlider->SetTarget(this);
fPrintSlider->SetTarget(this);
fSaveCache->SetTarget(this);
}
void
CacheView::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
case PRINT_FCS_MODIFICATION_MSG:
{
UpdatePrintSettings(fPrintSlider->Value());
Window()->PostMessage(M_ENABLE_REVERT);
break;
}
case SCREEN_FCS_MODIFICATION_MSG:
{
UpdateScreenSettings(fScreenSlider->Value());
Window()->PostMessage(M_ENABLE_REVERT);
break;
}
default:
{
BView::MessageReceived(msg);
break;
}
}
}
void CacheView::Revert(void)
{
fPrintSlider->SetValue(fSavedPrintValue);
fScreenSlider->SetValue(fSavedScreenValue);
UpdatePrintSettings(fSavedPrintValue);
UpdateScreenSettings(fSavedScreenValue);
}
void CacheView::SetDefaults(void)
{
fPrintSlider->SetValue(256);
fScreenSlider->SetValue(256);
UpdatePrintSettings(256);
UpdateScreenSettings(256);
}
void
CacheView::UpdatePrintSettings(int32 value)
{
struct font_cache_info fontCacheInfo;
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&fontCacheInfo);
fontCacheInfo.cache_size = value << 10;
set_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&fontCacheInfo);
BString str("Printing font cache size : ");
str << value << " kB";
fPrintSlider->SetLabel(str.String());
}
void
CacheView::UpdateScreenSettings(int32 value)
{
struct font_cache_info fontCacheInfo;
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&fontCacheInfo);
fontCacheInfo.cache_size = value << 10;
set_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&fontCacheInfo);
BString str("Screen font cache size : ");
str << value << " kB";
fScreenSlider->SetLabel(str.String());
}
-38
View File
@@ -1,38 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
*/
#ifndef CACHE_VIEW_H
#define CACHE_VIEW_H
#include <View.h>
#include <Box.h>
#include <Slider.h>
#include <Button.h>
class CacheView : public BView
{
public:
CacheView(const BRect &frame, const int32 &sliderMin,
const int32 &sliderMax, const int32 &printVal,
const int32 &screenVal);
void AttachedToWindow(void);
void MessageReceived(BMessage *msg);
void Revert(void);
void SetDefaults(void);
private:
void UpdatePrintSettings(int32 value);
void UpdateScreenSettings(int32 value);
BSlider *fScreenSlider;
BSlider *fPrintSlider;
BButton *fSaveCache;
int32 fSavedPrintValue;
int32 fSavedScreenValue;
};
#endif
+7 -21
View File
@@ -1,8 +1,9 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
*/ */
#include <Application.h> #include <Application.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <File.h> #include <File.h>
@@ -16,6 +17,7 @@
static const char kSettingsFile[] = "Font_Settings"; static const char kSettingsFile[] = "Font_Settings";
FontsSettings::FontsSettings() FontsSettings::FontsSettings()
{ {
BPath path; BPath path;
@@ -27,15 +29,13 @@ FontsSettings::FontsSettings()
if (file.InitCheck() != B_OK) if (file.InitCheck() != B_OK)
SetDefaults(); SetDefaults();
else else if (msg.Unflatten(&file) != B_OK)
if (msg.Unflatten(&file) != B_OK)
SetDefaults(); SetDefaults();
else else
{
msg.FindPoint("windowlocation", &fCorner); msg.FindPoint("windowlocation", &fCorner);
} }
} }
}
FontsSettings::~FontsSettings() FontsSettings::~FontsSettings()
{ {
@@ -50,21 +50,6 @@ FontsSettings::~FontsSettings()
if (file.InitCheck() == B_OK) { if (file.InitCheck() == B_OK) {
msg.AddPoint("windowlocation", fCorner); msg.AddPoint("windowlocation", fCorner);
// We need to add this to the settings file so that the app_server
// can get the font cache info on startup. This is the only
// place in the Fonts app that we actually need to do this because
// any other changes made are made through the API
struct font_cache_info cacheInfo;
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&cacheInfo);
msg.AddInt32("screencachesize",cacheInfo.cache_size);
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
&cacheInfo);
msg.AddInt32("printcachesize",cacheInfo.cache_size);
msg.Flatten(&file); msg.Flatten(&file);
} }
} }
@@ -76,8 +61,9 @@ FontsSettings::SetWindowCorner(BPoint where)
fCorner = where; fCorner = where;
} }
void void
FontsSettings::SetDefaults(void) FontsSettings::SetDefaults()
{ {
fCorner.Set(100, 100); fCorner.Set(100, 100);
} }
-1
View File
@@ -2,7 +2,6 @@ SubDir HAIKU_TOP src preferences fonts ;
Preference Fonts : Preference Fonts :
ButtonView.cpp ButtonView.cpp
CacheView.cpp
FontSelectionView.cpp FontSelectionView.cpp
FontsSettings.cpp FontsSettings.cpp
FontView.cpp FontView.cpp
+14 -31
View File
@@ -1,28 +1,21 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
*/ */
#include "MainWindow.h" #include "MainWindow.h"
MainWindow::MainWindow(void)
: BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | MainWindow::MainWindow()
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ) : BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{ {
BRect r; BRect r;
BTabView *tabView; BTabView *tabView;
BBox *topLevelView; BBox *topLevelView;
double buttonViewHeight = 43.0; double buttonViewHeight = 43.0;
struct font_cache_info cacheInfo;
int32 screenCacheSize, printCacheSize;
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo);
screenCacheSize = cacheInfo.cache_size >> 10;
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo);
printCacheSize = cacheInfo.cache_size >> 10;
r = Bounds(); r = Bounds();
r.top += 10; r.top += 10;
r.bottom -= buttonViewHeight+1; r.bottom -= buttonViewHeight+1;
@@ -38,9 +31,6 @@ MainWindow::MainWindow(void)
fSelectorView = new FontView(r); fSelectorView = new FontView(r);
tabView->AddTab(fSelectorView); tabView->AddTab(fSelectorView);
fCacheView = new CacheView(r, 64, 4096, printCacheSize, screenCacheSize);
tabView->AddTab(fCacheView);
r = Bounds(); r = Bounds();
r.top = r.bottom - buttonViewHeight; r.top = r.bottom - buttonViewHeight;
@@ -55,8 +45,9 @@ MainWindow::MainWindow(void)
MoveTo(fSettings.WindowCorner()); MoveTo(fSettings.WindowCorner());
} }
bool bool
MainWindow::QuitRequested(void) MainWindow::QuitRequested()
{ {
fSettings.SetWindowCorner(Frame().LeftTop()); fSettings.SetWindowCorner(Frame().LeftTop());
@@ -64,39 +55,31 @@ MainWindow::QuitRequested(void)
return true; return true;
} }
void void
MainWindow::MessageReceived(BMessage *message) MainWindow::MessageReceived(BMessage *message)
{ {
switch(message->what) switch (message->what) {
{
case M_ENABLE_REVERT: case M_ENABLE_REVERT:
{
fButtonView->SetRevertState(true); fButtonView->SetRevertState(true);
break; break;
}
case M_RESCAN_FONTS: case M_RESCAN_FONTS:
{
fSelectorView->RescanFonts(); fSelectorView->RescanFonts();
break; break;
}
case M_SET_DEFAULTS: case M_SET_DEFAULTS:
{
fSelectorView->SetDefaults(); fSelectorView->SetDefaults();
fCacheView->SetDefaults();
fButtonView->SetRevertState(true); fButtonView->SetRevertState(true);
break; break;
}
case M_REVERT: case M_REVERT:
{
fSelectorView->Revert(); fSelectorView->Revert();
fCacheView->Revert();
fButtonView->SetRevertState(false); fButtonView->SetRevertState(false);
break; break;
}
default: default:
{
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
break; break;
} }
} }
}
+5 -10
View File
@@ -1,7 +1,6 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
*/ */
#ifndef MAIN_WINDOW_H #ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H #define MAIN_WINDOW_H
@@ -12,7 +11,6 @@
#include <Box.h> #include <Box.h>
#include "FontView.h" #include "FontView.h"
#include "CacheView.h"
#include "ButtonView.h" #include "ButtonView.h"
#include "FontsSettings.h" #include "FontsSettings.h"
@@ -24,21 +22,18 @@
#define M_SET_BOLD 'stbl' #define M_SET_BOLD 'stbl'
#define M_SET_FIXED 'stfx' #define M_SET_FIXED 'stfx'
class MainWindow : public BWindow class MainWindow : public BWindow {
{
public: public:
MainWindow(void); MainWindow();
virtual bool QuitRequested(void);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
private: private:
FontView *fSelectorView; FontView *fSelectorView;
ButtonView *fButtonView; ButtonView *fButtonView;
CacheView *fCacheView;
FontsSettings fSettings; FontsSettings fSettings;
}; };
#endif #endif /* MAIN_WINDOW_H */