Documentation ¶
Index ¶
- Constants
- Variables
- func RoomTag(c *gotktrix.Client, id matrix.RoomID) matrix.TagName
- func SortSections(sections []*Section)
- func SortTags(tags []OrderedTag)
- func TagEqNamespace(n1, n2 matrix.TagName) bool
- func TagIsIntern(name matrix.TagName) bool
- func TagName(ctx context.Context, name matrix.TagName) string
- func TagNamespace(name matrix.TagName) string
- type Comparer
- type Controller
- type OrderedTag
- type Section
- func (s *Section) Changed(room *room.Room)
- func (s *Section) Expand()
- func (s *Section) HasRoom(id matrix.RoomID) bool
- func (s *Section) Insert(room *room.Room)
- func (s *Section) InvalidateFilter()
- func (s *Section) InvalidateSort()
- func (s *Section) Minimize()
- func (s *Section) MoveRoomToTag(src matrix.RoomID, tag matrix.TagName) bool
- func (s *Section) NHidden() int
- func (s *Section) OpenRoom(id matrix.RoomID)
- func (s *Section) OpenRoomInTab(id matrix.RoomID)
- func (s *Section) Reminify()
- func (s *Section) ReminifyAfter(after func())
- func (s *Section) Remove(room *room.Room)
- func (s *Section) Select(id matrix.RoomID)
- func (s *Section) SetSortMode(mode SortMode)
- func (s *Section) SortMode() SortMode
- func (s *Section) Tag() matrix.TagName
- func (s *Section) Unselect()
- type SortMode
Constants ¶
const ( InternalTagNamespace = "xyz.diamondb.gotktrix" DMSection matrix.TagName = InternalTagNamespace + ".dm_section" RoomsSection matrix.TagName = InternalTagNamespace + ".rooms_section" )
Pseudo tag names.
Variables ¶
var MatrixSectionOrder = map[matrix.TagName]int{ matrix.TagFavourite: 0, DMSection: 1, RoomsSection: 2, matrix.TagLowPriority: 3, matrix.TagServerNotice: 4, }
MatrixSectionOrder is the order of default Matrix rooms.
Functions ¶
func RoomTag ¶
RoomTag queries the client and returns the tag that the room with the given ID is in. It tries its best to be deterministic. If the room should be in the default room section, then an empty string is returned.
func SortSections ¶
func SortSections(sections []*Section)
SortSections sorts the given list of sections in a user-friendly way.
func SortTags ¶
func SortTags(tags []OrderedTag)
SortTags sorts the given list of ordered tags in a deterministic order.
func TagEqNamespace ¶
TagEqNamespace returns true if n1 and n2 are in the same namespace.
func TagIsIntern ¶
TagIsIntern returns true if the given tag is a Matrix tag or a tag that belongs only to us.
func TagNamespace ¶
TagNamespace returns the tag's namespace.
Types ¶
type Comparer ¶
type Comparer struct { // Tag is the tag that this comparer should use. If this is an empty string, // then Comparer will ignore room tags completely. Tag matrix.TagName // Mode is the sorting mode that this comparer should do. Mode SortMode // contains filtered or unexported fields }
Comparer partially implements sort.Interface: it provides a Less function that Sorter can easily build upon, but exposed for other uses.
func NewComparer ¶
NewComparer creates a new comparer.
func (*Comparer) Compare ¶
Compare behaves similarly to strings.Compare. Most users should use Less instead of Compare; this method only exists to satisfy bad C APIs.
As the API is similar to strings.Compare, 0 is returned if the position is equal; -1 is returned if iID's position is less than (above/before) jID, and 1 is returned if iID's position is more than (below/after) jID.
func (*Comparer) InvalidateRoomCache ¶
func (c *Comparer) InvalidateRoomCache()
InvalidateRoomCache invalidates the room name/timestamp cache. This is automatically called when Sort is called.
type Controller ¶
type Controller interface { OpenRoom(matrix.RoomID) OpenRoomInTab(matrix.RoomID) // RoomIsVisible returns true if the given room should be visible. RoomIsVisible(matrix.RoomID) bool // IsSearching returns true if the user is searching for any room. This will // cause the section to not collapse. IsSearching() bool // VAdjustment returns the vertical scroll adjustment of the parent // controller. If not in list, return nil. VAdjustment() *gtk.Adjustment // MoveRoomToSection moves a room to another section. The method is expected // to verify that the moving is valid. MoveRoomToSection(src matrix.RoomID, dst *Section) bool // 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 }
Controller describes the parent widget that Section controls.
type OrderedTag ¶
OrderedTag is a type that defines the tag order. It is used for sorting and prioritizing room tags.
func NewOrderedTags ¶
func NewOrderedTags(tags map[matrix.TagName]matrix.Tag) []OrderedTag
NewOrderedTags creates a new list of
type Section ¶
type Section struct { *gtk.Box // contains filtered or unexported fields }
Section is a room section, such as People or Favorites.
func (*Section) Expand ¶
func (s *Section) Expand()
Expand makes the section display all rooms inside it.
func (*Section) InvalidateFilter ¶
func (s *Section) InvalidateFilter()
InvalidateFilter invalidates the filter.
func (*Section) InvalidateSort ¶
func (s *Section) InvalidateSort()
InvalidateSort invalidates the section's sort. This should be called if any room inside the section has been changed.
func (*Section) Minimize ¶
func (s *Section) Minimize()
Minimize minimizes the section to only show 8 entries.
func (*Section) MoveRoomToTag ¶
MoveRoomToTag calls the parent controller's.
func (*Section) OpenRoomInTab ¶
OpenRoomInTab calls the parent controller's.
func (*Section) ReminifyAfter ¶
func (s *Section) ReminifyAfter(after func())
ReminifyAfter restores the minified state only after executing after. If the section is not minified, then after is executed immediately. If after is nil, then it does the same thing as Reminify does.
func (*Section) Select ¶
Select selects the room with the given ID. If an unknown ID is given, then the function panics.
func (*Section) SetSortMode ¶
SetSortMode sets the sorting mode for each room.