Tracker: Code cleanup around add-ons.

Mostly de-indents and some shuffling in headers.
No functional change intended.
This commit is contained in:
Augustin Cavalier
2024-06-26 16:37:26 -04:00
parent 28748463d9
commit 1a3dae790e
3 changed files with 130 additions and 135 deletions
+3 -2
View File
@@ -2897,7 +2897,9 @@ BContainerWindow::EachAddOn(bool (*eachAddOn)(const Model*, const char*,
void* passThru, BStringList& mimeTypes, BMenu* menu) void* passThru, BStringList& mimeTypes, BMenu* menu)
{ {
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList); AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) { if (!lock.IsLocked())
return;
for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) { for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) {
struct AddOnShortcut* item = fAddOnsList->ItemAt(i); struct AddOnShortcut* item = fAddOnsList->ItemAt(i);
bool primary = false; bool primary = false;
@@ -2943,7 +2945,6 @@ BContainerWindow::EachAddOn(bool (*eachAddOn)(const Model*, const char*,
((eachAddOn)(item->model, item->model->Name(), item->key, ((eachAddOn)(item->model, item->model->Name(), item->key,
item->modifiers, primary, passThru, this, menu)); item->modifiers, primary, passThru, this, menu));
} }
}
} }
+4 -10
View File
@@ -186,14 +186,7 @@ public:
static bool DefaultStateSourceNode(const char* name, BNode* result, static bool DefaultStateSourceNode(const char* name, BNode* result,
bool createNew = false, bool createFolder = true); bool createNew = false, bool createFolder = true);
// add-on iteration
void EachAddOn(bool (*)(const Model*, const char*, uint32 shortcut,
uint32 modifiers, bool primary, void*, BContainerWindow*, BMenu*),
void*, BStringList&, BMenu*);
BMessage* AddOnMessage(int32); BMessage* AddOnMessage(int32);
entry_ref GetCurrentDirRef();
BPopUpMenu* ContextMenu(); BPopUpMenu* ContextMenu();
// drag&drop support // drag&drop support
@@ -274,11 +267,12 @@ protected:
BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32, BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32,
const char*); const char*);
bool EachAddOn(BPath &path,
bool (*)(const Model*, const char*, uint32, bool, void*),
BObjectList<Model>*, void*, BStringList&);
void LoadAddOn(BMessage*); void LoadAddOn(BMessage*);
void EachAddOn(bool (*)(const Model*, const char*, uint32 shortcut,
uint32 modifiers, bool primary, void*, BContainerWindow*, BMenu*),
void*, BStringList&, BMenu*);
protected:
LockingList<BWindow>* fWindowList; LockingList<BWindow>* fWindowList;
uint32 fOpenFlags; uint32 fOpenFlags;
bool fUsesLayout; bool fUsesLayout;
+12 -12
View File
@@ -263,7 +263,9 @@ void
BDeskWindow::InitAddOnsList(bool update) BDeskWindow::InitAddOnsList(bool update)
{ {
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList); AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) { if (!lock.IsLocked())
return;
if (update) { if (update) {
for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) { for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) {
AddOnShortcut* item = fAddOnsList->ItemAt(i); AddOnShortcut* item = fAddOnsList->ItemAt(i);
@@ -276,11 +278,8 @@ BDeskWindow::InitAddOnsList(bool update)
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker", BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker",
addOnPaths); addOnPaths);
int32 count = addOnPaths.CountStrings(); int32 count = addOnPaths.CountStrings();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++)
LoadAddOnDir(BDirectory(addOnPaths.StringAt(i)), this, LoadAddOnDir(BDirectory(addOnPaths.StringAt(i)), this, fAddOnsList);
fAddOnsList);
}
}
} }
@@ -288,7 +287,9 @@ void
BDeskWindow::ApplyShortcutPreferences(bool update) BDeskWindow::ApplyShortcutPreferences(bool update)
{ {
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList); AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) { if (!lock.IsLocked())
return;
if (!update) { if (!update) {
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
@@ -315,7 +316,9 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
BMessage message; BMessage message;
while (fileMsg.FindMessage("spec", i++, &message) == B_OK) { while (fileMsg.FindMessage("spec", i++, &message) == B_OK) {
int32 key; int32 key;
if (message.FindInt32("key", &key) == B_OK) { if (message.FindInt32("key", &key) != B_OK)
continue;
// only handle shortcuts referring add-ons // only handle shortcuts referring add-ons
BString command; BString command;
if (message.FindString("command", &command) != B_OK) if (message.FindString("command", &command) != B_OK)
@@ -358,8 +361,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
modifiers |= (value != 0 ? B_OPTION_KEY : 0); modifiers |= (value != 0 ? B_OPTION_KEY : 0);
Model model(&entry); Model model(&entry);
AddOnShortcut* item = fAddOnsList->EachElement(FindElement, AddOnShortcut* item = fAddOnsList->EachElement(FindElement, &model);
&model);
if (item != NULL) { if (item != NULL) {
if (item->key != '\0') if (item->key != '\0')
RemoveShortcut(item->key, item->modifiers); RemoveShortcut(item->key, item->modifiers);
@@ -369,8 +371,6 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
AddOneShortcut(&model, item->key, item->modifiers, this); AddOneShortcut(&model, item->key, item->modifiers, this);
} }
} }
}
}
} }