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)
{
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) {
if (!lock.IsLocked())
return;
for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) {
struct AddOnShortcut* item = fAddOnsList->ItemAt(i);
bool primary = false;
@@ -2943,7 +2945,6 @@ BContainerWindow::EachAddOn(bool (*eachAddOn)(const Model*, const char*,
((eachAddOn)(item->model, item->model->Name(), item->key,
item->modifiers, primary, passThru, this, menu));
}
}
}
+4 -10
View File
@@ -186,14 +186,7 @@ public:
static bool DefaultStateSourceNode(const char* name, BNode* result,
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);
entry_ref GetCurrentDirRef();
BPopUpMenu* ContextMenu();
// drag&drop support
@@ -274,11 +267,12 @@ protected:
BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32,
const char*);
bool EachAddOn(BPath &path,
bool (*)(const Model*, const char*, uint32, bool, void*),
BObjectList<Model>*, void*, BStringList&);
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;
uint32 fOpenFlags;
bool fUsesLayout;
+12 -12
View File
@@ -263,7 +263,9 @@ void
BDeskWindow::InitAddOnsList(bool update)
{
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) {
if (!lock.IsLocked())
return;
if (update) {
for (int i = fAddOnsList->CountItems() - 1; i >= 0; i--) {
AddOnShortcut* item = fAddOnsList->ItemAt(i);
@@ -276,11 +278,8 @@ BDeskWindow::InitAddOnsList(bool update)
BPathFinder::FindPaths(B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker",
addOnPaths);
int32 count = addOnPaths.CountStrings();
for (int32 i = 0; i < count; i++) {
LoadAddOnDir(BDirectory(addOnPaths.StringAt(i)), this,
fAddOnsList);
}
}
for (int32 i = 0; i < count; i++)
LoadAddOnDir(BDirectory(addOnPaths.StringAt(i)), this, fAddOnsList);
}
@@ -288,7 +287,9 @@ void
BDeskWindow::ApplyShortcutPreferences(bool update)
{
AutoLock<LockingList<AddOnShortcut> > lock(fAddOnsList);
if (lock.IsLocked()) {
if (!lock.IsLocked())
return;
if (!update) {
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
@@ -315,7 +316,9 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
BMessage message;
while (fileMsg.FindMessage("spec", i++, &message) == B_OK) {
int32 key;
if (message.FindInt32("key", &key) == B_OK) {
if (message.FindInt32("key", &key) != B_OK)
continue;
// only handle shortcuts referring add-ons
BString command;
if (message.FindString("command", &command) != B_OK)
@@ -358,8 +361,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
modifiers |= (value != 0 ? B_OPTION_KEY : 0);
Model model(&entry);
AddOnShortcut* item = fAddOnsList->EachElement(FindElement,
&model);
AddOnShortcut* item = fAddOnsList->EachElement(FindElement, &model);
if (item != NULL) {
if (item->key != '\0')
RemoveShortcut(item->key, item->modifiers);
@@ -369,8 +371,6 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
AddOneShortcut(&model, item->key, item->modifiers, this);
}
}
}
}
}