Re: [Sugar-devel] State of Palettes for GTK+ 3.x

2011-11-04 Thread Benjamin Berg
Hello,

On Thu, 2011-11-03 at 23:54 +, Gary Martin wrote:
 This could only really work sanely from a design point of view if
 exposing a palette via a cursor hover/loiter also went away i.e.
 having to click outside somewhere to dismiss a palette that was auto
 triggered by a hovering action would be a painful UX. I guess this all
 stems from the design decision to have widgets with hover/right-click
 context menus that also have primary left-click actions. For touch,
 we'll need to cover this cast by having a touch and hold gesture mimic
 our current hover/right-click behaviour.

Hm, I had not thought about the primary action yet. A touch and hold
gesture seems like a pretty good solution. I guess we will also want the
action to be accessible from a button inside the palette itself.

I am wondering about the buttons that only use palettes as tooltips. In
this case requiring the user to hold down for a while might be a bit
weird, even if it is consistent with other palettes. But then, without
hover you never get normal tooltips ...

Benjamin

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


[Sugar-devel] [PATCH sugar-toolkit PoC v2] Taphold for Palettes

2011-11-04 Thread Sascha Silbe
Most touch screens only have a single kind of action, no direct equivalent to
the secondary (even n-ary) actions (right-click) of standard PC mice.

Taphold is a well-established way on touch screen oriented user interfaces
of getting responses similar to what right click would do on WIMP interaces.

This patch is a hack to add taphold support to Sugar palettes for evaluation
purposes. The real thing (TM) should hook into GTK instead in order to make
it work beyond just Sugar palettes.

Signed-off-by: Sascha Silbe si...@activitycentral.com
---
v1-v2: Added previously uncommitted fixes to make it actually work. Sorry.

 src/sugar/graphics/palettewindow.py |   89 ---
 1 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/src/sugar/graphics/palettewindow.py 
b/src/sugar/graphics/palettewindow.py
index 5281e54..4955966 100644
--- a/src/sugar/graphics/palettewindow.py
+++ b/src/sugar/graphics/palettewindow.py
@@ -22,6 +22,7 @@ STABLE.
 

 import logging
+import time

 import gtk
 import gobject
@@ -32,6 +33,12 @@ from sugar.graphics import animator
 from sugar.graphics import style


+# Shorter than 350ms is considered a tap, longer than 1s hold. Anything in
+# between is ignored as ambiguous.
+_TAP_TIMEOUT_MS = 350
+_HOLD_TIMEOUT_MS = 1000
+
+
 def _calculate_gap(a, b):
 Helper function to find the gap position and size of widget a
 # Test for each side if the palette and invoker are
@@ -460,6 +467,8 @@ class Invoker(gobject.GObject):
 self._cursor_y = -1
 self._palette = None
 self._cache_palette = True
+self._last_tap = None
+self._hold_timeout_hid = None

 def attach(self, parent):
 self.parent = parent
@@ -630,6 +639,10 @@ class Invoker(gobject.GObject):
 self.emit('mouse-enter')

 def notify_mouse_leave(self):
+if self._last_tap is not None:
+self._last_tap = None
+gobject.source_remove(self._hold_timeout_hid)
+
 self.emit('mouse-leave')

 def notify_right_click(self):
@@ -676,6 +689,40 @@ class Invoker(gobject.GObject):
 if not self.props.cache_palette:
 self.set_palette(None)

+def _button_release_event_cb(self, widget, event):
+logging.debug('_button_release_event_cb %d', event.button)
+if event.button == 3:
+logging.debug('right click detected')
+self.notify_right_click()
+return True
+elif self._last_tap is not None:
+time_elapsed = time.time() - self._last_tap
+self._last_tap = None
+gobject.source_remove(self._hold_timeout_hid)
+return time_elapsed = (_TAP_TIMEOUT_MS / 1000.)
+return False
+
+def _button_press_event_cb(self, widget, event):
+logging.debug('_button_press_event_cb %d', event.button)
+if event.button != 1:
+return False
+
+self._last_tap = time.time()
+self._hold_timeout_hid = gobject.timeout_add(_HOLD_TIMEOUT_MS,
+ self._tap_hold_cb)
+return False
+
+def _tap_hold_cb(self):
+logging.debug('_tap_hold_cb')
+
+if time.time() - self._last_tap  (_HOLD_TIMEOUT_MS / 1000.):
+logging.debug('too early')
+return False
+
+logging.debug('triggering after %.1fs', time.time() - self._last_tap)
+self.notify_right_click()
+return False
+

 class WidgetInvoker(Invoker):

