class Gdk::MiraclePainter

一つのMessageをPixbufにレンダリングするためのクラス。名前は言いたかっただけ。クラス名まで全てはつね色に染めて♪ 情報を設定してから、 #pixbuf で表示用の Gdk::Pixbuf のインスタンスを得ることができる。

Constants

BLACK
EMPTY
Event
WHITE

Attributes

message[R]
p_message[R]
selected[R]
to_message[R]
tree[R]

Public Class Methods

findbymessage(message) click to toggle source

message を内部に持っているGdk::MiraclePainterの集合をSetで返す。 ログ数によってはかなり重い処理なので注意

# File core/mui/cairo_miracle_painter.rb, line 42
def self.findbymessage(message)
  type_strict message => :to_message
  message = message.to_message
  result = Set.new
  Gtk::TimeLine.timelines.each{ |tl|
    found = tl.get_record_by_message(message)
    result << found.miracle_painter if found }
  result.freeze
end
findbymessage_d(message) click to toggle source

findbymessage のdeferred版。

# File core/mui/cairo_miracle_painter.rb, line 53
def self.findbymessage_d(message)
  type_strict message => :to_message
  message = message.to_message
  result = Set.new
  Gtk::TimeLine.timelines.deach{ |tl|
    if not tl.destroyed?
      found = tl.get_record_by_message(message)
      result << found.miracle_painter if found end
  }.next{
    result.freeze }
end
mp_modifier() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 65
def self.mp_modifier
  @mp_modifier ||= lambda { |miracle_painter|
    if (not miracle_painter.destroyed?) and (not miracle_painter.tree.destroyed?)
      miracle_painter.tree.model.each{ |model, path, iter|
        if iter[0].to_i == miracle_painter.message[:id]
          miracle_painter.tree.queue_draw
          break end } end
    false } end
new(message, *coodinate) click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 74
def initialize(message, *coodinate)
  type_strict message => :to_message
  @p_message = message
  @message = message.to_message
  @selected = false
  type_strict @message => Message
  super()
  coordinator(*coodinate)
  ssc(:modified, &Gdk::MiraclePainter.mp_modifier)
end
p_message() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 257
def self.p_message
  raise DestroyedError.new end
to_message() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 255
def self.to_message
  raise DestroyedError.new end
tree() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 253
def self.tree
  raise DestroyedError.new end

Public Instance Methods

__clicked_l7eOfD__(x, y, e) click to toggle source

名前からはプロフィールに、タイムスタンプからはツイートのパーマリンクにリンクしなければならない

Alias for: clicked
_schemer() click to toggle source

アイコン上のボタンの数の変更

# File core/plugin/display_requirements/display_requirements.rb, line 68
def _schemer
  {x_count: 1, y_count: 1} end
clicked(x, y, e) click to toggle source

座標 ( x , y ) にクリックイベントを発生させる

# File core/mui/cairo_miracle_painter.rb, line 131
def clicked(x, y, e)
  signal_emit(:click, e, x, y)
  case e.button
  when 1
    iob_clicked
    if not textselector_range
      index = main_pos_to_index(x, y)
      if index
        l = message.links.segment_by_index(index)
        l[:callback].call(l) if l and l[:callback] end end
  when 3
    @tree.get_ancestor(Gtk::Window).set_focus(@tree)
    Plugin::GUI::Command.menu_pop
  end end
Also aliased as: __clicked_l7eOfD__
destroy() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 252
def destroy
  def self.tree
    raise DestroyedError.new end
  def self.to_message
    raise DestroyedError.new end
  def self.p_message
    raise DestroyedError.new end

  instance_variables.each{ |v|
    instance_variable_set(v, nil) }

  @tree = nil
  signal_emit('destroy')
  super
  freeze
end
iob_clicked() click to toggle source

アイコンをクリックしたら必ずプロフィールを表示しなければならない

# File core/plugin/display_requirements/display_requirements.rb, line 80
def iob_clicked
  if(current_icon_pos)
    Plugin.call(:show_profile, Service.primary, message.user) end end
iob_etc_clicked() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 203
def iob_etc_clicked
end
iob_fav_clicked() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 199
def iob_fav_clicked
  message.favorite(!message.favorite?)
end
iob_icon_pixbuf() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 173
def iob_icon_pixbuf
  [ ["reply.png", "etc.png"],
    ["retweet.png",
     message.favorite? ? "unfav.png" : "fav.png"] ] end
iob_icon_pixbuf_off() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 178
def iob_icon_pixbuf_off
  [ [(UserConfig[:show_replied_icon] and message.mentioned_by_me? and "reply.png"),
     nil],
    [message.retweeted? ? "retweet.png" : nil,
     message.favorite? ? "unfav.png" : nil]
  ]
end
iob_reply_clicked() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 186
def iob_reply_clicked
  @tree.imaginary.create_reply_postbox(message) end
iob_retweet_clicked() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 189
def iob_retweet_clicked
  if message.retweeted?
    retweet = message.retweeted_statuses.find(&:from_me?)
    retweet.destroy if retweet
  else
    message.retweet
  end
  # @tree.imaginary.create_reply_postbox(message, :retweet => true)
end
main_pos_to_index(x, y) click to toggle source

つぶやきの左上座標から、クリックされた文字のインデックスを返す

# File core/mui/cairo_miracle_painter.rb, line 207
def main_pos_to_index(x, y)
  x -= pos.main_text.x
  y -= pos.main_text.y
  inside, byte, trailing = *main_message.xy_to_index(x * Pango::SCALE, y * Pango::SCALE)
  message.to_s.get_index_from_byte(byte) if inside end
main_pos_to_index_forclick(x, y) click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 213
def main_pos_to_index_forclick(x, y)
  x -= pos.main_text.x
  y -= pos.main_text.y
  result = main_message.xy_to_index(x * Pango::SCALE, y * Pango::SCALE)
  result[1] = message.to_s.get_index_from_byte(result[1])
  return *result end
on_modify(event=true) click to toggle source

更新イベントを発生させる

# File core/mui/cairo_miracle_painter.rb, line 227
def on_modify(event=true)
  if not destroyed?
    @pixmap = nil
    @pixbuf = nil
    @coordinate = nil
    if(defined? @last_modify_height and @last_modify_height != height)
      tree.get_column(0).queue_resize
      @last_modify_height = height end
    signal_emit('modified') if event
  end
end
on_selected() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 146
def on_selected
  if not frozen?
    @selected = true
    on_modify end end
on_unselected() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 151
def on_unselected
  if not frozen?
    @selected = false
    on_modify end end
pixbuf() click to toggle source

TLに表示するための Gdk::Pixbuf のインスタンスを返す

# File core/mui/cairo_miracle_painter.rb, line 114
def pixbuf
  @pixbuf ||= gen_pixbuf
end
pixmap() click to toggle source

TLに表示するための Gdk::Pixmap のインスタンスを返す

# File core/mui/cairo_miracle_painter.rb, line 109
def pixmap
  @pixmap ||= gen_pixmap
end
point_leaved(x, y) click to toggle source

leaveイベントを発生させる

# File core/mui/cairo_miracle_painter.rb, line 163
def point_leaved(x, y)
  iob_main_leave
  signal_emit(:leave_notify_event)
  # textselector_release
end
point_moved(x, y) click to toggle source

座標 ( x , y ) にマウスオーバーイベントを発生させる

# File core/mui/cairo_miracle_painter.rb, line 157
def point_moved(x, y)
  point_moved_main_icon(x, y)
  signal_emit(:motion_notify_event, x, y)
  textselector_select(*main_pos_to_index_forclick(x, y)[1..2]) end
pressed(x, y) click to toggle source

MiraclePainterの座標x, y上でポインティングデバイスのボタン1が押されたことを通知する

# File core/mui/cairo_miracle_painter.rb, line 119
def pressed(x, y)
  textselector_press(*main_pos_to_index_forclick(x, y)[1..2])
end
released(x=nil, y=nil) click to toggle source

MiraclePainterの座標x, y上でポインティングデバイスのボタン1が離されたことを通知する

# File core/mui/cairo_miracle_painter.rb, line 124
def released(x=nil, y=nil)
  if(x == y and not x)
    unselect
  else
    textselector_release(*main_pos_to_index_forclick(x, y)[1..2]) end end
set_tree(new) click to toggle source

Gtk::TimeLine::InnerTLのインスタンスを設定する。今後、このインスタンスは new に所属するものとして振舞う

# File core/mui/cairo_miracle_painter.rb, line 103
def set_tree(new)
  type_strict new => Gtk::TimeLine::InnerTL
  @tree = new
  self end
signal_do_click(event, cell_x, cell_y) click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 93
def signal_do_click(event, cell_x, cell_y)
end
signal_do_expose_event() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 223
def signal_do_expose_event()
end
signal_do_leave_notify_event() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 99
def signal_do_leave_notify_event()
end
signal_do_modified() click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 220
def signal_do_modified()
end
signal_do_motion_notify_event(cell_x, cell_y) click to toggle source
# File core/mui/cairo_miracle_painter.rb, line 96
def signal_do_motion_notify_event(cell_x, cell_y)
end
unselect() click to toggle source

MiraclePainterが選択解除されたことを通知する

# File core/mui/cairo_miracle_painter.rb, line 170
def unselect
  textselector_unselect end
visible?() click to toggle source

画面上にこれが表示されているかを返す

# File core/mui/cairo_miracle_painter.rb, line 240
def visible?
  if tree
    start, last = tree.visible_range
    if start
      range = tree.selected_range_bytime
      if(tree.vadjustment.value == 0)
        range.first <= message.modified.to_i
      else
        range.include?(message.modified.to_i) end end
  else
    true end end