Debian Codegraph @

core/mui/cairo_replyviewer.rb

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 require 'mui/cairo_sub_parts_message_base'
4
5 class Gdk::ReplyViewer < Gdk::SubPartsMessageBase
6 EDGE_ABSENT_SIZE = 2
7 EDGE_PRESENT_SIZE = 8
8
9 register
10
11 attr_reader :messages
12
13 def on_click(e, message)
14 case e.button
15 when 1
16 case UserConfig[:reply_clicked_action]
17 when :open
18 Plugin.call(:open, message)
19 when :smartthread
20 Plugin.call(:open_smartthread, [message]) end
21 end end
22
23 def initialize(*args)
24 super
25 @edge = show_edge? ? EDGE_PRESENT_SIZE : EDGE_ABSENT_SIZE
26 if helper.message.has_receive_message?
27 helper.message.replyto_source_d(true).next{ |reply|
28 @messages = [reply].freeze
29 render_messages
30 }.terminate('リプライ描画中にエラーが発生しました') end end
31
32 def edge
33 if show_edge?
34 unless @edge == EDGE_PRESENT_SIZE
35 @edge = EDGE_PRESENT_SIZE
36 helper.reset_height
37 end
38 else
39 unless @edge == EDGE_ABSENT_SIZE
40 @edge = EDGE_ABSENT_SIZE
41 helper.reset_height
42 end
43 end
44 Gdk.scale(@edge)
45 end
46
47 def badge(_message)
48 Skin[:reply].pixbuf(width: badge_radius*2, height: badge_radius*2)
49 end
50
51 def background_color(message)
52 color = Plugin.filtering(:subparts_replyviewer_background_color, message, nil).last
53 if color.is_a?(Array) && color.size == 3
54 color.map{ |c| c.fdiv(0xffff) }.freeze
55 else
56 [1.0, 1.0, 1.0].freeze
57 end
58 end
59
60 def main_text_color(message)
61 UserConfig[:reply_text_color].map{ |c| c.fdiv(0xffff) }
62 end
63
64 def main_text_font(message)
65 helper.font_description(UserConfig[:reply_text_font]) end
66
67 def header_left_content(*args)
68 if show_header?
69 super end end
70
71 def header_right_content(*args)
72 if show_header?
73 super end end
74
75 def icon_size
76 if show_icon?
77 if UserConfig[:reply_icon_size]
78 size = Gdk.scale UserConfig[:reply_icon_size]
79 Gdk::Rectangle.new(0, 0, size, size)
80 else
81 super
82 end
83 end
84 end
85
86 def text_max_line_count(message)
87 UserConfig[:reply_text_max_line_count] || super end
88
89 def render_outline(message, context, base_y)
90 return unless show_edge?
91 case UserConfig[:reply_edge]
92 when :floating
93 render_outline_floating(message, context, base_y)
94 when :solid
95 render_outline_solid(message, context, base_y)
96 when :flat
97 render_outline_flat(message, context, base_y) end end
98
99 def render_badge(message, context)
100 return unless show_edge?
101 case UserConfig[:reply_edge]
102 when :floating
103 render_badge_floating(message, context)
104 when :solid
105 render_badge_solid(message, context)
106 when :flat
107 render_badge_flat(message, context) end end
108
109 def show_header?
110 (UserConfig[:reply_present_policy] || []).include?(:header) end
111
112 def show_icon?
113 (UserConfig[:reply_present_policy] || []).include?(:icon) end
114
115 def show_edge?
116 (UserConfig[:reply_present_policy] || []).include?(:edge) end
117 end