@@ -686,6 +733,7 @@ class WidgetInvoker(Invoker):
 self._enter_hid = None
 self._leave_hid = None
 self._release_hid = None
+self._press_hid = None

 if parent or widget:
 self.attach_widget(parent, widget)
@@ -698,12 +746,16 @@ class WidgetInvoker(Invoker):

 self.notify('widget')

+self._widget.add_events(gtk.gdk.BUTTON_PRESS_MASK)
 self._enter_hid = self._widget.connect('enter-notify-event',
 self.__enter_notify_event_cb)
 self._leave_hid = self._widget.connect('leave-notify-event',
 self.__leave_notify_event_cb)
 self._release_hid = self._widget.connect('button-release-event',
-self.__button_release_event_cb)
+self._button_release_event_cb)
+self._press_hid = self._widget.connect('button-press-event',
+self._button_press_event_cb)
+logging.debug('press handler connected')

 self.attach(parent)

@@ -712,6 +764,7 @@ class WidgetInvoker(Invoker):
 self._widget.disconnect(self._enter_hid)
 self._widget.disconnect(self._leave_hid)
 self._widget.disconnect(self._release_hid)
+self._widget.disconnect(self._press_hid)

 def get_rect(self):
 allocation = self._widget.get_allocation()
@@ -764,13 +817,6 @@ class WidgetInvoker(Invoker):
 def __leave_notify_event_cb(self, widget, event):
 self.notify_mouse_leave()

-def 

[Sugar-devel] Help with testing SemanticXO's backend

2011-11-04 Thread Christophe Guéret

Dear everyone,

I recently did some scalability testing for the Journal implementation 
using the triple store Redstore. You can see the results for an XO-1 
in this blog post: http://wp.me/p1ffiZ-59


It would be cool if one of you would be willing to run the testing 
script on an XO-1.5 and send me back the statistics gathered. I'm very 
curious to see how things work on some more powerful hardware. Testing 
on an XO-1.75 would also be nice but I never tried to compile the triple 
store for ARM, so some help for this would also be appreciated.


There is a package at [1] with everything that is needed. To execute it, 
simply type the following from the Terminal activity:


wget https://github.com/downloads/cgueret/SemanticXO/performances.tar.gz
tar xzf performances.tar.gz
cd performances
python performances_test.py  /dev/null

The three CSV files that will be generated is what I need to generate 
the plots. It took almost 2 days to run it on the XO-1 so you may expect 
to wait some time before the script finishes.


Looking forward to hopefully getting some cool results :-)

Cheers,
Christophe

[1] https://github.com/downloads/cgueret/SemanticXO/performances.tar.gz
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Read port to Gtk 3 status

2011-11-04 Thread Gonzalo Odiard
I have ported Read to Gtk3.
Almost all is working, attached is a patch.
There are a few TODO, shared here:

epubview/epubview.py

-self._scrollbar.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
+# self._scrollbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)

(I think this was deprecated)

-self._view.set_flags(gtk.CAN_DEFAULT | gtk.CAN_FOCUS)
+# TODO
+#self._view.set_flags(Gtk.CAN_DEFAULT | Gtk.CAN_FOCUS)

(Dont know where are these constants now)

jobs.py

Here we do:

 screen = Gdk.Screen.get_default()
 screen.get_font_options()
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib64/python2.7/site-packages/gi/types.py, line 43, in
function
return info.invoke(*args, **kwargs)
TypeError: Couldn't find conversion for foreign struct 'cairo.FontOptions'

I think is a problem with the binding.

evinceadapter.py

# set dpi
# TODO why we need set this?

min_scale = self._model.get_min_scale()
max_scale = self._model.get_max_scale()
logging.error(min scale %s max_scale %s, min_scale, max_scale)
logging.error(setting min scale %s, min_scale * self.dpi /
72.0)
logging.error(setting max scale %s, max_scale * self.dpi /
72.0)
self._model.set_min_scale(min_scale * self.dpi / 72.0)
self._model.set_max_scale(max_scale * self.dpi / 72.0)


