[Sugar-devel] [sugar-toolkit-gtk3] Replace signal used in UnfullscreenButton to enable use with touch - SL #3798
Simon Schampijer
simon at schampijer.de
Tue Aug 14 06:47:06 EDT 2012
On 08/09/2012 10:27 PM, Manuel Quiñones wrote:
> Thanks Gonzalo,
Thanks Gonzalo. I was intrigued by that fact and looked a bit at the issue.
> 2012/8/9 <godiard at sugarlabs.org>:
>> From: Gonzalo Odiard <godiard at gmail.com>
>>
>> Use clicked instead of button-pressed, because this is not triggered
>> by touch device.
>
> Makes sense, clicked is more general than button-pressed. From the
> docs, "is emitted when the button has been activated (pressed and
> released)".
>
> http://developer.gnome.org/gtk3/stable/GtkButton.html#GtkButton-clicked
>
>> Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
>
> Acked-by: Manuel Quiñones <manuq at laptop.org>
I tested the behavior in GTK+3 and GTK+2, and it does behave differently:
In Gtk+2 I do get as well the press&release events with touch. In Gtk+3
I do not, only the clicked signal. Looking at the docs [1] the
button-release-event is only submitted when it is enabled using the
mask. Tried that, but the behavior is the same.
I am fine to go with 'clicked' as Gonzalo suggested but would be nice to
know the details as well.
Regards,
Simon
[1]
http://developer.gnome.org/gtk3/3.2/GtkWidget.html#GtkWidget-button-release-event
------------------------------------
from gi.repository import Gtk, Gdk
def _destroy_cb(widget, data=None):
Gtk.main_quit()
def __pressed_cb(button, event):
print 'pressed'
def __released_cb(button, event):
print 'released'
def __clicked_cb(button):
print 'clicked'
window = Gtk.Window()
window.connect("destroy", _destroy_cb)
window.set_default_size(450, 450)
b = Gtk.Button()
b.connect('clicked', __clicked_cb)
b.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK)
b.connect('button-press-event', __pressed_cb)
b.connect('button-release-event', __released_cb)
window.add(b)
b.show()
window.show()
Gtk.main()
---------------------------
import gtk
def _destroy_cb(widget, data=None):
gtk.main_quit()
def __pressed_cb(button, event):
print 'pressed'
def __released_cb(button, event):
print 'released'
def __clicked_cb(button):
print 'clicked'
window = gtk.Window()
window.connect("destroy", _destroy_cb)
window.set_default_size(450, 450)
b = gtk.Button()
b.connect('button-press-event', __pressed_cb)
b.connect('button-release-event', __released_cb)
b.connect('clicked', __clicked_cb)
window.add(b)
b.show()
window.show()
gtk.main()
More information about the Sugar-devel
mailing list