message

package
v0.0.0-...-6513b37 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AvatarSize = 40

Variables

View Source
var EmptyContentPlaceholder = fmt.Sprintf(
	`<span alpha="25%%">%s</span>`, html.EscapeString("<empty>"),
)

Functions

func NewTimestamp

func NewTimestamp() *gtk.Label

func NewUsername

func NewUsername() *labeluri.Label

Types

type Author

type Author struct {
	ID   cchat.ID
	Name rich.NameContainer
}

Author implements cchat.Author. It effectively contains a copy of cchat.Author.

func NewAuthor

func NewAuthor(author cchat.User) Author

NewAuthor creates a new Author that is a copy of the given author.

func NewCustomAuthor

func NewCustomAuthor(id cchat.ID, name text.Rich) Author

NewCustomAuthor creates a new Author from the given parameters.

func (*Author) Update

func (author *Author) Update(user cchat.Namer)

Update sets a new name.

type Container

type Container interface {
	// Unwrap returns the internal message state.
	Unwrap() *State
	// Revert unwraps and reverts all widget changes to the internal state then
	// returns that state.
	Revert() *State

	// UpdateContent updates the underlying content widget.
	UpdateContent(content text.Rich, edited bool)

	// SetReferenceHighlighter sets the reference highlighter into the message.
	SetReferenceHighlighter(refer labeluri.ReferenceHighlighter)
}

Container describes a message container that wraps a state. These methods are made for containers to override; methods not meant to be override are not exposed and will be done directly on the State.

type PresendMessage

type PresendMessage interface {
	cchat.MessageHeader
	cchat.SendableMessage
	cchat.Noncer

	Files() []attachment.File
}

PresendMessage is an interface for any message about to be sent.

type PresendState

type PresendState struct {
	*State
	// contains filtered or unexported fields
}

PresendState is the generic state with extra methods implemented for stateful mutability of the generic message state.

func NewPresendState

func NewPresendState(self *Author, msg PresendMessage) *PresendState

NewPresendState creates a new presend state. The caller must call one of the state setters, usually SetLoading.

func (*PresendState) SendingMessage

func (m *PresendState) SendingMessage() PresendMessage

func (*PresendState) SetDone

func (m *PresendState) SetDone(id cchat.ID)

SetDone sets the status of the state.

func (*PresendState) SetLoading

func (m *PresendState) SetLoading()

SetLoading greys the message to indicate that it's loading.

func (*PresendState) SetSensitive

func (m *PresendState) SetSensitive(sensitive bool)

SetSensitive sets the sensitivity of the content.

func (*PresendState) SetSentError

func (m *PresendState) SetSentError(err error)

SetSentError sets the error into the message to notify the user.

type Presender

type Presender interface {
	SendingMessage() PresendMessage
	SetDone(id cchat.ID)
	SetLoading()
	SetSentError(err error)
}

Presender describes actions doable on a presend message container.

type State

type State struct {
	gtk.Box
	Row *gtk.ListBoxRow // contains Box

	ID     cchat.ID
	Time   time.Time
	Nonce  string
	Author *Author

	Content          *gtk.Box
	ContentBody      *labeluri.Label
	ContentBodyStyle *gtk.StyleContext

	MenuItems []menu.Item
	// contains filtered or unexported fields
}

State provides a single generic message container for subpackages to use.

func NewEmptyState

func NewEmptyState() *State

NewEmptyState creates a new empty message state. The author should be set immediately afterwards; it is invalid once the state is used.

func NewState

func NewState(msg cchat.MessageCreate) *State

NewState creates a new message state with the given MessageCreate.

func (*State) ClearBox

func (m *State) ClearBox()

ClearBox clears the state's widget container.

func (*State) Focusable

func (m *State) Focusable() gtk.IWidget

func (*State) SetClass

func (m *State) SetClass(class string)

SetClass sets the internal row's class.

func (*State) SetReferenceHighlighter

func (m *State) SetReferenceHighlighter(r labeluri.ReferenceHighlighter)

SetReferenceHighlighter sets the reference highlighter into the message.

func (*State) Unwrap

func (m *State) Unwrap() *State

Unwrap returns itself.

func (*State) UpdateContent

func (m *State) UpdateContent(content text.Rich, edited bool)

UpdateContent replaces the internal content and the widget.

Jump to

Keyboard shortcuts

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