EvinceModel is returning min = 0, max = infinite but later have a error
when want set the values.
I have compared in the old bindings and the model was giving the same
values.
Probably does not have sense doing this process

readtoolbar.py

 pitchbar.set_draw_value(False)
-pitchbar.set_update_policy(gtk.UPDATE_DISCONTINUOUS)

Deprecated
http://mail.gnome.org/archives/commits-list/2011-January/msg01161.html

readtopbar.py

- self._progressbar.props.discrete_blocks = 10

(I couldn't found how set this value now)

To test this activity more, I need palettes working.
Overall, I am happy with the process, really I was think will be more
difficult.
We need organize how do the work in other activities.

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


Re: [Sugar-devel] Read port to Gtk 3 status

2011-11-04 Thread Gonzalo Odiard
A topic probably interesting to hackers working in sugar-toolkit:

If I start Read without selecting a file, will try to open a ObjectChooser
to select the file:
But after the port crash with a error:

1320441958.125536 ERROR dbus.connection: Unable to set arguments
(ReadActivity object at 0x282f960 (readactivity+ReadActivity at
0x28bd020), 'Text') according to signature u'is': type
'exceptions.TypeError': an integer is required
Traceback (most recent call last):
  File /home/gonzalo/sugar-jhbuild/install/bin/sugar-activity, line 147,
in module
main()
  File /home/gonzalo/sugar-jhbuild/install/bin/sugar-activity, line 142,
in main
instance = create_activity_instance(activity_constructor,
activity_handle)
  File /home/gonzalo/sugar-jhbuild/install/bin/sugar-activity, line 35,
in create_activity_instance
activity = constructor(handle)
  File /home/gonzalo/Activities/Read.activity/readactivity.py, line 335,
in __init__
self._show_journal_object_picker()
  File /home/gonzalo/Activities/Read.activity/readactivity.py, line 569,
in _show_journal_object_picker
result = chooser.run()
  File
/home/gonzalo/sugar-jhbuild/install/lib/python2.7/site-packages/sugar3/graphics/objectchooser.py,
line 86, in run
self._chooser_id = journal.ChooseObject(self._parent_xid, what_filter)
  File /usr/lib/python2.7/site-packages/dbus/proxies.py, line 68, in
__call__
return self._proxy_method(*args, **keywords)
  File /usr/lib/python2.7/site-packages/dbus/proxies.py, line 140, in
__call__
**keywords)
  File /usr/lib/python2.7/site-packages/dbus/connection.py, line 620, in
call_blocking
message.append(signature=signature, *args)
TypeError: an integer is required

The code in Read is:

chooser = ObjectChooser(_('Choose document'), self,
Gtk.DialogFlags.MODAL |
Gtk.DialogFlags.DESTROY_WITH_PARENT,
what_filter=mime.GENERIC_TYPE_TEXT)
try:
result = chooser.run()

and apparently the problem is with the parameter parent.

I can put:
chooser = ObjectChooser(_('Choose document'), None,
Gtk.DialogFlags.MODAL |
Gtk.DialogFlags.DESTROY_WITH_PARENT,
what_filter=mime.GENERIC_TYPE_TEXT)

and the activity will start, but with gtk2 sugar-toolkit we had a problem
when the activities do not set the parent, and the dialog was over any
activity,
if the user change the activity.

In the code of ObjectChooser in the gtk3 branch of sugar toolkit there is
the following code:

if parent is None:
parent_xid = 0
elif hasattr(parent, 'window') and hasattr(parent.window, 'xid'):
parent_xid = parent.window.xid
else:
parent_xid = parent

but the activity do not have a window and if I replace with get_window, I
couldn't find xdi.

Any idea about what to do with this issue?

Gonzalo




On Fri, Nov 4, 2011 at 5:42 PM, Gonzalo Odiard gonz...@laptop.org wrote:

 And the patch is here :P

 Gonzalo

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


Re: [Sugar-devel] Help with testing SemanticXO's backend

2011-11-04 Thread James Cameron
On Fri, Nov 04, 2011 at 05:17:07PM +0100, Christophe Gu?ret wrote:
 wget https://github.com/downloads/cgueret/SemanticXO/performances.tar.gz
 tar xzf performances.tar.gz
 cd performances
 python performances_test.py  /dev/null

No module named rdflib.

Suggestions?

-- 
James Cameron
http://quozl.linux.org.au/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel