1/*
2 * Copyright 2010-2017, Haiku, Inc. All Rights Reserved.
3 * Copyright 2009, Pier Luigi Fiorini.
4 * Distributed under the terms of the MIT License.
5 *
6 * Authors:
7 *		Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
8 *		Brian Hill, supernova@tycho.email
9 */
10
11#include <Catalog.h>
12#include <CardLayout.h>
13#include <GroupLayout.h>
14#include <GroupLayoutBuilder.h>
15#include <LayoutItem.h>
16#include <Message.h>
17#include <Window.h>
18
19#include "NotificationsView.h"
20#include "PrefletView.h"
21#include "SettingsHost.h"
22
23
24#undef B_TRANSLATION_CONTEXT
25#define B_TRANSLATION_CONTEXT "PrefletView"
26
27
28PrefletView::PrefletView(SettingsHost* host)
29	:
30	BTabView("pages", B_WIDTH_FROM_WIDEST)
31{
32	// Pages
33	fGeneralView = new GeneralView(host);
34	NotificationsView* apps = new NotificationsView(host);
35
36	// Page selector
37	BTab* tab = new BTab();
38	AddTab(fGeneralView, tab);
39	tab->SetLabel(B_TRANSLATE("General"));
40
41	tab = new BTab();
42	AddTab(apps, tab);
43	tab->SetLabel(B_TRANSLATE("Applications"));
44}
45
46
47BView*
48PrefletView::CurrentPage()
49{
50	return PageAt(FocusTab());
51}
52
53
54BView*
55PrefletView::PageAt(int32 index)
56{
57	return TabAt(index)->View();
58}
59
60
61void
62PrefletView::Select(int32 index)
63{
64	if (index == Selection())
65		return;
66
67	BTabView::Select(index);
68
69	SettingsPane* pane = dynamic_cast<SettingsPane*>(PageAt(index));
70	bool showButtons = (pane != NULL) && pane->UseDefaultRevertButtons();
71	BMessage showMessage(kShowButtons);
72	showMessage.AddBool(kShowButtonsKey, showButtons);
73	Window()->PostMessage(&showMessage);
74}
75