void
NetworkStatusView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_NETWORK_MONITOR:
			_Update();
			break;

		case kMsgShowConfiguration:
			_ShowConfiguration(message);
			break;

		case kMsgOpenNetworkPreferences:
			_OpenNetworksPreferences();
			break;

		case kMsgJoinNetwork:
		{
			const char* deviceName;
			const char* name;
			if (message->FindString("device", &deviceName) == B_OK
				&& message->FindString("name", &name) == B_OK) {
				BNetworkDevice device(deviceName);
				status_t status = device.JoinNetwork(name);
				if (status != B_OK) {
					BString text
						= B_TRANSLATE("Could not join wireless network:\n");
					text << strerror(status);
					BAlert* alert = new BAlert(name, text.String(),
						B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
						B_STOP_ALERT);
					alert->Go(NULL);
				}
			}
			break;
		}

		case B_ABOUT_REQUESTED:
			_AboutRequested();
			break;

		case B_QUIT_REQUESTED:
			_Quit();
			break;

		default:
			BView::MessageReceived(message);
	}
}
Esempio n. 2
0
bool
BootManagerController::_WriteBootMenu()
{
	BAlert* alert = new BAlert("confirm", B_TRANSLATE("About to write the "
			"boot menu to disk. Are you sure you want to continue?"),
		B_TRANSLATE_COMMENT("Write boot menu", "Button"),
		B_TRANSLATE_COMMENT("Back", "Button"), NULL, B_WIDTH_AS_USUAL,
		B_WARNING_ALERT);

	if (alert->Go() == 1)
		return false;

	fWriteBootMenuStatus = fBootMenu->Install(*fBootDrive, fSettings);
	return true;
}
Esempio n. 3
0
void
FolderShaper::AddTemplatesMessage	()
{
	BPath p;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK);
	if (p.SetTo(p.Path(),"Kirilla/FolderShaper/Templates") != B_OK);

	BString text("Put your template folders in this folder (");
	text.Append(p.Path());
	text.Append("), then try again.");

	BAlert *box = new BAlert("FolderShaper", text.String(),
							 "I will", NULL, NULL, B_WIDTH_AS_USUAL, B_IDEA_ALERT);
	box->Go();
}
Esempio n. 4
0
void
ServerAgent::DCCChatDialog(BString theNick, BString theIP, BString thePort)
{
  BString theText(theNick);
  theText << S_SERVER_DCC_CHAT_PROMPT;
  BAlert *myAlert = new BAlert("DCC request", theText.String(), "Accept",
    "Refuse");
  myAlert->SetFeel (B_FLOATING_APP_WINDOW_FEEL);
  BMessage *myMessage = new BMessage(M_CHAT_ACCEPT);
  myMessage->AddString("nick", theNick.String());
  myMessage->AddString("ip", theIP.String());
  myMessage->AddString("port", thePort.String());
  BInvoker *myInvoker = new BInvoker(myMessage, this);
  myAlert->Go(myInvoker);
}
Esempio n. 5
0
void
error_alert(const char* message, status_t status, alert_type type)
{
	char warning[512];
	if (status != B_OK) {
		snprintf(warning, sizeof(warning), "%s:\n\t%s\n", message,
			strerror(status));
	}

	BAlert* alert = new BAlert(B_TRANSLATE("FileTypes request"),
		status == B_OK ? message : warning,
		B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, type);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
}
void
NetworkStatusView::_OpenNetworksPreferences()
{
	status_t status = be_roster->Launch("application/x-vnd.Haiku-Network");
	if (status != B_OK && status != B_ALREADY_RUNNING) {
		BString errorMessage(B_TRANSLATE("Launching the network preflet "
			"failed.\n\nError: "));
		errorMessage << strerror(status);
		BAlert* alert = new BAlert("launch error", errorMessage.String(),
			B_TRANSLATE("OK"));

		// asynchronous alert in order to not block replicant host application
		alert->Go(NULL);
	}
}
void ColumnProperties::SetPrimaryKey(bool key)
{
	fPrimaryKey = key;

	if (!fPrimaryKey && fAutoNumber)
	{
		BString msg("AutoNumber fields are required to be primary keys.");
		BAlert* alert = new BAlert("Title", msg.String(), "Ok");
		alert->SetShortcut(0, B_ESCAPE);
		alert->Go();

		fPrimaryKey = true;
	}

}
Esempio n. 8
0
void
SudokuWindow::_MessageDropped(BMessage* message)
{
	status_t status = B_MESSAGE_NOT_UNDERSTOOD;
	bool hasRef = false;

	entry_ref ref;
	if (message->FindRef("refs", &ref) != B_OK) {
		const void* data;
		ssize_t size;
		if (message->FindData("text/plain", B_MIME_TYPE, &data,
				&size) == B_OK) {
			status = fSudokuView->SetTo((const char*)data);
		} else
			return;
	} else {
		status = fSudokuView->SetTo(ref);
		if (status == B_OK)
			be_roster->AddToRecentDocuments(&ref, kSignature);

		BEntry entry(&ref);
		entry_ref parent;
		if (entry.GetParent(&entry) == B_OK
			&& entry.GetRef(&parent) == B_OK)
			fSavePanel->SetPanelDirectory(&parent);

		hasRef = true;
	}

	if (status < B_OK) {
		char buffer[1024];
		if (hasRef) {
			snprintf(buffer, sizeof(buffer),
				B_TRANSLATE("Could not open \"%s\":\n%s\n"), ref.name,
				strerror(status));
		} else {
			snprintf(buffer, sizeof(buffer),
				B_TRANSLATE("Could not set Sudoku:\n%s\n"),
				strerror(status));
		}

		BAlert* alert = new BAlert(B_TRANSLATE("Sudoku request"),
			buffer, B_TRANSLATE("OK"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
	}
}
void
TermApp::ReadyToRun()
{
	// Prevent opeing window when option -h is given.
	if (sUsageRequested)
		return;

	// Install a SIGCHLD signal handler, so that we will be notified, when
	// a shell exits.
	struct sigaction action;
#ifdef __HAIKU__
	action.sa_handler = (__sighandler_t)_SigChildHandler;
#else
	action.sa_handler = (__signal_func_ptr)_SigChildHandler;
#endif
	sigemptyset(&action.sa_mask);
#ifdef SA_NODEFER
	action.sa_flags = SA_NODEFER;
#endif
	action.sa_userdata = this;
	if (sigaction(SIGCHLD, &action, NULL) < 0) {
		fprintf(stderr, "sigaction() failed: %s\n",
			strerror(errno));
		// continue anyway
	}

	// init the mouse copy'n'paste clipboard
	gMouseClipboard = new BClipboard(MOUSE_CLIPBOARD_NAME, true);

	status_t status = _MakeTermWindow();

	// failed spawn, print stdout and open alert panel
	// TODO: This alert does never show up.
	if (status < B_OK) {
		BAlert* alert = new BAlert("alert",
			B_TRANSLATE("Terminal couldn't start the shell. Sorry."),
			B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_FROM_LABEL,
			B_INFO_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
		PostMessage(B_QUIT_REQUESTED);
		return;
	}

	// using BScreen::Frame isn't enough
	if (fStartFullscreen)
		BMessenger(fTermWindow).SendMessage(FULLSCREEN);
}
Esempio n. 10
0
// Save data
void AppWindow::OnSave(BMessage *msg) {
entry_ref ref;
BString name;
	msg->FindRef("directory", &ref);
	msg->FindString("name", &name);
	BDirectory dir(&ref);
	BFile file(&dir, name.String(), B_CREATE_FILE | B_WRITE_ONLY);
	if (file.InitCheck() == B_OK) {
		BMessage archive;
		view->graph->Archive(&archive);
		archive.Flatten(&file);
	} else {
		BAlert *a = new BAlert("Save Error", "Could not write file", "OK");
		a->Go();
	}
}
void DeskbarPulseView::Remove() {
	// Remove ourselves from the deskbar by name
	BDeskbar *deskbar = new BDeskbar();
	status_t err = deskbar->RemoveItem("DeskbarPulseView");
	if (err != B_OK) {
		BString str;
		snprintf(str.LockBuffer(512), 512,
			B_TRANSLATE("Removing from Deskbar failed.\n%s"), strerror(err));
		str.UnlockBuffer();
		BAlert *alert = new BAlert(B_TRANSLATE("Info"), str.String(),
			B_TRANSLATE("OK"));
		alert->SetShortcut(0, B_ESCAPE);
		alert->Go(NULL);
	}
	delete deskbar;
}
Esempio n. 12
0
/* exported function defined in beos/gui.h */
nserror beos_warn_user(const char *warning, const char *detail)
{
	LOG("warn_user: %s (%s)", warning, detail);
	BAlert *alert;
	BString text(warning);
	if (detail)
		text << ":\n" << detail;

	alert = new BAlert("NetSurf Warning", text.String(), "Debug", "Ok",
                           NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
	if (alert->Go() < 1) {
		debugger("warn_user");
        }
        
        return NSERROR_OK;
}
Esempio n. 13
0
status_t
CPUButton::Invoke(BMessage *message)
{
	if (!LastEnabledCPU(fCPU)) {
		_kern_set_cpu_enabled(fCPU, Value());
	} else {
		BAlert *alert = new BAlert(B_TRANSLATE("Info"),
			B_TRANSLATE("You can't disable the last active CPU."),
			B_TRANSLATE("OK"));
		alert->SetShortcut(0, B_ESCAPE);
		alert->Go(NULL);
		SetValue(!Value());
	}

	return B_OK;
}
Esempio n. 14
0
void gui_message (const char *format,...)
{
    char msg[2048];
    va_list parms;
    BAlert *alert;

    va_start (parms,format);
    vsprintf (msg, format, parms);
    va_end (parms);

    write_log (msg);

    alert = new BAlert ("UAE Information", msg, "Okay", NULL, NULL,
			B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
    alert->Go();
}
Esempio n. 15
0
void
GrepWindow::_OnTrimSelection()
{
	if (fSearchResults->CurrentSelection() < 0) {
		BString text;
		text << B_TRANSLATE("Please select the files you wish to keep searching.");
		text << "\n";
		text << B_TRANSLATE("The unselected files will be removed from the list.");
		text << "\n";
		BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
		return;
	}

	BMessage message;
	BString path;

	for (int32 index = 0; ; index++) {
		BStringItem* item = dynamic_cast<BStringItem*>(
			fSearchResults->ItemAt(index));
		if (item == NULL)
			break;

		if (!item->IsSelected() || item->OutlineLevel() != 0)
			continue;

		if (path == item->Text())
			continue;

		path = item->Text();
		entry_ref ref;
		if (get_ref_for_path(path.String(), &ref) == B_OK)
			message.AddRef("refs", &ref);
	}

	fModel->fDirectory = entry_ref();
		// invalidated on purpose

	fModel->fSelectedFiles.MakeEmpty();
	fModel->fSelectedFiles = message;

	PostMessage(MSG_START_CANCEL);

	_SetWindowTitle();
}
Esempio n. 16
0
MainApp::MainApp()
	:
	BApplication(kAppSig),
	fPlayerCount(0),
	fSettingsWindow(NULL),

	fOpenFilePanel(NULL),
	fSaveFilePanel(NULL),
	fLastFilePanelFolder(),

	fMediaServerRunning(false),
	fMediaAddOnServerRunning(false),

	fAudioWindowFrameSaved(false),
	fLastSavedAudioWindowCreationTime(0)
{
	fLastFilePanelFolder = Settings::Default()->FilePanelFolder();

	// Now tell the application roster, that we're interested
	// in getting notifications of apps being launched or quit.
	// In this way we are going to detect a media_server restart.
	be_roster->StartWatching(BMessenger(this, this),
		B_REQUEST_LAUNCHED | B_REQUEST_QUIT);
	// we will keep track of the status of media_server
	// and media_addon_server
	fMediaServerRunning = be_roster->IsRunning(kMediaServerSig);
	fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig);

	if (!fMediaServerRunning || !fMediaAddOnServerRunning) {
		BAlert* alert = new BAlert("start_media_server",
			B_TRANSLATE("It appears the media server is not running.\n"
			"Would you like to start it ?"), B_TRANSLATE("Quit"),
			B_TRANSLATE("Start media server"), NULL,
			B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetShortcut(0, B_ESCAPE);
		
		if (alert->Go() == 0) {
			PostMessage(B_QUIT_REQUESTED);
			return;
		}

		launch_media_server();

		fMediaServerRunning = be_roster->IsRunning(kMediaServerSig);
		fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig);
	}
}
void
NotificationWindow::_LoadDisplaySettings(bool startMonitor)
{
	BPath path;
	BMessage settings;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return;

	path.Append(kSettingsDirectory);
	if (create_directory(path.Path(), 0755) == B_OK) {
		path.Append(kDisplaySettings);

		BFile file(path.Path(), B_READ_ONLY);
		settings.Unflatten(&file);
	}

	int32 setting;

	if (settings.FindFloat(kWidthName, &fWidth) != B_OK)
		fWidth = kDefaultWidth;

	if (settings.FindInt32(kIconSizeName, &setting) != B_OK)
		fIconSize = kDefaultIconSize;
	else
		fIconSize = (icon_size)setting;

	// Notify the view about the change
	views_t::iterator it;
	for (it = fViews.begin(); it != fViews.end(); ++it) {
		NotificationView* view = (*it);
		view->Invalidate();
	}

	if (startMonitor) {
		node_ref nref;
		BEntry entry(path.Path());
		entry.GetNodeRef(&nref);

		if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) {
			BAlert* alert = new BAlert(B_TRANSLATE("Warning"),
				B_TRANSLATE("Couldn't start display settings monitor.\n"
					"Live filter changes disabled."), B_TRANSLATE("OK"));
			alert->Go();
		}
	}
}
Esempio n. 18
0
bool PecoApp::NothingToDo() {

	FileListItem	*ListItem;
	
	bool nothing_to_do = true;
	
	for (int32 i = 0; (ListItem = (FileListItem *)fListView->ItemAt(i)) != NULL; i++ )
		if (ListItem->fNewName.Length() > 0 ) { nothing_to_do = false; break; }
	
	if (nothing_to_do) {
		BAlert	*myAlert	= new BAlert(NULL, MESSAGE_NOTHING_TO_DO, STR_WELL);
		myAlert->Go();
	}
	
	return	nothing_to_do;

}
Esempio n. 19
0
//Used when a files/joysticks are no were to be found
status_t
JoyWin::_ShowCantFindFileMessage(const char* port)
{
	BString str("The file '");
	str <<  _FixPathToName(port).String() << "' used by '" << port;
	str << "' cannot be found.\n Do you want to ";
	str << "try auto-detecting a joystick for this port?";

	BAlert *alert = new BAlert("test1", str.String(), "Stop", "Probe");
	alert->SetShortcut(1, B_ENTER);
	int32 bindex = alert->Go();

	if (bindex == 1)
		return B_OK;
	else
		return B_ERROR;
}
Esempio n. 20
0
/*!
	Is called when the app receives a B_READY_TO_RUN message. The message
	is sent automatically during the Run() function, and is sent after the
	initial B_REFS_RECEIVED and B_ARGV_RECEIVED messages (if any) have been
	handled.
*/
void
AlertApplication::ReadyToRun()
{
	if (GoodArguments()) {
		BAlert* alert = new BAlert("alert", fArgumentText,
			fArgumentButton0, fArgumentButton1, fArgumentButton2,
			B_WIDTH_AS_USUAL, fIcon);

		if (fModal)
			alert->SetFeel(B_MODAL_ALL_WINDOW_FEEL);

		_SetChoice(alert->Go());
	} else
		_Usage();

	Quit();
}
Esempio n. 21
0
status_t
UrlWrapper::_Warn(const char* url)
{
	BString message("An application has requested the system to open the "
		"following url: \n");
	message << "\n" << url << "\n\n";
	message << "This type of URL has a potential security risk.\n";
	message << "Proceed anyway?";
	BAlert* alert = new BAlert("Warning", message.String(), "Proceed", "Stop", NULL,
		B_WIDTH_AS_USUAL, B_WARNING_ALERT);
	int32 button;
	button = alert->Go();
	if (button == 0)
		return B_OK;
		
	return B_ERROR;
}
Esempio n. 22
0
void
FieldView::ToggleBox(const IntPoint &pt)
{
	switch (fField->GetState(pt))
	{
		case BOX_MARKED:
		{
			fField->SetState(pt,BOX_QUESTION);
			fFlagCount--;
			Window()->PostMessage(M_UPDATE_COUNT);
			break;
		}
		case BOX_QUESTION:
		{
			fField->SetState(pt,BOX_UNMARKED);
			break;
		}
		case BOX_UNMARKED:
		{
			if (fFlagCount == fField->MineCount())
			{
				BAlert *alert = new BAlert(B_TRANSLATE_SYSTEM_NAME("BeMines"),B_TRANSLATE("You have already set as many "
									"flags as there are mines. Unflag a tile "
									"before trying to flag another one."),B_TRANSLATE("OK"));
				alert->Go();
				break;
			}

			fField->SetState(pt,BOX_MARKED);
			fFlagCount++;
			Window()->PostMessage(M_UPDATE_COUNT);

			if (CheckWin())
			{
				DoWin();
				break;
			}
			break;
		}
		default:
		{
			break;
		}
	}
	Invalidate(gGameStyle->TileRect(pt.x,pt.y));
}
Esempio n. 23
0
void BepdfApplication::AboutRequested()
{
	BString version;
	BString str("BePDF\n");
	str += B_TRANSLATE("Version");
	str += " ";
	str += GetVersion(version);
	str += "\n";

	str += bePDFCopyright;

	str += "\n";
	str += B_TRANSLATE_COMMENT("Language 'English', translated by the BePDF authors.",
		"Replace 'English' with the language you're translating to, and 'the BePDF authors' with your name or your translation group's name.");
	str += "\n\n";

	str += BString().SetToFormat(B_TRANSLATE_COMMENT("BePDF is based on XPDF %s, %s.", "XPDF version, copyright"),
		xpdfVersion, xpdfCopyright);

	str += GPLCopyright;

	BAlert *about = new BAlert("About", str.String(), "OK");
	BTextView *v = about->TextView();
	if (v) {
		rgb_color red = {255, 0, 51, 255};
		rgb_color blue = {0, 102, 255, 255};

		v->SetStylable(true);
		char *text = (char*)v->Text();
		char *s = text;
		// set all Be in BePDF in blue and red
		while ((s = strstr(s, "BePDF")) != NULL) {
			int32 i = s - text;
			v->SetFontAndColor(i, i+1, NULL, 0, &blue);
			v->SetFontAndColor(i+1, i+2, NULL, 0, &red);
			s += 2;
		}
		// first text line
		s = strchr(text, '\n');
		BFont font;
		v->GetFontAndColor(0, &font);
		font.SetSize(16);
		v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE);
	};
	about->Go();
}
Esempio n. 24
0
// ShowTracker -- Asks if you wish to view your project in the Tracker or not after creation
void NewProjectWindow::ShowTracker(char apath[256],char AppName[256]) 
{
	char tmp[256];
	char cmd[256];
	BAlert *alert;
    long result;
    
	sprintf(tmp,"Your Project \"%s\" has now been created.\n\nAll your files are located at:-\n\n%s/%s",AppName,apath,AppName);
    alert = new BAlert("", tmp, "   Tracker   ", "   Continue   ", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
	alert->SetShortcut(0, B_ESCAPE);
	result = alert->Go();
    if (result == B_OK)
   	{
		sprintf(cmd,"$(finddir B_SYSTEM_DIRECTORY)/Tracker %s/projects/%s",apath,AppName);
		system(cmd);	
	}	
}
Esempio n. 25
0
void
FontsApp::AboutRequested()
{
	BAlert *alert = new BAlert("about", B_TRANSLATE("Fonts\n"
		"\tCopyright 2004-2005, Haiku.\n\n"), B_TRANSLATE("OK"));
	BTextView *view = alert->TextView();
	BFont font;

	view->SetStylable(true);

	view->GetFont(&font);
	font.SetSize(18);
	font.SetFace(B_BOLD_FACE);
	view->SetFontAndColor(0, 5, &font);

	alert->Go();
}
Esempio n. 26
0
/**	Hook function: called when user requests about information.
 */
void BmeApp::AboutRequested()
{	
	//get application version, from SimplyVorbis code!
	app_info ai;
	version_info vi;
	be_app->GetAppInfo(&ai);
	BFile file(&ai.ref,B_READ_ONLY);
	BAppFileInfo appinfo(&file);
	appinfo.GetVersionInfo(&vi,B_APP_VERSION_KIND);

	BString variety;
	switch(vi.variety)
	{
		case 0:
			variety = "d";
			break;
		case 1:
			variety = "a";
			break;
		case 2:
			variety = "b";
			break;
		case 3:
			variety = "g";
			break;
		case 4:
			variety = "rc";
			break;
		default:
			variety = "Final";
			break;
	}
	
	char version[64];
	if(variety!="Final")
		sprintf(version,"%s %lu.%lu %s%lu","v",vi.major,
			vi.middle,variety.String(),vi.internal);
	else
		sprintf(version,"%s %lu.%lu","v",vi.major,vi.middle);
	
	BString bmeVersion = "Bme ";
	bmeVersion << version << "\n\n" << AppConstants::K_ABOUT_TEXT;	
	BAlert *alert = new BAlert("Info", bmeVersion.String(), "OK");
	alert->Go(NULL);
	
}
Esempio n. 27
0
void
NetServer::AboutRequested()
{
	BAlert *alert = new BAlert("about", "Networking Server\n"
		"\tCopyright " B_UTF8_COPYRIGHT "2006, Antares.\n", "OK");
	BTextView *view = alert->TextView();
	BFont font;

	view->SetStylable(true);

	view->GetFont(&font);
	font.SetSize(18);
	font.SetFace(B_BOLD_FACE);
	view->SetFontAndColor(0, 17, &font);

	alert->Go(NULL);
}
Esempio n. 28
0
status_t
LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect)
{
	BView *view = NULL;
	if (translator->MakeConfigurationView(NULL, &view, &rect)) {
		BAlert *err = new BAlert(B_TRANSLATE("Error"),
			B_TRANSLATE("Unable to create the view."), B_TRANSLATE("OK"));
		err->SetFlags(err->Flags() | B_CLOSE_ON_ESCAPE);
		err->Go();
		return B_ERROR;
	}
	// release the translator even though I never really used it anyway
	translator->Release();
	translator = NULL;

	TranslatorWindow *wnd = new TranslatorWindow(rect, title);
	wnd->AddChild(view);
	BPoint wndpt = B_ORIGIN;
	{
		BScreen scrn;
		BRect frame = scrn.Frame();
		frame.InsetBy(10, 23);
		// if the point is outside of the screen frame,
		// use the mouse location to find a better point
		if (!frame.Contains(wndpt)) {
			uint32 dummy;
			view->GetMouse(&wndpt, &dummy, false);
			wndpt.x -= rect.Width() / 2;
			wndpt.y -= rect.Height() / 2;
			// clamp location to screen
			if (wndpt.x < frame.left)
				wndpt.x = frame.left;
			if (wndpt.y < frame.top)
				wndpt.y = frame.top;
			if (wndpt.x > frame.right)
				wndpt.x = frame.right;
			if (wndpt.y > frame.bottom)
				wndpt.y = frame.bottom;
		}
	}
	wnd->MoveTo(wndpt);
	wnd->Show();
	
	return B_OK;
}
Esempio n. 29
0
void
NotificationWindow::LoadAppFilters(bool startMonitor)
{
    BPath path;

    if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
        return;

    path.Append(kSettingsDirectory);

    if (create_directory(path.Path(), 0755) != B_OK)
        return;

    path.Append(kFiltersSettings);

    BFile file(path.Path(), B_READ_ONLY);
    BMessage settings;
    if (settings.Unflatten(&file) != B_OK)
        return;

    type_code type;
    int32 count = 0;

    if (settings.GetInfo("app_usage", &type, &count) != B_OK)
        return;

    for (int32 i = 0; i < count; i++) {
        AppUsage* app = new AppUsage();
        settings.FindFlat("app_usage", i, app);
        fAppFilters[app->Name()] = app;
    }

    if (startMonitor) {
        node_ref nref;
        BEntry entry(path.Path());
        entry.GetNodeRef(&nref);

        if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) {
            BAlert* alert = new BAlert(B_TRANSLATE("Warning"),
                                       B_TRANSLATE("Couldn't start filter monitor."
                                                   " Live filter changes disabled."), B_TRANSLATE("Darn."));
            alert->Go();
        }
    }
}
void
DecorSettingsView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case kMsgSetDecor:
		{
			BString newDecor;
			if (msg->FindString("decor", &newDecor) == B_OK)
				_SetDecor(newDecor);
			break;
		}
		case kMsgDecorInfo:
		{
			DecorInfo* decor = fDecorUtility.FindDecorator(fCurrentDecor);
			if (decor == NULL)
				break;

			BString authorsText(decor->Authors().String());
			authorsText.ReplaceAll(", ", "\n    ");

			BString infoText("Name: %decorName\n"
				"Authors:\n    %decorAuthors\n"
				"URL: %decorURL\n"
				"License: %decorLic\n"
				"Description:\n    %decorDesc\n");

			infoText.ReplaceFirst("%decorName", decor->Name().String());
			infoText.ReplaceFirst("%decorAuthors", authorsText.String());
			infoText.ReplaceFirst("%decorLic", decor->LicenseName().String());
			infoText.ReplaceFirst("%decorURL", decor->SupportURL().String());
			infoText.ReplaceFirst("%decorDesc", decor->ShortDescription().String());

			BAlert *infoAlert = new BAlert(B_TRANSLATE("About Decorator"),
				infoText.String(), B_TRANSLATE("OK"));
			infoAlert->SetShortcut(0, B_ESCAPE); 
			infoAlert->Go(); 

			break;
		}

		default:
			BView::MessageReceived(msg);
			break;
	}
}