gtkcord

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderHeight      = 42
	HeaderPadding     = 16
	GuildIconSize     = 48
	ChannelIconSize   = 32
	MessageAvatarSize = 42
	EmbedMaxWidth     = 250
	EmbedImgHeight    = 300
	InlineEmojiSize   = 22
	LargeEmojiSize    = 48
	StickerSize       = 92
	UserBarAvatarSize = 32
)

Constants for dimensions.

Variables

AllowedChannelTypes are the channel types that are shown.

View Source
var EmojiAttrs = textutil.Attrs(
	pango.NewAttrSize(32 * pango.SCALE),
)
View Source
var SnowflakeVariant = glib.NewVariantType("x")

SnowflakeVariant is the variant type for a discord.Snowflake.

Functions

func ChannelName

func ChannelName(ch *discord.Channel) string

ChannelName returns the channel's name in plain text.

func ChannelNameFromID

func ChannelNameFromID(ctx context.Context, id discord.ChannelID) string

ChannelNameFromID returns the channel's name in plain text from the channel with the given ID.

func EmojiURL

func EmojiURL(emojiID string, gif bool) string

EmojiURL returns a sized emoji URL.

func InjectAvatarSize

func InjectAvatarSize(urlstr string) string

InjectAvatarSize calls InjectSize with size being 64px.

func InjectSize

func InjectSize(urlstr string, size int) string

InjectSize injects the size query parameter into the URL. Size is automatically scaled up to 2x or more.

func InjectSizeUnscaled

func InjectSizeUnscaled(urlstr string, size int) string

InjectSizeUnscaled is like InjectSize, except the size is not scaled according to the scale factor.

func InjectState

func InjectState(ctx context.Context, state *State) context.Context

InjectState injects the given state to a new context.

func NewChannelIDVariant added in v0.0.18

func NewChannelIDVariant(id discord.ChannelID) *glib.Variant

NewChannelIDVariant creates a new ChannelID variant.

func NewGuildIDVariant added in v0.0.18

func NewGuildIDVariant(id discord.GuildID) *glib.Variant

NewGuildIDVariant creates a new GuildID variant.

func NewMessageIDVariant added in v0.0.18

func NewMessageIDVariant(id discord.MessageID) *glib.Variant

NewMessageIDVariant creates a new MessageID variant.

func NewSnowflakeVariant added in v0.0.18

func NewSnowflakeVariant(snowflake discord.Snowflake) *glib.Variant

NewSnowflakeVariant creates a new Snowflake variant.

func RecipientNames added in v0.0.3

func RecipientNames(ch *discord.Channel) string

RecipientNames formats the string for the list of recipients inside the given channel.

func SanitizeEmoji added in v0.0.14

func SanitizeEmoji(emoji string) string

SanitizeEmoji checks if provided emoji doesn't contain extraneous variation selector codepoint NOTE: This sanitizer covers ~70% of emojis

func WindowTitleFromID added in v0.0.18

func WindowTitleFromID(ctx context.Context, id discord.ChannelID) string

WindowTitleFromID returns the window title from the channel with the given ID.

Types

type MainThreadHandler added in v0.0.17

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

MainThreadHandler wraps a handler.Handler to run all events on the main thread.

func NewMainThreadHandler added in v0.0.17

func NewMainThreadHandler(h *handler.Handler) *MainThreadHandler

NewMainThreadHandler creates a new MainThreadHandler.

func (*MainThreadHandler) AddHandler added in v0.0.17

func (m *MainThreadHandler) AddHandler(handler any) func()

AddHandler adds a handler to the handler.Handler. The given handler will be called on the main thread. The returned function will remove the handler.

func (*MainThreadHandler) AddSyncHandler added in v0.0.17

func (m *MainThreadHandler) AddSyncHandler(handler any) func()

AddSyncHandler is the same as [AddHandler]. It exists for compatibility.

type State

type State struct {
	*MainThreadHandler
	*ningen.State
}

State extends the Discord state controller.

func FromContext

func FromContext(ctx context.Context) *State

FromContext gets the Discord state controller from the given context.

func Wrap

func Wrap(state *state.State) *State

Wrap wraps the given state.

func (*State) AddHandlerForWidget added in v0.0.17

func (s *State) AddHandlerForWidget(w gtk.Widgetter, fn any) func()

AddHandlerForWidget replaces BindWidget and provides a way to bind a handler that only receives events as long as the widget is mapped. As soon as the widget is unmapped, the handler is unbound.

func (*State) AuthorMarkup

func (s *State) AuthorMarkup(m *gateway.MessageCreateEvent, mods ...author.MarkupMod) string

AuthorMarkup renders the markup for the message author's name. It makes no API calls.

func (*State) BindHandler

func (s *State) BindHandler(ctx gtkutil.Cancellable, fn func(gateway.Event), filters ...gateway.Event)

BindHandler is similar to BindWidgetHandler, except the lifetime of the handler is bound to the context.

func (*State) BindWidget added in v0.0.10

func (s *State) BindWidget(w gtk.Widgetter, fn func(gateway.Event), filters ...gateway.Event)

BindWidget is similar to BindHandler, except it doesn't rely on contexts.

func (*State) MemberMarkup added in v0.0.2

func (s *State) MemberMarkup(gID discord.GuildID, u *discord.GuildUser, mods ...author.MarkupMod) string

MemberMarkup is like AuthorMarkup but for any member inside a guild.

func (*State) MessagePreview

func (s *State) MessagePreview(msg *discord.Message) string

MessagePreview renders the message into a short content string.

func (*State) Offline added in v0.0.18

func (s *State) Offline() *State

Offline creates a copy of State with a new offline state.

func (*State) Online added in v0.0.18

func (s *State) Online() *State

Online creates a copy of State with a new online state.

func (*State) UserIDMarkup added in v0.0.5

func (s *State) UserIDMarkup(chID discord.ChannelID, uID discord.UserID, mods ...author.MarkupMod) string

UserIDMarkup gets the User markup from just the channel and user IDs.

func (*State) UserMarkup added in v0.0.2

func (s *State) UserMarkup(gID discord.GuildID, u *discord.User, mods ...author.MarkupMod) string

UserMarkup is like AuthorMarkup but for any user optionally inside a guild.

func (*State) WithContext

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

WithContext creates a copy of State with a new context.

Jump to

Keyboard shortcuts

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