room

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AvatarSize = 32

AvatarSize is the size in pixels of the avatar.

Variables

This section is empty.

Functions

This section is empty.

Types

type Room

type Room struct {
	*State
	*gtk.ListBoxRow
	// contains filtered or unexported fields
}

Room is a single room row.

func AddTo

func AddTo(ctx context.Context, section Section, roomID matrix.RoomID) *Room

AddTo adds an empty room with the given ID to the given section Rooms created using this constructor will automatically update itself as soon as it's added into a parent, so the caller does not have to trigger the Invalidate methods.

func (*Room) Changed

func (r *Room) Changed()

Changed invalidates the order of this room within the list.

func (*Room) InvalidatePreview

func (r *Room) InvalidatePreview(ctx context.Context)

InvalidatePreview invalidate the room's preview. It only queries the state.

func (*Room) IsIn

func (r *Room) IsIn(s Section) bool

IsIn returns true if the room is in the given section.

func (*Room) Move

func (r *Room) Move(dst Section)

Move moves the room to the given section.

func (*Room) Order

func (r *Room) Order() float64

Order returns the current room's order number, or -1 if the room doesn't have one.

func (*Room) Section

func (r *Room) Section() Section

Section returns the current section that the room is in.

func (*Room) SetActive

func (r *Room) SetActive(active bool)

SetActive sets whether or not the room is active. This is different from being selected, since keyboard shortcuts may select a room but not activate it.

func (*Room) SetOrder

func (r *Room) SetOrder(order float64)

SetOrder sets the room's order within the section it is in. If the order is not within [0.0, 1.0], then it is cleared.

type Section

type Section interface {
	Tag() matrix.TagName

	Changed(*Room)
	Remove(*Room)
	Insert(*Room)

	OpenRoom(matrix.RoomID)
	OpenRoomInTab(matrix.RoomID)

	// MoveRoomToTag moves the room with the given ID to the given tag name. A
	// new section must be created if needed.
	MoveRoomToTag(src matrix.RoomID, tag matrix.TagName) bool
}

Section is the controller interface that Room holds as its parent section.

type State

type State struct {
	ID     matrix.RoomID
	Name   string
	Topic  string
	Avatar matrix.URL
	// contains filtered or unexported fields
}

State handles the room's internal state.

func NewState

func NewState(ctx context.Context, id matrix.RoomID) *State

NewState creates a new state.

func (*State) InvalidateAvatar

func (s *State) InvalidateAvatar(ctx context.Context)

InvalidateAvatar invalidates the room's avatar.

func (*State) InvalidateName

func (s *State) InvalidateName(ctx context.Context)

InvalidateName invalidates the room's name and refetches them from the state or API.

func (*State) InvalidateTopic

func (s *State) InvalidateTopic(ctx context.Context)

InvalidateTopic invalidates the room's name and refetches them from the state or API.

func (*State) NotifyAvatar

func (s *State) NotifyAvatar(f StateHandlerFunc) func()

NotifyAvatar calls f when Avatar is changed.

func (*State) NotifyName

func (s *State) NotifyName(f StateHandlerFunc) func()

NotifyName calls f when Name is changed.

func (*State) NotifyTopic

func (s *State) NotifyTopic(f StateHandlerFunc) func()

NotifyTopic calls f when Topic is changed.

func (*State) Subscribe

func (s *State) Subscribe() (unsub func())

Subscribe subscribes the State to update itself.

type StateChangeFuncs

type StateChangeFuncs struct {
	Name   func(context.Context, State)
	Avatar func(context.Context, State)
}

StateChangeFuncs contains functions that are called when the state is invalidated and sees a change in any of the fields.

type StateHandlerFunc

type StateHandlerFunc func(context.Context, State)

StateHandlerFunc is a function called when something in the state changes.

type StateHandlers

type StateHandlers registry.Registry

StateHandlers holds multiple state handlers.

func (*StateHandlers) Add

func (h *StateHandlers) Add(fn StateHandlerFunc) func()

Add adds fn into the registry.

Jump to

Keyboard shortcuts

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