Launchbox: autostart on boot

Use launch daemon to autostart Launchbox if enabled in settings.

Change-Id: Id0aaf454cfbc0cc42db2dbb54d6788c79dae6949
Reviewed-on: https://review.haiku-os.org/c/917
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Yatendra Singh
2019-02-19 18:29:17 +00:00
committed by waddlesplash
parent c62142a72b
commit e680a439bf
9 changed files with 50 additions and 12 deletions
+8
View File
@@ -12,6 +12,14 @@ target desktop {
on initial_volumes_mounted on initial_volumes_mounted
} }
job x-vnd.Haiku-LaunchBox {
launch /system/apps/LaunchBox
if setting ~/config/settings/LaunchBox/main_settings autostart
on initial_volumes_mounted
legacy
no_safemode
}
service x-vnd.Be-POST { service x-vnd.Be-POST {
launch /system/servers/mail_daemon launch /system/servers/mail_daemon
if setting ~/config/settings/Mail/new_mail_daemon DaemonAutoStarts if setting ~/config/settings/Mail/new_mail_daemon DaemonAutoStarts
+20 -1
View File
@@ -11,6 +11,8 @@
#include <Entry.h> #include <Entry.h>
#include <Message.h> #include <Message.h>
#include <String.h> #include <String.h>
#include <Directory.h>
#include <File.h>
#include "support.h" #include "support.h"
@@ -19,11 +21,13 @@
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "LaunchBox" #define B_TRANSLATION_CONTEXT "LaunchBox"
App::App() App::App()
: :
BApplication("application/x-vnd.Haiku-LaunchBox"), BApplication("application/x-vnd.Haiku-LaunchBox"),
fSettingsChanged(false), fSettingsChanged(false),
fNamePanelSize(200, 50) fNamePanelSize(200, 50),
fAutoStart(false)
{ {
SetPulseRate(3000000); SetPulseRate(3000000);
} }
@@ -69,6 +73,9 @@ App::ReadyToRun()
BSize size; BSize size;
if (settings.FindSize("name panel size", &size) == B_OK) if (settings.FindSize("name panel size", &size) == B_OK)
fNamePanelSize = size; fNamePanelSize = size;
bool auto_start;
if (settings.FindBool("autostart", &auto_start) == B_OK)
fAutoStart = auto_start;
} }
if (!windowAdded) { if (!windowAdded) {
@@ -97,6 +104,9 @@ App::MessageReceived(BMessage* message)
fSettingsChanged = true; fSettingsChanged = true;
break; break;
} }
case MSG_TOGGLE_AUTOSTART:
ToggleAutoStart();
break;
case MSG_SETTINGS_CHANGED: case MSG_SETTINGS_CHANGED:
fSettingsChanged = true; fSettingsChanged = true;
break; break;
@@ -124,6 +134,14 @@ App::SetNamePanelSize(const BSize& size)
} }
void
App::ToggleAutoStart()
{
fSettingsChanged = true;
fAutoStart = !AutoStart();
}
BSize BSize
App::NamePanelSize() App::NamePanelSize()
{ {
@@ -156,6 +174,7 @@ App::_StoreSettingsIfNeeded()
} }
} }
settings.AddSize("name panel size", fNamePanelSize); settings.AddSize("name panel size", fNamePanelSize);
settings.AddBool("autostart", AutoStart());
save_settings(&settings, "main_settings", "LaunchBox"); save_settings(&settings, "main_settings", "LaunchBox");
+3
View File
@@ -26,6 +26,8 @@ public:
void SetNamePanelSize(const BSize& size); void SetNamePanelSize(const BSize& size);
BSize NamePanelSize(); BSize NamePanelSize();
void ToggleAutoStart();
bool AutoStart() { return fAutoStart; }
private: private:
void _StoreSettingsIfNeeded(); void _StoreSettingsIfNeeded();
@@ -33,6 +35,7 @@ private:
bool fSettingsChanged; bool fSettingsChanged;
BSize fNamePanelSize; BSize fNamePanelSize;
bool fAutoStart;
}; };
+2 -2
View File
@@ -7,6 +7,8 @@
#include <stdio.h> #include <stdio.h>
#include <Directory.h>
#include <File.h>
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h> #include <Catalog.h>
@@ -49,7 +51,6 @@ MainWindow::MainWindow(const char* name, BRect frame, bool addDefaultButtons)
else else
_AddEmptyButtons(); _AddEmptyButtons();
} }
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(fPadView); AddChild(fPadView);
} }
@@ -653,4 +654,3 @@ MainWindow::_NotifySettingsChanged()
{ {
be_app->PostMessage(MSG_SETTINGS_CHANGED); be_app->PostMessage(MSG_SETTINGS_CHANGED);
} }
+1
View File
@@ -21,6 +21,7 @@ enum {
MSG_ADD_WINDOW = 'addw', MSG_ADD_WINDOW = 'addw',
MSG_SETTINGS_CHANGED = 'stch', MSG_SETTINGS_CHANGED = 'stch',
MSG_TOGGLE_AUTOSTART = 'tast'
}; };
+8 -1
View File
@@ -7,6 +7,8 @@
#include <stdio.h> #include <stdio.h>
#include <Directory.h>
#include <File.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h> #include <Catalog.h>
#include <GroupLayout.h> #include <GroupLayout.h>
@@ -19,6 +21,7 @@
#include "LaunchButton.h" #include "LaunchButton.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "App.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@@ -399,6 +402,11 @@ PadView::DisplayMenu(BPoint where, LaunchButton* button) const
item->SetMarked(what == MSG_HIDE_BORDER); item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item); settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Autostart"), new BMessage(MSG_TOGGLE_AUTOSTART));
item->SetTarget(be_app);
item->SetMarked(((App*)be_app)->AutoStart());
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE)); item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window); item->SetTarget(window);
item->SetMarked(window->AutoRaise()); item->SetMarked(window->AutoRaise());
@@ -512,4 +520,3 @@ PadView::_NotifySettingsChanged()
{ {
be_app->PostMessage(MSG_SETTINGS_CHANGED); be_app->PostMessage(MSG_SETTINGS_CHANGED);
} }