コード例 #1
0
ファイル: GoGmail.go プロジェクト: sqp/godock
// Show dialog with information for the given number of mails. Can display an
// additional comment about mails being new if the second param is set to true.
//
func (app *Applet) mailPopup(nb, duration int, templateFunc string) {
	// feed := app.data.Data().(*Feed)
	feed := app.data.(*Feed)

	// Prepare data for template formater.
	feed.New = nb
	feed.Plural = feed.New > 1
	max := ternary.Min(feed.New, len(feed.Mail))
	feed.MailsNew = make([]*Email, max)
	for i := 0; i < max; i++ {
		feed.MailsNew[i] = feed.Mail[i]
	}

	// if app.conf.DialogType == dialogInternal {
	text, e := app.conf.DialogTemplate.ToString(templateFunc, feed)
	if app.Log().Err(e, "Template ListMailsNew") {
		return
	}

	e = app.PopupDialog(cdtype.DialogData{
		Message:    strings.TrimRight(text, "\n"), // Remove last EOL if any (from template range).
		TimeLength: duration,
		UseMarkup:  true,
		Buttons:    "document-open;cancel",
		Callback:   cdtype.DialogCallbackValidNoArg(app.Action().Callback(ActionOpenClient)), // Open mail client if the user press the 1st button.
	})
	app.Log().Err(e, "popup")

	// } else {
	// 	if nb == 1 {
	// 		app.Log().Err(popUp(feed.Mail[0].AuthorName, feed.Mail[0].Title, app.FileLocation("icon"), app.conf.DialogTimer*1000), "libnotify")
	// 	} else {
	// 		title, eTit := app.ExecuteTemplate(DialogTemplate, "TitleCount", feed)
	// 		app.Log().Err(eTit, "Template TitleCount")
	// 		text, eTxt := app.ExecuteTemplate(DialogTemplate, "ListMails", feed)
	// 		app.Log().Err(eTxt, "Template ListMails")
	// 		app.Log().Err(popUp(title, text, app.FileLocation("icon"), app.conf.DialogTimer*1000), "Libnotify")
	// 	}
	// }

	// app.PopUp("Gmail", text)

	return
}
コード例 #2
0
ファイル: Notifications.go プロジェクト: sqp/godock
func (app *Applet) displayAll() {
	var msg string
	messages := app.notifs.List()
	if len(messages) == 0 {
		msg = "No recent notifications"

	} else {
		text, e := app.conf.DialogTemplate.ToString("ListNotif", messages)
		app.Log().Err(e, "template")
		msg = strings.TrimRight(text, "\n")
	}

	app.PopupDialog(cdtype.DialogData{
		Message:    msg,
		UseMarkup:  true,
		Buttons:    "edit-clear;cancel",
		TimeLength: app.conf.DialogDuration,
		Callback:   cdtype.DialogCallbackValidNoArg(app.Action().Callback(ActionClear)), // Clear notifs if the user press the 1st button.
	})

	// if self.config['clear'] else 4 + len(msg)/40 }  // if we're going to clear the history, show the dialog until the user closes it
}