def __browser_realize_cb(self, browser): x11_window = browser.get_window() x11_window.set_events(x11_window.get_events() | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.TOUCH_MASK) lp = SugarGestures.LongPressController() lp.connect('pressed', self.__long_pressed_cb) lp.attach(browser, SugarGestures.EventControllerFlags.NONE)
def _track_gesture_for_area(self, directions, x, y, width, height): rectangle = Gdk.Rectangle() rectangle.x = x rectangle.y = y rectangle.width = width rectangle.height = height swipe = SugarGestures.SwipeController(directions=directions) swipe.connect('swipe-ended', self.__swipe_ended_cb) self._gesture_grabber.add(swipe, rectangle) self._controller.append(swipe)
def __init__(self): Invoker.__init__(self) self._position_hint = self.AT_CURSOR self._tree_view = None self._cell_renderer = None self._motion_hid = None self._leave_hid = None self._release_hid = None self._long_pressed_hid = None self.path = None self._long_pressed_controller = SugarGestures.LongPressController()
def __init__(self, parent=None): Invoker.__init__(self) self._position_hint = self.AT_CURSOR self._enter_hid = None self._leave_hid = None self._release_hid = None self._item = None self._long_pressed_recognized = False self._long_pressed_hid = None self._long_pressed_controller = SugarGestures.LongPressController() if parent: self.attach(parent)
def __init__(self, parent=None, widget=None): Invoker.__init__(self) self._widget = None self._expanded = False self._enter_hid = None self._leave_hid = None self._release_hid = None self._click_hid = None self._touch_hid = None self._draw_hid = None self._long_pressed_recognized = False self._long_pressed_hid = None self._long_pressed_controller = SugarGestures.LongPressController() if parent or widget: self.attach_widget(parent, widget)
def __init__(self, handle): activity.Activity.__init__(self, handle) self._object_id = handle.object_id self._collab = collabwrapper.CollabWrapper(self) self._collab.incoming_file.connect(self.__incoming_file_cb) self._collab.buddy_joined.connect(self.__buddy_joined_cb) self._collab.joined.connect(self.__joined_cb) self._needs_file = False # Set to true when we join # Status of temp file used for write_file: self._tempfile = None self._close_requested = False self._want_document = True self._zoom_out_button = None self._zoom_in_button = None self.previous_image_button = None self.next_image_button = None self.scrolled_window = Gtk.ScrolledWindow() self.scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS) # disable sharing until a file is opened self.max_participants = 1 # Don't use the default kinetic scrolling, let the view do the # drag-by-touch and pinch-to-zoom logic. self.scrolled_window.set_kinetic_scrolling(False) self.view = ImageView.ImageViewer() # Connect to the touch signal for performing drag-by-touch. self.view.add_events(Gdk.EventMask.TOUCH_MASK) self._touch_hid = self.view.connect('touch-event', self.__touch_event_cb) self.scrolled_window.add(self.view) self.view.show() self.connect('key-press-event', self.__key_press_cb) if GESTURES_AVAILABLE: # Connect to the zoom signals for performing # pinch-to-zoom. zoom_controller = SugarGestures.ZoomController() zoom_controller.attach(self, SugarGestures.EventControllerFlags.NONE) zoom_controller.connect('began', self.__zoomtouch_began_cb) zoom_controller.connect('scale-changed', self.__zoomtouch_changed_cb) zoom_controller.connect('ended', self.__zoomtouch_ended_cb) self._progress_alert = None toolbar_box = ToolbarBox() self._add_toolbar_buttons(toolbar_box) self.set_toolbar_box(toolbar_box) toolbar_box.show() if self._object_id is None or not self._jobject.file_path: empty_widgets = Gtk.EventBox() empty_widgets.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color()) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox.pack_start(mvbox, True, False, 0) image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE, icon_name='imageviewer', stroke_color=style.COLOR_BUTTON_GREY.get_svg(), fill_color=style.COLOR_TRANSPARENT.get_svg()) mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING) label = Gtk.Label( '<span foreground="%s"><b>%s</b></span>' % (style.COLOR_BUTTON_GREY.get_html(), _('No image'))) label.set_use_markup(True) mvbox.pack_start(label, False, False, style.DEFAULT_PADDING) hbox = Gtk.Box() open_image_btn = Gtk.Button() open_image_btn.connect('clicked', self._show_picker_cb) add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON) buttonbox = Gtk.Box() buttonbox.pack_start(add_image, False, True, 0) buttonbox.pack_end(Gtk.Label(_('Choose an image')), True, True, 5) open_image_btn.add(buttonbox) hbox.pack_start(open_image_btn, True, False, 0) mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING) empty_widgets.add(vbox) empty_widgets.show_all() self.set_canvas(empty_widgets) else: self.set_canvas(self.scrolled_window) self.scrolled_window.show() Gdk.Screen.get_default().connect('size-changed', self._configure_cb) self._collab.setup()