2010-05-19 13:05:30 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Oliver Ruiz Dorantes. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Button.h>
|
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <ControlLook.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <ScrollView.h>
|
|
|
|
#include <StringView.h>
|
|
|
|
|
|
|
|
#include "CayaProtocol.h"
|
|
|
|
#include "PreferencesBehavior.h"
|
|
|
|
#include "CayaPreferences.h"
|
|
|
|
#include "ProtocolManager.h"
|
|
|
|
#include "ProtocolSettings.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "TheApp.h"
|
|
|
|
|
|
|
|
const uint32 kToCurrentWorkspace = 'CBcw';
|
|
|
|
const uint32 kActivateChatWindow = 'CBac';
|
2010-05-20 13:37:01 -05:00
|
|
|
const uint32 kIgnoreEmoticons = 'CBhe';
|
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2010-05-19 15:37:26 -05:00
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
PreferencesBehavior::PreferencesBehavior()
|
|
|
|
: BView("Behavior", B_WILL_DRAW)
|
|
|
|
{
|
|
|
|
|
|
|
|
fOnIncomming = new BStringView("onIncomming", "On incomming message ... ");
|
|
|
|
fOnIncomming->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
|
|
|
fOnIncomming->SetFont(be_bold_font);
|
|
|
|
|
|
|
|
fToCurrentWorkspace = new BCheckBox("ToCurrentWorkspace",
|
|
|
|
"Move window to current workspace",
|
|
|
|
new BMessage(kToCurrentWorkspace));
|
|
|
|
|
|
|
|
fActivateChatWindow = new BCheckBox("ActivateChatWindow",
|
|
|
|
"Get focus ",
|
|
|
|
new BMessage(kActivateChatWindow));
|
|
|
|
|
|
|
|
fPlaySoundOnMessageReceived = new BCheckBox("PlaySoundOnMessageReceived",
|
|
|
|
"Play sound event", NULL);
|
|
|
|
fPlaySoundOnMessageReceived->SetEnabled(false); // not implemented
|
|
|
|
|
2010-05-20 13:37:01 -05:00
|
|
|
fIgnoreEmoticons = new BCheckBox("IgnoreEmoticons",
|
|
|
|
"Ignore Emoticons",
|
|
|
|
new BMessage(kIgnoreEmoticons));
|
|
|
|
fIgnoreEmoticons->SetEnabled(true);
|
2010-05-19 13:05:30 -05:00
|
|
|
|
|
|
|
fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow",
|
|
|
|
"Mark unread window chat", NULL);
|
|
|
|
fMarkUnreadWindow->SetEnabled(false); // not implemented
|
|
|
|
|
|
|
|
const float spacing = be_control_look->DefaultItemSpacing();
|
|
|
|
|
|
|
|
SetLayout(new BGroupLayout(B_HORIZONTAL, spacing));
|
|
|
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
|
|
.Add(fOnIncomming)
|
|
|
|
.AddGroup(B_VERTICAL, spacing)
|
|
|
|
.Add(fToCurrentWorkspace)
|
|
|
|
.Add(fActivateChatWindow)
|
|
|
|
.Add(fMarkUnreadWindow)
|
|
|
|
.Add(fPlaySoundOnMessageReceived)
|
2010-05-19 17:06:25 -05:00
|
|
|
.SetInsets(spacing * 2, spacing, spacing, spacing)
|
2010-05-19 13:05:30 -05:00
|
|
|
.End()
|
2010-05-20 13:37:01 -05:00
|
|
|
.Add(fIgnoreEmoticons)
|
2010-05-19 17:06:25 -05:00
|
|
|
.AddGlue()
|
2010-05-19 13:05:30 -05:00
|
|
|
.SetInsets(spacing, spacing, spacing, spacing)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesBehavior::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fToCurrentWorkspace->SetTarget(this);
|
|
|
|
fActivateChatWindow->SetTarget(this);
|
2010-05-20 13:37:01 -05:00
|
|
|
fIgnoreEmoticons->SetTarget(this);
|
2010-05-19 13:05:30 -05:00
|
|
|
|
2010-05-19 15:37:26 -05:00
|
|
|
fToCurrentWorkspace->SetValue(
|
|
|
|
CayaPreferences::Item()->MoveToCurrentWorkspace);
|
|
|
|
fActivateChatWindow->SetValue(
|
|
|
|
CayaPreferences::Item()->ActivateWindow);
|
2010-05-20 13:37:01 -05:00
|
|
|
fIgnoreEmoticons->SetValue(
|
|
|
|
CayaPreferences::Item()->IgnoreEmoticons);
|
|
|
|
|
2010-05-19 13:05:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesBehavior::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
|
|
|
case kToCurrentWorkspace:
|
2010-05-19 15:37:26 -05:00
|
|
|
CayaPreferences::Item()->MoveToCurrentWorkspace
|
|
|
|
= fToCurrentWorkspace->Value();
|
2010-05-19 13:05:30 -05:00
|
|
|
break;
|
|
|
|
case kActivateChatWindow:
|
2010-05-19 15:37:26 -05:00
|
|
|
CayaPreferences::Item()->ActivateWindow
|
|
|
|
= fActivateChatWindow->Value();
|
2010-05-19 13:05:30 -05:00
|
|
|
break;
|
2010-05-20 13:37:01 -05:00
|
|
|
case kIgnoreEmoticons:
|
|
|
|
CayaPreferences::Item()->IgnoreEmoticons
|
|
|
|
= fIgnoreEmoticons->Value();
|
|
|
|
break;
|
2010-05-19 13:05:30 -05:00
|
|
|
default:
|
|
|
|
BView::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|