mirror of
https://github.com/diamondburned/cchat-gtk.git
synced 2025-01-23 02:16:43 +00:00
only highlight message for a short while
This commit is contained in:
parent
e2b316a4df
commit
bfad966cd2
|
@ -52,10 +52,8 @@ type Container interface {
|
|||
// Message finds and returns the message, if any.
|
||||
Message(id cchat.ID, nonce string) MessageRow
|
||||
|
||||
// Highlight temporarily highlights the given message.
|
||||
// Highlight temporarily highlights the given message for a short while.
|
||||
Highlight(msg MessageRow)
|
||||
// Unhighlight removes the message highlight.
|
||||
Unhighlight()
|
||||
|
||||
// UI methods.
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ func WrapCollapsedMessage(gc *message.GenericContainer) *CollapsedMessage {
|
|||
gc.Timestamp.SetSizeRequest(AvatarSize, -1)
|
||||
gc.Timestamp.SetVAlign(gtk.ALIGN_START)
|
||||
gc.Timestamp.SetXAlign(0.5) // middle align
|
||||
gc.Timestamp.SetMarginEnd(container.ColumnSpacing)
|
||||
gc.Timestamp.SetMarginStart(container.ColumnSpacing * 2)
|
||||
gc.Timestamp.SetMarginTop(container.ColumnSpacing)
|
||||
|
||||
// Set Content's padding accordingly to FullMessage's main box.
|
||||
gc.Content.ToWidget().SetMarginEnd(container.ColumnSpacing * 2)
|
||||
|
|
|
@ -3,6 +3,7 @@ package container
|
|||
import (
|
||||
"container/list"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/diamondburned/cchat"
|
||||
"github.com/diamondburned/cchat-gtk/internal/gts"
|
||||
|
@ -83,10 +84,10 @@ func (c *ListStore) findIndex(id cchat.ID) (*messageRow, int) {
|
|||
//
|
||||
// TODO: combine compact and full so they share the same attach method.
|
||||
func (c *ListStore) SwapMessage(msg MessageRow) bool {
|
||||
// Wrap msg inside a *messageRow if it's not already.
|
||||
// Unwrap msg from a *messageRow if it's not already.
|
||||
m, ok := msg.(*messageRow)
|
||||
if !ok {
|
||||
m = &messageRow{MessageRow: msg}
|
||||
if ok {
|
||||
msg = m.MessageRow
|
||||
}
|
||||
|
||||
// Get the current message's index.
|
||||
|
@ -95,16 +96,16 @@ func (c *ListStore) SwapMessage(msg MessageRow) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Remove the to-be-replaced message box. We should probably reuse the row.
|
||||
c.ListBox.Remove(oldMsg.Row())
|
||||
|
||||
// Add a row at index. The actual row we want to delete will be shifted
|
||||
// downwards.
|
||||
c.ListBox.Insert(m.Row(), ix)
|
||||
|
||||
// Delete the to-be-replaced message.
|
||||
oldMsg.Row().Destroy()
|
||||
c.ListBox.Insert(msg.Row(), ix)
|
||||
|
||||
// Set the message into the map.
|
||||
row := c.messages[idKey(m.ID())]
|
||||
*row = *m
|
||||
row := c.messages[idKey(msg.ID())]
|
||||
row.MessageRow = msg
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -403,9 +404,6 @@ func (c *ListStore) Highlight(msg MessageRow) {
|
|||
row := msg.Row()
|
||||
row.GrabFocus()
|
||||
c.ListBox.DragHighlightRow(row)
|
||||
gts.DoAfter(2*time.Second, c.ListBox.DragUnhighlightRow)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ListStore) Unhighlight() {
|
||||
c.ListBox.DragUnhighlightRow()
|
||||
}
|
||||
|
|
|
@ -113,6 +113,8 @@ func NewEmptyContainer() *GenericContainer {
|
|||
user.Show()
|
||||
|
||||
ctbody := labeluri.NewLabel(text.Rich{})
|
||||
ctbody.SetVExpand(true)
|
||||
ctbody.SetHExpand(true)
|
||||
ctbody.SetEllipsize(pango.ELLIPSIZE_NONE)
|
||||
ctbody.SetLineWrap(true)
|
||||
ctbody.SetLineWrapMode(pango.WRAP_WORD_CHAR)
|
||||
|
|
|
@ -108,7 +108,7 @@ func NewRequest(auther cchat.Authenticator, done func()) *Request {
|
|||
|
||||
continueBtn, _ := gtk.ButtonNewWithLabel("Continue")
|
||||
continueBtn.SetHAlign(gtk.ALIGN_CENTER)
|
||||
continueBtn.Connect("clicked", done)
|
||||
continueBtn.Connect("clicked", func(*gtk.Button) { done() })
|
||||
continueBtn.SetBorderWidth(12)
|
||||
continueBtn.Show()
|
||||
|
||||
|
|
Loading…
Reference in a new issue