gui

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShowEntry

func ShowEntry(ctx context.Context, entry *set.Entry) (r res.Entry, err error)
Example
package main

import (
	"runtime"

	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := settings.Entry{}
	t.Title = "SpamMails Remove"
	t.OkLabel = "Accept it"
	t.CancelLabel = "Cancel it"
	t.DefaultCancel = true
	if runtime.GOOS != "darwin" {
		t.ExtraButtons = []string{"Midnight"}
	}
	t.Text = "Enter the time:"
	t.DefaultEntry = "10:30"
	t.Width = 300
	t.Height = 500
	t.Icon = settings.InfoIcon
	t.WindowIcon = settings.InfoIcon

	_, _ = gui.ShowEntry(nil, &t) // nolint: staticcheck
}
Output:

func ShowFileSave

func ShowFileSave(ctx context.Context, s *set.FileSave) (res.File, error)
Example
package main

import (
	"fmt"
	"os"

	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := &settings.FileSave{}
	t.Title = "Save the pizza to your desktop:"
	t.Width = 300
	t.Height = 500
	t.ConfirmOverwrite = true
	t.ConfirmCreate = true
	t.FileFilters = []settings.FileFilter{{Name: "Dev", Patterns: []string{"*.go", "*.sh"}}}
	t.Filename = "MySuperFile/Pizza.dat"
	t.Root = "../.."
	t.OnlyDirectories = false
	t.WindowIcon = settings.QuestionIcon

	f, e := gui.ShowFileSave(nil, t) // nolint: staticcheck
	fmt.Fprintf(os.Stderr, "%v, %v", f, e)
}
Output:

func ShowFileSelection

func ShowFileSelection(ctx context.Context, s *set.FileSelection) (res.File, error)
Example
package main

import (
	"fmt"
	"os"

	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := settings.FileSelection{}
	t.Title = "Select your pizzas:"
	t.Width = 300
	t.Height = 500
	t.FileFilters = []settings.FileFilter{{Name: "Dev", Patterns: []string{"*.go", "*.sh"}}}
	t.Filename = "MySuperFile.dat"
	t.Root = "../.."
	t.MultipleSelection = true
	t.WindowIcon = settings.QuestionIcon
	t.ShowHidden = false

	f, e := gui.ShowFileSelection(nil, &t) // nolint: staticcheck
	fmt.Fprintf(os.Stderr, "%v, %v", f, e)
}
Output:

func ShowMessage

func ShowMessage(ctx context.Context, msg *set.Message) (r res.Message, err error)
Example
package main

import (
	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := settings.Message{}
	t.Title = "SpamMails Alert"
	t.OkLabel = "Okey"
	t.CancelLabel = "Cancel it"
	t.Text = "You have 200 spam mails in your mailbox, you should remove them sooooooon."
	t.Width = 300
	t.Height = 500
	t.WindowIcon = settings.ErrorIcon
	t.Icon = settings.ErrorIcon
	t.Style = settings.ErrorStyle

	_, _ = gui.ShowMessage(nil, &t) // nolint: staticcheck

	t.Icon = settings.WarningIcon
	_, _ = gui.ShowMessage(nil, &t) // nolint: staticcheck

	t.Icon = settings.InfoIcon
	_, _ = gui.ShowMessage(nil, &t) // nolint: staticcheck

}
Output:

func ShowNotification

func ShowNotification(ctx context.Context, s *set.Notification) error
Example
package main

import (
	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := settings.Notification{}
	t.Title = "Hura: Your pizza has arrived."
	t.Text = "Remove the card box and enjoy your stupid Hawai-Style Pizza.\nWuaaaaaaaa...."
	t.Width = 300
	t.Height = 500
	t.WindowIcon = settings.WarningIcon

	_ = gui.ShowNotification(nil, &t) // nolint: staticcheck
}
Output:

func ShowOptions

func ShowOptions(ctx context.Context, opts *set.Options) (r res.Options, err error)
Example
package main

import (
	"github.com/gabyx/githooks/githooks/apps/dialog/gui"
	"github.com/gabyx/githooks/githooks/apps/dialog/settings"
)

func main() {
	t := settings.Options{}
	t.Title = "What pizza do you want to order?"
	t.OkLabel = "Okey"
	t.CancelLabel = "Cancel it"
	t.Text = "Choose a pizza from below:"
	t.Options = []string{"Margherita", "Curry & Banana", "Hawai-Style"}
	t.MultipleSelection = true
	t.Width = 300
	t.Height = 500
	t.WindowIcon = settings.QuestionIcon

	_, _ = gui.ShowOptions(nil, &t) // nolint: staticcheck
}
Output:

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL