class TimeLine::InnerTL

Constants

MESSAGE
MIRACLE_PAINTER
ORDER
Record

TLの値を返すときに使う

URI

Attributes

force_retrieve_in_reply_to[W]
imaginary[RW]
postbox[RW]

Public Class Methods

current_tl() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 24
def self.current_tl
  ctl = @@current_tl and @@current_tl.toplevel.focus.get_ancestor(Gtk::TimeLine::InnerTL) rescue nil
  ctl if(ctl.is_a?(Gtk::TimeLine::InnerTL) and not ctl.destroyed?)
end
new(from = nil) click to toggle source

Args

from

設定値を引き継ぐ元のInnerTL

Calls superclass method Gtk::InnerTLDarkMatterPurification.new
# File core/mui/cairo_inner_tl.rb, line 31
def initialize(from = nil)
  super()
  @force_retrieve_in_reply_to = :auto
  @@current_tl ||= self
  @iter_dict = {} # String: Gdk::TreeIter
  @order = ->(m) { m.modified.to_i }
  self.name = 'timeline'
  set_headers_visible(false)
  set_enable_search(false)
  last_geo = nil
  selection.mode = Gtk::SELECTION_MULTIPLE
  get_column(0).set_sizing(Gtk::TreeViewColumn::AUTOSIZE)
  extend(from) if from
  set_events end

Public Instance Methods

add_postbox(i_postbox) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 103
def add_postbox(i_postbox)
  # ずっと表示される(投稿しても消えない)PostBoxの処理
  # 既にprocっぽいものが入っているときはそのままにしておく
  options = i_postbox.options.dup
  if options[:delegate_other] && !options[:delegate_other].respond_to?(:to_proc)
    i_timeline = i_postbox.ancestor_of(Plugin::GUI::Timeline)
    options[:delegate_other] = postbox_delegation_generator(i_timeline)
    options[:postboxstorage] = postbox end
  create_postbox(options) end
cell_renderer_message() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 46
def cell_renderer_message
  @cell_renderer_message ||= Gtk::CellRendererMessage.new
end
clear() click to toggle source

タイムラインの内容を全て削除する

Return

self

# File core/mui/cairo_inner_tl.rb, line 147
def clear
  deleted = @iter_dict
  @iter_dict = {}
  deleted.values.each{ |iter| iter[MIRACLE_PAINTER].destroy }
  model.clear end
column_schemer() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 50
def column_schemer
  [ {:renderer => lambda{ |x,y|
        cell_renderer_message.tree = self
        cell_renderer_message
      },
      :kind => :uri, :widget => :text, :type => String, :label => ''},
    {:kind => :text, :widget => :text, :type => Message},
    {:kind => :text, :type => Integer},
    {:kind => :text, :type => Object}
  ].freeze
end
extended() click to toggle source

別の InnerTL が自分をextend()した時に呼ばれる

# File core/mui/cairo_inner_tl.rb, line 204
def extended
  if @destroy_child_miraclepainters and signal_handler_is_connected?(@destroy_child_miraclepainters)
    signal_handler_disconnect(@destroy_child_miraclepainters) end end
force_retrieve_in_reply_to() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 173
def force_retrieve_in_reply_to
  if(:auto == @force_retrieve_in_reply_to)
    UserConfig[:retrieve_force_mumbleparent]
  else
    @force_retrieve_in_reply_to end end
get_active_iterators() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 120
def get_active_iterators
  selected = []
  if not destroyed?
    selection.selected_each{ |model, path, iter|
      selected << iter } end
  selected end
get_active_messages() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 117
def get_active_messages
  get_active_iterators.map{ |iter| iter[1] } end
get_active_pathes() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 127
def get_active_pathes
  selected = []
  if not destroyed?
    selection.selected_each{ |model, path, iter|
      selected << path } end
  selected end
get_order(m) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 62
def get_order(m)
  @order.call(m) end
get_path_by_message(message) click to toggle source

message に対応する Gtk::TreePath を返す。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 160
def get_path_by_message(message)
  get_path_and_iter_by_message(message)[1] end
get_record(path) click to toggle source

path からレコードを取得する。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 154
def get_record(path)
  iter = model.get_iter(path)
  if iter
    Record.new(iter[0], iter[1], iter[2], iter[3]) end end
get_record_by_message(message) click to toggle source

message に対応する値の構造体を返す。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 164
def get_record_by_message(message)
  get_record_by_uri(message.uri.to_s) end
get_record_by_uri(uri) click to toggle source

message に対応する値の構造体を返す。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 168
def get_record_by_uri(uri)
  path = get_path_and_iter_by_uri(uri)[1]
  if path
    get_record(path) end end
handle_row_activated() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 76
def handle_row_activated
end
include?(message) click to toggle source

message が含まれているかを返す

Args

message

Message タイムラインに含まれているかどうかを確認するMessage

Return

含まれていれば真

