hrev54560 adds 1 changeset to branch 'master'
old head: a52008cb44a01969383ee92966a3c03d55911b46
new head: 8ed52b6280d7ada345cd3014c2103e1f75df7047
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=8ed52b6280d7+%5Ea52008cb44a0
----------------------------------------------------------------------------
8ed52b6280d7: FirstBootPrompt: Exiting is now possible
- Exiting the window when the Desktop is not running will result in a reboot.
- Otherwise, the window will just close ordinarily.
- A confirmation box pops up before rebooting.
- Made other optimizations for running FirstBootPrompt on the Desktop.
- Moved some definitions to the header files.
- Added "UsePrivateSystemHeaders" to the Jamfile.
(Thank you, PulkoMandy!)
Change-Id: I34d6538d7b538d36448498ad1ecd442d76bd2bb6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3204
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
[ Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev54560
Commit: 8ed52b6280d7ada345cd3014c2103e1f75df7047
URL: https://git.haiku-os.org/haiku/commit/?id=8ed52b6280d7
Author: Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx>
Date: Thu Sep 10 12:44:03 2020 UTC
Committer: Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Mon Sep 14 13:35:51 2020 UTC
----------------------------------------------------------------------------
5 files changed, 99 insertions(+), 13 deletions(-)
src/apps/firstbootprompt/BootPrompt.cpp | 36 ++++++++++++--
src/apps/firstbootprompt/BootPrompt.h | 7 ++-
src/apps/firstbootprompt/BootPromptWindow.cpp | 59 +++++++++++++++++++----
src/apps/firstbootprompt/BootPromptWindow.h | 8 +++
src/apps/firstbootprompt/Jamfile | 2 +
----------------------------------------------------------------------------
diff --git a/src/apps/firstbootprompt/BootPrompt.cpp
b/src/apps/firstbootprompt/BootPrompt.cpp
index c19a41c295..9352123294 100644
--- a/src/apps/firstbootprompt/BootPrompt.cpp
+++ b/src/apps/firstbootprompt/BootPrompt.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2010, Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2020, Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx>
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -12,7 +13,7 @@
#include <LaunchRoster.h>
#include <Locale.h>
-#include "BootPromptWindow.h"
+#include <syscalls.h>
static int sExitValue;
@@ -31,6 +32,7 @@ main(int, char **)
const char* kAppSignature = "application/x-vnd.Haiku-FirstBootPrompt";
+const char* kDeskbarSignature = "application/x-vnd.Be-TSKB";
BootPromptApp::BootPromptApp()
@@ -44,16 +46,44 @@ void
BootPromptApp::MessageReceived(BMessage* message)
{
switch (message->what) {
+ // Booting the desktop or running the installer both result
+ // in sending a B_QUIT_REQUESTED message that ultimately
+ // closes the FirstBootPrompt window. However, according to
+ // BootPromptWindow::QuitRequested(), if the BootPromptWindow
+ // is not running on a desktop and the user decides to close
+ // the window using the button, the user will be asked if
+ // they wish to reboot their system.
+ //
+ // Asking that in the former scenarios would not make much
+ // sense. "dont_reboot" explicitly states that the user does
+ // not wish to reboot their system, which suppresses the
+ // confirm box.
case MSG_BOOT_DESKTOP:
+ {
BLaunchRoster().Target("desktop");
sExitValue = 1;
- PostMessage(B_QUIT_REQUESTED);
+
+ BMessage* newMessage = new BMessage(B_QUIT_REQUESTED);
+ newMessage->AddBool("dont_reboot", true);
+ PostMessage(newMessage);
break;
+ }
case MSG_RUN_INSTALLER:
+ {
BLaunchRoster().Target("installer");
sExitValue = 0;
- PostMessage(B_QUIT_REQUESTED);
+
+ BMessage* newMessage = new BMessage(B_QUIT_REQUESTED);
+ newMessage->AddBool("dont_reboot", true);
+ PostMessage(newMessage);
+ break;
+ }
+ case MSG_REBOOT_REQUESTED:
+ {
+ _kern_shutdown(true);
+ sExitValue = -1;
break;
+ }
default:
BApplication::MessageReceived(message);
diff --git a/src/apps/firstbootprompt/BootPrompt.h
b/src/apps/firstbootprompt/BootPrompt.h
index cb357bfc9d..c479c90a39 100644
--- a/src/apps/firstbootprompt/BootPrompt.h
+++ b/src/apps/firstbootprompt/BootPrompt.h
@@ -1,5 +1,6 @@
/*
* Copyright 2010, Stephan Aßmus <superstippi@xxxxxx>.
+ * Copyright 2020, Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BOOT_PROMPT_APP_H
@@ -7,13 +8,16 @@
#include <Application.h>
+#include "BootPromptWindow.h"
enum {
MSG_BOOT_DESKTOP = 'dktp',
- MSG_RUN_INSTALLER = 'inst'
+ MSG_RUN_INSTALLER = 'inst',
+ MSG_REBOOT_REQUESTED = 'rebt'
};
extern const char* kAppSignature;
+extern const char* kDeskbarSignature;
class BootPromptApp : public BApplication {
@@ -24,4 +28,5 @@ public:
virtual void ReadyToRun();
};
+
#endif // BOOT_PROMPT_APP_H
diff --git a/src/apps/firstbootprompt/BootPromptWindow.cpp
b/src/apps/firstbootprompt/BootPromptWindow.cpp
index 2987138d42..587a95243b 100644
--- a/src/apps/firstbootprompt/BootPromptWindow.cpp
+++ b/src/apps/firstbootprompt/BootPromptWindow.cpp
@@ -2,6 +2,7 @@
* Copyright 2010, Stephan Aßmus <superstippi@xxxxxx>
* Copyright 2010, Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx>
* Copyright 2011, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2020, Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx>
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -11,6 +12,7 @@
#include <new>
#include <stdio.h>
+#include <Alert.h>
#include <Bitmap.h>
#include <Button.h>
#include <Catalog.h>
@@ -30,6 +32,7 @@
#include <MutableLocaleRoster.h>
#include <ObjectList.h>
#include <Path.h>
+#include <Roster.h>
#include <Screen.h>
#include <ScrollView.h>
#include <SeparatorView.h>
@@ -46,12 +49,6 @@
using BPrivate::MutableLocaleRoster;
-enum {
- MSG_LANGUAGE_SELECTED = 'lngs',
- MSG_KEYMAP_SELECTED = 'kmps'
-};
-
-
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "BootPromptWindow"
@@ -138,9 +135,8 @@ compare_void_menu_items(const void* _a, const void* _b)
BootPromptWindow::BootPromptWindow()
:
BWindow(BRect(0, 0, 530, 400), "",
- B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE |
B_NOT_CLOSABLE
- | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS,
- B_ALL_WORKSPACES),
+ B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE |
B_NOT_RESIZABLE
+ | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES),
fDefaultKeymapItem(NULL)
{
SetSizeLimits(450, 16384, 350, 16384);
@@ -255,6 +251,13 @@ BootPromptWindow::BootPromptWindow()
fInfoTextView->SetText("x\n\n\n\n\n\n\n\n\n\n\n\n\n\nx");
ResizeToPreferred();
+ // Minimizing will not be possible, unless if the user is
+ // able to bring the window back up. That means that the
+ // Desktop must be running, in order for the window to be
+ // minimizable.
+ if (!be_roster->IsRunning(kDeskbarSignature))
+ SetFlags(Flags() | B_NOT_MINIMIZABLE);
+
_UpdateStrings();
CenterOnScreen();
Show();
@@ -299,6 +302,44 @@ BootPromptWindow::MessageReceived(BMessage* message)
}
+bool
+BootPromptWindow::QuitRequested()
+{
+ if (!be_roster->IsRunning(kDeskbarSignature) &&
+ !CurrentMessage()->GetBool("dont_reboot"))
+ {
+ // If the Deskbar is not running, then FirstBootPrompt is
+ // is the only thing visible on the screen and that we won't
+ // have anything else to show. In that case, it would make
+ // sense to reboot the machine instead, but doing so without
+ // a warning could be confusing.
+ //
+ // Rebooting is managed by BootPrompt.cpp.
+
+ BAlert* alert = new BAlert(B_TRANSLATE_SYSTEM_NAME("Quit
Haiku"),
+ B_TRANSLATE("Are you sure you want to close this
window? This will "
+ "restart your system!"),
+ B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"),
NULL,
+ B_WIDTH_AS_USUAL, B_STOP_ALERT);
+ alert->SetShortcut(0, B_ESCAPE);
+
+ if (alert->Go() == 0) {
+ return false;
+ }
+
+ be_app->PostMessage(MSG_REBOOT_REQUESTED);
+
+ } else {
+ // The aforementioned warning is only shown if the condition
+ // is true, because if FirstBootPrompt is running on the
Desktop,
+ // the system will not reboot upon closing the window.
+ be_app->PostMessage(B_QUIT_REQUESTED);
+ }
+
+ return true;
+}
+
+
void
BootPromptWindow::_InitCatalog(bool saveSettings)
{
diff --git a/src/apps/firstbootprompt/BootPromptWindow.h
b/src/apps/firstbootprompt/BootPromptWindow.h
index d3088ab0af..044cdc02db 100644
--- a/src/apps/firstbootprompt/BootPromptWindow.h
+++ b/src/apps/firstbootprompt/BootPromptWindow.h
@@ -1,5 +1,6 @@
/*
* Copyright 2010, Stephan Aßmus <superstippi@xxxxxx>.
+ * Copyright 2020, Panagiotis Vasilopoulos <hello@xxxxxxxxxxxxxxx>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef BOOT_PROMPT_WINDOW_H
@@ -9,6 +10,12 @@
#include <Window.h>
+enum {
+ MSG_LANGUAGE_SELECTED = 'lngs',
+ MSG_KEYMAP_SELECTED = 'kmps',
+};
+
+
class BButton;
class BLanguage;
class BListView;
@@ -22,6 +29,7 @@ class BootPromptWindow : public BWindow {
public:
BootPromptWindow();
+ bool QuitRequested();
virtual void MessageReceived(BMessage*
message);
private:
diff --git a/src/apps/firstbootprompt/Jamfile b/src/apps/firstbootprompt/Jamfile
index 00ed4c0d61..ac664b6dd8 100644
--- a/src/apps/firstbootprompt/Jamfile
+++ b/src/apps/firstbootprompt/Jamfile
@@ -1,7 +1,9 @@
SubDir HAIKU_TOP src apps firstbootprompt ;
UseHeaders [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) data keymaps ] ;
+
UsePrivateHeaders app interface locale shared ;
+UsePrivateSystemHeaders ;
Includes [ FGristFiles BootPromptWindow.cpp ] : <keymap-locale>KeymapNames.h ;