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
+21 -2
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,8 +174,9 @@ 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");
fSettingsChanged = false; fSettingsChanged = false;
} }
+4 -1
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,7 +35,8 @@ private:
bool fSettingsChanged; bool fSettingsChanged;
BSize fNamePanelSize; BSize fNamePanelSize;
bool fAutoStart;
}; };
#endif // APP_H #endif // APP_H
+1 -1
View File
@@ -448,4 +448,4 @@ LaunchButton::_DrawFrame(BRect r, rgb_color col1, rgb_color col2,
AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), col4); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), col4);
AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), col4); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), col4);
EndLineArray(); EndLineArray();
} }
+1 -1
View File
@@ -86,4 +86,4 @@ private:
static bool sIgnoreDoubleClick; static bool sIgnoreDoubleClick;
}; };
#endif // LAUNCH_BUTTON_H #endif // LAUNCH_BUTTON_H
+3 -3
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);
} }
@@ -652,5 +653,4 @@ void
MainWindow::_NotifySettingsChanged() MainWindow::_NotifySettingsChanged()
{ {
be_app->PostMessage(MSG_SETTINGS_CHANGED); be_app->PostMessage(MSG_SETTINGS_CHANGED);
} }
+2 -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'
}; };
@@ -77,4 +78,4 @@ private:
bool fShowOnAllWorkspaces; bool fShowOnAllWorkspaces;
}; };
#endif // MAIN_WINDOW_H #endif // MAIN_WINDOW_H
+9 -2
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());
@@ -511,5 +519,4 @@ void
PadView::_NotifySettingsChanged() PadView::_NotifySettingsChanged()
{ {
be_app->PostMessage(MSG_SETTINGS_CHANGED); be_app->PostMessage(MSG_SETTINGS_CHANGED);
} }
+1 -1
View File
@@ -53,4 +53,4 @@ private:
uint32 fIconSize; uint32 fIconSize;
}; };
#endif // PAD_VIEW_H #endif // PAD_VIEW_H