[haiku-commits] haiku: hrev43796 - src/preferences/appearance

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 26 Feb 2012 22:47:40 +0100 (CET)

hrev43796 adds 3 changesets to branch 'master'
old head: c9ce04c45e84c9d816c90422501f0441c5edd386
new head: b860013aa09c7da2c29e294e105efe6e94977969

----------------------------------------------------------------------------

f4183b0: Complete make over of DecorSettingsView inner workings
  
   * Cleaned up header (why declare some methods protected?!)
   * Refactoring by applying basic "write only once" rule
   * DecorInfoUtility is now cached as member
   * This also fixes multiple instances of it being leaked.
   * Return code of SetDecorator() is now checked, so it should be hard
     to go out of sync with actually visible Decorator.
   * fSavedDecor and fCurrentDecor were pointers to the memory of
     temporary BStrings, this never worked!
   * IsDefaultable() always returned true, despite it being pretty easy
     to implement properly.
   * Revert() didn't do anything, probably because fSavedDecor was never
     initialized anywhere.
   * The UI was not updated in all situations to decorator changes.
  
  Alexander, please have a close look at these changes.

9ed32a4: Embedded the Font into the Appearance Preflet
  
   * Copied the essential parts from the Font preflet into the Appearance
     preflet folder.
   * Adopted these files to better direct where BMessage arrive and why.
     The Font preflet just forwarded them from the BWindow handler,
     which was quite messy.
   * Embedded the Font preferences as another tab. The first one actually,
     with the Decor settings also moved in front of the Anti-Aliasing tab.
   * Refactored the Defaults and Revert button updates in the window code.
   * AInclude all active settings tabs in the Defaults and Revert handling
     for consistency. But eventually, the buttons should only affect the
     currently visible page.

b860013: Removed Fonts preflet from the image.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

13 files changed, 1033 insertions(+), 169 deletions(-)
build/jam/HaikuImage                             |    2 +-
src/preferences/appearance/APRView.cpp           |   80 ++--
src/preferences/appearance/APRView.h             |   45 +-
src/preferences/appearance/APRWindow.cpp         |   80 ++-
src/preferences/appearance/APRWindow.h           |   20 +-
src/preferences/appearance/DecorSettingsView.cpp |  103 ++---
src/preferences/appearance/DecorSettingsView.h   |   49 +-
src/preferences/appearance/FontSelectionView.cpp |  494 ++++++++++++++++++
src/preferences/appearance/FontSelectionView.h   |   77 +++
src/preferences/appearance/FontView.cpp          |  193 +++++++
src/preferences/appearance/FontView.h            |   51 ++
src/preferences/appearance/Jamfile               |    6 +-
src/preferences/appearance/defs.h                |    2 -

############################################################################

Commit:      f4183b0913b43f984b04330d5ea35fa9a59a9012
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f4183b0
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Feb 26 09:19:04 2012 UTC

Complete make over of DecorSettingsView inner workings

 * Cleaned up header (why declare some methods protected?!)
 * Refactoring by applying basic "write only once" rule
 * DecorInfoUtility is now cached as member
 * This also fixes multiple instances of it being leaked.
 * Return code of SetDecorator() is now checked, so it should be hard
   to go out of sync with actually visible Decorator.
 * fSavedDecor and fCurrentDecor were pointers to the memory of
   temporary BStrings, this never worked!
 * IsDefaultable() always returned true, despite it being pretty easy
   to implement properly.
 * Revert() didn't do anything, probably because fSavedDecor was never
   initialized anywhere.
 * The UI was not updated in all situations to decorator changes.

Alexander, please have a close look at these changes.

----------------------------------------------------------------------------

