本文整理汇总了C++中BMimeType::SetType方法的典型用法代码示例。如果您正苦于以下问题:C++ BMimeType::SetType方法的具体用法?C++ BMimeType::SetType怎么用?C++ BMimeType::SetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMimeType
的用法示例。
在下文中一共展示了BMimeType::SetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void
InitFileTypes(void)
{
BMimeType mime;
BString string;
BMessage msg,ext;
BBitmap large_icon(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_COLOR_8_BIT);
memcpy(large_icon.Bits(),kProjectLargeIconBits,1024);
BBitmap mini_icon(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_COLOR_8_BIT);
memcpy(mini_icon.Bits(),kProjectSmallIconBits,256);
mime.SetType(PROJECT_MIME_TYPE);
mime.SetShortDescription(TR("Paladin Project"));
mime.SetLongDescription(TR("File to build a program with Paladin"));
mime.SetIcon(&large_icon, B_LARGE_ICON);
mime.SetIcon(&mini_icon, B_MINI_ICON);
#ifdef __HAIKU__
mime.SetIcon(kProjectVectorIconBits, sizeof(kProjectVectorIconBits));
#endif
mime.SetSnifferRule("0.50 [0:32]( -i \"NAME=\" | \"TARGETNAME=\" | "
"\"PLATFORM=\" | \"GROUP=\" | \"SOURCEFILE=\")");
mime.SetPreferredApp(APP_SIGNATURE);
mime.Install();
ext.AddString("extensions","pld");
mime.SetFileExtensions(&ext);
}
示例2:
void
DockItem::GetGenericIcon( void )
{
if ( IsFolder() ) {
BMimeType type;
type.SetType( "application/x-vnd.Be-directory" );
type.GetIcon( mLargeIcon, B_LARGE_ICON );
type.GetIcon( mSmallIcon, B_MINI_ICON );
} else {
app_info appInfo;
BFile appFile;
BAppFileInfo appFileInfo;
be_app->GetAppInfo( &appInfo );
appFile.SetTo( &appInfo.ref, B_READ_WRITE );
appFileInfo.SetTo( &appFile );
appFileInfo.GetIconForType( "application/x-be-executable", mLargeIcon, B_LARGE_ICON );
appFileInfo.GetIconForType( "application/x-be-executable", mSmallIcon, B_MINI_ICON );
/*
BMimeType appType;
appType.SetType( "application/x-vnd.HK-LaunchPad" );
appType.GetIcon( mLargeIcon, B_LARGE_ICON );
appType.GetIcon( mSmallIcon, B_MINI_ICON );
*/
}
}
示例3: if
void
KindAttributeText::ReadValue(BString *result)
{
BMimeType mime;
char desc[B_MIME_TYPE_LENGTH];
// get the mime type
if (mime.SetType(fModel->MimeType()) != B_OK)
*result = "Unknown";
// get the short mime type description
else if (mime.GetShortDescription(desc) == B_OK)
*result = desc;
else
*result = fModel->MimeType();
fValueDirty = false;
}
示例4: if
void
KindAttributeText::ReadValue(BString* outString)
{
BMimeType mime;
char desc[B_MIME_TYPE_LENGTH];
// get the mime type
if (mime.SetType(fModel->MimeType()) != B_OK)
*outString = B_TRANSLATE("Unknown");
else if (mime.GetShortDescription(desc) == B_OK) {
// get the short mime type description
*outString = desc;
} else
*outString = fModel->MimeType();
fValueDirty = false;
}
示例5: InitFileTypes
// This handles the filetypes being installed with all the extra attributes over the
// regular R5 types
void MrPeeps::InitFileTypes(void)
{
BEntry entry("/boot/home/config/settings/MrPeeps");
BFile file;
// Check for settings directory
if(!entry.Exists())
create_directory("/boot/home/config/settings/MrPeeps",0777);
entry.SetTo("/boot/home/config/settings/MrPeeps/MrPeeps");
if(!entry.Exists())
{
file.SetTo("/boot/home/config/settings/MrPeeps/MrPeeps",B_READ_WRITE|B_CREATE_FILE);
file.Unset();
}
entry.SetTo("/boot/home/config/settings/MrPeeps/filetypes_installed");
if(!entry.Exists())
{
BFile file("/boot/home/config/settings/MrPeeps/filetypes_installed",B_CREATE_FILE);
BMimeType mime;
BString string;
BMessage msg,info;
uint8 installtype=2;
int32 index=0;
BBitmap large_icon(BRect(0, 0, B_LARGE_ICON-1, B_LARGE_ICON-1), B_COLOR_8_BIT);
BBitmap mini_icon(BRect(0, 0, B_MINI_ICON-1, B_MINI_ICON-1), B_COLOR_8_BIT);
// install person mime type
mime.SetType(PERSON_FILE_TYPE);
if(mime.IsInstalled())
{
if (mime.GetAttrInfo(&info) == B_OK)
{
while (info.FindString("attr:name", index++, &string) == B_OK)
{
if (string.Compare(PERSON_EMAIL5)==0)
installtype=1;
if (string.Compare(PERSON_BIRTHDAY)==0)
{
installtype=0;
break;
}
}
if (installtype>0)
mime.Delete();
}
}
if(installtype>0)
{
mime.Install();
large_icon.SetBits(kLargePersonIcon, large_icon.BitsLength(), 0, B_COLOR_8_BIT);
mini_icon.SetBits(kSmallPersonIcon, mini_icon.BitsLength(), 0, B_COLOR_8_BIT);
mime.SetShortDescription("Person");
mime.SetLongDescription("Information about a person");
mime.SetIcon(&large_icon, B_LARGE_ICON);
mime.SetIcon(&mini_icon, B_MINI_ICON);
BAlert *alert=new BAlert("Mr. Peeps!", "Would you like to make Mr. Peeps! the "
"default application for People files? If not sure, choose 'No'.","Yes","No");
if(alert->Go()==0)
mime.SetPreferredApp(APP_SIGNATURE);
else
mime.SetPreferredApp("application/x-vnd.Be-PEPL");
// General Person data
msg.AddString("attr:public_name", "First Name");
msg.AddString("attr:name", PERSON_FIRSTNAME);
msg.AddInt32("attr:type", B_STRING_TYPE);
msg.AddBool("attr:viewable", true);
msg.AddBool("attr:editable", true);
msg.AddInt32("attr:width", 120);
msg.AddInt32("attr:alignment", B_ALIGN_LEFT);
msg.AddBool("attr:extra", false);
msg.AddString("attr:public_name", "Last Name");
msg.AddString("attr:name", PERSON_LASTNAME);
msg.AddInt32("attr:type", B_STRING_TYPE);
msg.AddBool("attr:viewable", true);
msg.AddBool("attr:editable", true);
msg.AddInt32("attr:width", 120);
msg.AddInt32("attr:alignment", B_ALIGN_LEFT);
msg.AddBool("attr:extra", false);
msg.AddString("attr:public_name", "Nickname");
msg.AddString("attr:name", PERSON_NICKNAME);
msg.AddInt32("attr:type", B_STRING_TYPE);
msg.AddBool("attr:viewable", true);
msg.AddBool("attr:editable", true);
msg.AddInt32("attr:width", 120);
msg.AddInt32("attr:alignment", B_ALIGN_LEFT);
msg.AddBool("attr:extra", false);
msg.AddString("attr:public_name", "Title");
msg.AddString("attr:name", PERSON_TITLE);
//.........这里部分代码省略.........
示例6: nodeInfo
void
DockItem::SetTo( const entry_ref *ref )
{
BEntry entry;
BPath path;
BSymLink symLink;
BMimeType type;
BMimeType appType;
// Traverse the symbolic link if necessary.
entry.SetTo( ref, true );
entry.GetRef( &mRef );
/*
if ( entry.IsSymLink() ) {
symLink.SetTo( ref );
symLink.GetLinkedPath( &path );
printf( "path = %s\n", path.Path() );
entry.SetTo( path.Path() );
entry.GetRef( &mRef );
} else {
mRef = *ref;
}
*/
// Retrieve the ref's name.
entry.SetTo( &mRef );
entry.GetName( mCaption );
entry.GetPath( &path );
PRINT(( "entry ref name (%s)\n", mCaption ));
PRINT(( "path = %s\n", path.Path() ));
// Retrieve mime type.
BNode node;
node.SetTo( &mRef );
BNodeInfo nodeInfo( &node );
nodeInfo.GetType( mMimeType );
type.SetType( mMimeType );
// Remember the node type.
if ( node.IsDirectory() ) {
mNodeType = kFolder;
} else {
mNodeType = kFile;
}
/*
// First retrieve custom icon. (GetTrackerIcon's not perfect yet)
if ( ::GetTrackerIcon( &mRef, mLargeIcon, mSmallIcon ) != B_NO_ERROR ) {
this->GetGenericIcon();
}
*/
if ( BNodeInfo::GetTrackerIcon( &mRef, mLargeIcon, B_LARGE_ICON ) < B_NO_ERROR ) {
PRINT(( "Couldn't retrieve icon\n" ));
GetGenericIcon();
}
if ( BNodeInfo::GetTrackerIcon( &mRef, mSmallIcon, B_MINI_ICON ) < B_NO_ERROR ) {
PRINT(( "Couldn't retrive mini icon\n" ));
GetGenericIcon();
}
MakeHighlitIcon();
mHasRef = true;
}