[Sugar-devel] [sugar-toolkit-gtk3] Replace signal used in UnfullscreenButton to enable use with touch - SL #3798

2012-08-09 Thread godiard
From: Gonzalo Odiard 

Use clicked instead of button-pressed, because this is not triggered
by touch device.

Signed-off-by: Gonzalo Odiard 
---
 src/sugar3/graphics/window.py | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py
index 2d9764d..23a8d4f 100644
--- a/src/sugar3/graphics/window.py
+++ b/src/sugar3/graphics/window.py
@@ -65,8 +65,8 @@ class UnfullscreenButton(Gtk.Window):
 self._button.show()
 self.add(self._button)
 
-def connect_button_press(self, cb):
-self._button.connect('button-press-event', cb)
+def connect_button_clicked(self, cb):
+self._button.connect('clicked', cb)
 
 def _reposition(self):
 x = Gdk.Screen.width() - self._width
@@ -114,8 +114,8 @@ class Window(Gtk.Window):
 self._is_fullscreen = False
 self._unfullscreen_button = UnfullscreenButton()
 self._unfullscreen_button.set_transient_for(self)
-self._unfullscreen_button.connect_button_press(
-self.__unfullscreen_button_pressed)
+self._unfullscreen_button.connect_button_clicked(
+self.__unfullscreen_button_clicked)
 self._unfullscreen_button_timeout_id = None
 
 def reveal(self):
@@ -253,7 +253,7 @@ class Window(Gtk.Window):
 return True
 return False
 
-def __unfullscreen_button_pressed(self, widget, event):
+def __unfullscreen_button_clicked(self, button):
 self.unfullscreen()
 
 def __motion_notify_cb(self, widget, event):
-- 
1.7.11.2

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [sugar-toolkit-gtk3] Replace signal used in UnfullscreenButton to enable use with touch - SL #3798

2012-08-09 Thread Manuel Quiñones
Thanks Gonzalo,

2012/8/9  :
> From: Gonzalo Odiard 
>
> 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 

Acked-by: Manuel Quiñones 

> ---
>  src/sugar3/graphics/window.py | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py
> index 2d9764d..23a8d4f 100644
> --- a/src/sugar3/graphics/window.py
> +++ b/src/sugar3/graphics/window.py
> @@ -65,8 +65,8 @@ class UnfullscreenButton(Gtk.Window):
>  self._button.show()
>  self.add(self._button)
>
> -def connect_button_press(self, cb):
> -self._button.connect('button-press-event', cb)
> +def connect_button_clicked(self, cb):
> +self._button.connect('clicked', cb)
>
>  def _reposition(self):
>  x = Gdk.Screen.width() - self._width
> @@ -114,8 +114,8 @@ class Window(Gtk.Window):
>  self._is_fullscreen = False
>  self._unfullscreen_button = UnfullscreenButton()
>  self._unfullscreen_button.set_transient_for(self)
> -self._unfullscreen_button.connect_button_press(
> -self.__unfullscreen_button_pressed)
> +self._unfullscreen_button.connect_button_clicked(
> +self.__unfullscreen_button_clicked)
>  self._unfullscreen_button_timeout_id = None
>
>  def reveal(self):
> @@ -253,7 +253,7 @@ class Window(Gtk.Window):
>  return True
>  return False
>
> -def __unfullscreen_button_pressed(self, widget, event):
> +def __unfullscreen_button_clicked(self, button):
>  self.unfullscreen()
>
>  def __motion_notify_cb(self, widget, event):
> --
> 1.7.11.2
>
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [sugar-toolkit-gtk3] Replace signal used in UnfullscreenButton to enable use with touch - SL #3798

2012-08-14 Thread Simon Schampijer

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  :

From: Gonzalo Odiard 

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 


Acked-by: Manuel Quiñones 


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()

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [sugar-toolkit-gtk3] Replace signal used in UnfullscreenButton to enable use with touch - SL #3798

2012-08-14 Thread Gonzalo Odiard
>
>
> I am fine to go with 'clicked' as Gonzalo suggested but would be nice to
> know the details as well.
>
> Regards,
>Simon
>
>
The following info can be related:

In gtk3, a patch to check emulating_pointer before use touch as
button_press/release:

http://osdir.com/ml/commits.gnome/2012-02/msg09694.html

The code involved:

http://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.c#n5851

A XOrg announcement with changes related:

http://www.spinics.net/lists/xorg/msg53528.html

More patches to get the info:

https://mail.gnome.org/archives/commits-list/2012-March/msg01384.html

http://osdir.com/ml/commits.gnome/2012-03/msg01344.html

https://mail.gnome.org/archives/commits-list/2012-February/msg09965.html
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel