Exemple #1
0
/*static*/ void
BApplication::_InitAppResources()
{
	entry_ref ref;
	bool found = false;

	// App is already running. Get its entry ref with
	// GetAppInfo()
	app_info appInfo;
	if (be_app && be_app->GetAppInfo(&appInfo) == B_OK) {
		ref = appInfo.ref;
		found = true;
	} else {
		// Run() hasn't been called yet
		found = BPrivate::get_app_ref(&ref) == B_OK;
	}

	if (!found)
		return;

	BFile file(&ref, B_READ_ONLY);
	if (file.InitCheck() != B_OK)
		return;

	BResources* resources = new (std::nothrow) BResources(&file, false);
	if (resources == NULL || resources->InitCheck() != B_OK) {
		delete resources;
		return;
	}

	sAppResources = resources;
}
Exemple #2
0
BResources*
CayaResources()
{
	image_info info;
	if (our_image(info) != B_OK)
		return NULL;

	BFile file(info.name, B_READ_ONLY);
	if (file.InitCheck() != B_OK)
		return NULL;

	BResources* res = new BResources(&file);
	if (res->InitCheck() != B_OK) {
		delete res;
		return NULL;
	}

	return res;
}
Exemple #3
0
void
PowerStatusView::_NotifyLowBattery()
{
	BBitmap* bitmap = NULL;
	BResources resources;
	resources.SetToImage((void*)&instantiate_deskbar_item);

	if (resources.InitCheck() == B_OK) {
		size_t resourceSize = 0;
		const void* resourceData = resources.LoadResource(
			B_VECTOR_ICON_TYPE, fHasBattery
				? "battery_low" : "battery_critical", &resourceSize);
		if (resourceData != NULL) {
			BMemoryIO memoryIO(resourceData, resourceSize);
			bitmap = BTranslationUtils::GetBitmap(&memoryIO);
		}
	}

	BNotification notification(
		fHasBattery ? B_INFORMATION_NOTIFICATION : B_ERROR_NOTIFICATION);

	if (fHasBattery) {
		notification.SetTitle(B_TRANSLATE("Battery low"));
		notification.SetContent(B_TRANSLATE(
			"The battery level is getting low, please plug in the device."));
	} else {
		notification.SetTitle(B_TRANSLATE("Battery critical"));
		notification.SetContent(B_TRANSLATE(
			"The battery level is critical, please plug in the device "
			"immediately."));
	}

	notification.SetIcon(bitmap);
	notification.Send();
	delete bitmap;
}