機能 #607 » 0001-.patch
core/mui/cairo_cell_renderer_message.rb | ||
---|---|---|
155 | 155 |
end |
156 | 156 | |
157 | 157 |
def event_hooks |
158 |
@long_press ||= ::Gtk::LongPressHelper.new |
|
159 | ||
158 | 160 |
last_pressed = nil |
159 | 161 |
ssc(:click, @tree){ |r, e, path, column, cell_x, cell_y| |
160 | 162 |
record = @tree.get_record(path) |
... | ... | |
166 | 168 |
last_pressed = record.miracle_painter |
167 | 169 |
if e.button == 1 |
168 | 170 |
last_pressed.pressed(cell_x, cell_y) end |
171 | ||
172 |
@long_press.button_pressed { |
|
173 |
Delayer.new(:ui_response) { |
|
174 |
Plugin::GUI.keypress(::Gtk::buttonname([:long_press, e.button, e.state]), @tree.imaginary) |
|
175 |
} |
|
176 |
} |
|
177 | ||
169 | 178 |
Delayer.new(:ui_response) { |
170 | 179 |
Plugin::GUI.keypress(::Gtk::buttonname([e.event_type, e.button, e.state]), @tree.imaginary) } |
171 | 180 |
end |
172 | 181 |
false } |
173 | 182 |
ssc(:button_release_event, @tree){ |r, e, path, column, cell_x, cell_y| |
183 |
@long_press.button_released |
|
184 | ||
174 | 185 |
if e.button == 1 and last_pressed |
175 | 186 |
record = @tree.get_record(path) |
176 | 187 |
if record |
core/mui/gtk_extension.rb | ||
---|---|---|
83 | 83 |
r << 'Super + ' if (state & Gdk::Window::SUPER_MASK) != 0 |
84 | 84 |
r << 'Hyper + ' if (state & Gdk::Window::HYPER_MASK) != 0 |
85 | 85 |
r << "Button #{button} " |
86 |
case type |
|
87 |
when Gdk::Event::BUTTON_PRESS |
|
88 |
r << 'Click' |
|
89 |
when Gdk::Event::BUTTON2_PRESS |
|
90 |
r << 'Double Click' |
|
91 |
when Gdk::Event::BUTTON3_PRESS |
|
92 |
r << 'Triple Click' |
|
86 | ||
87 |
t = nil |
|
88 | ||
89 |
if type.is_a?(Symbol) |
|
90 |
case type |
|
91 |
when :long_press |
|
92 |
t = 'Long Press' |
|
93 |
end |
|
94 |
else |
|
95 |
case type |
|
96 |
when Gdk::Event::BUTTON_PRESS |
|
97 |
t = 'Click' |
|
98 |
when Gdk::Event::BUTTON2_PRESS |
|
99 |
t = 'Double Click' |
|
100 |
when Gdk::Event::BUTTON3_PRESS |
|
101 |
t = 'Triple Click' |
|
102 |
end |
|
103 |
end |
|
104 | ||
105 |
if t |
|
106 |
r << t |
|
107 |
return r |
|
93 | 108 |
else |
94 | 109 |
return '(割り当てなし)' end |
95 |
return r end end |
|
110 |
end end |
|
111 | ||
112 |
class LongPressHelper |
|
113 |
PRESS_TIME = 0.5 |
|
114 | ||
115 |
@long_pressing = nil |
|
116 | ||
117 |
def button_pressed(&proc) |
|
118 |
button_released |
|
96 | 119 | |
120 |
atomic do |
|
121 |
@long_pressing = Thread.new { |
|
122 |
sleep PRESS_TIME |
|
123 |
proc.call |
|
124 |
} |
|
125 |
end |
|
126 |
end |
|
127 | ||
128 |
def button_released |
|
129 |
atomic do |
|
130 |
if @long_pressing |
|
131 |
@long_pressing.kill |
|
132 |
@long_pressing = nil |
|
133 |
end |
|
134 |
end |
|
135 |
end |
|
136 |
end |
|
97 | 137 |
end |
98 | 138 | |
99 | 139 |
=begin rdoc |
... | ... | |
259 | 299 |
end |
260 | 300 |
end |
261 | 301 | |
302 | ||
303 | ||
262 | 304 |
module MUI |
263 | 305 |
Skin = ::Skin |
264 | 306 |
end |
core/mui/gtk_keyconfig.rb | ||
---|---|---|
17 | 17 |
@change_hook = nil |
18 | 18 |
super(*args) |
19 | 19 |
self.add(buttonlabel) |
20 |
@long_press = ::Gtk::LongPressHelper.new |
|
20 | 21 |
self.signal_connect('clicked', &method(:clicked_event)) |
21 | 22 |
end |
22 | 23 | |
... | ... | |
44 | 45 |
box.pack_start(button) |
45 | 46 |
button.signal_connect(:key_press_event, &key_set(label)) |
46 | 47 |
button.signal_connect(:button_press_event, &button_set(label)) |
48 |
button.signal_connect(:button_release_event) { @long_press.button_released } |
|
47 | 49 |
dialog.vbox.add(box) |
48 | 50 |
dialog.show_all |
49 | 51 |
dialog.run |
... | ... | |
59 | 61 | |
60 | 62 |
def button_set(label) |
61 | 63 |
lambda{ |widget, event| |
64 |
@long_press.button_pressed { |
|
65 |
Delayer.new(:ui_response) { |
|
66 |
self.keycode = Gtk.buttonname([:long_press, event.button, event.state]) |
|
67 |
buttonlabel.text = label.text = keycode |
|
68 |
self.change_hook.call(keycode) if self.change_hook |
|
69 |
} |
|
70 |
} |
|
71 | ||
62 | 72 |
self.keycode = Gtk.buttonname([event.event_type, event.button, event.state]) |
63 | 73 |
buttonlabel.text = label.text = keycode |
64 | 74 |
self.change_hook.call(keycode) if self.change_hook |