func applyChangesGradually(progressBar *gtk3.ProgressBar, assistant *gtk3.Assistant) bool { fraction := progressBar.GetFraction() fraction = fraction + 0.05 if fraction < 1.0 { progressBar.SetFraction(fraction) return true } assistant.Destroy() return false }
func createPage3(assistant *gtk3.Assistant) { label := gtk3.NewLabel("This is a confirmation page, press 'Apply' to apply changes") label.Show() assistant.AppendPage(label) assistant.SetPageType(label, gtk3.GtkAssistantPage.CONFIRM) assistant.SetPageComplete(label, true) assistant.SetPageTitle(label, "Confirmation") }
func onEntryChanged(assistant *gtk3.Assistant, data ...interface{}) { pageNumber := assistant.GetCurrentPage() currentPage := assistant.GetNthPage(pageNumber) entry := data[0].(*gtk3.Entry) textLen := entry.GetTextLength() if textLen > 0 { assistant.SetPageComplete(currentPage, true) } else { assistant.SetPageComplete(currentPage, false) } }
func createPage4(assistant *gtk3.Assistant) *gtk3.ProgressBar { progressBar := gtk3.NewProgressBar() progressBar.SetHalign(gtk3.GtkAlign.CENTER) progressBar.SetValign(gtk3.GtkAlign.CENTER) progressBar.Show() assistant.AppendPage(progressBar) assistant.SetPageType(progressBar, gtk3.GtkAssistantPage.PROGRESS) assistant.SetPageTitle(progressBar, "Applying changes") // this prevents assistant window from being closed while we're "busy" applying changes assistant.SetPageComplete(progressBar, false) return progressBar }
func createPage2(assistant *gtk3.Assistant) { box := gtk3.NewVBox(12) box.SetBorderWidth(12) checkButton := gtk3.NewCheckButtonWithLabel("This is optional data, you may continue even if you do not check this") box.PackStart(checkButton, false, false, 0) box.ShowAll() assistant.AppendPage(box) assistant.SetPageComplete(box, true) assistant.SetPageTitle(box, "Page 2") }
func createPage1(assistant *gtk3.Assistant) { box := gtk3.NewHBox(12) box.SetBorderWidth(12) label := gtk3.NewLabel("You must fill out this entry to continue") box.PackStart(label, false, false, 0) entry := gtk3.NewEntry() entry.SetActivatesDefault(true) box.PackStart(entry, true, true, 0) entry.Connect("changed", onEntryChanged, assistant) box.ShowAll() assistant.AppendPage(box) assistant.SetPageTitle(box, "Page 1") assistant.SetPageType(box, gtk3.GtkAssistantPage.INTRO) }