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:
Ingo Weinhold
2013-06-29 14:58:52 +02:00
parent dbd97804ea
commit 26ea70667a
13 changed files with 121 additions and 81 deletions
-39
View File
@@ -211,45 +211,6 @@ AddDirectoryToHaikuImage home mail out ;
# global settings when a package is installed in ~/config # global settings when a package is installed in ~/config
AddDirectoryToHaikuImage home config settings global ; AddDirectoryToHaikuImage home config settings global ;
# Deskbar Application links
AddDirectoryToHaikuImage home config settings deskbar menu Applications ;
DESKBAR_APPLICATIONS = ActivityMonitor CharacterMap CodyCam CDPlayer DeskCalc
Devices DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer
Magnify Mail MediaConverter MediaPlayer MidiPlayer People PoorMan
Screenshot SoundRecorder StyledEdit Terminal TV
;
local linkTarget ;
for linkTarget in $(DESKBAR_APPLICATIONS) {
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/system/apps/$(linkTarget) : $(linkTarget) ;
}
# Deskbar Desktop applets links
AddDirectoryToHaikuImage home config settings deskbar menu Desktop\ applets ;
DESKBAR_DESKTOP_APPLETS = LaunchBox NetworkStatus PowerStatus ProcessController
Workspaces
;
for linkTarget in $(DESKBAR_DESKTOP_APPLETS) {
AddSymlinkToHaikuImage home config settings deskbar menu Desktop\ applets
: /boot/system/apps/$(linkTarget) : $(linkTarget) ;
}
# Deskbar Preferences links
AddDirectoryToHaikuImage home config settings deskbar menu Preferences ;
DESKBAR_PREFERENCES = $(SYSTEM_PREFERENCES:B) ;
for linkTarget in $(DESKBAR_PREFERENCES) {
AddSymlinkToHaikuImage home config settings deskbar menu Preferences
: /boot/system/preferences/$(linkTarget)
: $(linkTarget) ;
}
# Deskbar Demo links
AddDirectoryToHaikuImage home config settings deskbar menu Demos ;
for linkTarget in $(SYSTEM_DEMOS) {
AddSymlinkToHaikuImage home config settings deskbar menu Demos
: /boot/system/demos/$(linkTarget) : $(linkTarget) ;
}
# scripts and data files # scripts and data files
local userBootScripts = UserBootscript UserSetupEnvironment.sample ; local userBootScripts = UserBootscript UserSetupEnvironment.sample ;
-14
View File
@@ -300,8 +300,6 @@ if [ IsOptionalHaikuImagePackageAdded BePDF ] {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/bepdf-1.1.1~beta5_2013_04_28-1-x86_gcc2.hpkg ; $(hpkgBaseURL)/bepdf-1.1.1~beta5_2013_04_28-1-x86_gcc2.hpkg ;
} }
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/common/apps/BePDF/BePDF ;
} }
} }
@@ -318,8 +316,6 @@ if [ IsOptionalHaikuImagePackageAdded BeZillaBrowser ] {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/bezillabrowser-2.0.0.22pre_2010_05_02-1-x86_gcc2.hpkg ; $(hpkgBaseURL)/bezillabrowser-2.0.0.22pre_2010_05_02-1-x86_gcc2.hpkg ;
} }
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/common/apps/BeZillaBrowser/BeZillaBrowser ;
} }
} }
@@ -630,8 +626,6 @@ if [ IsOptionalHaikuImagePackageAdded DemoPackage_Video ] {
# Development # Development
if [ IsOptionalHaikuImagePackageAdded Development ] { if [ IsOptionalHaikuImagePackageAdded Development ] {
if $(TARGET_ARCH) = x86 { if $(TARGET_ARCH) = x86 {
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/system/apps/Debugger : Debugger ;
# autotools # autotools
if $(HAIKU_GCC_VERSION[1]) >= 4 { if $(HAIKU_GCC_VERSION[1]) >= 4 {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
@@ -1151,8 +1145,6 @@ if [ IsOptionalHaikuImagePackageAdded KeymapSwitcher ] {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/keymapswitcher-1.2.7.10-1-x86_gcc2.hpkg ; $(hpkgBaseURL)/keymapswitcher-1.2.7.10-1-x86_gcc2.hpkg ;
} }
AddSymlinkToHaikuImage home config settings deskbar menu Preferences
: /boot/common/bin/KeymapSwitcher ;
} else if $(TARGET_ARCH) = x86_64 { } else if $(TARGET_ARCH) = x86_64 {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(baseURL)/KeymapSwitcher-1.2.7-x86_64-2013-01-08.zip $(baseURL)/KeymapSwitcher-1.2.7-x86_64-2013-01-08.zip
@@ -1668,8 +1660,6 @@ if [ IsOptionalHaikuImagePackageAdded Pe ] {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/pe-2.4.3_hg602-4-x86_gcc2.hpkg ; $(hpkgBaseURL)/pe-2.4.3_hg602-4-x86_gcc2.hpkg ;
} }
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/common/apps/Pe/Pe ;
} }
} }
@@ -2016,8 +2006,6 @@ if [ IsOptionalHaikuImagePackageAdded Vision ] {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/vision-0.9.7.r944-1-x86_gcc2.hpkg ; $(hpkgBaseURL)/vision-0.9.7.r944-1-x86_gcc2.hpkg ;
} }
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/common/apps/Vision/Vision ;
} }
} }
@@ -2132,8 +2120,6 @@ if [ IsOptionalHaikuImagePackageAdded WonderBrush ] {
} else { } else {
InstallOptionalHaikuImagePackage InstallOptionalHaikuImagePackage
$(hpkgBaseURL)/wonderbrush-2.1.2-3-x86_gcc2.hpkg ; $(hpkgBaseURL)/wonderbrush-2.1.2-3-x86_gcc2.hpkg ;
AddSymlinkToHaikuImage home config settings deskbar menu Applications
: /boot/common/apps/WonderBrush/WonderBrush ;
} }
} }
+43
View File
@@ -315,6 +315,49 @@ AddFilesToPackage add-ons disk_systems
CopyDirectoryToPackage data : <mimedb>mime_db : : : isTarget ; CopyDirectoryToPackage data : <mimedb>mime_db : : : isTarget ;
# Deskbar menu symlinks
# "Applications" links
DESKBAR_APPLICATIONS = ActivityMonitor CharacterMap CodyCam CDPlayer DeskCalc
Devices DiskProbe DriveSetup DiskUsage Expander Icon-O-Matic Installer
Magnify Mail MediaConverter MediaPlayer MidiPlayer People PoorMan
Screenshot SoundRecorder StyledEdit Terminal TV
;
local linkTarget ;
for linkTarget in $(DESKBAR_APPLICATIONS) {
AddSymlinkToPackage data deskbar menu Applications
: ../../../../apps/$(linkTarget) : $(linkTarget) ;
}
# "Desktop applets" links
DESKBAR_DESKTOP_APPLETS = LaunchBox NetworkStatus PowerStatus ProcessController
Workspaces
;
for linkTarget in $(DESKBAR_DESKTOP_APPLETS) {
AddSymlinkToPackage data deskbar menu Desktop\ applets
: ../../../../apps/$(linkTarget) : $(linkTarget) ;
}
# "Preferences" links
AddDirectoryToPackage data deskbar menu Preferences ;
DESKBAR_PREFERENCES = $(SYSTEM_PREFERENCES:B) ;
for linkTarget in $(DESKBAR_PREFERENCES) {
AddSymlinkToPackage data deskbar menu Preferences
: ../../../../preferences/$(linkTarget)
: $(linkTarget) ;
}
# "Demo" links
AddDirectoryToPackage data deskbar menu Demos ;
for linkTarget in $(SYSTEM_DEMOS) {
AddSymlinkToPackage data deskbar menu Demos
: ../../../../demos/$(linkTarget) : $(linkTarget) ;
}
# Deskbar menu entries file
AddFilesToPackage data deskbar : <deskbar>menu_entries ;
# optional # optional
# TODO: We should probably build another package (including the data files # TODO: We should probably build another package (including the data files
# above) that can be installed, if desired. # above) that can be installed, if desired.
+4
View File
@@ -89,4 +89,8 @@ if $(TARGET_ARCH) = x86 {
: $(mesaGlHeaders) : : : isTarget ; : $(mesaGlHeaders) : : : isTarget ;
} }
# Deskbar menu symlinks
AddSymlinkToPackage data deskbar menu Applications
: ../../../../apps/Debugger : Debugger ;
BuildHaikuPackage $(haikuDevelPackage) : haiku_devel ; BuildHaikuPackage $(haikuDevelPackage) : haiku_devel ;
+3 -3
View File
@@ -266,13 +266,13 @@ TBarApp::InitSettings()
clock.showTimeZone = false; clock.showTimeZone = false;
BPath dirPath; BPath dirPath;
const char* settingsFileName = "Deskbar_settings"; const char* settingsFileName = "settings";
const char* clockSettingsFileName = "Deskbar_clock_settings"; const char* clockSettingsFileName = "clock_settings";
find_directory(B_USER_DESKBAR_DIRECTORY, &dirPath, true); find_directory(B_USER_DESKBAR_DIRECTORY, &dirPath, true);
// just make it // just make it
if (find_directory(B_USER_SETTINGS_DIRECTORY, &dirPath, true) == B_OK) { if (GetDeskbarSettingsDirectory(dirPath, true) == B_OK) {
BPath filePath = dirPath; BPath filePath = dirPath;
filePath.Append(settingsFileName); filePath.Append(settingsFileName);
fSettingsFile = new BFile(filePath.Path(), O_RDWR); fSettingsFile = new BFile(filePath.Path(), O_RDWR);
+12 -18
View File
@@ -54,6 +54,7 @@ All rights reserved.
#include "BarApp.h" #include "BarApp.h"
#include "BarMenuBar.h" #include "BarMenuBar.h"
#include "BarView.h" #include "BarView.h"
#include "DeskbarUtils.h"
#include "DeskbarMenu.h" #include "DeskbarMenu.h"
#include "PublicCommands.h" #include "PublicCommands.h"
#include "StatusView.h" #include "StatusView.h"
@@ -115,27 +116,20 @@ TBarWindow::MenusBeginning()
{ {
BPath path; BPath path;
entry_ref ref; entry_ref ref;
BEntry entry;
find_directory (B_USER_DESKBAR_DIRECTORY, &path); if (GetDeskbarSettingsDirectory(path) == B_OK
get_ref_for_path(path.Path(), &ref); && path.Append(kDeskbarMenuEntriesFileName) == B_OK
&& entry.SetTo(path.Path(), true) == B_OK
BEntry entry(&ref, true); && entry.Exists()
if (entry.InitCheck() == B_OK && entry.IsDirectory()) { && entry.GetRef(&ref) == B_OK) {
// need the entry_ref to the actual item
entry.GetRef(&ref);
// set the nav directory to the deskbar folder
sDeskbarMenu->SetNavDir(&ref); sDeskbarMenu->SetNavDir(&ref);
} else if (!entry.Exists()) { } else if (GetDeskbarDataDirectory(path) == B_OK
// the deskbar folder does not exist && path.Append(kDeskbarMenuEntriesFileName) == B_OK
// create one now && entry.SetTo(path.Path(), true) == B_OK
BDirectory dir; && entry.Exists()
if (entry.GetParent(&dir) == B_OK) { && entry.GetRef(&ref) == B_OK) {
BDirectory deskbarDir;
dir.CreateDirectory("deskbar", &deskbarDir);
if (deskbarDir.GetEntry(&entry) == B_OK
&& entry.GetRef(&ref) == B_OK)
sDeskbarMenu->SetNavDir(&ref); sDeskbarMenu->SetNavDir(&ref);
}
} else { } else {
// this really should never happen // this really should never happen
TRESPASS(); TRESPASS();
+31
View File
@@ -56,6 +56,11 @@ All rights reserved.
#include "ExpandoMenuBar.h" #include "ExpandoMenuBar.h"
const char* const kDeskbarMenuEntriesFileName = "menu_entries";
static const char* const kDeskbarDirectoryName = "deskbar";
void void
AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory) 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);
}
+7
View File
@@ -43,7 +43,14 @@ All rights reserved.
class BMessage; class BMessage;
extern const char* const kDeskbarMenuEntriesFileName;
void AddRefsToDeskbarMenu(const BMessage* m, entry_ref* subdirectory); 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 */ #endif /* DB_UTILS_H */
+3 -2
View File
@@ -35,13 +35,14 @@
#include <View.h> #include <View.h>
#include "BarApp.h" #include "BarApp.h"
#include "DeskbarUtils.h"
#include "StatusView.h" #include "StatusView.h"
static const float kIndentSpacing static const float kIndentSpacing
= be_control_look->DefaultItemSpacing() * 2.3; = be_control_look->DefaultItemSpacing() * 2.3;
static const uint32 kSettingsViewChanged = 'Svch'; static const uint32 kSettingsViewChanged = 'Svch';
static const char* kSettingsFileName = "Deskbar_prefs_window_settings"; static const char* kSettingsFileName = "prefs_window_settings";
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@@ -418,7 +419,7 @@ status_t
PreferencesWindow::_InitSettingsFile(BFile* file, bool write) PreferencesWindow::_InitSettingsFile(BFile* file, bool write)
{ {
BPath prefsPath; BPath prefsPath;
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &prefsPath); status_t status = GetDeskbarSettingsDirectory(prefsPath);
if (status != B_OK) if (status != B_OK)
return status; return status;
+3 -4
View File
@@ -86,7 +86,7 @@ using std::max;
const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item"; const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item";
const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry"; const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry";
const char* const kReplicantSettingsFile = "Deskbar_replicants"; const char* const kReplicantSettingsFile = "replicants";
const char* const kReplicantPathField = "replicant_path"; const char* const kReplicantPathField = "replicant_path";
float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth; float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth;
@@ -467,7 +467,7 @@ TReplicantTray::InitAddOnSupport()
fItemList = new BList(); fItemList = new BList();
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { if (GetDeskbarSettingsDirectory(path, true) == B_OK) {
path.Append(kReplicantSettingsFile); path.Append(kReplicantSettingsFile);
BFile file(path.Path(), B_READ_ONLY); BFile file(path.Path(), B_READ_ONLY);
@@ -1259,8 +1259,7 @@ TReplicantTray::_SaveSettings()
{ {
status_t result; status_t result;
BPath path; BPath path;
if ((result = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)) if ((result = GetDeskbarSettingsDirectory(path, true)) == B_OK) {
== B_OK) {
path.Append(kReplicantSettingsFile); path.Append(kReplicantSettingsFile);
BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
+1
View File
@@ -1,5 +1,6 @@
SubDir HAIKU_TOP src data ; SubDir HAIKU_TOP src data ;
HaikuSubInclude deskbar ;
HaikuSubInclude etc ; HaikuSubInclude etc ;
HaikuSubInclude keymaps ; HaikuSubInclude keymaps ;
HaikuSubInclude mime_db ; HaikuSubInclude mime_db ;
+6
View File
@@ -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 ;
+7
View File
@@ -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