Make Tracker MIME type add-ons list a BStringList
This commit is contained in:
@@ -291,19 +291,20 @@ OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AddMimeTypeString(BObjectList<BString>& list, Model* model)
|
AddMimeTypeString(BStringList& list, Model* model)
|
||||||
{
|
{
|
||||||
const char* modelMimeType = model->MimeType();
|
if (model == NULL)
|
||||||
if (modelMimeType != NULL && *modelMimeType != '\0') {
|
return;
|
||||||
// only add the type if it's not already there
|
|
||||||
for (int32 i = list.CountItems(); i-- > 0;) {
|
|
||||||
BString* string = list.ItemAt(i);
|
|
||||||
if (string != NULL && string->ICompare(modelMimeType) == 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.AddItem(new BString(modelMimeType));
|
const char* modelMimeType = model->MimeType();
|
||||||
}
|
if (modelMimeType == NULL || *modelMimeType == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
|
BString type = BString(modelMimeType);
|
||||||
|
if (list.HasString(type, true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
list.Add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3004,7 +3005,7 @@ BContainerWindow::AddTrashContextMenus(BMenu* menu)
|
|||||||
void
|
void
|
||||||
BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*,
|
BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*,
|
||||||
uint32 shortcut, uint32 modifiers, bool primary, void* context),
|
uint32 shortcut, uint32 modifiers, bool primary, void* context),
|
||||||
void* passThru, BObjectList<BString> &mimeTypes)
|
void* passThru, BStringList& mimeTypes)
|
||||||
{
|
{
|
||||||
AutoLock<LockingList<AddonShortcut> > lock(fAddonsList);
|
AutoLock<LockingList<AddonShortcut> > lock(fAddonsList);
|
||||||
if (lock.IsLocked()) {
|
if (lock.IsLocked()) {
|
||||||
@@ -3012,7 +3013,7 @@ BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*,
|
|||||||
struct AddonShortcut* item = fAddonsList->ItemAt(i);
|
struct AddonShortcut* item = fAddonsList->ItemAt(i);
|
||||||
bool primary = false;
|
bool primary = false;
|
||||||
|
|
||||||
if (mimeTypes.CountItems()) {
|
if (mimeTypes.CountStrings() > 0) {
|
||||||
BFile file(item->model->EntryRef(), B_READ_ONLY);
|
BFile file(item->model->EntryRef(), B_READ_ONLY);
|
||||||
if (file.InitCheck() == B_OK) {
|
if (file.InitCheck() == B_OK) {
|
||||||
BAppFileInfo info(&file);
|
BAppFileInfo info(&file);
|
||||||
@@ -3022,20 +3023,21 @@ BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*,
|
|||||||
// does this add-on has types set at all?
|
// does this add-on has types set at all?
|
||||||
BMessage message;
|
BMessage message;
|
||||||
if (info.GetSupportedTypes(&message) == B_OK) {
|
if (info.GetSupportedTypes(&message) == B_OK) {
|
||||||
type_code type;
|
type_code typeCode;
|
||||||
int32 count;
|
int32 count;
|
||||||
if (message.GetInfo("types", &type,
|
if (message.GetInfo("types", &typeCode,
|
||||||
&count) == B_OK)
|
&count) == B_OK) {
|
||||||
secondary = false;
|
secondary = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check all supported types if it has some set
|
// check all supported types if it has some set
|
||||||
if (!secondary) {
|
if (!secondary) {
|
||||||
for (int32 i = mimeTypes.CountItems();
|
for (int32 i = mimeTypes.CountStrings();
|
||||||
!primary && i-- > 0;) {
|
!primary && i-- > 0;) {
|
||||||
BString* type = mimeTypes.ItemAt(i);
|
BString type = mimeTypes.StringAt(i);
|
||||||
if (info.IsSupportedType(type->String())) {
|
if (info.IsSupportedType(type.String())) {
|
||||||
BMimeType mimeType(type->String());
|
BMimeType mimeType(type.String());
|
||||||
if (info.Supports(&mimeType))
|
if (info.Supports(&mimeType))
|
||||||
primary = true;
|
primary = true;
|
||||||
else
|
else
|
||||||
@@ -3057,7 +3059,7 @@ BContainerWindow::EachAddon(bool (*eachAddon)(const Model*, const char*,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BContainerWindow::BuildMimeTypeList(BObjectList<BString>& mimeTypes)
|
BContainerWindow::BuildMimeTypeList(BStringList& mimeTypes)
|
||||||
{
|
{
|
||||||
int32 count = PoseView()->SelectionList()->CountItems();
|
int32 count = PoseView()->SelectionList()->CountItems();
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
@@ -3111,7 +3113,7 @@ BContainerWindow::BuildAddOnMenu(BMenu* menu)
|
|||||||
|
|
||||||
BObjectList<BMenuItem> primaryList;
|
BObjectList<BMenuItem> primaryList;
|
||||||
BObjectList<BMenuItem> secondaryList;
|
BObjectList<BMenuItem> secondaryList;
|
||||||
BObjectList<BString> mimeTypes(10, true);
|
BStringList mimeTypes(10);
|
||||||
BuildMimeTypeList(mimeTypes);
|
BuildMimeTypeList(mimeTypes);
|
||||||
|
|
||||||
AddOneAddonParams params;
|
AddOneAddonParams params;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ All rights reserved.
|
|||||||
#define _CONTAINER_WINDOW_H
|
#define _CONTAINER_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <StringList.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "LockingList.h"
|
#include "LockingList.h"
|
||||||
@@ -42,6 +43,7 @@ All rights reserved.
|
|||||||
#include "SlowContextPopup.h"
|
#include "SlowContextPopup.h"
|
||||||
#include "TaskLoop.h"
|
#include "TaskLoop.h"
|
||||||
|
|
||||||
|
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
|
|
||||||
@@ -185,8 +187,7 @@ public:
|
|||||||
|
|
||||||
// add-on iteration
|
// add-on iteration
|
||||||
void EachAddon(bool (*)(const Model*, const char*, uint32 shortcut,
|
void EachAddon(bool (*)(const Model*, const char*, uint32 shortcut,
|
||||||
uint32 modifiers, bool primary, void*), void*,
|
uint32 modifiers, bool primary, void*), void*, BStringList&);
|
||||||
BObjectList<BString> &);
|
|
||||||
|
|
||||||
BPopUpMenu* ContextMenu();
|
BPopUpMenu* ContextMenu();
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ protected:
|
|||||||
virtual void SetUpDiskMenu(BMenu*);
|
virtual void SetUpDiskMenu(BMenu*);
|
||||||
|
|
||||||
virtual void BuildAddOnMenu(BMenu*);
|
virtual void BuildAddOnMenu(BMenu*);
|
||||||
void BuildMimeTypeList(BObjectList<BString>& mimeTypes);
|
void BuildMimeTypeList(BStringList& mimeTypes);
|
||||||
|
|
||||||
enum UpdateMenuContext {
|
enum UpdateMenuContext {
|
||||||
kMenuBarContext,
|
kMenuBarContext,
|
||||||
@@ -270,7 +271,7 @@ protected:
|
|||||||
|
|
||||||
bool EachAddon(BPath &path,
|
bool EachAddon(BPath &path,
|
||||||
bool (*)(const Model*, const char*, uint32, bool, void*),
|
bool (*)(const Model*, const char*, uint32, bool, void*),
|
||||||
BObjectList<Model>*, void*, BObjectList<BString> &);
|
BObjectList<Model>*, void*, BStringList&);
|
||||||
void LoadAddOn(BMessage*);
|
void LoadAddOn(BMessage*);
|
||||||
|
|
||||||
BPopUpMenu* fFileContextMenu;
|
BPopUpMenu* fFileContextMenu;
|
||||||
|
|||||||
Reference in New Issue
Block a user