// SetExportMode
void
SavePanel::SetExportMode(bool exportMode)
{
	BWindow* window = Window();
	if (!window || !window->Lock())
		return;

	// adjust window title and enable format menu
	BString helper("Icon-O-Matic: ");
	if (exportMode) {
		fFormatMF->SetEnabled(true);
		SetExportMode(fExportMode);
		_EnableSettings();
		helper << B_TRANSLATE_CONTEXT("Export Icon", "Dialog title");
	} else {
		fExportMode = ExportMode();
			// does not overwrite fExportMode in case we already were
			// in native save mode
		fNativeMI->SetMarked(true);

		fFormatMF->SetEnabled(false);
		fSettingsB->SetEnabled(false);
		helper << B_TRANSLATE_CONTEXT("Save Icon", "Dialog title");
	}

	window->Unlock();
}
Esempio n. 2
0
status_t TaskFS::SetUpMimeTyp(void)
{
	status_t err;
	//set the MimeType
	BMimeType mime(TASK_MIMETYPE);
	//later do better check
	bool valid = mime.IsInstalled();
	if (!valid) {
		mime.Install();
		mime.SetShortDescription(B_TRANSLATE_CONTEXT("Tasks",
			"Short mimetype description"));
		mime.SetLongDescription(B_TRANSLATE_CONTEXT("Tasks",
			"Long mimetype description"));
		//get the icon from our Ressources
		BResources* res = BApplication::AppResources();
		if (res != NULL){
			size_t size;
			const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "TASK_ICON", &size);
			if (data!=NULL)
				mime.SetIcon(reinterpret_cast<const uint8*>(data), size);
		}
		mime.SetPreferredApp(APP_SIG);

		// add default task fields to meta-mime type
		BMessage fields;
		for (int32 i = 0; sDefaultAttributes[i].attribute; i++) {
			fields.AddString("attr:public_name", sDefaultAttributes[i].name);
			fields.AddString("attr:name", sDefaultAttributes[i].attribute);
			fields.AddInt32("attr:type", sDefaultAttributes[i].type);
			fields.AddString("attr:display_as", sDefaultAttributes[i].displayAs);
			fields.AddBool("attr:viewable", sDefaultAttributes[i].isPublic);
			fields.AddBool("attr:editable", sDefaultAttributes[i].editable);
			fields.AddInt32("attr:width", sDefaultAttributes[i].width);
			fields.AddInt32("attr:alignment", B_ALIGN_LEFT);
			fields.AddBool("attr:extra", false);
		}
		mime.SetAttrInfo(&fields);
			// create indices on all volumes for the found attributes.
		int32 count = 8;
		BVolumeRoster volumeRoster;
		BVolume volume;
		while (volumeRoster.GetNextVolume(&volume) == B_OK) {
			for (int32 i = 0; i < count; i++) {
				if (sDefaultAttributes[i].isPublic == true)
					fs_create_index(volume.Device(), sDefaultAttributes[i].attribute,
						sDefaultAttributes[i].type, 0);
			}
		}
	}
	else
		err = B_OK;
	return err;
}
Esempio n. 3
0
void
ShowImageWindow::_LoadError(const entry_ref& ref)
{
	// TODO: give a better error message!
	BAlert* alert = new BAlert(B_TRANSLATE_SYSTEM_NAME("ShowImage"),
		B_TRANSLATE_CONTEXT("Could not load image! Either the "
			"file or an image translator for it does not exist.",
			"LoadAlerts"),
		B_TRANSLATE_CONTEXT("OK", "Alerts"), NULL, NULL,
		B_WIDTH_AS_USUAL, B_STOP_ALERT);
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();
}
Esempio n. 4
0
void
TMagnify::CopyImage()
{
	StartSave();
	be_clipboard->Lock();
	be_clipboard->Clear();

	BMessage *message = be_clipboard->Data();
	if (!message) {
		printf(B_TRANSLATE_CONTEXT("no clip msg\n",
			"In console, when clipboard is empty after clicking Copy image"));
		return;
	}

	BMessage *embeddedBitmap = new BMessage();
	(fImageView->Bitmap())->Archive(embeddedBitmap,false);
	status_t err = message->AddMessage(kBitmapMimeType, embeddedBitmap);
	if (err == B_OK)
		err = message->AddRect("rect", fImageView->Bitmap()->Bounds());
	if (err == B_OK)
		be_clipboard->Commit();

	be_clipboard->Unlock();
	EndSave();
}
Esempio n. 5
0
BString
PlaylistItem::Title() const
{
	BString title;
	if (GetAttribute(ATTR_STRING_TITLE, title) != B_OK)
		title = B_TRANSLATE_CONTEXT("<untitled>", "PlaylistItem-title");
	return title;
}
Esempio n. 6
0
BString
PlaylistItem::Name() const
{
	BString name;
	if (GetAttribute(ATTR_STRING_NAME, name) != B_OK)
		name = B_TRANSLATE_CONTEXT("<unnamed>", "PlaylistItem-name");
	return name;
}
Esempio n. 7
0
void
MediaConverterWindow::_CreateMenu()
{
	BMenu* menu;
	BMenuItem* item;

	menu = new BMenu(B_TRANSLATE_CONTEXT("File", "Menu"));
	item = new BMenuItem(B_TRANSLATE_CONTEXT("Open" B_UTF8_ELLIPSIS, "Menu"),
		new BMessage(OPEN_FILE_MESSAGE), 'O');
	menu->AddItem(item);
	menu->AddSeparatorItem();
	item = new BMenuItem(B_TRANSLATE_CONTEXT("Quit", "Menu"),
		new BMessage(QUIT_MESSAGE), 'Q');
	menu->AddItem(item);

	fMenuBar->AddItem(menu);
}
Esempio n. 8
0
BString
PlaylistItem::Author() const
{
	BString author;
	if (GetAttribute(ATTR_STRING_AUTHOR, author) != B_OK)
		author = B_TRANSLATE_CONTEXT("<unknown>", "PlaylistItem-author");
	return author;
}
Esempio n. 9
0
BString
PlaylistItem::Album() const
{
	BString album;
	if (GetAttribute(ATTR_STRING_ALBUM, album) != B_OK)
		album = B_TRANSLATE_CONTEXT("<unknown>", "PlaylistItem-album");
	return album;
}
Esempio n. 10
0
BString
WirelessNetworkMenuItem::AuthenticationName(int32 mode)
{
	switch (mode) {
		default:
		case B_NETWORK_AUTHENTICATION_NONE:
			return B_TRANSLATE_CONTEXT("open", "Open network");
			break;
		case B_NETWORK_AUTHENTICATION_WEP:
			return B_TRANSLATE_CONTEXT("WEP", "WEP protected network");
			break;
		case B_NETWORK_AUTHENTICATION_WPA:
			return B_TRANSLATE_CONTEXT("WPA", "WPA protected network");
			break;
		case B_NETWORK_AUTHENTICATION_WPA2:
			return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network");
			break;
		case B_NETWORK_AUTHENTICATION_EAP:
			return B_TRANSLATE_CONTEXT("EAP", "EAP protected network");
			break;
	}
}
Esempio n. 11
0
static size_t
mkColumnsBits(BMallocIO& stream, const ColumnData* src, int32 nelm,
	const char* context)
{
	for (int32 i = 0; i < nelm; i++) {
		BColumn c(
			B_TRANSLATE_CONTEXT(src[i].title, context),
			src[i].offset, src[i].width, src[i].align, src[i].attributeName,
			src[i].attrType, src[i].statField, src[i].editable);
		c.ArchiveToStream(&stream);
	}

	return stream.Position();
}
Esempio n. 12
0
void KlondikeApplication::AboutRequested()
{
	BString aboutText = "";
	aboutText << "BeKlondike v0.1" << "\n"
	<< B_TRANSLATE("A klondike solitaire clone for Haiku.")<<"\n\n"
	<< B_TRANSLATE("BeKlondike (c) 2013-14 Przemysław Buczkowski <*****@*****.**>")<<"\n"
	<< B_TRANSLATE("Distributed under the terms of the MIT license.")<<"\n\n"
	<< B_TRANSLATE("SVG-Z-cards (c) 2008 David Bellot, Brandon Ardiente.")<<"\n"
	<< B_TRANSLATE("Licensed under GNU Lesser General Public License 2.1.")<<"\n\n"
	<< B_TRANSLATE("Fanfare sound (c) 2009 Anthony Batiste.")<<"\n"
	<< B_TRANSLATE("Licensed under Creative Commons Attribution 3.0.");
	
	(new BAlert("AboutAlert", aboutText, B_TRANSLATE_CONTEXT("OK", "About alert")))->Go();
}
Esempio n. 13
0
int
main(int argc, char* argv[])
{
	int32 pixelCount = -1;

	if (argc > 2) {
		printf(B_TRANSLATE_CONTEXT(
			"usage: magnify [size] (magnify size * size pixels)\n",
			"Console"));
		exit(1);
	} else {
		if (argc == 2) {
			pixelCount = abs(atoi(argv[1]));

			if ((pixelCount > 100) || (pixelCount < 4)) {
				printf(B_TRANSLATE_CONTEXT(
					"usage: magnify [size] (magnify size * size pixels)\n",
					"Console"));
				printf(B_TRANSLATE_CONTEXT(
					"  size must be > 4 and a multiple of 4\n",
					"Console"));
				exit(1);
			}

			if (pixelCount % 4) {
				printf(B_TRANSLATE_CONTEXT(
					"magnify: size must be a multiple of 4\n",
					"Console"));
				exit(1);
			}
		}
	}

	TApp app(pixelCount);
	app.Run();
	return 0;
}
Esempio n. 14
0
void
SizeField::SetSize(double size)
{
	if (size < 0.0)
		size = 0.0;

	if (size == fSize)
		return;

	BString sizeString;
	if (size == 0) {
		sizeString = B_TRANSLATE_CONTEXT("-", "no package size");
	} else {
		char buffer[256];
		sizeString = string_for_size(size, buffer, sizeof(buffer));
	}

	fSize = size;
	SetString(sizeString.String());
}
Esempio n. 15
0
void
PersonView::BuildGroupMenu()
{
	if (fGroups == NULL)
		return;

	BMenuItem* item;
	while ((item = fGroups->ItemAt(0)) != NULL) {
		fGroups->RemoveItem(item);
		delete item;
	}

	int32 count = 0;

	BVolumeRoster volumeRoster;
	BVolume volume;
	while (volumeRoster.GetNextVolume(&volume) == B_OK) {
		BQuery query;
		query.SetVolume(&volume);

		char buffer[256];
		snprintf(buffer, sizeof(buffer), "%s=*", fCategoryAttribute.String());
		query.SetPredicate(buffer);
		query.Fetch();

		BEntry entry;
		while (query.GetNextEntry(&entry) == B_OK) {
			BFile file(&entry, B_READ_ONLY);
			attr_info info;

			if (file.InitCheck() == B_OK
				&& file.GetAttrInfo(fCategoryAttribute, &info) == B_OK
				&& info.size > 1) {
				if (info.size > (off_t)sizeof(buffer))
					info.size = sizeof(buffer);

				if (file.ReadAttr(fCategoryAttribute.String(), B_STRING_TYPE,
						0, buffer, info.size) < 0) {
					continue;
				}

				const char *text = buffer;
				while (true) {
					char* offset = strstr(text, ",");
					if (offset != NULL)
						offset[0] = '\0';

					if (!fGroups->FindItem(text)) {
						int32 index = 0;
						while ((item = fGroups->ItemAt(index)) != NULL) {
							if (strcmp(text, item->Label()) < 0)
								break;
							index++;
						}
						BMessage* message = new BMessage(M_GROUP_MENU);
						message->AddString("group", text);
						fGroups->AddItem(new BMenuItem(text, message), index);
						count++;
					}
					if (offset) {
						text = offset + 1;
						while (*text == ' ')
							text++;
					}
					else
						break;
				}
			}
		}
	}

	if (count == 0) {
		fGroups->AddItem(item = new BMenuItem(
			B_TRANSLATE_CONTEXT("none", "Groups list"),
			new BMessage(M_GROUP_MENU)));
		item->SetEnabled(false);
	}

	fGroups->SetTargetForItems(this);
}
Esempio n. 16
0
void
MediaConverterWindow::BuildAudioVideoMenus()
{
	BMenu* menu = fAudioMenu->Menu();
	BMenuItem* item;

	// clear out old audio codec menu items
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	bool separator = true;

	// get selected file format
	FileFormatMenuItem* ffmi
		= (FileFormatMenuItem*)fFormatMenu->Menu()->FindMarked();
	media_file_format* mf_format = &(ffmi->fFileFormat);

	media_format format, outfmt;
	memset(&format, 0, sizeof(format));
	media_codec_info codec_info;
	int32 cookie = 0;
	CodecMenuItem* cmi;

	// add available audio encoders to menu
	format.type = B_MEDIA_RAW_AUDIO;
	format.u.raw_audio = media_raw_audio_format::wildcard;
	while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
			== B_OK) {
		if (separator) {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE_CONTEXT("No audio", "Audio codecs list"),
				new BMessage(AUDIO_CODEC_SELECT_MESSAGE)));
			menu->AddSeparatorItem();
			separator = false;
		}

		cmi = new CodecMenuItem(&codec_info, AUDIO_CODEC_SELECT_MESSAGE);
		menu->AddItem(cmi);
		// reset media format struct