# File core/mui/cairo_inner_tl.rb, line 184
def include?(message)
  @iter_dict.has_key?(message.uri.to_s) end
menu_pop(widget, event) click to toggle source
reply(options = {}) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 90
def reply(options = {})
  ctl = Gtk::TimeLine::InnerTL.current_tl
  pb = nil
  if ctl
    pb = create_postbox(options)
    ctl.selection.unselect_all end
  pb end
set_cursor_to_display_top() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 113
def set_cursor_to_display_top
  iter = model.iter_first
  set_cursor(iter.path, get_column(0), false) if iter end
set_iter_dict(iter) click to toggle source

Gtk::TreeIterの対を再利用できるように登録しておく

Args

iter

Gtk::TreeIter

Return

self

# File core/mui/cairo_inner_tl.rb, line 192
def set_iter_dict(iter)
  uri = iter[URI]
  if not @iter_dict.has_key?(uri)
    @iter_dict[uri] = iter
    iters = @iter_dict
    iter[MIRACLE_PAINTER].signal_connect(:destroy) {
      iters.delete(uri)
      false } end
  self end
set_order(&block) click to toggle source

レコードの並び順を決めるブロックを登録する。ブロックは一つの Message を受け取り、数値を返す

Args

&block

並び順を決めるブロック

Return

self

# File core/mui/cairo_inner_tl.rb, line 70
def set_order(&block)
  @order = block end
update!(message, column, value) click to toggle source

message のレコードの column 番目のカラムの値を value にセットする。 成功したら value を返す

# File core/mui/cairo_inner_tl.rb, line 136
def update!(message, column, value)
  iter = get_iter_by_message(message)
  if iter
    iter[column] = value
    # 更新の結果、高さが変わる可能性がある
    iter[MIRACLE_PAINTER].reset_height
    value end end

Private Instance Methods

create_postbox(options) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 79
def create_postbox(options)
  options = options.dup
  options[:before_post_hook] = ->(this) {
    get_ancestor(Gtk::Window).set_focus(self) unless self.destroyed? }
  pb = Gtk::PostBox.new(options).show_all
  postbox.closeup(pb)
  pb.on_delete(&Proc.new) if block_given?
  get_ancestor(Gtk::Window).set_focus(pb.post)
  pb end
extend(from) click to toggle source

self に from の内容をコピーする

Args

from

InnerTL

Return

self

# File core/mui/cairo_inner_tl.rb, line 215
def extend(from)
  @force_retrieve_in_reply_to = from.instance_eval{ @force_retrieve_in_reply_to }
  @imaginary = from.imaginary
  from.extended
  from.model.each{ |from_model, from_path, from_iter|
    iter = model.append
    iter[URI] = from_iter[URI]
    iter[MESSAGE] = from_iter[MESSAGE]
    iter[ORDER] = from_iter[ORDER]
    iter[MIRACLE_PAINTER] = from_iter[MIRACLE_PAINTER].set_tree(self)
    set_iter_dict(iter) }
  self
end
get_iter_by_message(message) click to toggle source

message に対応する Gtk::TreeIter を返す。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 240
def get_iter_by_message(message)
  get_path_and_iter_by_message(message)[2] end
get_iter_by_uri(uri) click to toggle source

message に対応する Gtk::TreeIter を返す。なければnilを返す。

# File core/mui/cairo_inner_tl.rb, line 244
def get_iter_by_uri(uri)
  get_path_and_iter_by_uri(uri)[2] end
get_path_and_iter_by_message(message) click to toggle source

message から [model, path, iter] の配列を返す。見つからなかった場合は空の配列を返す。

# File core/mui/cairo_inner_tl.rb, line 248
def get_path_and_iter_by_message(message)
  get_path_and_iter_by_uri(message.uri.to_s) end
get_path_and_iter_by_uri(uri) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 251
def get_path_and_iter_by_uri(uri)
  uri = uri.to_s
  iter = @iter_dict[uri]
  if iter
    if iter[MIRACLE_PAINTER].destroyed?
      warn "destroyed miracle painter in cache (##{uri})"
      @iter_dict.delete(uri)
      []
    else
      [model, iter.path, iter] end
  else
    [] end end
postbox_delegation_generator(i_timeline) click to toggle source
# File core/mui/cairo_inner_tl.rb, line 98
def postbox_delegation_generator(i_timeline)
  ->(params) {
    i_timeline.create_postbox(params) } end
set_events() click to toggle source
# File core/mui/cairo_inner_tl.rb, line 229
def set_events
  @destroy_child_miraclepainters = signal_connect(:destroy) {
    model.each{ |m, p, iter|
      iter[MIRACLE_PAINTER].destroy }
  }
  signal_connect(:focus_in_event){
    @@current_tl.selection.unselect_all if not(@@current_tl.destroyed?) and @@current_tl and @@current_tl != self
    @@current_tl = self
    false } end