Esempio n. 1
0
// Poller return the applet poller if any.
//
func (cda *CDApplet) Poller() cdtype.AppPoller {
	if cda.poller == nil {
		return poller.NewNil(func(call func()) cdtype.AppPoller {
			cda.poller = poller.New(call)
			return cda.poller
		})
	}
	return cda.poller
}
Esempio n. 2
0
// Create a new applet instance.
//
func NewAppletGmail() *AppletGmail {
	app := &AppletGmail{
		CDApplet: dock.Applet(), // Icon controler and interface to cairo-dock.
	}
	app.defineActions()

	// Prepare mailbox with the display callback that will receive update info.
	onResult := func(i int, e error) { app.updateDisplay(i, e) }
	app.data = NewFeed(app.FileLocation(loginLocation), onResult)

	// The poller will check for new mails on a timer.
	app.poller = poller.New(func() { app.data.Check() })

	// Set updates callbacks pre and post check: Displays a small emblem during
	// the polling, and clears it after.
	app.poller.SetPreCheck(func() { app.SetEmblem(app.FileLocation("img", "go-down.svg"), cdtype.EmblemTopLeft) })
	app.poller.SetPostCheck(func() { app.SetEmblem("none", cdtype.EmblemTopLeft) })

	return app
}