dialog

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 4 Imported by: 0

README

DIALOG

A simple message dialog package.

Usage:

This package needs GoTK3 (GTK) to run (see link below), and you will need to run gtk.Init() somewhere in your application, before using the dialogs.

// Initialize gtk
gtk.Init(&os.Args)

// Super simple dialog
dialog.Title("Hello World!").OkButton().Show()

// Normal dialog
dialog.Title("Hello World!").Text("How are you today?").OkButton().Show()

// Question dialog
response := dialog.Title("Hello World!").
    Text("How are you today?").
    Extra(getLongText()).
    QuestionIcon().
    YesNoButtons().
    Height(400).
    Show()

if response == gtk.RESPONSE_YES {
    // Warning dialog
    dialog.Title("Your response...").
        Text("...was affirmative!").
        WarningIcon().
        OkButton().
        Width(400).
        Show()
} else {
    // Error dialog
    dialog.Title("Your response...").
        Text("...was very negative!").
        ErrorIcon().
        OkButton().
        Width(400).
        Show()
}

TODO

  • Choose between smaller and larger icons

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialog

type Dialog struct {
	// contains filtered or unexported fields
}

Dialog contains information about the dialog the user wants

func Title

func Title(title string) *Dialog

Title is the starting method (constructor), since every dialog needs a title.

func (*Dialog) ErrorIcon

func (d *Dialog) ErrorIcon() *Dialog

ErrorIcon adds an error icon to the dialog

func (*Dialog) Extra

func (d *Dialog) Extra(extra string) *Dialog

Extra sets the extra text that will be displayed in a scrollable text box.

func (*Dialog) Height

func (d *Dialog) Height(height int) *Dialog

Height sets the minimum height of the dialog.

func (*Dialog) InfoIcon

func (d *Dialog) InfoIcon() *Dialog

InfoIcon adds an information icon to the dialog

func (*Dialog) OkButton

func (d *Dialog) OkButton() *Dialog

OkButton adds an ok button to the dialog

func (*Dialog) OkCancelButtons

func (d *Dialog) OkCancelButtons() *Dialog

OkCancelButtons adds an ok button and a cancel button to the dialog

func (*Dialog) QuestionIcon

func (d *Dialog) QuestionIcon() *Dialog

QuestionIcon adds a question icon to the dialog

func (*Dialog) Show

func (d *Dialog) Show() (gtk.ResponseType, error)

Show will display the dialog

func (*Dialog) Size

func (d *Dialog) Size(width, height int) *Dialog

Size sets the minimum size of the dialog.

func (*Dialog) Text

func (d *Dialog) Text(text string) *Dialog

Text sets the main text in the dialog.

func (*Dialog) TextMarkup

func (d *Dialog) TextMarkup(textMarkup string) *Dialog

TextMarkup sets the main text in the dialog in the GTK markup format.

func (*Dialog) WarningIcon

func (d *Dialog) WarningIcon() *Dialog

WarningIcon adds a warning icon to the dialog

func (*Dialog) Width

func (d *Dialog) Width(width int) *Dialog

Width sets the minimum width of the dialog.

func (*Dialog) YesNoButtons

func (d *Dialog) YesNoButtons() *Dialog

YesNoButtons adds a yes button and no cancel button to the dialog

func (*Dialog) YesNoCancelButtons

func (d *Dialog) YesNoCancelButtons() *Dialog

YesNoCancelButtons adds a yes button, a no button, and a cancel button to the dialog

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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