vfs: check userland buffers before reading them.
[haiku.git] / src / preferences / notifications / PrefletView.cpp
blobe69505f3be6fca8ddce8fc5636d65ffe8ac68c1d
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.
6 * Authors:
7 * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
8 * Brian Hill, supernova@tycho.email
9 */
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>
19 #include "NotificationsView.h"
20 #include "PrefletView.h"
21 #include "SettingsHost.h"
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "PrefletView"
28 PrefletView::PrefletView(SettingsHost* host)
30 BTabView("pages", B_WIDTH_FROM_WIDEST)
32 // Pages
33 fGeneralView = new GeneralView(host);
34 NotificationsView* apps = new NotificationsView(host);
36 // Page selector
37 BTab* tab = new BTab();
38 AddTab(fGeneralView, tab);
39 tab->SetLabel(B_TRANSLATE("General"));
41 tab = new BTab();
42 AddTab(apps, tab);
43 tab->SetLabel(B_TRANSLATE("Applications"));
47 BView*
48 PrefletView::CurrentPage()
50 return PageAt(FocusTab());
54 BView*
55 PrefletView::PageAt(int32 index)
57 return TabAt(index)->View();
61 void
62 PrefletView::Select(int32 index)
64 if (index == Selection())
65 return;
67 BTabView::Select(index);
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);