/*
		format.type = B_MEDIA_RAW_AUDIO;
		format.u.raw_audio = media_raw_audio_format::wildcard;
*/
	}

	// mark first audio encoder
	item = menu->ItemAt(0);
	if (item != NULL) {
		fAudioMenu->SetEnabled(fEnabled);
		fAudioQualitySlider->SetEnabled(fEnabled);
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	} else {
		item = new BMenuItem(
			B_TRANSLATE_CONTEXT("None available", "Audio codecs"), NULL);
		menu->AddItem(item);
		item->SetMarked(true);
		fAudioMenu->SetEnabled(false);
		fAudioQualitySlider->SetEnabled(false);
	}

	// clear out old video codec menu items
	menu = fVideoMenu->Menu();
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	separator = true;

	// construct a generic video format.  Some of these parameters
	// seem silly, but are needed for R4.5.x, which is more picky
	// than subsequent BeOS releases will be.
	memset(&format, 0, sizeof(format));
	format.type = B_MEDIA_RAW_VIDEO;
	format.u.raw_video.last_active = (uint32)(240 - 1);
	format.u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT;
	format.u.raw_video.display.format = B_RGB32;
	format.u.raw_video.display.line_width = (int32)320;
	format.u.raw_video.display.line_count = (int32)240;
	format.u.raw_video.display.bytes_per_row = 4 * 320;

	// add available video encoders to menu
	cookie = 0;
	while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
			== B_OK) {
		if (separator) {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE_CONTEXT("No video", "Video codecs list"),
				new BMessage(VIDEO_CODEC_SELECT_MESSAGE)));
			menu->AddSeparatorItem();
			separator = false;
		}

		cmi = new CodecMenuItem(&codec_info, VIDEO_CODEC_SELECT_MESSAGE);
		menu->AddItem(cmi);
	}

	// mark first video encoder
	item = menu->ItemAt(0);
	if (item != NULL) {
		fVideoMenu->SetEnabled(fEnabled);
		fVideoQualitySlider->SetEnabled(fEnabled);
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	} else {
		item = new BMenuItem(
			B_TRANSLATE_CONTEXT("None available", "Video codecs"), NULL);
		menu->AddItem(item);
		item->SetMarked(true);
		fVideoMenu->SetEnabled(false);
		fVideoQualitySlider->SetEnabled(false);
	}
}
Esempio n. 17
0
ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
	const BMessenger& trackerMessenger)
	:
	BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
	fNavigator(ref, trackerMessenger),
	fSavePanel(NULL),
	fBar(NULL),
	fBrowseMenu(NULL),
	fGoToPageMenu(NULL),
	fSlideShowDelayMenu(NULL),
	fToolBar(NULL),
	fImageView(NULL),
	fStatusView(NULL),
	fProgressWindow(new ProgressWindow()),
	fModified(false),
	fFullScreen(false),
	fShowCaption(true),
	fShowToolBar(true),
	fPrintSettings(NULL),
	fSlideShowRunner(NULL),
	fSlideShowDelay(kDefaultSlideShowDelay)
{
	_ApplySettings();

	SetLayout(new BGroupLayout(B_VERTICAL, 0));

	// create menu bar
	fBar = new BMenuBar("menu_bar");
	_AddMenus(fBar);
	float menuBarMinWidth = fBar->MinSize().width;
	AddChild(fBar);

	// Add a content view so the tool bar can be moved outside of the
	// visible portion without colliding with the menu bar.

	BView* contentView = new BView(BRect(), "content", B_FOLLOW_NONE, 0);
	contentView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	contentView->SetExplicitMinSize(BSize(250, 100));
	AddChild(contentView);

	// Create the tool bar
	BRect viewFrame = contentView->Bounds();
	viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
	fToolBar = new BToolBar(viewFrame);

	// Add the tool icons.

//	fToolBar->AddAction(MSG_FILE_OPEN, be_app,
//		tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS));
	fToolBar->AddAction(MSG_FILE_PREV, this,
		tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false);
	fToolBar->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext),
		B_TRANSLATE("Next file"), false);
	BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW);
	fullScreenSlideShow->AddBool("full screen", true);
	fToolBar->AddAction(fullScreenSlideShow, this,
		tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"),
		false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(MSG_SELECTION_MODE, this,
		tool_bar_icon(kIconDrawRectangularSelection),
		B_TRANSLATE("Selection mode"), false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(kMsgOriginalSize, this,
		tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true);
	fToolBar->AddAction(kMsgFitToWindow, this,
		tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false);
	fToolBar->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn),
		B_TRANSLATE("Zoom in"), false);
	fToolBar->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut),
		B_TRANSLATE("Zoom out"), false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(MSG_PAGE_PREV, this, tool_bar_icon(kIconPagePrevious),
		B_TRANSLATE("Previous page"), false);
	fToolBar->AddAction(MSG_PAGE_NEXT, this, tool_bar_icon(kIconPageNext),
		B_TRANSLATE("Next page"), false);
	fToolBar->AddGlue();
	fToolBar->AddAction(MSG_FULL_SCREEN, this,
		tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"),
		false);
	fToolBar->SetActionVisible(MSG_FULL_SCREEN, false);

	fToolBar->ResizeTo(viewFrame.Width(), fToolBar->MinSize().height);

	contentView->AddChild(fToolBar);

	if (fShowToolBar)
		viewFrame.top = fToolBar->Frame().bottom + 1;
	else
		fToolBar->Hide();

	fToolBarVisible = fShowToolBar;

	viewFrame.bottom = contentView->Bounds().bottom;
	viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;

	// create the image view
	fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED
			| B_FRAME_EVENTS);
	// wrap a scroll view around the view
	fScrollView = new BScrollView("image_scroller", fImageView,
		B_FOLLOW_ALL, 0, true, true, B_PLAIN_BORDER);
	contentView->AddChild(fScrollView);

	fStatusView = new ShowImageStatusView(fScrollView);
	fScrollView->AddChild(fStatusView);

	// Update minimum window size
	float toolBarMinWidth = fToolBar->MinSize().width;
	SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100,
		100000);

	// finish creating the window
	if (_LoadImage() != B_OK) {
		_LoadError(ref);
		Quit();
		return;
	}

	// add View menu here so it can access ShowImageView methods
	BMenu* menu = new BMenu(B_TRANSLATE_CONTEXT("View", "Menus"));
	_BuildViewMenu(menu, false);
	fBar->AddItem(menu);

	fBar->AddItem(_BuildRatingMenu());

	SetPulseRate(100000);
		// every 1/10 second; ShowImageView needs it for marching ants

	_MarkMenuItem(menu, MSG_SELECTION_MODE,
		fImageView->IsSelectionModeEnabled());

	// Tell application object to query the clipboard
	// and tell this window if it contains interesting data or not
	be_app_messenger.SendMessage(B_CLIPBOARD_CHANGED);

	// The window will be shown on screen automatically
	Run();
}