Exemple #1
0
bool
PrefWindow::QuitRequested()
{
	if (!fDirty)
		return true;

	BAlert *alert = new BAlert("",
		B_TRANSLATE("Save changes to this settings panel?"),
		B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"), B_TRANSLATE("Save"),
		B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
		B_WARNING_ALERT);
	alert->SetShortcut(0, B_ESCAPE);
	alert->SetShortcut(1, 'd');
	alert->SetShortcut(2, 's');

	int32 index = alert->Go();
	if (index == 0)
		return false;

	if (index == 2)
		_Save();
	else
		_Revert();

	return true;
}
Exemple #2
0
void
PrefWindow::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case MSG_SAVEAS_PRESSED:
			_SaveAs();
			break;

		case MSG_REVERT_PRESSED:
			_Revert();
			break;

		case MSG_DEFAULTS_PRESSED:
			PrefHandler::SetDefault(new PrefHandler(false));
			fTerminalMessenger.SendMessage(MSG_HALF_FONT_CHANGED);
			fTerminalMessenger.SendMessage(MSG_COLOR_CHANGED);
			fTerminalMessenger.SendMessage(MSG_TAB_TITLE_SETTING_CHANGED);
			fTerminalMessenger.SendMessage(MSG_WINDOW_TITLE_SETTING_CHANGED);
			fAppearanceView->Revert();
			// fallthrough

		case MSG_PREF_MODIFIED:
			fDirty = true;
			fRevertButton->SetEnabled(fDirty);
			break;

		case B_SAVE_REQUESTED:
			_SaveRequested(msg);
			break;

		default:
			BWindow::MessageReceived(msg);
			break;
	}
}
Exemple #3
0
void
PrefWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case MSG_SAVE_PRESSED:
			_Save();
			PostMessage(B_QUIT_REQUESTED);
			break;

		case MSG_SAVEAS_PRESSED:
			_SaveAs();
			break;

		case MSG_REVERT_PRESSED:
			_Revert();
			PostMessage(B_QUIT_REQUESTED);
			break;

		case MSG_PREF_MODIFIED:
			fDirty = true;
			break;

		case B_SAVE_REQUESTED:
			_SaveRequested(msg);
			break;

		default:
			BWindow::MessageReceived(msg);
			break;
	}
}
Exemple #4
0
void
ClockView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kGetClockSettings:
		{
			// Get current clock settings from Deskbar
			bool showClock;
			bool showSeconds;
			bool showDayOfWeek;
			bool showTimeZone;

			if (message->FindBool("showSeconds", &showSeconds) == B_OK) {
				fCachedShowSeconds = showSeconds
					? B_CONTROL_ON : B_CONTROL_OFF;
				fShowSeconds->SetValue(fCachedShowSeconds);
				fShowSeconds->SetEnabled(true);
			}

			if (message->FindBool("showDayOfWeek", &showDayOfWeek) == B_OK) {
				fCachedShowDayOfWeek = showDayOfWeek
					? B_CONTROL_ON : B_CONTROL_OFF;
				fShowDayOfWeek->SetValue(fCachedShowDayOfWeek);
				fShowDayOfWeek->SetEnabled(true);
			}

			if (message->FindBool("showTimeZone", &showTimeZone) == B_OK) {
				fCachedShowTimeZone = showTimeZone
					? B_CONTROL_ON : B_CONTROL_OFF;
				fShowTimeZone->SetValue(fCachedShowTimeZone);
				fShowTimeZone->SetEnabled(true);
			}

			// do this one last because it might disable the others
			if (message->FindBool("showClock", &showClock) == B_OK) {
				fCachedShowClock = showClock ? B_CONTROL_ON : B_CONTROL_OFF;
				fShowClock->SetValue(fCachedShowClock);
				fShowClock->SetEnabled(true);
				fShowSeconds->SetEnabled(showClock);
				fShowDayOfWeek->SetEnabled(showClock);
				fShowTimeZone->SetEnabled(showClock);
			}
			break;
		}

		case kShowHideTime:
		{
			bool showClock;
			if (message->FindBool("showClock", &showClock) == B_OK) {
				// message originated from Deskbar, handle special
				fShowClock->SetValue(showClock ? B_CONTROL_ON : B_CONTROL_OFF);
				fShowSeconds->SetEnabled(showClock);
				fShowDayOfWeek->SetEnabled(showClock);
				fShowTimeZone->SetEnabled(showClock);

				Window()->PostMessage(kMsgChange);
				break;
					// don't fall through
			}
			showClock = fShowClock->Value() == B_CONTROL_ON;
			fShowSeconds->SetEnabled(showClock);
			fShowDayOfWeek->SetEnabled(showClock);
			fShowTimeZone->SetEnabled(showClock);
		}
		// fall-through
		case kShowSeconds:
		case kShowDayOfWeek:
		case kShowTimeZone:
		{
			BMessenger* messenger = new BMessenger(kDeskbarSignature);
			messenger->SendMessage(message);

			Window()->PostMessage(kMsgChange);

			break;
		}

		case kMsgRevert:
			_Revert();
			break;

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