Deskbar: use a virtual directory for the user-configurable menu
* Deskbar now uses ~/config/settings/deskbar/menu_entries for its menu, falling back to /system/data/deskbar/menu_entries, when the former doesn't exist. The latter always exists and is a virtual directory merging the deskbar/menu subdirectories of ~/config/settings/ and <any installation location>/data/. So, if a package provides a deskbar menu symlink, it is added automatically when the package is activated. The user can add own menu items by putting stuff into ~/config/settings/deskbar/menu/, only use their own organization by symlinking it to menu_entries, or do fun stuff by making menu_entries a customized virtual directory. * HaikuImage: No longer create any deskbar menu symlinks in the user's settings directory. Instead add them to the Haiku package. * OptionalPackages: At least for the optional packages that do have hpkgs, no longer create deskbar menu symlinks in the user's settings directory. * Move all Deskbar settings files to ~/config/settings/deskbar/ and drop the "Deskbar_" prefix.
This commit is contained in:
@@ -266,13 +266,13 @@ TBarApp::InitSettings()
|
||||
clock.showTimeZone = false;
|
||||
|
||||
BPath dirPath;
|
||||
const char* settingsFileName = "Deskbar_settings";
|
||||
const char* clockSettingsFileName = "Deskbar_clock_settings";
|
||||
const char* settingsFileName = "settings";
|
||||
const char* clockSettingsFileName = "clock_settings";
|
||||
|
||||
find_directory(B_USER_DESKBAR_DIRECTORY, &dirPath, true);
|
||||
// just make it
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &dirPath, true) == B_OK) {
|
||||
if (GetDeskbarSettingsDirectory(dirPath, true) == B_OK) {
|
||||
BPath filePath = dirPath;
|
||||
filePath.Append(settingsFileName);
|
||||
fSettingsFile = new BFile(filePath.Path(), O_RDWR);
|
||||
|
||||
@@ -54,6 +54,7 @@ All rights reserved.
|
||||
#include "BarApp.h"
|
||||
#include "BarMenuBar.h"
|
||||
#include "BarView.h"
|
||||
#include "DeskbarUtils.h"
|
||||
#include "DeskbarMenu.h"
|
||||
#include "PublicCommands.h"
|
||||
#include "StatusView.h"
|
||||
@@ -115,27 +116,20 @@ TBarWindow::MenusBeginning()
|
||||
{
|
||||
BPath path;
|
||||
entry_ref ref;
|
||||
BEntry entry;
|
||||
|
||||
find_directory (B_USER_DESKBAR_DIRECTORY, &path);
|
||||
get_ref_for_path(path.Path(), &ref);
|
||||
|
||||
BEntry entry(&ref, true);
|
||||
if (entry.InitCheck() == B_OK && entry.IsDirectory()) {
|
||||
// need the entry_ref to the actual item
|
||||
entry.GetRef(&ref);
|
||||
// set the nav directory to the deskbar folder
|
||||
if (GetDeskbarSettingsDirectory(path) == B_OK
|
||||
&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
|
||||
&& entry.SetTo(path.Path(), true) == B_OK
|
||||
&& entry.Exists()
|
||||
&& entry.GetRef(&ref) == B_OK) {
|
||||
sDeskbarMenu->SetNavDir(&ref);
|
||||
} else if (GetDeskbarDataDirectory(path) == B_OK
|
||||
&& path.Append(kDeskbarMenuEntriesFileName) == B_OK
|
||||
&& entry.SetTo(path.Path(), true) == B_OK
|
||||
&& entry.Exists()
|
||||
&& entry.GetRef(&ref) == B_OK) {
|
||||
sDeskbarMenu->SetNavDir(&ref);
|
||||
} else if (!entry.Exists()) {
|
||||
// the deskbar folder does not exist
|
||||
// create one now
|
||||
BDirectory dir;
|
||||
if (entry.GetParent(&dir) == B_OK) {
|
||||
BDirectory deskbarDir;
|
||||
dir.CreateDirectory("deskbar", &deskbarDir);
|
||||
if (deskbarDir.GetEntry(&entry) == B_OK
|
||||
&& entry.GetRef(&ref) == B_OK)
|
||||
sDeskbarMenu->SetNavDir(&ref);
|
||||
}
|
||||
} else {
|
||||
// this really should never happen
|
||||
TRESPASS();
|
||||
|
||||
@@ -56,6 +56,11 @@ All rights reserved.
|
||||
#include "ExpandoMenuBar.h"
|
||||
|
||||
|
||||
const char* const kDeskbarMenuEntriesFileName = "menu_entries";
|
||||
|
||||
static const char* const kDeskbarDirectoryName = "deskbar";
|
||||
|
||||
|
||||
void
|
||||
AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory)
|
||||
{
|
||||
@@ -102,3 +107,29 @@ AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetDeskbarSettingsDirectory(BPath& _path, bool create)
|
||||
{
|
||||
status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &_path, create);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
error = _path.Append(kDeskbarDirectoryName);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
return create ? create_directory(_path.Path(), 0755) : error;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetDeskbarDataDirectory(BPath& _path)
|
||||
{
|
||||
status_t error = find_directory(B_SYSTEM_DATA_DIRECTORY, &_path, false);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
return _path.Append(kDeskbarDirectoryName);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,14 @@ All rights reserved.
|
||||
|
||||
class BMessage;
|
||||
|
||||
|
||||
extern const char* const kDeskbarMenuEntriesFileName;
|
||||
|
||||
|
||||
void AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory);
|
||||
|
||||
status_t GetDeskbarSettingsDirectory(BPath& _path, bool create = false);
|
||||
status_t GetDeskbarDataDirectory(BPath& _path);
|
||||
|
||||
|
||||
#endif /* DB_UTILS_H */
|
||||
|
||||
@@ -35,13 +35,14 @@
|
||||
#include <View.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "DeskbarUtils.h"
|
||||
#include "StatusView.h"
|
||||
|
||||
|
||||
static const float kIndentSpacing
|
||||
= be_control_look->DefaultItemSpacing() * 2.3;
|
||||
static const uint32 kSettingsViewChanged = 'Svch';
|
||||
static const char* kSettingsFileName = "Deskbar_prefs_window_settings";
|
||||
static const char* kSettingsFileName = "prefs_window_settings";
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
@@ -418,7 +419,7 @@ status_t
|
||||
PreferencesWindow::_InitSettingsFile(BFile* file, bool write)
|
||||
{
|
||||
BPath prefsPath;
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &prefsPath);
|
||||
status_t status = GetDeskbarSettingsDirectory(prefsPath);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ using std::max;
|
||||
|
||||
const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item";
|
||||
const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry";
|
||||
const char* const kReplicantSettingsFile = "Deskbar_replicants";
|
||||
const char* const kReplicantSettingsFile = "replicants";
|
||||
const char* const kReplicantPathField = "replicant_path";
|
||||
|
||||
float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth;
|
||||
@@ -467,7 +467,7 @@ TReplicantTray::InitAddOnSupport()
|
||||
fItemList = new BList();
|
||||
BPath path;
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
|
||||
if (GetDeskbarSettingsDirectory(path, true) == B_OK) {
|
||||
path.Append(kReplicantSettingsFile);
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
@@ -1259,8 +1259,7 @@ TReplicantTray::_SaveSettings()
|
||||
{
|
||||
status_t result;
|
||||
BPath path;
|
||||
if ((result = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true))
|
||||
== B_OK) {
|
||||
if ((result = GetDeskbarSettingsDirectory(path, true)) == B_OK) {
|
||||
path.Append(kReplicantSettingsFile);
|
||||
|
||||
BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
SubDir HAIKU_TOP src data ;
|
||||
|
||||
HaikuSubInclude deskbar ;
|
||||
HaikuSubInclude etc ;
|
||||
HaikuSubInclude keymaps ;
|
||||
HaikuSubInclude mime_db ;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
SubDir HAIKU_TOP src data deskbar ;
|
||||
|
||||
local deskbarMenuEntries = <deskbar>menu_entries ;
|
||||
MakeLocateCommonPlatform $(deskbarMenuEntries) ;
|
||||
File $(deskbarMenuEntries) : menu_entries ;
|
||||
SetType $(deskbarMenuEntries) : application/x-vnd.haiku-virtual-directory ;
|
||||
@@ -0,0 +1,7 @@
|
||||
directory /boot/home/config/settings/deskbar/menu
|
||||
directory /boot/home/config/non-packaged/data/deskbar/menu
|
||||
directory /boot/home/config/data/deskbar/menu
|
||||
directory /boot/common/non-packaged/data/deskbar/menu
|
||||
directory /boot/common/data/deskbar/menu
|
||||
directory /boot/system/data/deskbar/menu
|
||||
|
||||
Reference in New Issue
Block a user