|
From: CVS C. to T. <the...@li...> - 2010-11-02 21:39:45
|
Revision: 557
http://themis.svn.sourceforge.net/themis/?rev=557&view=rev
Author: mark_hellegers
Date: 2010-11-02 21:39:38 +0000 (Tue, 02 Nov 2010)
Log Message:
-----------
- Changed the preferences to make them more dynamic. It now checks the list of addons for preferences instead of showing a hardcoded list.
- Removed hardcoded reference to /boot/home/config/settings
Modified Paths:
--------------
trunk/themis/framework/PrefsViews.cpp
trunk/themis/framework/PrefsViews.h
trunk/themis/framework/PrefsWin.cpp
trunk/themis/framework/PrefsWin.h
trunk/themis/framework/app.cpp
Modified: trunk/themis/framework/PrefsViews.cpp
===================================================================
--- trunk/themis/framework/PrefsViews.cpp 2010-11-02 21:37:42 UTC (rev 556)
+++ trunk/themis/framework/PrefsViews.cpp 2010-11-02 21:39:38 UTC (rev 557)
@@ -26,29 +26,6 @@
/*
- * BasePrefsView
- */
-
-
-BasePrefsView :: BasePrefsView(BRect frame,
- const char* name)
- : BView(frame,
- name,
- B_FOLLOW_ALL,
- 0) {
-
- fMainBox = new BBox(
- Bounds(),
- "MainBox",
- B_FOLLOW_ALL);
- fMainBox->SetLabel(Name());
- AddChild(fMainBox);
-
- SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-
-}
-
-/*
* WindowPrefsView
*/
@@ -75,7 +52,7 @@
homepage->SetModificationMessage(new BMessage(HOMEPAGE_CHANGED));
homepage->SetDivider(be_plain_font->StringWidth("Home Page:") + kDividerSpacing);
homepage->SetText(str.String());
- fMainBox->AddChild(homepage);
+ mMainBox->AddChild(homepage);
/* blank button */
rect.top = homepage->Frame().bottom + kItemSpacing;
@@ -92,7 +69,7 @@
blankbtn->MoveTo(
homepage->Frame().right - blankbtn->Bounds().Width(),
blankbtn->Frame().top );
- fMainBox->AddChild(blankbtn);
+ mMainBox->AddChild(blankbtn);
/* intelligent zoom */
rect.left = Bounds().left + kItemSpacing;
@@ -109,7 +86,7 @@
IZcbox->SetValue(0);
else
IZcbox->SetValue(1);
- fMainBox->AddChild(IZcbox);
+ mMainBox->AddChild(IZcbox);
/* type ahead */
rect.top = IZcbox->Frame().bottom + kItemSpacing;
@@ -122,7 +99,7 @@
bool ShowTypeAhead = false;
AppSettings->FindBool(kPrefsShowTypeAheadWindow, &ShowTypeAhead);
ShowTypeAhead ? ShowTypeAheadbox->SetValue(1) : ShowTypeAheadbox->SetValue(0);
- fMainBox->AddChild(ShowTypeAheadbox);
+ mMainBox->AddChild(ShowTypeAheadbox);
/* show tabs */
rect.top = ShowTypeAheadbox->Frame().bottom + kItemSpacing;
@@ -135,7 +112,7 @@
bool ShowTabs = false;
AppSettings->FindBool(kPrefsShowTabsAtStartup, &ShowTabs);
ShowTabs ? ShowTabscbox->SetValue(1) : ShowTabscbox->SetValue(0);
- fMainBox->AddChild(ShowTabscbox);
+ mMainBox->AddChild(ShowTabscbox);
/* open tabs in background */
rect.top = ShowTabscbox->Frame().bottom + kItemSpacing;
@@ -148,7 +125,7 @@
bool OpenInBackground = false;
AppSettings->FindBool(kPrefsOpenTabsInBackground, &OpenInBackground);
OpenInBackground ? OpenTabsInBackgroundcbox->SetValue(1) : OpenTabsInBackgroundcbox->SetValue(0);
- fMainBox->AddChild( OpenTabsInBackgroundcbox );
+ mMainBox->AddChild( OpenTabsInBackgroundcbox );
/* open blank targets in tab (instead of new window) */
rect.top = OpenTabsInBackgroundcbox->Frame().bottom + kItemSpacing;
@@ -161,7 +138,7 @@
bool OpenBlankInTab = false;
AppSettings->FindBool(kPrefsOpenBlankTargetInTab, &OpenBlankInTab);
OpenBlankInTab ? OpenBlankTargetInTab_CBox->SetValue(1) : OpenBlankTargetInTab_CBox->SetValue(0);
- fMainBox->AddChild(OpenBlankTargetInTab_CBox);
+ mMainBox->AddChild(OpenBlankTargetInTab_CBox);
/* new windows open with ... */
rect = Bounds();
@@ -170,7 +147,7 @@
rect.bottom = rect.top + 100;
BBox * newInPageBox = new BBox(rect, "NEWWINPAGEBOX");
newInPageBox->SetLabel("New Windows open with ...");
- fMainBox->AddChild(newInPageBox);
+ mMainBox->AddChild(newInPageBox);
/* blank page */
rect = newInPageBox->Bounds();
@@ -241,7 +218,7 @@
: BasePrefsView(frame,
name) {
- BRect rect = fMainBox->Bounds();
+ BRect rect = mMainBox->Bounds();
rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
@@ -251,7 +228,7 @@
rect,
"historyBox");
historyBox->SetLabel("History");
- fMainBox->AddChild(historyBox);
+ mMainBox->AddChild(historyBox);
/* history depth */
rect = historyBox->Bounds();
@@ -359,7 +336,7 @@
rect.bottom = rect.top + 100;
BBox* CacheBox = new BBox(rect, "CACHEBOX");
CacheBox->SetLabel("Cache");
- fMainBox->AddChild(CacheBox);
+ mMainBox->AddChild(CacheBox);
/* cookie box */
rect = CacheBox->Frame();
@@ -367,117 +344,12 @@
rect.bottom = rect.top + 100;
BBox* CookieBox = new BBox(rect, "COOKIEBOX");
CookieBox->SetLabel("Cookies");
- fMainBox->AddChild(CookieBox);
+ mMainBox->AddChild(CookieBox);
}
/*
- * HTMLParserPrefsView
- */
-
-
-HTMLParserPrefsView :: HTMLParserPrefsView(BRect frame,
- const char* name)
- : BasePrefsView(frame,
- name) {
-
- /* DTD selection */
- mPopUpMenu = new BPopUpMenu(
- "No DTD selected or available!",
- true,
- true,
- B_ITEMS_IN_COLUMN);
-
- /* find a DTD */
- AppSettings->FindString(kPrefsSettingsDirectory, &mDTDDir);
- mDTDDir.Append("/dtd/");
- printf("DTD dir: %s\n", mDTDDir.String());
-
- BDirectory dir(mDTDDir.String());
- if(dir.InitCheck() != B_OK) {
- printf("DTD directory (%s) not found!\n", mDTDDir.String());
- printf("Setting DTDToUsePath to \"none\"\n");
- AppSettings->AddString(kPrefsActiveDTDPath, kNoDTDFoundString);
- }
- else {
- BString activeDTD;
- AppSettings->FindString(kPrefsActiveDTDPath, &activeDTD);
-
- BEntry entry;
- while(dir.GetNextEntry(&entry, false) != B_ENTRY_NOT_FOUND) {
- BPath path;
- entry.GetPath(&path);
- char name[B_FILE_NAME_LENGTH];
- entry.GetName(name);
-
- BString nstring(name);
- printf("----------------\n");
- printf("found file: %s\n", nstring.String());
- if(nstring.IFindFirst("DTD", nstring.Length() - 3) != B_ERROR) {
- printf("found DTD file: %s\n", nstring.String());
-
- /* add the file to the popupmenu */
- BMessage* msg = new BMessage(DTD_SELECTED);
- msg->AddString("DTDFileString", path.Path());
- BMenuItem* item = new BMenuItem(name, msg, 0, 0);
- mPopUpMenu->AddItem(item);
-
- // if the path of the current file equals the one of the settings,
- // mark the item
- if(strcmp(activeDTD.String(), path.Path()) == 0) {
- printf("DTD from settings found -> SetMarked( true )\n");
- (mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1))->SetMarked(true);
- }
- }
- } // while
-
- }
- // end: find a DTD
- BRect rect = fMainBox->Bounds();
- rect.InsetBy(kItemSpacing, kItemSpacing);
- rect.top += kBBoxExtraInset;
-
- BMenuField* dtdmenufield = new BMenuField(
- rect,
- "DTDFIELD", "Document Type Definition:",
- mPopUpMenu,
- true,
- B_FOLLOW_TOP,
- B_WILL_DRAW);
- dtdmenufield->SetDivider(be_plain_font->StringWidth("Document Type Definition:") + kItemSpacing);
- fMainBox->AddChild(dtdmenufield);
-
-}
-
-void HTMLParserPrefsView :: AttachedToWindow() {
-
- // if we found some DTDs, but still no DTD is saved in the prefs,
- // or no DTD is selected:
- // set the last found DTD in the prefs. we save it to the prefs,
- // because the user might not reselect a DTD in the list, which
- // would save the DTD.
- BMessage imsg(DTD_SELECTED);
- BMessenger msgr(NULL, Window()->Looper());
- if(mPopUpMenu->CountItems() > 0) {
- if(mPopUpMenu->FindMarked() == NULL) {
- printf("no marked item found\n");
- BMenuItem* item = mPopUpMenu->ItemAt(mPopUpMenu->CountItems() - 1);
- item->SetMarked(true);
- // as we cannot invoke the item here, send the DTD_SELECTED message here
- BString dtdstring(mDTDDir.String());
- dtdstring.Append(item->Label());
- imsg.AddString("DTDFileString", dtdstring.String());
- msgr.SendMessage(&imsg);
- }
- }
- else {
- imsg.AddString("DTDFileString", kNoDTDFoundString);
- msgr.SendMessage(&imsg);
- }
-}
-
-/*
* CSSParserPrefsView
*/
@@ -537,7 +409,7 @@
}
// end: find a CSS file
- BRect rect = fMainBox->Bounds();
+ BRect rect = mMainBox->Bounds();
rect.InsetBy(kItemSpacing, kItemSpacing);
rect.top += kBBoxExtraInset;
@@ -549,7 +421,7 @@
B_FOLLOW_TOP,
B_WILL_DRAW);
cssmenufield->SetDivider(be_plain_font->StringWidth("Cascading Style Sheet:") + kItemSpacing);
- fMainBox->AddChild(cssmenufield);
+ mMainBox->AddChild(cssmenufield);
}
void CSSParserPrefsView :: AttachedToWindow() {
Modified: trunk/themis/framework/PrefsViews.h
===================================================================
--- trunk/themis/framework/PrefsViews.h 2010-11-02 21:37:42 UTC (rev 556)
+++ trunk/themis/framework/PrefsViews.h 2010-11-02 21:39:38 UTC (rev 557)
@@ -11,8 +11,10 @@
#include <View.h>
#include <String.h>
+// Themis headers
+#include "BasePrefsView.hpp"
+
// Declarations used
-class BBox;
class BPopUpMenu;
/*
@@ -22,18 +24,6 @@
class WindowPrefsView;
-class BasePrefsView : public BView {
-
- protected:
- BBox * fMainBox;
-
- public:
- BasePrefsView(BRect frame,
- const char* name);
-
-};
-
-
/*
* WindowPrefsView
*/
@@ -77,25 +67,6 @@
/*
- * HTML ParserPrefsView
- */
-
-
-class HTMLParserPrefsView : public BasePrefsView {
-
- private:
- BPopUpMenu * mPopUpMenu;
- BString mDTDDir;
-
- public:
- HTMLParserPrefsView(BRect frame,
- const char* name);
- virtual void AttachedToWindow();
-
-};
-
-
-/*
* CSS ParserPrefsView
*/
Modified: trunk/themis/framework/PrefsWin.cpp
===================================================================
--- trunk/themis/framework/PrefsWin.cpp 2010-11-02 21:37:42 UTC (rev 556)
+++ trunk/themis/framework/PrefsWin.cpp 2010-11-02 21:39:38 UTC (rev 557)
@@ -34,8 +34,8 @@
};
-PrefsWin :: PrefsWin(BRect frame)
- : BWindow(frame,
+PrefsWin :: PrefsWin(BRect aFrame, BMessage * aPluginList)
+ : BWindow(aFrame,
"Preferences",
B_TITLED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL,
@@ -58,7 +58,7 @@
rect.InsetBy(kItemSpacing, kItemSpacing);
rect.right = rect.left + 100;
- fPrefsListView = new PrefsListView(rect);
+ fPrefsListView = new PrefsListView(rect, aPluginList);
fBackgroundView->AddChild(fPrefsListView);
/* calculate the view frame */
@@ -67,8 +67,8 @@
rect.left = fPrefsListView->Frame().right + kItemSpacing;
fViewFrame = rect;
- CreatePrefViews();
-
+ CreatePrefViews(aPluginList);
+
Show();
}
@@ -82,11 +82,11 @@
printf("Deleting preferences views\n");
for (unsigned int i = 0; i < mPrefViews.size(); i++) {
delete mPrefViews[i];
- }
+ }
}
-void PrefsWin :: CreatePrefViews() {
+void PrefsWin :: CreatePrefViews(BMessage * aPluginList) {
printf("Creating preferences views\n");
@@ -94,22 +94,30 @@
new WindowPrefsView(fViewFrame,
kPrefsItems[0].name));
mPrefViews.push_back(
- new NetworkPrefsView(fViewFrame,
- kPrefsItems[1].name));
- mPrefViews.push_back(
new PrivacyPrefsView(fViewFrame,
kPrefsItems[2].name));
- mPrefViews.push_back(
- new HTMLParserPrefsView(fViewFrame,
- kPrefsItems[3].name));
- mPrefViews.push_back(
- new CSSParserPrefsView(fViewFrame,
- kPrefsItems[4].name));
- mPrefViews.push_back(
- new RendererPrefsView(fViewFrame,
- kPrefsItems[5].name));
+
+ int32 countFound;
+ type_code typeFound;
+ status_t status = aPluginList->GetInfo(
+ "plug_name",
+ &typeFound,
+ &countFound);
+ if (status == B_OK) {
-
+ const char * name;
+ PlugClass * plugin;
+ BView * view = NULL;
+ for (int32 i = 0; i < countFound; i++) {
+ aPluginList->FindPointer("plug_object", i, (void **)&plugin);
+ view = plugin->SettingsView(fViewFrame);
+ if (view != NULL) {
+ mPrefViews.push_back(view);
+
+ }
+ }
+ }
+
}
void PrefsWin :: MessageReceived(BMessage* msg) {
@@ -117,7 +125,6 @@
switch(msg->what) {
case LIST_SELECTION_CHANGED: {
int32 selection = fPrefsListView->CurrentSelection();
-
/*
* if the user presses in the empty area, we ignore this,
* but the BListView does take away the focus from the curent
@@ -135,8 +142,10 @@
fCurrentPrefsView = NULL;
}
- fCurrentPrefsView = mPrefViews[selection];
- fBackgroundView->AddChild(fCurrentPrefsView);
+ if ((unsigned int)selection < mPrefViews.size()) {
+ fCurrentPrefsView = mPrefViews[selection];
+ fBackgroundView->AddChild(fCurrentPrefsView);
+ }
}
}
@@ -327,23 +336,6 @@
break;
}
- case DTD_SELECTED: {
- printf("PREFS: DTD_SELECTED\n");
-
- BString str;
- msg->FindString("DTDFileString", &str);
-
- AppSettings->ReplaceString(kPrefsActiveDTDPath, str.String());
-
- SaveAppSettings();
-
- /*
- * use the app to tell html parser about the DTD change.
- */
- be_app_messenger.SendMessage(DTD_CHANGED);
-
- break;
- }
case CSS_SELECTED: {
printf("PREFS: CSS_SELECTED\n");
@@ -391,11 +383,14 @@
*/
-PrefsListView :: PrefsListView(BRect frame)
- : BView(frame,
+PrefsListView :: PrefsListView(BRect aFrame, BMessage * aPluginList)
+ : BView(aFrame,
"PrefsListView",
0,
0) {
+
+ mPluginList = aPluginList;
+
}
PrefsListView :: ~PrefsListView() {
@@ -405,6 +400,9 @@
delete fListView->RemoveItem((int32) 0);
}
fListView->MakeEmpty();
+
+ delete mPluginList;
+
}
void PrefsListView :: AttachedToWindow() {
@@ -428,18 +426,50 @@
/* I want a font size of 12.0 */
fListView->SetFontSize( 12.0 );
-
+
/* add the list items */
int32 i = 0;
- while(kPrefsItems[i].name != NULL) {
- fListView->AddItem(
- new PrefsListItem(
- kPrefsItems[i].name,
- kPrefsItems[i].bitmap));
-
- i++;
- }
+ fListView->AddItem(
+ new PrefsListItem(
+ "Window",
+ kPrefsIconGeneral));
+ fListView->AddItem(
+ new PrefsListItem(
+ "Privacy",
+ kPrefsIconPrivacy));
+ int32 countFound;
+ type_code typeFound;
+ status_t status = mPluginList->GetInfo(
+ "plug_name",
+ &typeFound,
+ &countFound);
+ if (status == B_OK) {
+ int32 type;
+ const char * name;
+ PlugClass * plugin;
+ for (int32 i = 0; i < countFound; i++) {
+ mPluginList->FindPointer("plug_object", i, (void **)&plugin);
+ type = plugin->Type();
+ name = plugin->SettingsViewLabel();
+ if (name != NULL) {
+ if (type != TARGET_PARSER) {
+ fListView->AddItem(
+ new PrefsListItem(
+ name,
+ kPrefsIconParser));
+
+ }
+ else {
+ fListView->AddItem(
+ new PrefsListItem(
+ name,
+ kPrefsIconGeneral));
+ }
+ }
+ }
+ }
+
fListView->SetSelectionMessage(new BMessage(LIST_SELECTION_CHANGED));
fListView->MakeFocus(true);
Modified: trunk/themis/framework/PrefsWin.h
===================================================================
--- trunk/themis/framework/PrefsWin.h 2010-11-02 21:37:42 UTC (rev 556)
+++ trunk/themis/framework/PrefsWin.h 2010-11-02 21:39:38 UTC (rev 557)
@@ -29,11 +29,11 @@
BRect fViewFrame;
vector<BView *> mPrefViews;
- void CreatePrefViews();
+ void CreatePrefViews(BMessage * aPluginList);
void SaveAppSettings();
public:
- PrefsWin(BRect frame);
+ PrefsWin(BRect aFrame, BMessage * aPluginList);
virtual ~PrefsWin();
virtual void MessageReceived(BMessage* msg);
virtual bool QuitRequested();
@@ -58,9 +58,10 @@
private:
BListView * fListView;
BBox * fBox;
+ BMessage * mPluginList;
public:
- PrefsListView(BRect frame);
+ PrefsListView(BRect aFrame, BMessage * aPluginList);
virtual ~PrefsListView();
virtual void AttachedToWindow();
int32 CurrentSelection();
Modified: trunk/themis/framework/app.cpp
===================================================================
--- trunk/themis/framework/app.cpp 2010-11-02 21:37:42 UTC (rev 556)
+++ trunk/themis/framework/app.cpp 2010-11-02 21:39:38 UTC (rev 557)
@@ -266,15 +266,6 @@
break;
}
- case DTD_CHANGED :
- {
- printf( "APP DTD_CHANGED\n" );
- BMessage* chgmsg = new BMessage( DTD_CHANGED_PARSER );
- chgmsg->AddInt32( "command", COMMAND_INFO );
- Broadcast( MS_TARGET_PARSER, chgmsg );
- delete chgmsg;
- break;
- }
case CSS_CHANGED :
{
printf( "APP CSS_CHANGED\n" );
@@ -310,7 +301,8 @@
rect.OffsetTo( 200, 200 );
}
fPrefsWin = new PrefsWin(
- rect );
+ rect,
+ PluginManager->GetPluginList());
}
else
fPrefsWin->Activate(true);
@@ -617,64 +609,6 @@
AppSettings->AddInt8( kPrefsTabHistoryDepth, 10 );
/* Prefs Parser */
- if( !AppSettings->HasString( kPrefsDTDDirectory ) )
- {
- BString dir;
- AppSettings->FindString( kPrefsSettingsDirectory, &dir );
- dir.Append( "/dtd" );
- AppSettings->AddString( kPrefsDTDDirectory, dir.String() );
- }
- if( !AppSettings->HasString( kPrefsActiveDTDPath ) ||
- strcmp( AppSettings->FindString( kPrefsActiveDTDPath ), kNoDTDFoundString ) == 0 )
- {
- /* set our default */
- if( !AppSettings->HasString( kPrefsActiveDTDPath ) )
- AppSettings->AddString( kPrefsActiveDTDPath, kNoDTDFoundString );
-
- /* find a DTD */
- BString dtddir;
- AppSettings->FindString( kPrefsSettingsDirectory, &dtddir );
- dtddir.Append( "/dtd/" );
- printf( "DTD dir: %s\n", dtddir.String() );
-
- BDirectory dir( dtddir.String() );
- if( dir.InitCheck() != B_OK )
- {
- printf( "DTD directory (%s) not found!\n", dtddir.String() );
- printf( "Setting kPrefsActiveDTDPath to \"none\"\n" );
- AppSettings->AddString( kPrefsActiveDTDPath, kNoDTDFoundString );
- }
- else
- {
- BEntry entry;
- while( dir.GetNextEntry( &entry, false ) != B_ENTRY_NOT_FOUND )
- {
- BPath path;
- entry.GetPath( &path );
- char name[B_FILE_NAME_LENGTH];
- entry.GetName( name );
-
- BString nstring( name );
- printf( "----------------\n" );
- printf( "found file: %s\n", nstring.String() );
- if( nstring.IFindFirst( "DTD", nstring.Length() - 3 ) != B_ERROR )
- {
- printf( "found DTD file: %s\n", nstring.String() );
- if( AppSettings->HasString( kPrefsActiveDTDPath ) )
- {
- printf( "replacing kPrefsActiveDTDPath with: %s\n", path.Path() );
- AppSettings->ReplaceString( kPrefsActiveDTDPath, path.Path() );
- }
- else
- {
- printf( "adding kPrefsActiveDTDPath: %s\n", path.Path() );
- AppSettings->AddString( kPrefsActiveDTDPath, path.Path() );
- }
- }
- }
- }
- /* end: find a DTD */
- }
if( !AppSettings->HasString( kPrefsActiveCSSPath ) ||
strcmp( AppSettings->FindString( kPrefsActiveCSSPath ), kNoCSSFoundString ) == 0 )
{
@@ -720,7 +654,7 @@
}
}
}
- /* end: find a DTD */
+ /* end: find a CSS file */
}
AppSettings->PrintToStream();
@@ -816,13 +750,6 @@
printf( "App::LoadSettings()\n" );
if( AppSettings != NULL )
{
- /* check if dtd dir exists, if not, create it */
- {
- BEntry ent("/boot/home/config/settings/Themis/dtd/",true);
- if (!ent.Exists())
- create_directory("/boot/home/config/settings/Themis/dtd/",0555);
- }
-
status_t ret=B_OK;
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path)==B_OK)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|