Debian Codegraph @

plugin/gui/postbox.rb

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 # ツイート投稿ウィジェット
3
4 require_relative 'cuscadable'
5 require_relative 'hierarchy_child'
6 require_relative 'window'
7 require_relative 'timeline'
8 require_relative 'widget'
9
10 class Plugin::GUI::Postbox
11
12 module PostboxParent; end
13
14 include Plugin::GUI::Cuscadable
15 include Plugin::GUI::HierarchyChild
16 include Plugin::GUI::Widget
17
18 role :postbox
19
20 set_parent_event :gui_postbox_join_widget
21
22 set_parent_class Plugin::GUI::Postbox::PostboxParent
23
24 attr_accessor :options
25
26 class << self
27 # Postboxは、他のウィジェットと違ってキー入力中に他のロールに対するmikutterコマンドを実行すべきでない。
28 # なので、find_role_ancestorは常に _find_ がPostboxの時だけ有効な値を返す
29 # ==== Args
30 # [find] 探すロール
31 # ==== Return
32 # findがPlugin::GUI::Postboxならそれを、それ以外ならnil
33 def find_role_ancestor(find)
34 self if role == find end
35 end
36
37 def initialize(*args)
38 super
39 @options = {}
40 Plugin.call(:postbox_created, self) end
41
42 # このPostboxの内容を投稿する
43 # ==== Args
44 # [world:] 投稿先のWorld。nilを与えた場合は自動選択。
45 # ==== Return
46 # self
47 def post_it!(world: nil)
48 Plugin.call(:gui_postbox_post, self, {world: world})
49 self
50 end
51
52 # このPostboxがユーザの入力を受け付けているなら真。
53 # 偽を返すPostboxは、投稿処理中か、投稿が完了して破棄されたもの
54 # ==== Return
55 # 編集中なら真
56 def editable?
57 editable = Plugin.filtering(:gui_postbox_input_editable, self, false)
58 editable.last if editable end
59
60 end
61
62 class Plugin::GUI::Window
63 include Plugin::GUI::Postbox::PostboxParent end
64
65 class Plugin::GUI::Timeline
66 include Plugin::GUI::Postbox::PostboxParent end