Example #1
0
// Init load user configuration if needed and initialise applet.
//
func (app *Applet) Init(def *cdtype.Defaults, confLoaded bool) {
	// Reset data to be sure our display will be refreshed.
	app.data.Clear()
	app.data.LoadLogin(app.FileDataDir(loginLocation))
	app.err = nil

	// Define the mail client action.
	if app.conf.MailClientName == "" { //  Set default to webpage if not provided.
		app.conf.MailClientAction = MailClientLocation
		app.conf.MailClientName = app.conf.DefaultMonitorName
	}

	// Defaults.
	def.Label = "Mail unchecked"
	def.PollerInterval = app.conf.UpdateDelay.Value()

	// Add 1 to action as we don't provide the none option.
	cmd := cdtype.NewCommandStd(app.conf.MailClientAction+1, app.conf.MailClientName, app.conf.MailClientClass)
	def.Commands = cdtype.Commands{cmdMailClient: cmd}

	// Create the renderer.
	switch app.conf.Renderer {
	case QuickInfo:
		app.render = NewRenderedQuick(app)

	case EmblemSmall, EmblemLarge:
		var e error
		app.render, e = NewRenderedSVG(app, app.conf.Renderer)
		app.Log().Err(e, "renderer svg")

	default: // NoDisplay case, but using default to be sure we have a valid renderer.
		app.render = NewRenderedNone()
	}
}