* Copyright (c) 1999-2000, Eric Moon.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "DormantNodeInfoView.h"
#include "InfoWindowManager.h"
#include "MediaIcon.h"
#include "MediaString.h"
#undef B_CATALOG
#define B_CATALOG (&sCatalog)
#include <Catalog.h>
#include <MediaAddOn.h>
#include <MediaRoster.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "DormantNodeInfoView"
__USE_CORTEX_NAMESPACE
#include <Debug.h>
#define D_METHOD(x)
static BCatalog sCatalog("x-vnd.Cortex.InfoView");
DormantNodeInfoView::DormantNodeInfoView(
const dormant_node_info &info)
: InfoView(info.name, B_TRANSLATE("Dormant media node"),
new MediaIcon(info, B_LARGE_ICON)),
m_addOnID(info.addon),
m_flavorID(info.flavor_id)
{
D_METHOD(("DormantNodeInfoView::DormantNodeInfoView()\n"));
setSideBarWidth(be_plain_font->StringWidth(B_TRANSLATE("Output formats"))
+ 2 * InfoView::M_H_MARGIN);
BString s;
s = "";
s << info.addon;
addField(B_TRANSLATE("AddOn ID"), s);
s = "";
s << info.flavor_id;
addField(B_TRANSLATE("Flavor ID"), s);
addField("", "");
dormant_flavor_info flavorInfo;
BMediaRoster *roster = BMediaRoster::Roster();
if (roster && (roster->GetDormantFlavorInfoFor(info, &flavorInfo) == B_OK))
{
s = flavorInfo.info;
addField(B_TRANSLATE("Description"), s);
addField(B_TRANSLATE("Kinds"), MediaString::getStringFor(
static_cast<node_kind>(flavorInfo.kinds)));
addField(B_TRANSLATE("Flavor flags"), "?");
if (flavorInfo.possible_count > 0)
{
s = "";
s << flavorInfo.possible_count;
}
else
{
s = B_TRANSLATE_COMMENT("Any number", "For 'Max. instances' field");
}
addField(B_TRANSLATE("Max. instances"), s);
if (flavorInfo.in_format_count > 0)
{
if (flavorInfo.in_format_count == 1)
{
addField(B_TRANSLATE("Input format"),
MediaString::getStringFor(flavorInfo.in_formats[0], false));
}
else
{
addField(B_TRANSLATE("Input formats"), "");
for (int32 i = 0; i < flavorInfo.in_format_count; i++)
{
s = "";
s << "(" << i + 1 << ")";
addField(s, MediaString::getStringFor(flavorInfo.in_formats[i], false));
}
}
}
if (flavorInfo.out_format_count > 0)
{
if (flavorInfo.out_format_count == 1)
{
addField(B_TRANSLATE("Output format"),
MediaString::getStringFor(
flavorInfo.out_formats[0], false));
}
else
{
addField(B_TRANSLATE("Output formats"), "");
for (int32 i = 0; i < flavorInfo.out_format_count; i++)
{
s = "";
s << "(" << i + 1 << ")";
addField(s, MediaString::getStringFor(flavorInfo.out_formats[i], false));
}
}
}
}
}
DormantNodeInfoView::~DormantNodeInfoView()
{
D_METHOD(("DormantNodeInfoView::~DormantNodeInfoView()\n"));
}
void DormantNodeInfoView::DetachedFromWindow() {
D_METHOD(("DormantNodeInfoView::DetachedFromWindow()\n"));
InfoWindowManager *manager = InfoWindowManager::Instance();
if (manager) {
BMessage message(InfoWindowManager::M_DORMANT_NODE_WINDOW_CLOSED);
message.AddInt32("addOnID", m_addOnID);
message.AddInt32("flavorID", m_flavorID);
manager->PostMessage(&message);
}
}