Example #1
0
// This is used as action (no arg) to popup a string entry dialog.
//
func (app *AppletWithAction) askText() {
	app.PopupDialog(cdtype.DialogData{
		Message: "Enter some text",
		Buttons: "ok;cancel",
		Widget:  cdtype.DialogWidgetText{},
		Callback: cdtype.DialogCallbackValidString(func(data string) {
			app.Log().Info("user validated with ok or enter", data)
		}),
	})
}
Example #2
0
File: clouds.go Project: sqp/godock
// AskLocationText asks the user his location name.
//
// If confirmed, continues the selection process.
// A default text may be used as argument.
//
func (app *Applet) AskLocationText(deftxt string) {
	msg := app.Translate("Enter your location:") + "\n\n" +
		app.Translate("Leave empty to autodetect.")

	e := app.PopupDialog(cdtype.DialogData{
		Message:  msg,
		Widget:   cdtype.DialogWidgetText{InitialValue: deftxt},
		Buttons:  "ok;cancel",
		Callback: cdtype.DialogCallbackValidString(app.AskLocationConfirm),
	})
	app.Log().Err(e, "popup AskLocation")
}
Example #3
0
// Request login informations from user. Popup an AskText dialog.
// Save to disk and try to get new data if confirmed.
//
func (app *Applet) actionRegister() {
	text := ternary.String(app.data.IsValid(), "", "No account configured.\n\n")
	e := app.PopupDialog(cdtype.DialogData{
		Message: text + "Please enter your login in the format username:password",
		Buttons: "ok;cancel",
		Widget:  cdtype.DialogWidgetText{},
		Callback: cdtype.DialogCallbackValidString(func(str string) {
			app.data.SaveLogin(str)
			app.Action().Launch(ActionCheckMail) // CheckMail will launch a check and reset the timer.
		}),
	})

	app.Log().Err(e, "popup")
}
Example #4
0
func (app *AppTest) ExampleAppIcon_popupDialogListEditable() {
	app.PopupDialog(cdtype.DialogData{
		Message:   "Please choose:",
		UseMarkup: true,
		Widget: cdtype.DialogWidgetList{
			Values:       []string{"one", "two", "three"},
			InitialValue: "four",
		},
		Buttons: "ok;cancel",
		Callback: cdtype.DialogCallbackValidString(func(str string) {
			app.Log().Info("value", str)
			// ... do something with your validated value ...
		}),
	})
}