Removed the MIME type picker from the MimeTypeEditor - it was not yet finished
anyway, and I think it doesn't really belong to this app's realm. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6759 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -51,10 +51,7 @@ class MimeTypeEditor : public BView {
|
|||||||
void UpdateText();
|
void UpdateText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddMimeTypesToMenu();
|
|
||||||
|
|
||||||
DataEditor &fEditor;
|
DataEditor &fEditor;
|
||||||
BMenu *fMimeTypeMenu;
|
|
||||||
BTextControl *fTextControl;
|
BTextControl *fTextControl;
|
||||||
BString fPreviousText;
|
BString fPreviousText;
|
||||||
};
|
};
|
||||||
@@ -195,28 +192,20 @@ StringEditor::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
MimeTypeEditor::MimeTypeEditor(BRect rect, DataEditor &editor)
|
MimeTypeEditor::MimeTypeEditor(BRect rect, DataEditor &editor)
|
||||||
: BView(rect, "MIME Type Editor", B_FOLLOW_NONE, 0),
|
: BView(rect, "MIME Type Editor", B_FOLLOW_LEFT_RIGHT, 0),
|
||||||
fEditor(editor)
|
fEditor(editor)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
rect.right -= 100;
|
|
||||||
fTextControl = new BTextControl(rect.InsetByCopy(5, 5), B_EMPTY_STRING, "MIME Type:", NULL,
|
fTextControl = new BTextControl(rect.InsetByCopy(5, 5), B_EMPTY_STRING, "MIME Type:", NULL,
|
||||||
new BMessage(kMsgValueChanged), B_FOLLOW_ALL);
|
new BMessage(kMsgValueChanged), B_FOLLOW_ALL);
|
||||||
fTextControl->SetDivider(StringWidth(fTextControl->Label()) + 8);
|
fTextControl->SetDivider(StringWidth(fTextControl->Label()) + 8);
|
||||||
|
|
||||||
fMimeTypeMenu = new BMenu(B_EMPTY_STRING);
|
float width, height;
|
||||||
rect = fTextControl->Frame();
|
fTextControl->GetPreferredSize(&width, &height);
|
||||||
rect.left = rect.right + 5;
|
fTextControl->ResizeTo(rect.Width() - 10, height);
|
||||||
rect.right = Bounds().right;
|
|
||||||
//rect.top++;
|
|
||||||
BMenuField *menuField = new BMenuField(rect, NULL, NULL, fMimeTypeMenu);
|
|
||||||
menuField->SetDivider(0);
|
|
||||||
menuField->ResizeToPreferred();
|
|
||||||
AddChild(menuField);
|
|
||||||
|
|
||||||
ResizeTo(fTextControl->Bounds().Width() + menuField->Bounds().Width() + 10,
|
ResizeTo(rect.Width(), height + 10);
|
||||||
menuField->Bounds().Height() + 10);
|
|
||||||
|
|
||||||
AddChild(fTextControl);
|
AddChild(fTextControl);
|
||||||
}
|
}
|
||||||
@@ -243,7 +232,6 @@ MimeTypeEditor::AttachedToWindow()
|
|||||||
fTextControl->SetTarget(this);
|
fTextControl->SetTarget(this);
|
||||||
fEditor.StartWatching(this);
|
fEditor.StartWatching(this);
|
||||||
|
|
||||||
AddMimeTypesToMenu();
|
|
||||||
UpdateText();
|
UpdateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,48 +267,6 @@ MimeTypeEditor::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MimeTypeEditor::AddMimeTypesToMenu()
|
|
||||||
{
|
|
||||||
// add MIME type tree list
|
|
||||||
|
|
||||||
BMessage types;
|
|
||||||
if (BMimeType::GetInstalledSupertypes(&types) == B_OK) {
|
|
||||||
const char *superType;
|
|
||||||
int32 index = 0;
|
|
||||||
|
|
||||||
while (types.FindString("super_types", index++, &superType) == B_OK) {
|
|
||||||
BMenu *superMenu = new BMenu(superType);
|
|
||||||
|
|
||||||
// ToDo: there are way too many "application" types... (need to lay off to another thread)
|
|
||||||
if (!strcmp(superType, "application"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BMessage subTypes;
|
|
||||||
if (BMimeType::GetInstalledTypes(superType, &subTypes) == B_OK) {
|
|
||||||
const char *type;
|
|
||||||
int32 subIndex = 0;
|
|
||||||
while (subTypes.FindString("types", subIndex++, &type) == B_OK) {
|
|
||||||
BMessage *message = new BMessage(kMimeTypeItem);
|
|
||||||
message->AddString("super_type", superType);
|
|
||||||
message->AddString("mime_type", type);
|
|
||||||
superMenu->AddItem(new BMenuItem(strchr(type, '/') + 1, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (superMenu->CountItems() != 0) {
|
|
||||||
fMimeTypeMenu->AddItem(new BMenuItem(superMenu));
|
|
||||||
|
|
||||||
// the MimeTypeMenu's font is not correct at this time
|
|
||||||
superMenu->SetFont(be_plain_font);
|
|
||||||
superMenu->SetTargetForItems(this);
|
|
||||||
} else
|
|
||||||
delete superMenu;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user