class Gtk::PostBox

Attributes

return_to_top[RW]

Public Class Methods

list() click to toggle source

既存のGtk::PostBoxのインスタンスを返す

# File core/mui/gtk_postbox.rb, line 20
def self.list
  return @@postboxes
end
new(postable = nil, to: [], from: nil, header: ''.freeze, footer: ''.freeze, to_display_only: false, use_blind_footer: true, **kwrest) click to toggle source

Args

postable

Service|Message リプライ先か、投稿するアカウント(3.3 obsolete)

to

Enumerable 返信するMessage

from

Service|nil 送信者。nilを指定すると、その時のプライマリアカウントになる

header

String テキストフィールドのカーソルの前に最初から入力されている文字列

footer

String テキストフィールドのカーソルの後ろに最初から入力されている文字列

to_display_only

true|false toに宛てたリプライを送るなら偽。真ならUI上にtoが表示されるだけ

use_blind_footer

true|false blind footerを追加するか否か

kwrest

Hash 以下の値から成る連想配列

- delegated_by :: Gtk::PostBox 投稿処理をこのPostBoxに移譲したPostBox
- postboxstrage :: Gtk::Container PostBoxの親で、複数のPostBoxを持つことができるコンテナ
- delegate_other :: true|false|Proc 投稿時、このPostBoxを使わないで、新しいPostBoxで投稿する。そのPostBoxにはdelegated_byに _self_ が設定される。Procを指定した場合、新しいPostBoxを作る処理として、その無名関数を使う
- before_post_hook :: Proc 投稿前に、 _self_ を引数に呼び出される
Calls superclass method
# File core/mui/gtk_postbox.rb, line 37
def initialize(postable = nil,
               to: [],
               from: nil,
               header: ''.freeze,
               footer: ''.freeze,
               to_display_only: false,
               use_blind_footer: true,
               **kwrest)
  mainthread_only
  @posting = nil
  @return_to_top = nil
  @options = kwrest

  @from = from
  @to = (Array(to) + Array(@options[:subreplies])).uniq.freeze
  case postable
  when Service
    @from = postable
  when Message
    @to = [postable, *@to].freeze unless @to.include? postable end
  @header = (header || '').freeze
  @footer = (footer || '').freeze
  @to_display_only = !!to_display_only
  @use_blind_footer = !!use_blind_footer
  super()
  signal_connect('parent-set'){
    if parent
      sw = get_ancestor(Gtk::ScrolledWindow)
      if(sw)
        @return_to_top = sw.vadjustment.value == 0
      else
        @return_to_top = false end
      post_it if @options[:delegated_by] end }
  add(generate_box)
  set_border_width(2)
  register end

Public Instance Methods

active() click to toggle source

このPostBoxにフォーカスを合わせる

# File core/mui/gtk_postbox.rb, line 141
def active
  get_ancestor(Gtk::Window).set_focus(widget_post) if(get_ancestor(Gtk::Window)) end
delegatable?() click to toggle source

このPostBoxを使って投稿したとき、delegateを作成するように設定されていれば真を返す

# File core/mui/gtk_postbox.rb, line 137
def delegatable?
  @options[:delegate_other] end
destroy() click to toggle source
Calls superclass method
# File core/mui/gtk_postbox.rb, line 159
def destroy
  @@ringlock.synchronize{
    if not(destroyed?) and not(frozen?) and parent
      parent.remove(self)
      @@postboxes.delete(self)
      super
      on_delete
      self.freeze end } end
post()
Alias for: widget_post
post_it() click to toggle source

入力されている投稿する。投稿に成功したら、self.destroyを呼んで自分自身を削除する

# File core/mui/gtk_postbox.rb, line 145
def post_it
  if postable?
    return unless before_post
    text = widget_post.buffer.text
    text += UserConfig[:footer] if use_blind_footer?
    @posting = service.post(:message => text){ |event, msg|
      case event
      when :start
        Delayer.new{ start_post }
      when :fail
        Delayer.new{ end_post }
      when :success
        Delayer.new{ destroy } end } end end
posting?() click to toggle source

現在メッセージの投稿中なら真を返す

# File core/mui/gtk_postbox.rb, line 133
def posting?
  !!@posting end
refresh_buttons(refresh_brothers = true) click to toggle source

各ボタンのクリック可否状態を更新する

# File core/mui/gtk_postbox.rb, line 124
def refresh_buttons(refresh_brothers = true)
  if refresh_brothers and @options.has_key?(:postboxstorage)
    @options[:postboxstorage].children.each{ |brother|
      brother.refresh_buttons(false) }
  else
    widget_send.sensitive = postable?
    widget_tool.sensitive = destructible? || posting? end end
widget_post() click to toggle source
# File core/mui/gtk_postbox.rb, line 74
def widget_post
  return @post if defined?(@post)
  @post = gen_widget_post
  post_set_default_text(@post)
  @post.wrap_mode = Gtk::TextTag::WRAP_CHAR
  @post.border_width = 2
  @post.buffer.ssc('changed') { |textview|
    refresh_buttons(false)
    false }
  @post.signal_connect_after('focus_out_event', &method(:focus_out_event))
  @post end
Also aliased as: post
widget_remain() click to toggle source
# File core/mui/gtk_postbox.rb, line 87
def widget_remain
  return @remain if defined?(@remain)
  @remain = Gtk::Label.new('---')
  Delayer.new{
    if not @remain.destroyed?
      @remain.set_text(remain_charcount.to_s) end }
  widget_post.buffer.ssc(:changed){ |textview, event|
    @remain.set_text(remain_charcount.to_s) }
  @remain end
widget_send() click to toggle source
# File core/mui/gtk_postbox.rb, line 97
def widget_send
  return @send if defined?(@send)
  @send = Gtk::Button.new.add(Gtk::WebIcon.new(Skin.get_path('post.png'), 16, 16))
  @send.sensitive = postable?
  @send.signal_connect('clicked'){|button|
    post_it
    false }
  @send end
widget_tool() click to toggle source
# File core/mui/gtk_postbox.rb, line 106
def widget_tool
  return @tool if defined?(@tool)
  @tool = Gtk::Button.new.add(Gtk::WebIcon.new(Skin.get_path('close.png'), 16, 16))
  @tool.signal_connect_after('focus_out_event', &method(:focus_out_event))
  @tool.ssc('event'){
    @tool.sensitive = destructible? || posting?
    false }
  @tool.ssc('clicked'){
    if posting?
      @posting.cancel
      @tool.sensitive = destructible? || posting?
      cancel_post
    else
      destroy if destructible? end
    false }
  @tool end