void
HEventList::SetType(const char* type)
{
	RemoveAll();
	BMediaFiles mfiles;
	mfiles.RewindRefs(type);
	delete fType;
	fType = strdup(type);

	BString name;
	entry_ref ref;
	while (mfiles.GetNextRef(&name,&ref) == B_OK) {
		BPath path(&ref);
		if (path.InitCheck() != B_OK || ref.name == NULL
			|| strcmp(ref.name, "") == 0)
			AddRow(new HEventRow(name.String(), NULL));
		else
			AddRow(new HEventRow(name.String(), path.Path()));
	}
}
Exemplo n.º 2
0
status_t
SoundsThemesAddon::MakeTheme(BMessage &theme, uint32 flags)
{
	BMessage sounds;
	status_t err;
	BMediaFiles bmfs;
	BString item;
	entry_ref entry;
	BEntry ent;
	BPath path;
	float gain;
	
	(void)flags;
	err = MyMessage(theme, sounds);
	if (err)
		sounds.MakeEmpty();
	
	bmfs.RewindRefs(BMediaFiles::B_SOUNDS);
	while (bmfs.GetNextRef(&item, &entry) == B_OK) {
		BMessage msg('SndI');
		path.Unset();
		ent.SetTo(&entry);
		ent.GetPath(&path);
		//printf("\t%s: %s\n", item.String(), path.Path());
		if (path.Path()) {
			msg.AddString("sounds:file", path.Path());
			gain = 1.0;
#if defined(__ANTARES__) || defined(B_BEOS_VERSION_DANO)
			bmfs.GetAudioGainFor(BMediaFiles::B_SOUNDS, item.String(), &gain);
#endif
			msg.AddFloat("sounds:volume", gain);
		}
		sounds.AddMessage(item.String(), &msg);
	}
	
	err = SetMyMessage(theme, sounds);
	return err;
}
Exemplo n.º 3
0
status_t
SoundsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
{
	BMessage sounds;
	status_t err;
	BMediaFiles bmfs;
	BString item;
	entry_ref entry;
	BEntry ent;
	BPath path;
	const char *p;
	float gain;
	int32 index;
	char *field_name;
	type_code field_code;
	int32 field_count;
	BMessage msg;

	if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
		return B_OK;
	
	err = MyMessage(theme, sounds);
	if (err)
		return err;

	bmfs.RewindRefs(BMediaFiles::B_SOUNDS);
	for (index = 0; sounds.GetInfo(B_ANY_TYPE, index,  
							GET_INFO_NAME_PTR(&field_name), 
							&field_code, 
							&field_count) == B_OK; index++) {
		if (field_code != B_MESSAGE_TYPE)
			continue;
		if (sounds.FindMessage(field_name, &msg) < B_OK)
			continue;
		/* remove old ref if any */
		if ((bmfs.GetRefFor(BMediaFiles::B_SOUNDS, field_name, &entry) >= B_OK)
				 && (entry.device >= 0))
			bmfs.RemoveRefFor(BMediaFiles::B_SOUNDS, field_name, entry);
		if (msg.FindString("sounds:file", &p) < B_OK)
			continue;
		path.SetTo(p);
		if (ent.SetTo(path.Path()) < B_OK)
			continue;
		if (ent.GetRef(&entry) < B_OK)
			continue;
		if (bmfs.SetRefFor(BMediaFiles::B_SOUNDS, field_name, entry) < B_OK)
			continue;
		if (msg.FindFloat("sounds:volume", &gain) < B_OK)
			continue;
#if defined(__ANTARES__) || defined(B_BEOS_VERSION_DANO)
		if (bmfs.SetAudioGainFor(BMediaFiles::B_SOUNDS, field_name, gain) < B_OK)
			continue;
#endif
	}

	return B_OK;
}