/
show_tweet.rb
56 lines (51 loc) · 1.41 KB
/
show_tweet.rb
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
Plugin.create(:show_tweet) do
on_window_created do |i_wnd|
@i_main_wnd = i_wnd
end
def main_window
Plugin.filtering(:gui_get_gtk_widget, @i_main_wnd).first
end
on_show_tweet do |id|
Thread.new{
Message.findbyid(id)
}.next {|msg|
slug = :"show_tweet_#{id}"
tab slug, "ツイート" do
set_deletable true
set_icon Skin.get("list.png")
temporary_tab
timeline slug
end
timeline(slug) << msg
timeline(slug).active!
}.terminate {|e|
activity :error, "ツイーヨが取得できませんでした", description: "#{e.to_s}\n#{e.backtrace.join("\n")}"
}
end
command(:open_tweet_url_dialog,
name: 'URL指定でツイートを表示',
condition: lambda{|opt| true},
visible: true,
icon: File.join(File.dirname(__FILE__),"show_tweet.png"),
role: :window) do |opt|
dlg = Gtk::Dialog.new("ツイートのURL",
main_window,
Gtk::Dialog::MODAL,
[Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK],
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL])
begin
entry = Gtk::Entry.new
dlg.vbox.add(entry)
dlg.show_all
if dlg.run == Gtk::Dialog::RESPONSE_OK
url = entry.text
# Be robust ;)
if m = url.match(/\d+$/)
Plugin.call(:show_tweet, m[0].to_i)
end
end
ensure
dlg.destroy
end
end
end