Debian Codegraph @

plugin/gui/tablike.rb

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 module Plugin::GUI::TabLike
4
5 attr_reader :icon
6 attr_accessor :deletable
7
8 def initialize(*args)
9 @expand = true
10 super
11 end
12
13 # できるだけ小さく表示する
14 # ==== Return
15 # self
16 def shrink
17 @expand = false
18 self end
19
20 # できるだけ大きく表示する
21 # ==== Return
22 # self
23 def expand(new = true)
24 @expand = new
25 self end
26
27 def expand?
28 @expand end
29
30 def pack_rule
31 @pack_rule ||= [] end
32
33 def add_child(child, *args)
34 result = super(child, *args)
35 pack_rule[children.index(child)] = expand?
36 result end
37 alias << add_child
38
39 # タイムラインを作成してこの中に入れる
40 # ==== Args
41 # [slug] タイムラインスラッグ
42 # [&proc] 処理
43 # ==== Return
44 # 新しく作成したタイムライン
45 def timeline(slug, &proc)
46 timeline = Plugin::GUI::Timeline.instance(slug)
47 self << timeline
48 timeline.instance_eval(&proc) if proc
49 timeline end
50
51 # プロフィールを作成してこの中に入れる
52 # ==== Args
53 # [slug] プロフィールスラッグ
54 # [&proc] 処理
55 # ==== Return
56 # 新しく作成したプロフィール
57 def cluster(slug, &proc)
58 cluster = Plugin::GUI::Cluster.instance(slug)
59 self << cluster
60 pack_rule.push(expand?)
61 cluster.instance_eval(&proc) if proc
62 cluster end
63
64 # UIツールキットのウィジェット(Gtk等)をタブに入れる
65 # ==== Args
66 # [widget] ウィジェット
67 # ==== Return
68 # self
69 def nativewidget(widget)
70 i_container = Plugin::GUI::TabChildWidget.instance
71 self << i_container
72 Plugin.call("gui_nativewidget_join_#{self.class.role}".to_sym, self, i_container, widget)
73 pack_rule.push(expand?)
74 self end
75
76 def set_icon(icon)
77 icon_model = case icon
78 when Diva::Model
79 icon
80 when String, URI, Addressable::URI, Diva::URI
81 Plugin.collect(:photo_filter, icon, Pluggaloid::COLLECT).first || Skin[:notfound]
82 else
83 raise RuntimeError, "Unexpected class `#{icon.class}'."
84 end
85 if @icon != icon_model
86 @icon = icon_model
87 Plugin.call(:gui_tab_change_icon, self) end
88 self end
89
90 def set_deletable(new)
91 @deletable = new
92 self end
93
94 def name=(new_name)
95 result = super new_name
96 Plugin.call(:gui_tab_change_icon, self)
97 result end
98
99 end