[Bugs] #3992 sugar UNSP: Views: implement long-press behavior

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Tue Oct 9 19:51:56 EDT 2012


#3992: Views: implement long-press behavior
------------------------------------------+---------------------------------
    Reporter:  erikos                     |          Owner:  erikos  
        Type:  task                       |         Status:  new     
    Priority:  Unspecified by Maintainer  |      Milestone:  0.98    
   Component:  sugar                      |        Version:  0.97.x  
    Severity:  Major                      |       Keywords:          
Distribution:  OLPC                       |   Status_field:  Assigned
------------------------------------------+---------------------------------

Comment(by erikos):

 We could pack the logic into the EventIcon directly like we do for the
 invoker.

 {{{
 diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
 index 9008f3f..2391860 100644
 --- a/src/sugar3/graphics/icon.py
 +++ b/src/sugar3/graphics/icon.py
 @@ -32,6 +32,8 @@ from gi.repository import GdkPixbuf
  from gi.repository import Rsvg
  import cairo

 +from gi.repository import SugarGestures
 +
  from sugar3.graphics import style
  from sugar3.graphics.xocolor import XoColor
  from sugar3.util import LRU
 @@ -497,6 +499,12 @@ class EventIcon(Gtk.EventBox):
          from sugar3.graphics.palette import CursorInvoker
          self._palette_invoker = CursorInvoker()
          self._palette_invoker.attach(self)
 +
 +        gesture_controller = SugarGestures.LongPressController()
 +        gesture_controller.connect('pressed', self.__long_pressed_cb)
 +        gesture_controller.attach(self,
 +
 SugarGestures.EventControllerFlags.NONE)
 +
          self.connect('destroy', self.__destroy_cb)

      def do_draw(self, cr):
 @@ -678,6 +686,9 @@ class EventIcon(Gtk.EventBox):

          self.set_palette(Palette(text))

 +    def __long_pressed_cb(self, controller, x, y):
 +        self.props.palette.popup(immediate=True, state=1)
 +

 }}}

-- 
Ticket URL: <http://bugs.sugarlabs.org/ticket/3992#comment:1>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list