機能 #607 » 0001-.patch
| core/mui/cairo_cell_renderer_message.rb | ||
|---|---|---|
|
end
|
||
|
def event_hooks
|
||
|
@long_press ||= ::Gtk::LongPressHelper.new
|
||
|
last_pressed = nil
|
||
|
ssc(:click, @tree){ |r, e, path, column, cell_x, cell_y|
|
||
|
record = @tree.get_record(path)
|
||
| ... | ... | |
|
last_pressed = record.miracle_painter
|
||
|
if e.button == 1
|
||
|
last_pressed.pressed(cell_x, cell_y) end
|
||
|
@long_press.button_pressed {
|
||
|
Delayer.new(:ui_response) {
|
||
|
Plugin::GUI.keypress(::Gtk::buttonname([:long_press, e.button, e.state]), @tree.imaginary)
|
||
|
}
|
||
|
}
|
||
|
Delayer.new(:ui_response) {
|
||
|
Plugin::GUI.keypress(::Gtk::buttonname([e.event_type, e.button, e.state]), @tree.imaginary) }
|
||
|
end
|
||
|
false }
|
||
|
ssc(:button_release_event, @tree){ |r, e, path, column, cell_x, cell_y|
|
||
|
@long_press.button_released
|
||
|
if e.button == 1 and last_pressed
|
||
|
record = @tree.get_record(path)
|
||
|
if record
|
||
| core/mui/gtk_extension.rb | ||
|---|---|---|
|
r << 'Super + ' if (state & Gdk::Window::SUPER_MASK) != 0
|
||
|
r << 'Hyper + ' if (state & Gdk::Window::HYPER_MASK) != 0
|
||
|
r << "Button #{button} "
|
||
|
case type
|
||
|
when Gdk::Event::BUTTON_PRESS
|
||
|
r << 'Click'
|
||
|
when Gdk::Event::BUTTON2_PRESS
|
||
|
r << 'Double Click'
|
||
|
when Gdk::Event::BUTTON3_PRESS
|
||
|
r << 'Triple Click'
|
||
|
t = nil
|
||
|
if type.is_a?(Symbol)
|
||
|
case type
|
||
|
when :long_press
|
||
|
t = 'Long Press'
|
||
|
end
|
||
|
else
|
||
|
case type
|
||
|
when Gdk::Event::BUTTON_PRESS
|
||
|
t = 'Click'
|
||
|
when Gdk::Event::BUTTON2_PRESS
|
||
|
t = 'Double Click'
|
||
|
when Gdk::Event::BUTTON3_PRESS
|
||
|
t = 'Triple Click'
|
||
|
end
|
||
|
end
|
||
|
if t
|
||
|
r << t
|
||
|
return r
|
||
|
else
|
||
|
return '(割り当てなし)' end
|
||
|
return r end end
|
||
|
end end
|
||
|
class LongPressHelper
|
||
|
PRESS_TIME = 0.5
|
||
|
@long_pressing = nil
|
||
|
def button_pressed(&proc)
|
||
|
button_released
|
||
|
atomic do
|
||
|
@long_pressing = Thread.new {
|
||
|
sleep PRESS_TIME
|
||
|
proc.call
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
def button_released
|
||
|
atomic do
|
||
|
if @long_pressing
|
||
|
@long_pressing.kill
|
||
|
@long_pressing = nil
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
=begin rdoc
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
module MUI
|
||
|
Skin = ::Skin
|
||
|
end
|
||
| core/mui/gtk_keyconfig.rb | ||
|---|---|---|
|
@change_hook = nil
|
||
|
super(*args)
|
||
|
self.add(buttonlabel)
|
||
|
@long_press = ::Gtk::LongPressHelper.new
|
||
|
self.signal_connect('clicked', &method(:clicked_event))
|
||
|
end
|
||
| ... | ... | |
|
box.pack_start(button)
|
||
|
button.signal_connect(:key_press_event, &key_set(label))
|
||
|
button.signal_connect(:button_press_event, &button_set(label))
|
||
|
button.signal_connect(:button_release_event) { @long_press.button_released }
|
||
|
dialog.vbox.add(box)
|
||
|
dialog.show_all
|
||
|
dialog.run
|
||
| ... | ... | |
|
def button_set(label)
|
||
|
lambda{ |widget, event|
|
||
|
@long_press.button_pressed {
|
||
|
Delayer.new(:ui_response) {
|
||
|
self.keycode = Gtk.buttonname([:long_press, event.button, event.state])
|
||
|
buttonlabel.text = label.text = keycode
|
||
|
self.change_hook.call(keycode) if self.change_hook
|
||
|
}
|
||
|
}
|
||
|
self.keycode = Gtk.buttonname([event.event_type, event.button, event.state])
|
||
|
buttonlabel.text = label.text = keycode
|
||
|
self.change_hook.call(keycode) if self.change_hook
|
||