2 * Copyright (c) 2005-2010, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * DarkWyrm <darkwyrm@gmail.com>
8 #include "ResourceRoster.h"
10 #include <Application.h>
12 #include <Directory.h>
19 #include "InternalEditors.h"
20 #include "ResourceData.h"
21 #include "ResFields.h"
23 // For the MakeFieldForType temp code
24 #include <TranslatorFormats.h>
25 #include <TranslationUtils.h>
28 #include <TypeConstants.h>
33 EditorInfo(const image_id
&id
, const char *name
,
34 create_editor
*allocator
);
37 status_t
ID(void) const { return fID
; }
38 const char * Name(void) const { return fName
.String(); }
39 Editor
* Instantiate(void);
44 create_editor
* fAllocator
;
47 EditorInfo::EditorInfo(const image_id
&id
, const char *name
,
48 create_editor
*allocator
)
56 EditorInfo::~EditorInfo(void)
62 EditorInfo::Instantiate(void)
68 ResourceRoster::ResourceRoster(void)
73 ResourceRoster::~ResourceRoster(void)
79 ResourceRoster::MakeFieldForType(const int32
&type
, const char *data
,
82 // temporary code until editors are done
84 case B_MIME_STRING_TYPE
:
85 return new StringPreviewField(data
);
93 BMemoryIO
memio(data
, length
);
94 BBitmap
*bitmap
= BTranslationUtils::GetBitmap(&memio
);
96 BitmapPreviewField
*field
= new BitmapPreviewField(bitmap
);
110 ResourceRoster::LoadEditors(void)
113 be_app
->GetAppInfo(&info
);
116 BEntry
entry(&info
.ref
);
117 entry
.GetParent(&dir
);
118 entry
.SetTo(&dir
, "addons");
123 while (dir
.GetNextRef(&ref
) == B_OK
) {
126 image_id addon
= load_add_on(path
.Path());
131 if (get_image_symbol(addon
, "description", B_SYMBOL_TYPE_DATA
, (void **)(&temp
)) != B_OK
) {
132 unload_add_on(addon
);
136 create_editor
*createFunc
;
137 if (get_image_symbol(addon
, "instantiate_editor", B_SYMBOL_TYPE_TEXT
, (void **)(&createFunc
)) != B_OK
) {
139 unload_add_on(addon
);
143 if (createFunc
&& temp
)
144 fList
.AddItem(new EditorInfo(addon
, temp
, createFunc
));
151 ResourceRoster::SpawnEditor(ResourceData
*data
, BHandler
*handler
)
153 // temporary code until editors are done
154 switch (data
->GetType()) {
156 case B_MIME_STRING_TYPE
: {
157 StringEditor
*strEd
= new StringEditor(BRect(100, 100, 400, 200),
168 case B_JPEG_FORMAT
: {
169 ImageEditor
*imgEd
= new ImageEditor(BRect(100, 100, 300, 200),