class Gtk::InnerUserList

Constants

COL_ICON
COL_NAME
COL_ORDER
COL_SCREEN_NAME
COL_USER

Public Class Methods

new(userlist) click to toggle source
Calls superclass method Gtk::TreeViewPrettyScroll.new
# File core/mui/gtk_inneruserlist.rb, line 13
def initialize(userlist)
  @userlist = userlist
  super(::Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, String, Object, Integer))
  append_column ::Gtk::TreeViewColumn.new("", ::Gtk::CellRendererPixbuf.new, pixbuf: COL_ICON)
  append_column ::Gtk::TreeViewColumn.new("SN", ::Gtk::CellRendererText.new, text: COL_SCREEN_NAME)
  append_column ::Gtk::TreeViewColumn.new("名前", ::Gtk::CellRendererText.new, text: COL_NAME)
  model.set_sort_column_id(COL_ORDER,  Gtk::SORT_DESCENDING)
end

Public Instance Methods

add_user(users) click to toggle source

Userの配列 users を追加する

Args

users

Enumerable ユーザを繰り返すEnumerable

Return

self

# File core/mui/gtk_inneruserlist.rb, line 27
def add_user(users)
  exist_users = Set.new(model.to_enum.map{ |model,path,iter| iter[COL_USER] })
  users.select{|user|
    user.is_a?(Diva::Model)
  }.reject{|user|
    exist_users.include?(user)
  }.deach{|user|
    iter = model.append
    iter[COL_ICON] = user.icon.load_pixbuf(width: 24, height: 24){|pixbuf|
      iter[COL_ICON] = pixbuf unless destroyed?
    }
    iter[COL_SCREEN_NAME] = user[:idname]
    iter[COL_NAME] = user[:name]
    iter[COL_USER] = user
    iter[COL_ORDER] = @userlist.gen_order(user)
  }.terminate
  scroll_to_zero_lator! if realized? and vadjustment.value == 0.0
  self end
remove_user(users) click to toggle source

Userの配列 users に含まれるユーザを削除する

Args

users

ユーザの配列

Return

self

# File core/mui/gtk_inneruserlist.rb, line 51
def remove_user(users)
  Enumerator.new(model).each{ |model,path,iter|
    if users.include?(iter[COL_USER])
       model.remove(iter) end }
  self end
reorder(user) click to toggle source

ユーザ user の順番を再計算する

Args

user

ユーザ

Return

self

# File core/mui/gtk_inneruserlist.rb, line 62
def reorder(user)
  each{ |m, p, iter|
    if iter[COL_USER] == user
      iter[COL_ORDER] = @userlist.gen_order(user)
      return self end }
  self end