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 <pulkomandy@gmail.com>
This commit is contained in:
Yatendra Singh 2019-02-13 23:07:06 +05:30 committed by waddlesplash
parent c62142a72b
commit e680a439bf
9 changed files with 50 additions and 12 deletions

View File

@ -12,6 +12,14 @@ target desktop {
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 {
launch /system/servers/mail_daemon
if setting ~/config/settings/Mail/new_mail_daemon DaemonAutoStarts

View File

@ -11,6 +11,8 @@
#include <Entry.h>
#include <Message.h>
#include <String.h>
#include <Directory.h>
#include <File.h>
#include "support.h"
@ -19,11 +21,13 @@
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "LaunchBox"
App::App()
:
BApplication("application/x-vnd.Haiku-LaunchBox"),
fSettingsChanged(false),
fNamePanelSize(200, 50)
fNamePanelSize(200, 50),
fAutoStart(false)
{
SetPulseRate(3000000);
}
@ -69,6 +73,9 @@ App::ReadyToRun()
BSize size;
if (settings.FindSize("name panel size", &size) == B_OK)
fNamePanelSize = size;
bool auto_start;
if (settings.FindBool("autostart", &auto_start) == B_OK)
fAutoStart = auto_start;
}
if (!windowAdded) {
@ -97,6 +104,9 @@ App::MessageReceived(BMessage* message)
fSettingsChanged = true;
break;
}
case MSG_TOGGLE_AUTOSTART:
ToggleAutoStart();
break;
case MSG_SETTINGS_CHANGED:
fSettingsChanged = true;
break;
@ -124,6 +134,14 @@ App::SetNamePanelSize(const BSize& size)
}
void
App::ToggleAutoStart()
{
fSettingsChanged = true;
fAutoStart = !AutoStart();
}
BSize
App::NamePanelSize()
{
@ -156,8 +174,9 @@ App::_StoreSettingsIfNeeded()
}
}
settings.AddSize("name panel size", fNamePanelSize);
settings.AddBool("autostart", AutoStart());
save_settings(&settings, "main_settings", "LaunchBox");
fSettingsChanged = false;
}
}

View File

@ -26,6 +26,8 @@ public:
void SetNamePanelSize(const BSize& size);
BSize NamePanelSize();
void ToggleAutoStart();
bool AutoStart() { return fAutoStart; }
private:
void _StoreSettingsIfNeeded();
@ -33,7 +35,8 @@ private:
bool fSettingsChanged;
BSize fNamePanelSize;
bool fAutoStart;
};
#endif // APP_H
#endif // APP_H

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 - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), col4);
EndLineArray();
}
}

View File

@ -86,4 +86,4 @@ private:
static bool sIgnoreDoubleClick;
};
#endif // LAUNCH_BUTTON_H
#endif // LAUNCH_BUTTON_H

View File

@ -7,6 +7,8 @@
#include <stdio.h>
#include <Directory.h>
#include <File.h>
#include <Alert.h>
#include <Application.h>
#include <Catalog.h>
@ -49,7 +51,6 @@ MainWindow::MainWindow(const char* name, BRect frame, bool addDefaultButtons)
else
_AddEmptyButtons();
}
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(fPadView);
}
@ -652,5 +653,4 @@ void
MainWindow::_NotifySettingsChanged()
{
be_app->PostMessage(MSG_SETTINGS_CHANGED);
}
}

View File

@ -21,6 +21,7 @@ enum {
MSG_ADD_WINDOW = 'addw',
MSG_SETTINGS_CHANGED = 'stch',
MSG_TOGGLE_AUTOSTART = 'tast'
};
@ -77,4 +78,4 @@ private:
bool fShowOnAllWorkspaces;
};
#endif // MAIN_WINDOW_H
#endif // MAIN_WINDOW_H

View File

@ -7,6 +7,8 @@
#include <stdio.h>
#include <Directory.h>
#include <File.h>
#include <Application.h>
#include <Catalog.h>
#include <GroupLayout.h>
@ -19,6 +21,7 @@
#include "LaunchButton.h"
#include "MainWindow.h"
#include "App.h"
#undef B_TRANSLATION_CONTEXT
@ -399,6 +402,11 @@ PadView::DisplayMenu(BPoint where, LaunchButton* button) const
item->SetMarked(what == MSG_HIDE_BORDER);
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->SetTarget(window);
item->SetMarked(window->AutoRaise());
@ -511,5 +519,4 @@ void
PadView::_NotifySettingsChanged()
{
be_app->PostMessage(MSG_SETTINGS_CHANGED);
}
}

View File

@ -53,4 +53,4 @@ private:
uint32 fIconSize;
};
#endif // PAD_VIEW_H
#endif // PAD_VIEW_H