class GtkMessageRow

Attributes

message[R]

Public Class Methods

init() click to toggle source
# File gtk3/sample/gtk-demo/listbox.rb, line 84
def init
  set_template(:resource => "/listbox/listbox.ui")
  bind_template_child("content_label")
  bind_template_child("source_name")
  bind_template_child("source_nick")
  bind_template_child("short_time_label")
  bind_template_child("detailed_time_label")
  bind_template_child("extra_buttons_box")
  bind_template_child("details_revealer")
  bind_template_child("avatar_image")
  bind_template_child("resent_box")
  bind_template_child("resent_by_button")
  bind_template_child("n_reshares_label")
  bind_template_child("n_favorites_label")
  bind_template_child("expand_button")

  set_connect_func do |name|
    method(name)
  end
end
new(message) click to toggle source
Calls superclass method
# File gtk3/sample/gtk-demo/listbox.rb, line 130
def initialize(message)
  super()
  @message = message
  @avatar_pixbuf_other = GdkPixbuf::Pixbuf.new(:resource => "/listbox/apple-red.png",
                                               :width => 32, :height => 32,
                                               :preserve_aspect_ratio => false)
  message_row_update
  extra_buttons_box.hide
  extra_buttons_box.visible = false
  extra_buttons_box.unset_state_flags([:prelight, :selected])
  set_state_flags(Gtk::StateFlags::NORMAL, false)

  signal_connect "state-flags-changed" do |widget, _previous_flags|
    flags = widget.state_flags

    is_prelight_or_selected = flags & (Gtk::StateFlags::PRELIGHT |
                                       Gtk::StateFlags::SELECTED)
    if is_prelight_or_selected.nonzero?
      widget.extra_buttons_box.visible = true
    else
      widget.extra_buttons_box.visible = false
    end
  end
end

Public Instance Methods

message_row_update() click to toggle source
# File gtk3/sample/gtk-demo/listbox.rb, line 155
def message_row_update
  source_name.text = @message.sender_name
  source_nick.text = @message.sender_nick
  content_label.text = @message.message
  short_time_label.text = Time.at(@message.time).utc.strftime("%e %b %y")
  detailed_time_label.text = Time.at(@message.time).utc.strftime("%Y - %e %b %Y")
  n_favorites_label.visible = !@message.n_favorites.zero?
  n_favorites_label.markup = "<b>#{@message.n_favorites}</b>\nFavorites"
  n_reshares_label.visible = !@message.n_reshares.zero?
  n_reshares_label.markup = "<b>#{@message.n_reshares}</b>\nReshares"
  resent_box.visible = !@message.resent_by.nil?
  resent_by_button.label = @message.resent_by if @message.resent_by
  if @message.sender_nick == "@GTKtoolkit"
    avatar_image.set_from_icon_name("gtk3-demo", Gtk::IconSize::DND)
  else
    avatar_image.from_pixbuf = @avatar_pixbuf_other
  end
end
row_expand() click to toggle source
# File gtk3/sample/gtk-demo/listbox.rb, line 178
def row_expand
  expand = !details_revealer.reveal_child?
  details_revealer.reveal_child = expand
  expand ? expand_button.label = "Hide" : expand_button.label = "Expand"
end
sort(b) click to toggle source
# File gtk3/sample/gtk-demo/listbox.rb, line 174
def sort(b)
  @message.time - b.message.time
end