diff --git a/src/preferences/appearance/DecorSettingsView.cpp 
b/src/preferences/appearance/DecorSettingsView.cpp
index c149c5c..d5afffd 100644
--- a/src/preferences/appearance/DecorSettingsView.cpp
+++ b/src/preferences/appearance/DecorSettingsView.cpp
@@ -1,9 +1,10 @@
 /*
- *  Copyright 2010-2011 Haiku, Inc. All rights reserved.
+ *  Copyright 2010-2012 Haiku, Inc. All rights reserved.
  *  Distributed under the terms of the MIT license.
  *
  *     Authors:
  *             Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 
 
@@ -14,6 +15,7 @@
 
 #include <Alert.h>
 #include <Box.h>
+#include <Button.h>
 #include <Catalog.h>
 #include <GridLayoutBuilder.h>
 #include <GroupLayoutBuilder.h>
@@ -23,7 +25,6 @@
 #include <PopUpMenu.h>
 #include <Slider.h>
 #include <SpaceLayoutItem.h>
-#include <String.h>
 #include <TextView.h>
 
 #include "APRWindow.h"
@@ -92,39 +93,15 @@ DecorSettingsView::MessageReceived(BMessage *msg)
                case kMsgSetDecor:
                {
                        BString newDecor;
-                       if (msg->FindString("decor", &newDecor) != B_OK)
-                               break;
-
-                       DecorInfoUtility* decorUtility
-                               = new(std::nothrow) DecorInfoUtility();
-
-                       if (decorUtility == NULL)
-                               return;
-
-                       DecorInfo* decor = 
decorUtility->FindDecorator(newDecor);
-                       if (decor == NULL)
-                               return;
-
-                       fSavedDecor = fCurrentDecor;
-                       fCurrentDecor = (char*)decor->Name().String();
-
-                       decorUtility->SetDecorator(decor);
-
-                       Window()->PostMessage(kMsgUpdate);
+                       if (msg->FindString("decor", &newDecor) == B_OK)
+                               _SetDecor(newDecor);
                        break;
                }
                case kMsgDecorInfo:
                {
-                       DecorInfoUtility* decorUtility
-                               = new(std::nothrow) DecorInfoUtility();
-
-                       if (decorUtility == NULL)
-                               return;
-
-                       BString decoratorName(fCurrentDecor);
-                       DecorInfo* decor = 
decorUtility->FindDecorator(decoratorName);
+                       DecorInfo* decor = 
fDecorUtility.FindDecorator(fCurrentDecor);
                        if (decor == NULL)
-                               return;
+                               break;
 
                        BString authorsText(decor->Authors().String());
                        authorsText.ReplaceAll(", ", "\n    ");
@@ -146,11 +123,12 @@ DecorSettingsView::MessageReceived(BMessage *msg)
                        infoAlert->SetShortcut(0, B_ESCAPE); 
                        infoAlert->Go(); 
 
-                       Window()->PostMessage(kMsgUpdate);
                        break;
                }
+
                default:
                        BView::MessageReceived(msg);
+                       break;
        }
 }
 
@@ -159,18 +137,11 @@ void
 DecorSettingsView::_BuildDecorMenu()
 {
        fDecorMenu = new BPopUpMenu(B_TRANSLATE("Choose Decorator"));
-       DecorInfo* decorator = NULL;
 
        // collect the current system decor settings
-       DecorInfoUtility* decorUtility = new(std::nothrow) DecorInfoUtility();
-
-       if (decorUtility == NULL) {
-               return;
-       }
-
-       int32 count = decorUtility->CountDecorators();
+       int32 count = fDecorUtility.CountDecorators();
        for (int32 i = 0; i < count; ++i) {
-               decorator = decorUtility->DecoratorAt(i);
+               DecorInfo* decorator = fDecorUtility.DecoratorAt(i);
                if (decorator == NULL) {
                        fprintf(stderr, "Decorator : error NULL entry @ %li / 
%li\n",
                                i, count);
@@ -186,18 +157,41 @@ DecorSettingsView::_BuildDecorMenu()
 
                fDecorMenu->AddItem(item);
        }
-       fCurrentDecor = 
(char*)decorUtility->CurrentDecorator()->Name().String();
-       delete decorUtility;
 
-       _SetCurrentDecor();
+       _AdoptToCurrentDecor();
 }
 
 
 void
-DecorSettingsView::_SetCurrentDecor()
+DecorSettingsView::_SetDecor(const BString& name)
 {
-       BMenuItem *item = fDecorMenu->FindItem(fCurrentDecor);
-       BString currDecor = fCurrentDecor;
+       _SetDecor(fDecorUtility.FindDecorator(name));
+}      
+
+
+void
+DecorSettingsView::_SetDecor(DecorInfo* decorInfo)
+{
+       if (fDecorUtility.SetDecorator(decorInfo) == B_OK) {
+               _AdoptToCurrentDecor();
+               Window()->PostMessage(kMsgUpdate);
+       }
+}      
+
+
+void
+DecorSettingsView::_AdoptToCurrentDecor()
+{
+       fCurrentDecor = fDecorUtility.CurrentDecorator()->Name();
+       if (fSavedDecor.Length() == 0)
+               fSavedDecor = fCurrentDecor;
+       _AdoptInterfaceToCurrentDecor();
+}
+
+void
+DecorSettingsView::_AdoptInterfaceToCurrentDecor()
+{
+       BMenuItem* item = fDecorMenu->FindItem(fCurrentDecor);
        if (item != NULL)
                item->SetMarked(true);
 }
@@ -206,23 +200,14 @@ DecorSettingsView::_SetCurrentDecor()
 void
 DecorSettingsView::SetDefaults()
 {
-       DecorInfoUtility* decorUtility
-               = new(std::nothrow) DecorInfoUtility();
-
-       if (decorUtility == NULL)
-               return;
-       DecorInfo* defaultDecorator(decorUtility->DefaultDecorator());
-       decorUtility->SetDecorator(defaultDecorator);
-       _BuildDecorMenu();
-
-       delete decorUtility;
+       _SetDecor(fDecorUtility.DefaultDecorator());
 }
 
 
 bool
 DecorSettingsView::IsDefaultable()
 {
-       return true;
+       return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name();
 }
 
 
@@ -236,7 +221,5 @@ DecorSettingsView::IsRevertable()
 void
 DecorSettingsView::Revert()
 {
-       if (!IsRevertable())
-               return;
+       _SetDecor(fSavedDecor);
 }
-
diff --git a/src/preferences/appearance/DecorSettingsView.h 
b/src/preferences/appearance/DecorSettingsView.h
index 637f964..520bde2 100644
--- a/src/preferences/appearance/DecorSettingsView.h
+++ b/src/preferences/appearance/DecorSettingsView.h
@@ -1,54 +1,55 @@
 /*
- *  Copyright 2010-2011 Haiku, Inc. All rights reserved.
+ *  Copyright 2010-2012 Haiku, Inc. All rights reserved.
  *  Distributed under the terms of the MIT license.
  *
  *  Authors:
  *      Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 #ifndef DECOR_SETTINGS_VIEW_H
 #define DECOR_SETTINGS_VIEW_H
 
 
-#include <Button.h>
-#include <GroupView.h>
-#include <InterfaceDefs.h>
-#include <View.h>
-
 #include <DecorInfo.h>
+#include <String.h>
+#include <View.h>
 
 
-class BBox;
+class BButton;
 class BMenuField;
 class BPopUpMenu;
 
 
 class DecorSettingsView : public BView {
 public:
-                                                       DecorSettingsView(const 
char* name);
-       virtual                                 ~DecorSettingsView();
+                                                               
DecorSettingsView(const char* name);
+       virtual                                         ~DecorSettingsView();
 
-       virtual void                    AttachedToWindow();
-       virtual void                    MessageReceived(BMessage* message);
+       virtual void                            AttachedToWindow();
+       virtual void                            MessageReceived(BMessage* 
message);
 
-                       void                    SetDefaults();
-                       void                    Revert();
-                       bool                    IsDefaultable();
-                       bool                    IsRevertable();
+                       void                            SetDefaults();
+                       void                            Revert();
+                       bool                            IsDefaultable();
+                       bool                            IsRevertable();
 
 private:
-                       void                    _BuildDecorMenu();
-                       void                    _SetCurrentDecor();
+                       void                            _SetDecor(const 
BString& name);
+                       void                            
_SetDecor(BPrivate::DecorInfo* decorInfo);
 
-                       BButton*                fDecorInfoButton;       
+                       void                            _BuildDecorMenu();
+                       void                            _AdoptToCurrentDecor();
+                       void                            
_AdoptInterfaceToCurrentDecor();
 
-protected:
-                       float                   fDivider;
+private:
+                       DecorInfoUtility        fDecorUtility;
 
-                       BMenuField*             fDecorMenuField;
-                       BPopUpMenu*             fDecorMenu;
+                       BButton*                        fDecorInfoButton;
+                       BMenuField*                     fDecorMenuField;
+                       BPopUpMenu*                     fDecorMenu;
 
-                       char*                   fSavedDecor;
-                       char*                   fCurrentDecor;
+                       BString                         fSavedDecor;
+                       BString                         fCurrentDecor;
 };
 
 #endif // DECOR_SETTINGS_VIEW_H

############################################################################

Commit:      9ed32a430ccf673f99beffe3bdc7b1f5478b5a81
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9ed32a4
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Feb 26 09:22:45 2012 UTC

Embedded the Font into the Appearance Preflet

 * Copied the essential parts from the Font preflet into the Appearance
   preflet folder.
 * Adopted these files to better direct where BMessage arrive and why.
   The Font preflet just forwarded them from the BWindow handler,
   which was quite messy.
 * Embedded the Font preferences as another tab. The first one actually,
   with the Decor settings also moved in front of the Anti-Aliasing tab.
 * Refactored the Defaults and Revert button updates in the window code.
 * AInclude all active settings tabs in the Defaults and Revert handling
   for consistency. But eventually, the buttons should only affect the
   currently visible page.

----------------------------------------------------------------------------

diff --git a/src/preferences/appearance/APRView.cpp 
b/src/preferences/appearance/APRView.cpp
index 8dbb5f1..952efad 100644
--- a/src/preferences/appearance/APRView.cpp
+++ b/src/preferences/appearance/APRView.cpp
@@ -37,9 +37,9 @@
 #define DECORATOR_CHANGED 'dcch'
 
 
-APRView::APRView(const char* name, uint32 flags)
+APRView::APRView(const char* name)
        :
-       BView(name, flags),
+       BView(name, B_WILL_DRAW),
        fDefaultSet(ColorSet::DefaultColorSet())
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -136,7 +136,7 @@ APRView::MessageReceived(BMessage *msg)
 
                if (msg->FindData("RGBColor", (type_code)'RGBC', (const 
void**)&color,
                                &size) == B_OK) {
-                       SetCurrentColor(*color);
+                       _SetCurrentColor(*color);
                }
        }
 
@@ -145,7 +145,7 @@ APRView::MessageReceived(BMessage *msg)
                {
                        // Received from the color fPicker when its color 
changes
                        rgb_color color = fPicker->ValueAsColor();
-                       SetCurrentColor(color);
+                       _SetCurrentColor(color);
 
                        Window()->PostMessage(kMsgUpdate);
                        break;
@@ -161,27 +161,7 @@ APRView::MessageReceived(BMessage *msg)
 
                        fWhich = item->ColorWhich();
                        rgb_color color = fCurrentSet.GetColor(fWhich);
-                       SetCurrentColor(color);
-
-                       Window()->PostMessage(kMsgUpdate);
-                       break;
-               }
-               case REVERT_SETTINGS:
-               {
-                       fCurrentSet = fPrevSet;
-
-                       UpdateControls();
-                       UpdateAllColors();
-
-                       Window()->PostMessage(kMsgUpdate);
-                       break;
-               }
-               case DEFAULT_SETTINGS:
-               {
-                       fCurrentSet = ColorSet::DefaultColorSet();
-
-                       UpdateControls();
-                       UpdateAllColors();
+                       _SetCurrentColor(color);
 
                        Window()->PostMessage(kMsgUpdate);
                        break;
@@ -205,6 +185,30 @@ APRView::LoadSettings()
 }
 
 
+void
+APRView::SetDefaults()
+{
+       fCurrentSet = ColorSet::DefaultColorSet();
+
+       _UpdateControls();
+       _UpdateAllColors();
+
+       Window()->PostMessage(kMsgUpdate);
+}
+
+
+void
+APRView::Revert()
+{
+       fCurrentSet = fPrevSet;
+
+       _UpdateControls();
+       _UpdateAllColors();
+
+       Window()->PostMessage(kMsgUpdate);
+}
+
+
 bool
 APRView::IsDefaultable()
 {
@@ -217,31 +221,43 @@ APRView::IsDefaultable()
 }
 
 
-void
-APRView::UpdateAllColors()
+bool
+APRView::IsRevertable()
 {
        for (int32 i = 0; i < color_description_count(); i++) {
                color_which which = get_color_description(i)->which;
-               rgb_color color = fCurrentSet.GetColor(which);
-               set_ui_color(which, color);
+               if (fCurrentSet.GetColor(which) != fPrevSet.GetColor(which))
+                       return true;
        }
+       return false;
 }
 
 
 void
-APRView::SetCurrentColor(rgb_color color)
+APRView::_SetCurrentColor(rgb_color color)
 {
        fCurrentSet.SetColor(fWhich, color);
        set_ui_color(fWhich, color);
-       UpdateControls();
+       _UpdateControls();
 }
 
 
 void
-APRView::UpdateControls()
+APRView::_UpdateControls()
 {
        rgb_color color = fCurrentSet.GetColor(fWhich);
        fPicker->SetValue(color);
        fColorWell->SetColor(color);
        fColorWell->Invalidate();
 }
+
+
+void
+APRView::_UpdateAllColors()
+{
+       for (int32 i = 0; i < color_description_count(); i++) {
+               color_which which = get_color_description(i)->which;
+               rgb_color color = fCurrentSet.GetColor(which);
+               set_ui_color(which, color);
+       }
+}
diff --git a/src/preferences/appearance/APRView.h 
b/src/preferences/appearance/APRView.h
index b447927..1cfd600 100644
--- a/src/preferences/appearance/APRView.h
+++ b/src/preferences/appearance/APRView.h
@@ -1,10 +1,11 @@
 /*
- * Copyright 2002-2008, Haiku. All rights reserved.
+ * Copyright 2002-2012, Haiku. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             DarkWyrm (darkwyrm@xxxxxxxxxxxxx)
  *             Rene Gollent (rene@xxxxxxxxxxx)
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 #ifndef APR_VIEW_H_
 #define APR_VIEW_H_
@@ -36,33 +37,39 @@ class APRWindow;
 
 class APRView : public BView {
 public:
-                       APRView(const char *name, uint32 flags);
-                       ~APRView(void);
-       void    AttachedToWindow(void);
-       void    MessageReceived(BMessage *msg);
+                                                               APRView(const 
char *name);
+       virtual                                         ~APRView();
 
-       void    LoadSettings(void);
-       bool    IsDefaultable(void);
+       virtual void                            AttachedToWindow();
+       virtual void                            MessageReceived(BMessage *msg);
 
-protected:
+                       void                            LoadSettings();
 
-       void    SetCurrentColor(rgb_color color);
-       void    UpdateControls();
-       void    UpdateAllColors();
+                       void                            SetDefaults();
+                       void                            Revert();
 
-       BColorControl   *fPicker;
+                       bool                            IsDefaultable();
+                       bool                            IsRevertable();
 
-       BListView               *fAttrList;
+private:
+                       void                            
_SetCurrentColor(rgb_color color);
+                       void                            _UpdateControls();
+                       void                            _UpdateAllColors();
 
-       color_which             fWhich;
+private:
+                       BColorControl*          fPicker;
 
-       BScrollView             *fScrollView;
+                       BListView*                      fAttrList;
 
-       ColorWell               *fColorWell;
+                       color_which                     fWhich;
 
-       ColorSet                fCurrentSet;
-       ColorSet                fPrevSet;
-       ColorSet                fDefaultSet;
+                       BScrollView*            fScrollView;
+
+                       ColorWell*                      fColorWell;
+
+                       ColorSet                        fCurrentSet;
+                       ColorSet                        fPrevSet;
+                       ColorSet                        fDefaultSet;
 };
 
 #endif
diff --git a/src/preferences/appearance/APRWindow.cpp 
b/src/preferences/appearance/APRWindow.cpp
index 2c05d13..dbc2ff5 100644
--- a/src/preferences/appearance/APRWindow.cpp
+++ b/src/preferences/appearance/APRWindow.cpp
@@ -5,6 +5,7 @@
  * Authors:
  *             DarkWyrm (darkwyrm@xxxxxxxxxxxxx)
  *             Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 
 
@@ -18,8 +19,11 @@
 #include <SpaceLayoutItem.h>
 #include <TabView.h>
 
+#include "AntialiasingSettingsView.h"
 #include "APRView.h"
+#include "DecorSettingsView.h"
 #include "defs.h"
+#include "FontView.h"
 
 
 #undef B_TRANSLATE_CONTEXT
@@ -33,9 +37,9 @@ static const uint32 kMsgRevert = 'rvrt';
 APRWindow::APRWindow(BRect frame)
        :
        BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Appearance"), B_TITLED_WINDOW,
-               B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES)
+               B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | 
B_QUIT_ON_WINDOW_CLOSE,
+               B_ALL_WORKSPACES)
 {
-
        SetLayout(new BGroupLayout(B_HORIZONTAL));
 
        fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
@@ -46,22 +50,22 @@ APRWindow::APRWindow(BRect frame)
 
        BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
 
-       fAntialiasingSettings = new AntialiasingSettingsView(
-               B_TRANSLATE("Antialiasing"));
+       fFontSettings = new FontView(B_TRANSLATE("Fonts"));
+
+       fColorsView = new APRView(B_TRANSLATE("Colors"));
 
        fDecorSettings = new DecorSettingsView(
                B_TRANSLATE("Window Decorator"));
 
-       fColorsView = new APRView(B_TRANSLATE("Colors"), B_WILL_DRAW);
+       fAntialiasingSettings = new AntialiasingSettingsView(
+               B_TRANSLATE("Antialiasing"));
 
+       tabView->AddTab(fFontSettings);
        tabView->AddTab(fColorsView);
-       tabView->AddTab(fAntialiasingSettings);
        tabView->AddTab(fDecorSettings);
+       tabView->AddTab(fAntialiasingSettings);
 
-       fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
-               || fAntialiasingSettings->IsDefaultable()
-               || fDecorSettings->IsDefaultable());
-       fRevertButton->SetEnabled(false);
+       _UpdateButtons();
 
        AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
                .Add(tabView)
@@ -81,23 +85,25 @@ APRWindow::MessageReceived(BMessage *message)
 {
        switch (message->what) {
                case kMsgUpdate:
-                       fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
-                                                               || 
fAntialiasingSettings->IsDefaultable());
-                       fRevertButton->SetEnabled(true);
+                       _UpdateButtons();
                        break;
+
                case kMsgSetDefaults:
-                       fColorsView -> MessageReceived(new 
BMessage(DEFAULT_SETTINGS));
+                       fFontSettings->SetDefaults();
+                       fColorsView->SetDefaults();
                        fAntialiasingSettings->SetDefaults();
-                       fDefaultsButton->SetEnabled(false);
-                       fRevertButton->SetEnabled(true);
+                       fDecorSettings->SetDefaults();
+
+                       _UpdateButtons();
                        break;
 
                case kMsgRevert:
-                       fColorsView -> MessageReceived(new 
BMessage(REVERT_SETTINGS));
+                       fColorsView->Revert();
                        fAntialiasingSettings->Revert();
-                       fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
-                                                               || 
fAntialiasingSettings->IsDefaultable());
-                       fRevertButton->SetEnabled(false);
+                       fFontSettings->Revert();
+                       fDecorSettings->Revert();
+
+                       _UpdateButtons();
                        break;
 
                default:
@@ -107,9 +113,37 @@ APRWindow::MessageReceived(BMessage *message)
 }
 
 
+void
+APRWindow::_UpdateButtons()
+{
+       fDefaultsButton->SetEnabled(_IsDefaultable());
+       fRevertButton->SetEnabled(_IsRevertable());
+}      
+
+
+bool
+APRWindow::_IsDefaultable() const
+{
+//     printf("fonts defaultable: %d\n", fFontSettings->IsDefaultable());
+//     printf("colors defaultable: %d\n", fColorsView->IsDefaultable());
+//     printf("AA defaultable: %d\n", fAntialiasingSettings->IsDefaultable());
+//     printf("decor defaultable: %d\n", fDecorSettings->IsDefaultable());
+       return fColorsView->IsDefaultable()
+               || fFontSettings->IsDefaultable()
+               || fAntialiasingSettings->IsDefaultable()
+               || fDecorSettings->IsDefaultable();
+}
+
+
 bool
-APRWindow::QuitRequested(void)
+APRWindow::_IsRevertable() const
 {
-       be_app->PostMessage(B_QUIT_REQUESTED);
-       return(true);
+//     printf("fonts revertable: %d\n", fFontSettings->IsRevertable());
+//     printf("colors revertable: %d\n", fColorsView->IsRevertable());
+//     printf("AA revertable: %d\n", fAntialiasingSettings->IsRevertable());
+//     printf("decor revertable: %d\n", fDecorSettings->IsRevertable());
+       return fColorsView->IsRevertable()
+               || fFontSettings->IsRevertable()
+               || fAntialiasingSettings->IsRevertable()
+               || fDecorSettings->IsRevertable();
 }
diff --git a/src/preferences/appearance/APRWindow.h 
b/src/preferences/appearance/APRWindow.h
index 6fbecdf..ab6f582 100644
--- a/src/preferences/appearance/APRWindow.h
+++ b/src/preferences/appearance/APRWindow.h
@@ -1,10 +1,11 @@
 /*
- * Copyright 2002-2011, Haiku. All rights reserved.
+ * Copyright 2002-2012, Haiku. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             DarkWyrm (darkwyrm@xxxxxxxxxxxxx)
  *             Alexander von Gluck, kallisti5@xxxxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 #ifndef APR_WINDOW_H
 #define APR_WINDOW_H
@@ -16,27 +17,32 @@
 #include <Message.h>
 #include <TabView.h>
 
-#include "APRView.h"
-#include "AntialiasingSettingsView.h"
-#include "DecorSettingsView.h"
+class APRView;
+class AntialiasingSettingsView;
+class FontView;
+class DecorSettingsView;
 
 
-class APRWindow : public BWindow
-{
+class APRWindow : public BWindow {
 public:
                                                        APRWindow(BRect frame);
-                       bool                    QuitRequested(void);
                        void                    MessageReceived(BMessage 
*message);
 
 private:
+                       void                    _UpdateButtons();
+                       bool                    _IsDefaultable() const;
+                       bool                    _IsRevertable() const;
+
                APRView*                        fColorsView;
                BButton*                        fDefaultsButton;
                BButton*                        fRevertButton;
 
                AntialiasingSettingsView* fAntialiasingSettings;
+               FontView*                       fFontSettings;
                DecorSettingsView*      fDecorSettings;
 };
 
+
 static const int32 kMsgUpdate = 'updt';
 
 
diff --git a/src/preferences/appearance/FontSelectionView.cpp 
b/src/preferences/appearance/FontSelectionView.cpp
new file mode 100644
index 0000000..3f00f53
--- /dev/null
+++ b/src/preferences/appearance/FontSelectionView.cpp
@@ -0,0 +1,494 @@
+/*
+ * Copyright 2001-2011, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Mark Hogben
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
+ */
+
+#include "FontSelectionView.h"
+
+#include <Box.h>
+#include <Catalog.h>
+#include <Locale.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <PopUpMenu.h>
+#include <String.h>
+#include <StringView.h>
+#include <LayoutItem.h>
+#include <GroupLayoutBuilder.h>
+
+#include <stdio.h>
+
+
+#undef B_TRANSLATE_CONTEXT
+#define B_TRANSLATE_CONTEXT "Font Selection view"
+
+
+#define INSTANT_UPDATE
+       // if defined, the system font will be updated immediately, and not
+       // only on exit
+
+static const float kMinSize = 8.0;
+static const float kMaxSize = 18.0;
+
+
+// private font API
+extern void _set_system_font_(const char *which, font_family family,
+       font_style style, float size);
+extern status_t _get_system_default_font_(const char* which,
+       font_family family, font_style style, float* _size);
+
+
+#ifdef B_BEOS_VERSION_DANO
+// this call only exists under R5
+void
+_set_system_font_(const char *which, font_family family,
+       font_style style, float size)
+{
+       puts("you don't have _set_system_font_()");
+}
+#endif
+
+#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && 
!defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
+// this call only exists under Haiku (and the test environment)
+status_t
+_get_system_default_font_(const char* which, font_family family,
+       font_style style, float* _size)
+{
+       puts("you don't have _get_system_default_font_()");
+       return B_ERROR;
+}
+#endif
+
+
+//     #pragma mark -
+
+
+FontSelectionView::FontSelectionView(const char* name,
+       const char* label, const BFont* currentFont)
+       :
+       BView(name, B_WILL_DRAW),
+       fMessageTarget(this)
+{
+       if (currentFont == NULL) {
+               if (!strcmp(Name(), "plain"))
+                       fCurrentFont = *be_plain_font;
+               else if (!strcmp(Name(), "bold"))
+                       fCurrentFont = *be_bold_font;
+               else if (!strcmp(Name(), "fixed"))
+                       fCurrentFont = *be_fixed_font;
+               else if (!strcmp(Name(), "menu")) {
+                       menu_info info;
+                       get_menu_info(&info);
+
+                       fCurrentFont.SetFamilyAndStyle(info.f_family, 
info.f_style);
+                       fCurrentFont.SetSize(info.font_size);
+               }
+       } else
+               fCurrentFont = *currentFont;
+
+       fSavedFont = fCurrentFont;
+
+       fSizesMenu = new BPopUpMenu("size menu");
+       _BuildSizesMenu();
+
+       fFontsMenu = new BPopUpMenu("font menu");
+
+       // font menu
+       fFontsMenuField = new BMenuField("fonts", label, fFontsMenu);
+       fFontsMenuField->SetAlignment(B_ALIGN_RIGHT);
+
+       // size menu
+       fSizesMenuField = new BMenuField("size", B_TRANSLATE("Size:"), 
fSizesMenu);
+       fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
+
+       // preview
+       fPreviewText = new BStringView("preview text",
+               B_TRANSLATE_COMMENT("The quick brown fox jumps over the lazy 
dog.",
+                       "Don't translate this literally ! Use a phrase showing 
all chars "
+                       "from A to Z."));
+
+       fPreviewText->SetFont(&fCurrentFont);
+       fPreviewText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
+
+       // box around preview
+       fPreviewBox = new BBox("preview box", B_WILL_DRAW | B_FRAME_EVENTS);
+       fPreviewBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
+               .Add(fPreviewText)
+               .SetInsets(5, 5, 5, 5)
+               .TopView()
+       );
+}
+
+
+FontSelectionView::~FontSelectionView()
+{
+#ifndef INSTANT_UPDATE
+       _UpdateSystemFont();
+#endif
+}
+
+
+void
+FontSelectionView::SetTarget(BHandler* messageTarget)
+{
+       fMessageTarget = messageTarget;
+       fSizesMenu->SetTargetForItems(fMessageTarget);
+}
+
+
+BView*
+FontSelectionView::GetPreviewBox()
+{
+       return fPreviewBox;
+}
+
+
+void
+FontSelectionView::MessageReceived(BMessage *msg)
+{
+       switch (msg->what) {
+               case kMsgSetSize:
+               {
+                       int32 size;
+                       if (msg->FindInt32("size", &size) != B_OK
+                               || size == fCurrentFont.Size())
+                               break;
+
+                       fCurrentFont.SetSize(size);
+                       _UpdateFontPreview();
+                       break;
+               }
+
+               case kMsgSetFamily:
+               {
+                       const char* family;
+                       if (msg->FindString("family", &family) != B_OK)
+                               break;
+
+                       font_style style;
+                       fCurrentFont.GetFamilyAndStyle(NULL, &style);
+
+                       BMenuItem *familyItem = fFontsMenu->FindItem(family);
+                       if (familyItem != NULL) {
+                               _SelectCurrentFont(false);
+
+                               BMenuItem *item = 
familyItem->Submenu()->FindItem(style);
+                               if (item == NULL)
+                                       item = familyItem->Submenu()->ItemAt(0);
+
+                               if (item != NULL) {
+                                       item->SetMarked(true);
+                                       fCurrentFont.SetFamilyAndStyle(family, 
item->Label());
+                                       _UpdateFontPreview();
+                               }
+                       }
+                       break;
+               }
+
+               case kMsgSetStyle:
+               {
+                       const char* family;
+                       const char* style;
+                       if (msg->FindString("family", &family) != B_OK
+                               || msg->FindString("style", &style) != B_OK)
+                               break;
+
+                       BMenuItem *familyItem = fFontsMenu->FindItem(family);
+                       if (!familyItem)
+                               break;
+
+                       _SelectCurrentFont(false);
+                       familyItem->SetMarked(true);
+
+                       fCurrentFont.SetFamilyAndStyle(family, style);
+                       _UpdateFontPreview();
+                       break;
+               }
+
+               default:
+                       BView::MessageReceived(msg);
+       }
+}
+
+
+BLayoutItem*
+FontSelectionView::CreateSizesLabelLayoutItem()
+{
+       return fSizesMenuField->CreateLabelLayoutItem();
+}
+
+
+BLayoutItem*
+FontSelectionView::CreateSizesMenuBarLayoutItem()
+{
+       return fSizesMenuField->CreateMenuBarLayoutItem();
+}
+
+
+BLayoutItem*
+FontSelectionView::CreateFontsLabelLayoutItem()
+{
+       return fFontsMenuField->CreateLabelLayoutItem();
+}
+
+
+BLayoutItem*
+FontSelectionView::CreateFontsMenuBarLayoutItem()
+{
+       return fFontsMenuField->CreateMenuBarLayoutItem();
+}
+
+
+void
+FontSelectionView::_BuildSizesMenu()
+{
+       const int32 sizes[] = {7, 8, 9, 10, 11, 12, 13, 14, 18, 21, 24, 0};
+
+       // build size menu
+       for (int32 i = 0; sizes[i]; i++) {
+               int32 size = sizes[i];
+               if (size < kMinSize || size > kMaxSize)
+                       continue;
+
+               char label[32];
+               snprintf(label, sizeof(label), "%ld", size);
+
+               BMessage* message = new BMessage(kMsgSetSize);
+               message->AddInt32("size", size);
+               message->AddString("name", Name());
+
+               BMenuItem* item = new BMenuItem(label, message);
+               if (size == fCurrentFont.Size())
+                       item->SetMarked(true);
+
+               fSizesMenu->AddItem(item);
+       }
+}
+
+
+void
+FontSelectionView::_SelectCurrentFont(bool select)
+{
+       font_family family;
+       font_style style;
+       fCurrentFont.GetFamilyAndStyle(&family, &style);
+
+       BMenuItem *item = fFontsMenu->FindItem(family);
+       if (item != NULL) {
+               item->SetMarked(select);
+
+               if (item->Submenu() != NULL) {
+                       item = item->Submenu()->FindItem(style);
+                       if (item != NULL)
+                               item->SetMarked(select);
+               }
+       }
+}
+
+
+void
+FontSelectionView::_SelectCurrentSize(bool select)
+{
+       char label[16];
+       snprintf(label, sizeof(label), "%ld", (int32)fCurrentFont.Size());
+
+       BMenuItem* item = fSizesMenu->FindItem(label);
+       if (item != NULL)
+               item->SetMarked(select);
+}
+
+
+void
+FontSelectionView::_UpdateFontPreview()
+{
+       fPreviewText->SetFont(&fCurrentFont);
+
+#ifdef INSTANT_UPDATE
+       _UpdateSystemFont();
+#endif
+}
+
+
+void
+FontSelectionView::_UpdateSystemFont()
+{
+       font_family family;
+       font_style style;
+       fCurrentFont.GetFamilyAndStyle(&family, &style);
+
+       if (strcmp(Name(), "menu") == 0) {
+               // The menu font is not handled as a system font
+               menu_info info;
+               get_menu_info(&info);
+
+               strlcpy(info.f_family, (const char*)family, 
B_FONT_FAMILY_LENGTH);
+               strlcpy(info.f_style, (const char*)style, B_FONT_STYLE_LENGTH);
+               info.font_size = fCurrentFont.Size();
+
+               set_menu_info(&info);
+       } else
+               _set_system_font_(Name(), family, style, fCurrentFont.Size());
+}
+
+
+void
+FontSelectionView::SetDefaults()
+{
+       font_family family;
+       font_style style;
+       float size;
+       const char* fontName;
+
+       if (strcmp(Name(), "menu") == 0)
+               fontName = "plain";
+       else
+               fontName = Name();
+
+       if (_get_system_default_font_(fontName, family, style, &size) != B_OK) {
+               Revert();
+               return;
+       }
+
+       BFont defaultFont;
+       defaultFont.SetFamilyAndStyle(family, style);
+       defaultFont.SetSize(size);
+
+       if (defaultFont == fCurrentFont)
+               return;
+
+       _SelectCurrentFont(false);
+
+       fCurrentFont = defaultFont;
+       _UpdateFontPreview();
+
+       _SelectCurrentFont(true);
+       _SelectCurrentSize(true);
+}
+
+
+void
+FontSelectionView::Revert()
+{
+       if (!IsRevertable())
+               return;
+
+       _SelectCurrentFont(false);
+
+       fCurrentFont = fSavedFont;
+       _UpdateFontPreview();
+
+       _SelectCurrentFont(true);
+       _SelectCurrentSize(true);
+}
+
+
+bool
+FontSelectionView::IsDefaultable()
+{
+       font_family defaultFamily;
+       font_style defaultStyle;
+       float defaultSize;
+       const char* fontName;
+
+       if (strcmp(Name(), "menu") == 0)
+               fontName = "plain";
+       else
+               fontName = Name();
+
+       if (_get_system_default_font_(fontName, defaultFamily, defaultStyle,
+               &defaultSize) != B_OK) {
+               return false;
+       }
+
+       font_family currentFamily;
+       font_style currentStyle;
+       float currentSize;
+
+       fCurrentFont.GetFamilyAndStyle(&currentFamily, &currentStyle);
+       currentSize = fCurrentFont.Size();
+
+       return strcmp(currentFamily, defaultFamily) != 0
+               || strcmp(currentStyle, defaultStyle) != 0
+               || currentSize != defaultSize;
+}
+
+
+bool
+FontSelectionView::IsRevertable()
+{
+       return fCurrentFont != fSavedFont;
+}
+
+
+void
+FontSelectionView::UpdateFontsMenu()
+{
+       int32 numFamilies = count_font_families();
+
+       fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true);
+       BFont font;
+       fFontsMenu->GetFont(&font);
+
+       font_family currentFamily;
+       font_style currentStyle;
+       fCurrentFont.GetFamilyAndStyle(&currentFamily, &currentStyle);
+
+       for (int32 i = 0; i < numFamilies; i++) {
+               font_family family;
+               uint32 flags;
+               if (get_font_family(i, &family, &flags) != B_OK)
+                       continue;
+
+               // if we're setting the fixed font, we only want to show fixed 
fonts
+               if (!strcmp(Name(), "fixed") && (flags & B_IS_FIXED) == 0)
+                       continue;
+
+               float width = font.StringWidth(family);
+               if (width > fMaxFontNameWidth)
+                       fMaxFontNameWidth = width;
+
+               BMenu* stylesMenu = new BMenu(family);
+               stylesMenu->SetRadioMode(true);
+               stylesMenu->SetFont(&font);
+
+               BMessage* message = new BMessage(kMsgSetFamily);
+               message->AddString("family", family);
+               message->AddString("name", Name());
+
+               BMenuItem* familyItem = new BMenuItem(stylesMenu, message);
+               fFontsMenu->AddItem(familyItem);
+
+               int32 numStyles = count_font_styles(family);
+
+               for (int32 j = 0; j < numStyles; j++) {
+                       font_style style;
+                       if (get_font_style(family, j, &style, &flags) != B_OK)
+                               continue;
+
+                       message = new BMessage(kMsgSetStyle);
+                       message->AddString("family", (char*)family);
+                       message->AddString("style", (char*)style);
+                       message->AddString("name", Name());
+
+                       BMenuItem *item = new BMenuItem(style, message);
+
+                       if (!strcmp(style, currentStyle)
+                               && !strcmp(family, currentFamily)) {
+                               item->SetMarked(true);
+                               familyItem->SetMarked(true);
+                       }
+                       stylesMenu->AddItem(item);
+               }
+
+               stylesMenu->SetTargetForItems(fMessageTarget);
+       }
+
+       fFontsMenu->SetTargetForItems(fMessageTarget);
+}
diff --git a/src/preferences/appearance/FontSelectionView.h 
b/src/preferences/appearance/FontSelectionView.h
new file mode 100644
index 0000000..130a8fe
--- /dev/null
+++ b/src/preferences/appearance/FontSelectionView.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2001-2009, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Mark Hogben
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ */
+#ifndef FONT_SELECTION_VIEW_H
+#define FONT_SELECTION_VIEW_H
+
+
+#include <View.h>
+
+class BLayoutItem;
+class BBox;
+class BMenuField;
+class BPopUpMenu;
+class BStringView;
+
+static const int32 kMsgSetFamily = 'fmly';
+static const int32 kMsgSetStyle = 'styl';
+static const int32 kMsgSetSize = 'size';
+
+
+class FontSelectionView : public BView {
+public:
+                                                               
FontSelectionView(const char* name,
+                                                                       const 
char* label,
+                                                                       const 
BFont* font = NULL);
+       virtual                                         ~FontSelectionView();
+
+       virtual void                            MessageReceived(BMessage* 
message);
+
+                       void                            SetTarget(BHandler* 
messageTarget);
+
+                       void                            SetDefaults();
+                       void                            Revert();
+                       bool                            IsDefaultable();
+                       bool                            IsRevertable();
+
+                       void                            UpdateFontsMenu();
+
+                       BLayoutItem*            CreateSizesLabelLayoutItem();
+                       BLayoutItem*            CreateSizesMenuBarLayoutItem();
+
+                       BLayoutItem*            CreateFontsLabelLayoutItem();
+                       BLayoutItem*            CreateFontsMenuBarLayoutItem();
+
+                       BView*                          GetPreviewBox();
+                       
+private:
+                       void                            _SelectCurrentFont(bool 
select);
+                       void                            _SelectCurrentSize(bool 
select);
+                       void                            _UpdateFontPreview();
+                       void                            _UpdateSystemFont();
+                       void                            _BuildSizesMenu();
+
+protected:
+                       BHandler*                       fMessageTarget;
+
+                       BMenuField*                     fFontsMenuField;
+                       BMenuField*                     fSizesMenuField;
+                       BPopUpMenu*                     fFontsMenu;
+                       BPopUpMenu*                     fSizesMenu;
+
+                       BBox*                           fPreviewBox;
+                       BStringView*            fPreviewText;
+
+                       BFont                           fSavedFont;
+                       BFont                           fCurrentFont;
+                       float                           fMaxFontNameWidth;
+};
+
+#endif // FONT_SELECTION_VIEW_H
diff --git a/src/preferences/appearance/FontView.cpp 
b/src/preferences/appearance/FontView.cpp
new file mode 100644
index 0000000..0159dcf
--- /dev/null
+++ b/src/preferences/appearance/FontView.cpp
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2001-2012, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Mark Hogben
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Philippe St-Pierre, stpere@xxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
+ */
+
+
+#include "FontView.h"
+
+#include <string.h>
+
+#include <Catalog.h>
+#include <GridLayoutBuilder.h>
+#include <GroupLayoutBuilder.h>
+#include <Locale.h>
+#include <MessageRunner.h>
+#include <SpaceLayoutItem.h>
+
+#include "APRWindow.h"
+#include "FontSelectionView.h"
+
+
+#undef B_TRANSLATE_CONTEXT
+#define B_TRANSLATE_CONTEXT "Font view"
+
+
+static const uint32 kMsgCheckFonts = 'chkf';
+
+
+static void
+add_font_selection_view(BGridLayout* layout, FontSelectionView* view,
+       int32& row, bool withExtraSpace)
+{
+       layout->AddItem(view->CreateFontsLabelLayoutItem(), 0, row);
+       layout->AddItem(view->CreateFontsMenuBarLayoutItem(), 1, row);
+
+       layout->AddItem(BSpaceLayoutItem::CreateGlue(), 2, row);
+
+       layout->AddItem(view->CreateSizesLabelLayoutItem(), 3, row);
+       layout->AddItem(view->CreateSizesMenuBarLayoutItem(), 4, row);
+
+       row++;
+
+       layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, row);
+       layout->AddView(view->GetPreviewBox(), 1, row, 4);
+
+       row++;
+
+       if (withExtraSpace) {
+               layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5), 0, 
row, 5);
+               row++;
+       }
+}
+
+
+FontView::FontView(const char* name)
+       :
+       BView(name, B_WILL_DRAW )
+{
+       SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+
+       fPlainView = new FontSelectionView("plain", B_TRANSLATE("Plain font:"));
+       fBoldView = new FontSelectionView("bold", B_TRANSLATE("Bold font:"));
+       fFixedView = new FontSelectionView("fixed", B_TRANSLATE("Fixed font:"));
+       fMenuView = new FontSelectionView("menu", B_TRANSLATE("Menu font:"));
+
+       BGridLayout* layout = new BGridLayout(5, 5);
+       layout->SetInsets(10, 10, 10, 10);
+       SetLayout(layout);
+
+       int32 row = 0;
+       add_font_selection_view(layout, fPlainView, row, true);
+       add_font_selection_view(layout, fBoldView, row, true);
+       add_font_selection_view(layout, fFixedView, row, true);
+       add_font_selection_view(layout, fMenuView, row, false);
+}
+
+
+void
+FontView::AttachedToWindow()
+{
+       fPlainView->SetTarget(this);
+       fBoldView->SetTarget(this);
+       fFixedView->SetTarget(this);
+       fMenuView->SetTarget(this);
+
+       UpdateFonts();
+       fRunner = new BMessageRunner(this, new BMessage(kMsgCheckFonts), 
3000000);
+               // every 3 seconds
+}
+
+
+void
+FontView::DetachedFromWindow()
+{
+       delete fRunner;
+       fRunner = NULL;
+}
+
+
+void
+FontView::SetDefaults()
+{
+       fPlainView->SetDefaults();
+       fBoldView->SetDefaults();
+       fFixedView->SetDefaults();
+       fMenuView->SetDefaults();
+}
+
+
+void
+FontView::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+               case kMsgSetSize:
+               case kMsgSetFamily:
+               case kMsgSetStyle:
+               {
+                       const char* name;
+                       if (message->FindString("name", &name) != B_OK)
+                               break;
+
+                       if (!strcmp(name, "plain"))
+                               fPlainView->MessageReceived(message);
+                       else if (!strcmp(name, "bold"))
+                               fBoldView->MessageReceived(message);
+                       else if (!strcmp(name, "fixed"))
+                               fFixedView->MessageReceived(message);
+                       else if (!strcmp(name, "menu"))
+                               fMenuView->MessageReceived(message);
+                       else
+                               break;
+
+                       Window()->PostMessage(kMsgUpdate);
+                       break;
+               }
+
+               case kMsgCheckFonts:
+                       if (update_font_families(true))
+                               UpdateFonts();
+                       break;
+
+               default:
+                       BView::MessageReceived(message);
+       }
+}
+
+
+void
+FontView::Revert()
+{
+       fPlainView->Revert();
+       fBoldView->Revert();
+       fFixedView->Revert();
+       fMenuView->Revert();
+}
+
+
+void
+FontView::UpdateFonts()
+{
+       fPlainView->UpdateFontsMenu();
+       fBoldView->UpdateFontsMenu();
+       fFixedView->UpdateFontsMenu();
+       fMenuView->UpdateFontsMenu();
+}
+
+
+bool
+FontView::IsDefaultable()
+{
+       return fPlainView->IsDefaultable()
+               || fBoldView->IsDefaultable()
+               || fFixedView->IsDefaultable()
+               || fMenuView->IsDefaultable();
+}
+
+
+bool
+FontView::IsRevertable()
+{
+       return fPlainView->IsRevertable()
+               || fBoldView->IsRevertable()
+               || fFixedView->IsRevertable()
+               || fMenuView->IsRevertable();
+}
+
diff --git a/src/preferences/appearance/FontView.h 
b/src/preferences/appearance/FontView.h
new file mode 100644
index 0000000..0b13afd
--- /dev/null
+++ b/src/preferences/appearance/FontView.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2001-2012, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Mark Hogben
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ *             Stephan Aßmus <superstippi@xxxxxx>
+ */
+#ifndef FONT_VIEW_H
+#define FONT_VIEW_H
+
+
+#include <View.h>
+
+
+class BMessageRunner;
+class FontSelectionView;
+
+
+class FontView : public BView {
+public:
+                                                               FontView(const 
char* name);
+
+       virtual void                            AttachedToWindow();
+       virtual void                            DetachedFromWindow();
+
+       virtual void                            MessageReceived(BMessage* 
message);
+
+                       void                            SetDefaults();
+                       void                            Revert();
+                       void                            UpdateFonts();
+
+                       bool                            IsDefaultable();
+                       bool                            IsRevertable();
+
+
+
+private:
+                       FontSelectionView*      fPlainView;
+                       FontSelectionView*      fBoldView;
+                       FontSelectionView*      fFixedView;
+                       FontSelectionView*      fMenuView;
+
+                       BMessageRunner*         fRunner;
+};
+
+
+#endif /* FONT_VIEW_H */
diff --git a/src/preferences/appearance/Jamfile 
b/src/preferences/appearance/Jamfile
index a52f9e6..498bfdd 100644
--- a/src/preferences/appearance/Jamfile
+++ b/src/preferences/appearance/Jamfile
@@ -7,6 +7,8 @@ Preference Appearance :
        APRMain.cpp
        AntialiasingSettingsView.cpp
        DecorSettingsView.cpp
