Beispiel #1
0
void
AppWindowPrefsView::MessageReceived (BMessage *msg)
{
	switch (msg->what)
	{
		case M_APPWINDOWPREFS_ENCODING_CHANGED:
			{
				BMenuItem *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				source->SetMarked(true);
				int32 encoding (msg->FindInt32("encoding"));
				vision_app->SetInt32("encoding", encoding);
			}
			break;
			
		case M_APPWINDOWPREFS_SETTING_CHANGED:
			{
				BControl *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				BString setting;
				msg->FindString ("setting", &setting);
				int32 value (source->Value() == B_CONTROL_ON);
				if ((setting.ICompare ("versionParanoid") == 0))
					value = !value;
				vision_app->SetBool (setting.String(), value);
			}
			break;
		default:
			BView::MessageReceived(msg);
			break;
	}
}
Beispiel #2
0
status_t
PControl::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	if (!fView)
		return B_NO_INIT;
	
	BControl *viewAsControl = (BControl*)fView;
	
	if (str.ICompare("Enabled") == 0)
		((BoolProperty*)prop)->SetValue(viewAsControl->IsEnabled());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(viewAsControl->Label());
	else if (str.ICompare("Value") == 0)
		((IntProperty*)prop)->SetValue(viewAsControl->Value());
	else
		return PView::GetProperty(name,value,index);
	
	return prop->GetValue(value);
}
Beispiel #3
0
bool HDialog::IsOn(const char *name) const
{
	BControl *ctrl;
	ctrl = dynamic_cast<BControl *>(FindView(name));
	if (ctrl)
		return ctrl->Value() == B_CONTROL_ON;
	else
		return false;
} /* HDialog::IsOn */
Beispiel #4
0
status_t
BMailProtocolConfigView::Archive(BMessage *into, bool deep) const
{
	const char *host = TextControl((BView *)this,"host");
	int32 port = -1;
	BString host_name = host;
	if (host_name.FindFirst(':') > -1) {
		port = atol(host_name.String() + host_name.FindFirst(':') + 1);
		host_name.Truncate(host_name.FindFirst(':'));
	}

	if (into->ReplaceString("server",host_name.String()) != B_OK)
		into->AddString("server",host_name.String());

	// since there is no need for the port option, remove it here
	into->RemoveName("port");
	if (port != -1)
		into->AddInt32("port",port);

	if (into->ReplaceString("username",TextControl((BView *)this,"user")) != B_OK)
		into->AddString("username",TextControl((BView *)this,"user"));

	// remove old unencrypted passwords
	into->RemoveName("password");

	set_passwd(into,"cpasswd",TextControl((BView *)this,"pass"));

	BMenuField *field;
	int32 index = -1;

	if ((field = (BMenuField *)(FindView("flavor"))) != NULL) {
		BMenuItem *item = field->Menu()->FindMarked();
		if (item != NULL)
			index = field->Menu()->IndexOf(item);
	}

	if (into->ReplaceInt32("flavor",index) != B_OK)
		into->AddInt32("flavor",index);

	index = -1;

	if ((field = (BMenuField *)(FindView("auth_method"))) != NULL) {
		BMenuItem *item = field->Menu()->FindMarked();
		if (item != NULL)
			index = field->Menu()->IndexOf(item);
	}

	if (into->ReplaceInt32("auth_method",index) != B_OK)
		into->AddInt32("auth_method",index);

	if (FindView("leave_mail_on_server") != NULL) {
		BControl* control = (BControl*)FindView("leave_mail_on_server");
		bool on = (control->Value() == B_CONTROL_ON);
		if (into->ReplaceBool("leave_mail_on_server", on) != B_OK)
			into->AddBool("leave_mail_on_server", on);

		control = (BControl*)FindView("delete_remote_when_local");
		on = (control->Value() == B_CONTROL_ON);
		if (into->ReplaceBool("delete_remote_when_local", on)) {
			into->AddBool("delete_remote_when_local", on);
		}
	} else {
		if (into->ReplaceBool("leave_mail_on_server", false) != B_OK)
			into->AddBool("leave_mail_on_server", false);

		if (into->ReplaceBool("delete_remote_when_local", false) != B_OK)
			into->AddBool("delete_remote_when_local", false);
	}

	if (fBodyDownloadConfig)
		fBodyDownloadConfig->Archive(into, deep);
	return B_OK;
}