File: postbox.rb

package info (click to toggle)
mikutter 3.8.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,544 kB
  • sloc: ruby: 20,548; sh: 99; makefile: 19
file content (63 lines) | stat: -rw-r--r-- 1,711 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
# ツイート投稿ウィジェット

require_relative 'cuscadable'
require_relative 'hierarchy_child'
require_relative 'window'
require_relative 'timeline'
require_relative 'widget'

class Plugin::GUI::Postbox

  module PostboxParent; end

  include Plugin::GUI::Cuscadable
  include Plugin::GUI::HierarchyChild
  include Plugin::GUI::Widget

  role :postbox

  set_parent_event :gui_postbox_join_widget

  set_parent_class Plugin::GUI::Postbox::PostboxParent

  attr_accessor :options

  class << self
    # Postboxは、他のウィジェットと違ってキー入力中に他のロールに対するmikutterコマンドを実行すべきでない。
    # なので、find_role_ancestorは常に _find_ がPostboxの時だけ有効な値を返す
    # ==== Args
    # [find] 探すロール
    # ==== Return
    # findがPlugin::GUI::Postboxならそれを、それ以外ならnil
    def find_role_ancestor(find)
      self if role == find end
  end

  def initialize(*args)
    super
    @options = {}
    Plugin.call(:postbox_created, self) end

  # このPostboxの内容を投稿する
  # ==== Return
  # self
  def post_it!
    Plugin.call(:gui_postbox_post, self)
    self end

  # このPostboxがユーザの入力を受け付けているなら真。
  # 偽を返すPostboxは、投稿処理中か、投稿が完了して破棄されたもの
  # ==== Return
  # 編集中なら真
  def editable?
    editable = Plugin.filtering(:gui_postbox_input_editable, self, false)
    editable.last if editable end

end

class Plugin::GUI::Window
  include Plugin::GUI::Postbox::PostboxParent end

class Plugin::GUI::Timeline
  include Plugin::GUI::Postbox::PostboxParent end