+       FontSelectionView.cpp
+       FontView.cpp
        APRView.cpp
        APRWindow.cpp
        ColorSet.cpp
@@ -30,11 +32,13 @@ DoCatalogs Appearance :
        x-vnd.Haiku-Appearance
        :
        AntialiasingSettingsView.cpp
-       DecorSettingsView.cpp
        APRView.cpp
        APRWindow.cpp
        ColorSet.cpp
        ColorWell.cpp
        ColorWhichItem.cpp
+       DecorSettingsView.cpp
+       FontView.cpp
+       FontSelectionView.cpp
 ;
 
diff --git a/src/preferences/appearance/defs.h 
b/src/preferences/appearance/defs.h
index 5755621..d14a0f1 100644
--- a/src/preferences/appearance/defs.h
+++ b/src/preferences/appearance/defs.h
@@ -20,8 +20,6 @@
 #define APPEARANCE_APP_SIGNATURE "application/x-vnd.Haiku-Appearance"
 
 #define APPLY_SETTINGS 'aply'
-#define REVERT_SETTINGS 'rvrt'
-#define DEFAULT_SETTINGS 'dflt'
 #define TRY_SETTINGS 'trys'
 
 #define ATTRIBUTE_CHOSEN 'atch'

############################################################################

Revision:    hrev43796
Commit:      b860013aa09c7da2c29e294e105efe6e94977969
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b860013
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Feb 26 09:43:21 2012 UTC

Removed Fonts preflet from the image.

----------------------------------------------------------------------------

diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage
index 3c8db6b..3440b84 100644
--- a/build/jam/HaikuImage
+++ b/build/jam/HaikuImage
@@ -73,7 +73,7 @@ SYSTEM_APPS = AboutSystem ActivityMonitor 
$(X86_ONLY)BootManager CharacterMap
        TextSearch TV WebWatch Workspaces
 ;
 SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations
-       <preference>Deskbar E-mail FileTypes Fonts Keyboard Keymap Locale Media
+       <preference>Deskbar E-mail FileTypes Keyboard Keymap Locale Media
        Mouse Network Notifications $(X86_ONLY)3DRendering Printers Screen 
ScreenSaver
        Shortcuts Sounds Time Touchpad <preference>Tracker VirtualMemory
 ;


Other related posts: