class Gdk::SubPartsVoter

Attributes

icon_height[R]
icon_width[R]
margin[R]
votes[R]

Public Class Methods

new(*args) click to toggle source
Calls superclass method Gdk::SubParts.new
# File core/mui/cairo_sub_parts_voter.rb, line 11
def initialize(*args)
  super
  @icon_width, @icon_height, @margin, @votes, @user_icon = 24, 24, 2, get_default_votes.to_a, Hash.new
  @avatar_rect = []
  @icon_ofst = 0
  helper.ssc(:click){ |this, e, x, y|
    ofsty = helper.mainpart_height
    helper.subparts.each{ |part|
      break if part == self
      ofsty += part.height }
    if ofsty <= y and (ofsty + height) >= y
      case e.button
      when 1
        if(x >= @icon_ofst)
          user = get_user_by_point(x)
          if user
            Plugin.call(:open, user)
          end
        end
      end
    end
    false
  }
  last_motion_user = nil
  usertip = Gtk::Tooltips.instance
  helper.ssc(:motion_notify_event){ |this, x, y|
    if 0 != height
      tipset = ''
      ofsty = helper.mainpart_height
      helper.subparts.each{ |part|
        break if part == self
        ofsty += part.height }
      if ofsty <= y and (ofsty + height) >= y
        if(x >= @icon_ofst)
          user = get_user_by_point(x)
          last_motion_user = user
          if user
            tipset = user.idname end end end
      usertip.set_tip(helper.tree, tipset, '')
      if tipset == ''
        last_motion_user = nil
        usertip.disable
      else
        usertip.enable end end
    false }
  helper.ssc(:leave_notify_event){
    usertip.set_tip(helper.tree, '', '')
    usertip.disable
    false
  }
end

Public Instance Methods

<<(new)
Alias for: add
add(new) click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 84
def add(new)
  if UserConfig[:"#{name}_by_anyone_show_timeline"]
    if not @votes.include?(new)
      before_height = height
      @votes << new
      if(before_height == height)
        helper.on_modify
      else
        helper.reset_height end
      self end end end
Also aliased as: <<
delete(user) click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 96
def delete(user)
  if UserConfig[:"#{name}_by_anyone_show_timeline"]
    if not @votes.include?(user)
      before_height = height
      @votes.delete(user)
      if(before_height == height)
        helper.on_modify
      else
        helper.reset_height end
      self end end end
get_user_by_point(x) click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 63
def get_user_by_point(x)
  if(x >= @icon_ofst)
    node = @avatar_rect.each_with_index.to_a.bsearch{|_| _[0].last > x }
    if node
      @votes[node.last] end end end
height() click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 78
def height
  if get_vote_count == 0
    0
  else
    icon_height end end
name() click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 107
def name
  raise end
render(context) click to toggle source
# File core/mui/cairo_sub_parts_voter.rb, line 69
def render(context)
  if get_vote_count != 0
    context.save{
      context.translate(@margin, 0)
      put_title_icon(context)
      put_counter(context)
      put_voter(context) } end
  @last_height = height end
title_icon() click to toggle source

このSubPartsのアイコンのPixbufを返す。 #title_icon_model メソッドをオーバライドしない場合、こちらを必ずオーバライドしなければならない

# File core/mui/cairo_sub_parts_voter.rb, line 112
def title_icon
  title_icon_model.pixbuf(width: @icon_width, height: @icon_height)
end
title_icon_model() click to toggle source

このSubPartsのアイコンをあらわすModelを返す。 #title_icon の内部でしか使われないので、このメソッドを使わないように #title_icon を再定義した場合は このメソッドをオーバライドする必要はない。

# File core/mui/cairo_sub_parts_voter.rb, line 119
def title_icon_model
  raise
end