From 21f3e082b187190910950714d14427b71e91e72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Tue, 29 Sep 2009 21:47:45 +0000 Subject: [PATCH] Moving Deskbar options to a dedicated preferences window. Adding a preference application that simply tells Deskbar to open that window. Adjusting default settings Recent Folders from off to 10, and Auto-raise from on to off. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33363 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/HaikuImage | 7 +- src/apps/deskbar/BarApp.cpp | 68 ++-- src/apps/deskbar/BarApp.h | 11 +- src/apps/deskbar/BarView.h | 1 + src/apps/deskbar/BeMenu.cpp | 81 +--- src/apps/deskbar/Jamfile | 2 + src/apps/deskbar/PreferencesWindow.cpp | 348 ++++++++++++++++++ src/apps/deskbar/PreferencesWindow.h | 65 ++++ src/preferences/Jamfile | 2 + .../deskbar/DeskbarPreferences.cpp | 23 ++ .../deskbar/DeskbarPreferences.rdef | 59 +++ src/preferences/deskbar/Jamfile | 10 + 12 files changed, 551 insertions(+), 126 deletions(-) create mode 100644 src/apps/deskbar/PreferencesWindow.cpp create mode 100644 src/apps/deskbar/PreferencesWindow.h create mode 100644 src/preferences/deskbar/DeskbarPreferences.cpp create mode 100644 src/preferences/deskbar/DeskbarPreferences.rdef create mode 100644 src/preferences/deskbar/Jamfile diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index cd9e47fcbb..151fefff42 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -68,9 +68,10 @@ SYSTEM_APPS = AboutSystem ActivityMonitor CharacterMap CodyCam DeskCalc DiskProb PackageInstaller People PoorMan PowerStatus ProcessController Screenshot ShowImage SoundRecorder StyledEdit Terminal TextSearch TV Workspaces ; -SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations E-mail - FileTypes Fonts Keyboard Keymap Locale Media Mouse Network OpenGL Printers - Screen ScreenSaver Sounds Time Touchpad Tracker VirtualMemory +SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations + Deskbar E-mail FileTypes Fonts Keyboard Keymap Locale Media + Mouse Network OpenGL Printers Screen ScreenSaver Sounds Time Touchpad + Tracker VirtualMemory ; SYSTEM_DEMOS = BSnow Chart Clock Cortex FontDemo GLTeapot Haiku3d Mandelbrot Pairs Playground Pulse Sudoku Gradients diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 21e0b53626..44498971a4 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -51,8 +51,6 @@ All rights reserved. # include #endif -#include "FavoritesConfig.h" - #include "icons.h" #include "tracker_private.h" #include "BarApp.h" @@ -101,7 +99,7 @@ main() TBarApp::TBarApp() : BApplication(kDeskbarSignature), fSettingsFile(NULL), - fConfigWindow(NULL) + fPreferencesWindow(NULL) { InitSettings(); InitIconPreloader(); @@ -164,9 +162,23 @@ TBarApp::~TBarApp() bool TBarApp::QuitRequested() { - if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) - // don't allow user quitting + // don't allow user quitting + if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) { + // but allow quitting to hide fPreferencesWindow + int32 index = 0; + BWindow* window = NULL; + while ((window = WindowAt(index++)) != NULL) { + if (window == fPreferencesWindow) { + if (fPreferencesWindow->Lock()) { + if (fPreferencesWindow->IsActive()) + fPreferencesWindow->PostMessage(B_QUIT_REQUESTED); + fPreferencesWindow->Unlock(); + } + break; + } + } return false; + } // system quitting, call inherited to notify all loopers fBarWindow->SaveSettings(); @@ -221,7 +233,7 @@ TBarApp::InitSettings() settings.recentDocsCount = 10; settings.timeShowSeconds = false; settings.timeShowMil = false; - settings.recentFoldersCount = 0; // default is hidden + settings.recentFoldersCount = 10; settings.timeShowEuro = false; settings.alwaysOnTop = false; settings.timeFullDate = false; @@ -229,7 +241,7 @@ TBarApp::InitSettings() settings.sortRunningApps = false; settings.superExpando = false; settings.expandNewTeams = false; - settings.autoRaise = true; + settings.autoRaise = false; BPath dirPath; const char *settingsFileName = "Deskbar_settings"; @@ -316,13 +328,7 @@ TBarApp::MessageReceived(BMessage *message) break; case kConfigShow: - if (message->FindInt32("count", &count) == B_OK) - fSettings.recentDocsCount = count; - break; - - case kUpdateAppsCount: - if (message->FindInt32("count", &count) == B_OK) - fSettings.recentAppsCount = count; + ShowPreferencesWindow(); break; case kShowBeMenu: @@ -339,19 +345,17 @@ TBarApp::MessageReceived(BMessage *message) } break; - case msg_config_db: - ShowConfigWindow(); - break; - - case kConfigClose: + case kUpdateRecentCounts: if (message->FindInt32("applications", &count) == B_OK) fSettings.recentAppsCount = count; if (message->FindInt32("folders", &count) == B_OK) fSettings.recentFoldersCount = count; if (message->FindInt32("documents", &count) == B_OK) fSettings.recentDocsCount = count; + break; - fConfigWindow = NULL; + case kConfigClose: + fPreferencesWindow = NULL; break; case B_SOME_APP_LAUNCHED: @@ -691,27 +695,13 @@ TBarApp::RemoveTeam(team_id team) void -TBarApp::ShowConfigWindow() +TBarApp::ShowPreferencesWindow() { - if (fConfigWindow) - fConfigWindow->Activate(); + if (fPreferencesWindow) + fPreferencesWindow->Activate(); else { - // always start at top, could be cached and we could start - // where we left off. - BPath path; - find_directory (B_USER_DESKBAR_DIRECTORY, &path); - entry_ref startref; - get_ref_for_path(path.Path(), &startref); - - fConfigWindow = new TFavoritesConfigWindow(BRect(0, 0, 320, 240), -#ifdef __HAIKU__ - "Configure Deskbar Menu", false, B_ANY_NODE, -#else - "Configure Be Menu", false, B_ANY_NODE, -#endif - BMessenger(this), &startref, - fSettings.recentAppsCount, fSettings.recentDocsCount, - fSettings.recentFoldersCount); + fPreferencesWindow = new PreferencesWindow(BRect(0, 0, 320, 240)); + fPreferencesWindow->Show(); } } diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 479421a1d8..0321d8bb75 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -38,6 +38,7 @@ All rights reserved. #include #include #include "BarWindow.h" +#include "PreferencesWindow.h" /* ------------------------------------ */ @@ -68,7 +69,6 @@ const uint32 msg_Mac = 'WcOS'; const uint32 msg_Be = 'Tabs'; const uint32 msg_AlwaysTop = 'TTop'; const uint32 msg_ToggleDraggers = 'TDra'; -const uint32 msg_config_db = 'cnfg'; const uint32 msg_Unsubscribe = 'Unsb'; const uint32 msg_AddTeam = 'AdTm'; const uint32 msg_RemoveTeam = 'RmTm'; @@ -131,10 +131,6 @@ const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9; class TBarView; class BFile; -namespace BPrivate { - class TFavoritesConfigWindow; -} - using namespace BPrivate; class TBarApp : public BApplication { @@ -163,7 +159,7 @@ class TBarApp : public BApplication { void InitSettings(); void SaveSettings(); - void ShowConfigWindow(); + void ShowPreferencesWindow(); TBarWindow *fBarWindow; BMessenger fSwitcherMessenger; @@ -171,7 +167,7 @@ class TBarApp : public BApplication { BFile *fSettingsFile; desk_settings fSettings; - TFavoritesConfigWindow *fConfigWindow; + PreferencesWindow* fPreferencesWindow; static BLocker sSubscriberLock; static BList sBarTeamInfoList; @@ -179,3 +175,4 @@ class TBarApp : public BApplication { }; #endif // BAR_APP_H + diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index dc091c4e4e..9e714f9486 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -134,6 +134,7 @@ class TBarView : public BView { TExpandoMenuBar *ExpandoMenuBar() const; TBarMenuBar *BarMenuBar() const; friend class TBeMenu; + friend class PreferencesWindow; private: status_t SendDragMessage(const char *signature, entry_ref *ref = NULL); diff --git a/src/apps/deskbar/BeMenu.cpp b/src/apps/deskbar/BeMenu.cpp index dcf708b207..0d200a4ac4 100644 --- a/src/apps/deskbar/BeMenu.cpp +++ b/src/apps/deskbar/BeMenu.cpp @@ -255,83 +255,10 @@ TBeMenu::AddStandardBeMenuItems() AddItem(mountMenu); #endif - // insert preferences menu - BMenu *subMenu = new BMenu("Deskbar Settings"); - subMenu->SetEnabled(!dragging); - -#ifdef __HAIKU__ - item = new BMenuItem("Configure Deskbar Menu"B_UTF8_ELLIPSIS, new BMessage(msg_config_db)); -#else - item = new BMenuItem("Configure Be Menu"B_UTF8_ELLIPSIS, new BMessage(msg_config_db)); -#endif + item = new BMenuItem("Deskbar Preferences" B_UTF8_ELLIPSIS, + new BMessage(kConfigShow)); item->SetTarget(be_app); - subMenu->AddItem(item); - - item = new BMenuItem("Always on Top", new BMessage(msg_AlwaysTop)); - item->SetTarget(be_app); - // set checkbox based on current state of Deskbar's main window feel - if (BWindow *window = static_cast(be_app)->BarWindow()) - item->SetMarked((window->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0); - subMenu->AddItem(item); - - item = new BMenuItem("Auto Raise", new BMessage(msg_AutoRaise)); - item->SetTarget(be_app); - item->SetMarked(static_cast(be_app)->Settings()->autoRaise); - subMenu->AddItem(item); - - item = new BMenuItem("Sort Running Applications", new BMessage(msg_sortRunningApps)); - item->SetTarget(be_app); - item->SetMarked(static_cast(be_app)->Settings()->sortRunningApps); - subMenu->AddItem(item); - - item = new BMenuItem("Tracker Always First", new BMessage(msg_trackerFirst)); - item->SetTarget(be_app); - item->SetMarked(static_cast(be_app)->Settings()->trackerAlwaysFirst); - subMenu->AddItem(item); - - subMenu->AddSeparatorItem(); - - TReplicantTray *replicantTray = ((TBarApp *)be_app)->BarView()->fReplicantTray; - - item = new BMenuItem("24 Hour Clock", new BMessage(kMsgMilTime)); - item->SetTarget(replicantTray); - item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock()); - item->SetMarked(replicantTray->ShowingMiltime()); - subMenu->AddItem(item); - - item = new BMenuItem("Show Seconds", new BMessage(kMsgShowSeconds)); - item->SetTarget(replicantTray); - item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock()); - item->SetMarked(replicantTray->ShowingSeconds()); - subMenu->AddItem(item); - - item = new BMenuItem("European Date", new BMessage(kMsgEuroDate)); - item->SetTarget(replicantTray); - item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock()); - item->SetMarked(replicantTray->ShowingEuroDate()); - subMenu->AddItem(item); - - item = new BMenuItem("Full Date", new BMessage(kMsgFullDate)); - item->SetTarget(replicantTray); - item->SetEnabled(replicantTray->CanShowFullDate()); - item->SetMarked(replicantTray->ShowingFullDate()); - subMenu->AddItem(item); - - subMenu->AddSeparatorItem(); - - item = new BMenuItem("Show Application Expander", new BMessage(msg_superExpando)); - item->SetTarget(be_app); - item->SetMarked(static_cast(be_app)->Settings()->superExpando); - subMenu->AddItem(item); - - item = new BMenuItem("Expand New Applications", new BMessage(msg_expandNewTeams)); - item->SetTarget(be_app); - item->SetMarked(static_cast(be_app)->Settings()->expandNewTeams); - item->SetEnabled(static_cast(be_app)->Settings()->superExpando); - subMenu->AddItem(item); - - subMenu->SetFont(be_plain_font); - AddItem(subMenu); + AddItem(item); #ifndef __HAIKU__ if ((modifiers() & (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY)) @@ -448,7 +375,7 @@ TBeMenu::ResetTargets() break; case msg_ToggleDraggers: - case msg_config_db: + case kConfigShow: case msg_AlwaysTop: case kMsgShowSeconds: case kMsgMilTime: diff --git a/src/apps/deskbar/Jamfile b/src/apps/deskbar/Jamfile index 70c7dfd62f..ae87d42007 100644 --- a/src/apps/deskbar/Jamfile +++ b/src/apps/deskbar/Jamfile @@ -3,6 +3,7 @@ SubDir HAIKU_TOP src apps deskbar ; SetSubDirSupportedPlatformsBeOSCompatible ; UsePrivateHeaders app interface shared tracker ; +UsePrivateHeaders private shared ; SubDirHdrs $(HAIKU_TOP) src kits tracker ; AddResources Deskbar : Deskbar.rdef icon-freelogo.rdef icons.rdef ; @@ -33,6 +34,7 @@ Application Deskbar : CalendarMenuItem.cpp DeskBarUtils.cpp ExpandoMenuBar.cpp + PreferencesWindow.cpp ShowHideMenuItem.cpp StatusView.cpp StatusViewShelf.cpp diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp new file mode 100644 index 0000000000..293ec2763a --- /dev/null +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -0,0 +1,348 @@ +/* + * Copyright 2009 Haiku, Inc. + * All Rights Reserved. Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas@kirilla.com + */ + + +#include "PreferencesWindow.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include "BarApp.h" +#include "StatusView.h" + + +PreferencesWindow::PreferencesWindow(BRect frame) + : + BWindow(frame, "Deskbar Preferences", B_TITLED_WINDOW, B_NOT_RESIZABLE + | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE) +{ + // Controls + fMenuRecentDocuments = new BCheckBox("Recent Documents:", + new BMessage(kUpdateRecentCounts)); + fMenuRecentApplications = new BCheckBox("Recent Applications:", + new BMessage(kUpdateRecentCounts)); + fMenuRecentFolders = new BCheckBox("Recent Folders:", + new BMessage(kUpdateRecentCounts)); + + fMenuRecentDocumentCount = new BTextControl(NULL, NULL, + new BMessage(kUpdateRecentCounts)); + fMenuRecentApplicationCount = new BTextControl(NULL, NULL, + new BMessage(kUpdateRecentCounts)); + fMenuRecentFolderCount = new BTextControl(NULL, NULL, + new BMessage(kUpdateRecentCounts)); + + fAppsSort = new BCheckBox("Sort Running Applications", + new BMessage(msg_sortRunningApps)); + fAppsSortTrackerFirst = new BCheckBox("Tracker Always First", + new BMessage(msg_trackerFirst)); + fAppsShowExpanders = new BCheckBox("Show Application Expander", + new BMessage(msg_superExpando)); + fAppsExpandNew = new BCheckBox("Expand New Applications", + new BMessage(msg_expandNewTeams)); + + fClock24Hours = new BCheckBox("24 Hour Clock", new BMessage(kMsgMilTime)); + fClockSeconds = new BCheckBox("Show Seconds", + new BMessage(kMsgShowSeconds)); + fClockEuropeanDate = new BCheckBox("European Date", + new BMessage(kMsgEuroDate)); + fClockFullDate = new BCheckBox("Full Date", new BMessage(kMsgFullDate)); + + fWindowAlwaysOnTop = new BCheckBox("Always On Top", + new BMessage(msg_AlwaysTop)); + fWindowAutoRaise = new BCheckBox("Auto-raise", new BMessage(msg_AutoRaise)); + + BTextView* docTextView = fMenuRecentDocumentCount->TextView(); + BTextView* appTextView = fMenuRecentApplicationCount->TextView(); + BTextView* folderTextView = fMenuRecentFolderCount->TextView(); + + for (int32 i = 0; i < 256; i++) { + if (!isdigit(i)) { + docTextView->DisallowChar(i); + appTextView->DisallowChar(i); + folderTextView->DisallowChar(i); + } + } + + docTextView->SetMaxBytes(4); + appTextView->SetMaxBytes(4); + folderTextView->SetMaxBytes(4); + + // Values + TBarApp* barApp = static_cast(be_app); + desk_settings* appSettings = barApp->Settings();; + + fAppsSort->SetValue(appSettings->sortRunningApps); + fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst); + fAppsShowExpanders->SetValue(appSettings->superExpando); + fAppsExpandNew->SetValue(appSettings->expandNewTeams); + + fMenuRecentDocuments->SetValue(false); + fMenuRecentApplications->SetValue(false); + fMenuRecentFolders->SetValue(false); + + fMenuRecentDocumentCount->SetEnabled(false); + fMenuRecentApplicationCount->SetEnabled(false); + fMenuRecentFolderCount->SetEnabled(false); + + int32 docCount = appSettings->recentDocsCount; + int32 appCount = appSettings->recentAppsCount; + int32 folderCount = appSettings->recentFoldersCount; + + if (docCount > 0) { + fMenuRecentDocuments->SetValue(true); + fMenuRecentDocumentCount->SetEnabled(true); + } + + if (appCount > 0) { + fMenuRecentApplications->SetValue(true); + fMenuRecentApplicationCount->SetEnabled(true); + } + + if (folderCount > 0) { + fMenuRecentFolders->SetValue(true); + fMenuRecentFolderCount->SetEnabled(true); + } + + BString docString; + BString appString; + BString folderString; + + docString << docCount; + appString << appCount; + folderString << folderCount; + + fMenuRecentDocumentCount->SetText(docString.String()); + fMenuRecentApplicationCount->SetText(appString.String()); + fMenuRecentFolderCount->SetText(folderString.String()); + + TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray; + + fClock24Hours->SetValue(replicantTray->ShowingMiltime()); + fClockSeconds->SetValue(replicantTray->ShowingSeconds()); + fClockEuropeanDate->SetValue(replicantTray->ShowingEuroDate()); + fClockFullDate->SetValue(replicantTray->ShowingFullDate()); + + bool showingClock = barApp->BarView()->ShowingClock(); + fClock24Hours->SetEnabled(showingClock); + fClockSeconds->SetEnabled(showingClock); + fClockEuropeanDate->SetEnabled(showingClock); + fClockFullDate->SetEnabled(replicantTray->CanShowFullDate()); + + fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop); + fWindowAutoRaise->SetValue(appSettings->autoRaise); + + _EnableDisableDependentItems(); + + // Targets + fAppsSort->SetTarget(be_app); + fAppsSortTrackerFirst->SetTarget(be_app); + fAppsExpandNew->SetTarget(be_app); + + fClock24Hours->SetTarget(replicantTray); + fClockSeconds->SetTarget(replicantTray); + fClockEuropeanDate->SetTarget(replicantTray); + fClockFullDate->SetTarget(replicantTray); + + fWindowAlwaysOnTop->SetTarget(be_app); + fWindowAutoRaise->SetTarget(be_app); + + // Layout + fMenuBox = new BBox("fMenuBox"); + fAppsBox = new BBox("fAppsBox"); + fClockBox = new BBox("fClockBox"); + fWindowBox = new BBox("fWindowBox"); + + BStringView* menuString = new BStringView(NULL, "Menu"); + BStringView* appsString = new BStringView(NULL, "Applications"); + BStringView* clockString = new BStringView(NULL, "Clock"); + BStringView* windowString = new BStringView(NULL, "Window"); + + BFont font; + menuString->GetFont(&font); + font.SetFace(B_BOLD_FACE); + + menuString->SetFont(&font, B_FONT_FACE); + appsString->SetFont(&font, B_FONT_FACE); + clockString->SetFont(&font, B_FONT_FACE); + windowString->SetFont(&font, B_FONT_FACE); + + fMenuBox->SetLabel(menuString); + fAppsBox->SetLabel(appsString); + fClockBox->SetLabel(clockString); + fWindowBox->SetLabel(windowString); + + BView* view; + view = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 10) + .AddGroup(B_HORIZONTAL, 10) + .AddGroup(B_VERTICAL, 10) + .Add(fMenuRecentDocuments) + .Add(fMenuRecentFolders) + .Add(fMenuRecentApplications) + .End() + .AddGroup(B_VERTICAL, 10) + .Add(fMenuRecentDocumentCount) + .Add(fMenuRecentApplicationCount) + .Add(fMenuRecentFolderCount) + .End() + .End() + .Add(new BButton("Edit Menu" B_UTF8_ELLIPSIS, + new BMessage(kEditMenuInTracker))) + .SetInsets(14, 14, 14, 14) + .End() + .View(); + fMenuBox->AddChild(view); + + view = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 10) + .Add(fAppsSort) + .Add(fAppsSortTrackerFirst) + .Add(fAppsShowExpanders) + .AddGroup(B_HORIZONTAL, 0) + .SetInsets(20, 0, 0, 0) + .Add(fAppsExpandNew) + .End() + .SetInsets(14, 14, 14, 14) + .End() + .View(); + fAppsBox->AddChild(view); + + view = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 10) + .Add(fClock24Hours) + .Add(fClockSeconds) + .Add(fClockEuropeanDate) + .Add(fClockFullDate) + .SetInsets(14, 14, 14, 14) + .End() + .View(); + fClockBox->AddChild(view); + + view = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 10) + .Add(fWindowAlwaysOnTop) + .Add(fWindowAutoRaise) + .SetInsets(14, 14, 14, 14) + .End() + .View(); + fWindowBox->AddChild(view); + + BLayoutBuilder::Group<>(this) + .AddGroup(B_VERTICAL, 10) + .Add(fMenuBox) + .Add(fWindowBox) + .Add(fAppsBox) + .Add(fClockBox) + .SetInsets(14, 14, 14, 14) + .End() + .End(); + + CenterOnScreen(); +} + + +PreferencesWindow::~PreferencesWindow() +{ + _UpdateRecentCounts(); + be_app->PostMessage(kConfigClose); +} + + +void +PreferencesWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + + case kEditMenuInTracker: + OpenWithTracker(B_USER_DESKBAR_DIRECTORY); + break; + + case kUpdateRecentCounts: + _UpdateRecentCounts(); + break; + + case msg_superExpando: + _EnableDisableDependentItems(); + be_app->PostMessage(message); + break; + + default: + BWindow::MessageReceived(message); + break; + } +} + + +void +PreferencesWindow::_UpdateRecentCounts() +{ + BMessage message(kUpdateRecentCounts); + + int32 docCount = atoi(fMenuRecentDocumentCount->Text()); + int32 appCount = atoi(fMenuRecentApplicationCount->Text()); + int32 folderCount = atoi(fMenuRecentFolderCount->Text()); + + if (docCount <= 0 || fMenuRecentDocuments->Value() == false) + message.AddInt32("documents", 0); + else + message.AddInt32("documents", docCount); + + if (appCount <= 0 || fMenuRecentApplications->Value() == false) + message.AddInt32("applications", 0); + else + message.AddInt32("applications", appCount); + + if (folderCount <= 0 || fMenuRecentFolders->Value() == false) + message.AddInt32("folders", 0); + else + message.AddInt32("folders", folderCount); + + be_app->PostMessage(&message); + + _EnableDisableDependentItems(); +} + + +void +PreferencesWindow::_EnableDisableDependentItems() +{ + if (fAppsShowExpanders->Value()) + fAppsExpandNew->SetEnabled(true); + else + fAppsExpandNew->SetEnabled(false); + + if (fMenuRecentDocuments->Value()) + fMenuRecentDocumentCount->SetEnabled(true); + else + fMenuRecentDocumentCount->SetEnabled(false); + + if (fMenuRecentApplications->Value()) + fMenuRecentApplicationCount->SetEnabled(true); + else + fMenuRecentApplicationCount->SetEnabled(false); + + if (fMenuRecentFolders->Value()) + fMenuRecentFolderCount->SetEnabled(true); + else + fMenuRecentFolderCount->SetEnabled(false); +} + + +void +PreferencesWindow::WindowActivated(bool active) +{ + if (!active && IsMinimized()) + PostMessage(B_QUIT_REQUESTED); +} + diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h new file mode 100644 index 0000000000..0d3928c7fe --- /dev/null +++ b/src/apps/deskbar/PreferencesWindow.h @@ -0,0 +1,65 @@ +/* + * Copyright 2009 Haiku, Inc. + * All Rights Reserved. Distributed under the terms of the MIT License. + */ +#ifndef _PREFERENCES_WINDOW_H +#define _PREFERENCES_WINDOW_H + + +#include +#include +#include +#include +#include +#include +#include + + +const uint32 kConfigShow = 'show'; +const uint32 kConfigClose = 'canc'; +const uint32 kUpdateRecentCounts = 'upct'; +const uint32 kEditMenuInTracker = 'mtrk'; + + +class PreferencesWindow : public BWindow +{ +public: + PreferencesWindow(BRect frame); + ~PreferencesWindow(); + + virtual void MessageReceived(BMessage* message); + virtual void WindowActivated(bool active); + +private: + void _UpdateRecentCounts(); + void _EnableDisableDependentItems(); + + BBox* fMenuBox; + BBox* fAppsBox; + BBox* fClockBox; + BBox* fWindowBox; + + BCheckBox* fMenuRecentDocuments; + BCheckBox* fMenuRecentApplications; + BCheckBox* fMenuRecentFolders; + + BTextControl* fMenuRecentDocumentCount; + BTextControl* fMenuRecentApplicationCount; + BTextControl* fMenuRecentFolderCount; + + BCheckBox* fAppsSort; + BCheckBox* fAppsSortTrackerFirst; + BCheckBox* fAppsShowExpanders; + BCheckBox* fAppsExpandNew; + + BCheckBox* fClock24Hours; + BCheckBox* fClockSeconds; + BCheckBox* fClockEuropeanDate; + BCheckBox* fClockFullDate; + + BCheckBox* fWindowAlwaysOnTop; + BCheckBox* fWindowAutoRaise; +}; + +#endif // _PREFERENCES_WINDOW_H + diff --git a/src/preferences/Jamfile b/src/preferences/Jamfile index a864a66297..2b68b2f49c 100644 --- a/src/preferences/Jamfile +++ b/src/preferences/Jamfile @@ -5,6 +5,7 @@ SubInclude HAIKU_TOP src preferences backgrounds ; SubInclude HAIKU_TOP src preferences bluetooth ; SubInclude HAIKU_TOP src preferences cpufrequency ; SubInclude HAIKU_TOP src preferences datatranslations ; +SubInclude HAIKU_TOP src preferences deskbar ; SubInclude HAIKU_TOP src preferences devices ; #SubInclude HAIKU_TOP src preferences dun ; SubInclude HAIKU_TOP src preferences filetypes ; @@ -26,3 +27,4 @@ SubInclude HAIKU_TOP src preferences time ; SubInclude HAIKU_TOP src preferences touchpad ; SubInclude HAIKU_TOP src preferences tracker ; SubInclude HAIKU_TOP src preferences virtualmemory ; + diff --git a/src/preferences/deskbar/DeskbarPreferences.cpp b/src/preferences/deskbar/DeskbarPreferences.cpp new file mode 100644 index 0000000000..49213add32 --- /dev/null +++ b/src/preferences/deskbar/DeskbarPreferences.cpp @@ -0,0 +1,23 @@ +/* + * Copyright 2009, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jonas Sundström, jonas@kirilla.com + */ + + +#include "PreferencesWindow.h" + +#include +#include + + +int +main(int argc, char **argv) +{ + BApplication app("application/x-vnd.Haiku-DeskbarPreferences"); + be_roster->Launch("application/x-vnd.Be-TSKB", new BMessage(kConfigShow)); + return 0; +} + diff --git a/src/preferences/deskbar/DeskbarPreferences.rdef b/src/preferences/deskbar/DeskbarPreferences.rdef new file mode 100644 index 0000000000..3beb720256 --- /dev/null +++ b/src/preferences/deskbar/DeskbarPreferences.rdef @@ -0,0 +1,59 @@ + +resource app_signature "application/x-vnd.Haiku-DeskbarPreferences"; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + /* 0 = development 1 = alpha 2 = beta + 3 = gamma 4 = golden master 5 = final */ + variety = 0, + + internal = 0, + + short_info = "Deskbar Preferences", + long_info = "Deskbar Preferences ©2009 Haiku Inc." +}; + +resource app_flags B_SINGLE_LAUNCH | B_BACKGROUND_APP; + +resource vector_icon { + $"6E6369661C050004006B020006023A498437D931BA09203C6B6D4B49E74A11B7" + $"01663300FF9B663203603307020006023393B0B84A2E3B59D6369E0646DFD84A" + $"A888007C3F03FF66330003CB986702000602B2F596355C9ABD515DBAEBB14A33" + $"354A96BF00A8733FFFD69E6803986432020006023E20000000000000003D8000" + $"49C00046000000FFEDDCFFFFCB98020006023A498437D931BA09203C6B6D4B39" + $"E749636E0089511AFF98622D05FF020116023C0F0A0000000000003C2F0A4AB5" + $"5C4766660080FF000201160338A28F00000000000038228F4AE1D748575C00FF" + $"54FFFF80020016023400000000000000003800004B0000478D1E00FFFF800201" + $"06023C7FE93652B8B419503A42244A941840DDAF0000FF00FF108E35050003EC" + $"666603FFACAC02000602391C19387422BA98E03B4AAA4B7CB44814B800A3043C" + $"FFFF90AF0500020016023B36393B4D9CBB8E093B74DE49CD5749A86B00EDFFA5" + $"05FF0200160232A2B43A4A46BDFF62364CDF49944E49622E0091FFB502001602" + $"3A77F53CD3D5BF3B3C3CD23D4AD98548BAB300FFFFE90200060234298D3A09A0" + $"BB2AE6355C88480B804842B500FFEA00FFFFB8300381A4E40200060239F67037" + $"5210BA15E43C7D2149DBC6B9D8AC00E3EDFFFF9EC2FF030039B01C0A032E5438" + $"54384A0A0746605A4A5A47604A5A5258524C6008092638264E2E52364A3A4C3A" + $"58465E5A495A390A062234223748485E375E3438280A04465E5A495A3846490A" + $"05382822344844C5C2BF4AC878B9F20A032E462E52364A0A083A5846CBAD46C2" + $"8926BD5B264E2E522E463AC4870A04465446523A4C3A4E0A0428C2772CC3432C" + $"C42728C35B0A0429C38E2CC4272CC4A529C40C0A04484448485E375E340A0422" + $"342237484848440A074E3EC631BEF95E34C887B9F73E363E3B463B0A062E282E" + $"343A394232422636B3F20A042E282E343A393A2C0A042E283A2C422636B3F20A" + $"043A2C3A39423242260A06422C42384E3D5636562A4AB58A0A04422C42384E3D" + $"4E300A04422C4E30562A4AB58A0A044E304E3D5636562A0A0622483A523A392C" + $"352C30222E0A04223222483A523A390A06374D25462447384F383B373D0A0624" + $"35244725462537373D383B0A0425372546374D373D0A04222E22332C362C302D" + $"0A01020100000A0001021001178400040A020104000A040106000A060107000A" + $"070108000A03010928362215FF0A03010928362C15FF0A08010A28362215FF0A" + $"08010A28362C15FF0A0001031815FF01178400040A0001031800150117860004" + $"0A080105000A05010C000A09010B000A0500000A0A00000A0000000A0400000A" + $"05010D000A0B001001178400040A0C00000A0D00000A00001815FF0117840204" + $"0A000018001501178502040A0E00000A0F010E1001178400040A19010F000A1B" + $"0111000A1A0110000A0F01121001178400040A100113000A120115000A110114" + $"000A13011630241801178402040A1401172024180A1501182024180A16011920" + $"24180A18011B2024180A1301161001178402040A140117000A150118000A1601" + $"19000A17011A000A18011B00" +}; + diff --git a/src/preferences/deskbar/Jamfile b/src/preferences/deskbar/Jamfile new file mode 100644 index 0000000000..d8156a32aa --- /dev/null +++ b/src/preferences/deskbar/Jamfile @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src preferences deskbar ; + +SubDirSysHdrs $(HAIKU_TOP) src apps deskbar ; + +Preference Deskbar : + DeskbarPreferences.cpp + : be + : DeskbarPreferences.rdef + ; +