def __undisplay(self, *args, **kwargs): if not self.__view: return send_leave = kwargs.pop("send_leave", True) # XXXXXXXX!: for overlay scrollbars the parent scrolled window # listens to notify-leave events to hide them. In case we show # the tooltip and leave the SW through the tooltip the SW will never # get an event and the scrollbar stays visible forever. # This creates a half broken leave event which is just enough # to make this work. parent = self.__view.get_parent() fake_event = None if parent and isinstance(parent, Gtk.ScrolledWindow) and send_leave: fake_event = Gdk.Event.new(Gdk.EventType.LEAVE_NOTIFY) fake_event.any.window = parent.get_window() struct = fake_event.crossing struct.time = Gtk.get_current_event_time() ok, state = Gtk.get_current_event_state() if ok: struct.state = state device = Gtk.get_current_event_device() if device is not None: struct.set_device(device) if self.__current_renderer and self.__edit_id: self.__current_renderer.disconnect(self.__edit_id) self.__current_renderer = self.__edit_id = None self.__current_path = self.__current_col = None self.__view = None def hide(fake_event): if fake_event is not None: Gtk.main_do_event(fake_event) self.__hide_id = None self.hide() return False if gtk_version < (3, 13): # https://bugzilla.gnome.org/show_bug.cgi?id=731055 # Work around Gnome Shell redraw bugs: it doesn't like # multiple hide()/show(), so we try to reduce calls to hide # by aborting it if the pointer is on a new cell shortly after. self.__hide_id = GLib.timeout_add(20, hide, fake_event) else: # mutter3.12 and gtk3.14 are a bit broken together, so it's safe # to assume we have a fixed mutter release.. hide(fake_event)
def on_download_row_clicked(self, listbox, row): _ret, state = Gtk.get_current_event_state() modifiers = Gtk.accelerator_get_default_mod_mask() # Enter selection mode if <Control>+Click or <Shift>+Click is done if state & modifiers in ( Gdk.ModifierType.CONTROL_MASK, Gdk.ModifierType.SHIFT_MASK) and not self.selection_mode: self.enter_selection_mode() if not self.selection_mode: return if state & modifiers == Gdk.ModifierType.SHIFT_MASK: # Enter range selection mode if <Shift>+Click is done self.selection_mode_range = True if self.selection_mode_range and self.selection_mode_last_row_index is not None: # Range selection mode: select all rows between last selected row and clicked row walk_index = self.selection_mode_last_row_index last_index = row.get_index() while walk_index != last_index: walk_row = self.listbox.get_row_at_index(walk_index) if walk_row and not walk_row._selected: self.selection_mode_count += 1 self.listbox.select_row(walk_row) walk_row._selected = True if walk_index < last_index: walk_index += 1 else: walk_index -= 1 self.selection_mode_range = False if row._selected: self.selection_mode_count -= 1 self.listbox.unselect_row(row) self.selection_mode_last_row_index = None row._selected = False else: self.selection_mode_count += 1 self.listbox.select_row(row) self.selection_mode_last_row_index = row.get_index() row._selected = True if self.selection_mode_count == 0: self.leave_selection_mode()
def _on_view_clicked(self, gesture, n_press, x, y): """Ctrl+click on self._view triggers selection mode.""" _, state = Gtk.get_current_event_state() modifiers = Gtk.accelerator_get_default_mod_mask() if (state & modifiers == Gdk.ModifierType.CONTROL_MASK and not self.props.selection_mode): self.props.selection_mode = True # FIXME: In selection mode, star clicks might still trigger # activation. if self.props.selection_mode: path, col, cell_x, cell_y = self._view.get_path_at_pos(x, y) iter_ = self._view.props.model.get_iter(path) self._model[iter_][1] = not self._model[iter_][1] self._model[iter_][7].props.selected = self._model[iter_][7]
def _on_view_clicked(self, gesture, n_press, x, y): """Ctrl+click on self._view triggers selection mode.""" _, state = Gtk.get_current_event_state() modifiers = Gtk.accelerator_get_default_mod_mask() if (state & modifiers == Gdk.ModifierType.CONTROL_MASK and not self.props.selection_mode): self._on_selection_mode_request() if (self.selection_mode and not self._star_handler.star_renderer_click): path, col, cell_x, cell_y = self._view.get_path_at_pos(x, y) iter_ = self.model.get_iter(path) self.model[iter_][6] = not self.model[iter_][6] selected_iters = self._get_selected_iters() self.props.selected_items_count = len(selected_iters)
def on_manga_clicked(self, flowbox, child): overlay = child.get_children()[0] _ret, state = Gtk.get_current_event_state() modifiers = state & Gtk.accelerator_get_default_mod_mask() # Enter selection mode if <Control>+Click or <Shift>+Click is done if modifiers in (Gdk.ModifierType.CONTROL_MASK, Gdk.ModifierType.SHIFT_MASK) and not self.selection_mode: self.enter_selection_mode(selected_child=child) return Gdk.EVENT_PROPAGATE if self.selection_mode: if modifiers == Gdk.ModifierType.SHIFT_MASK: # Enter range selection mode if <Shift>+Click is done self.selection_mode_range = True if self.selection_mode_range and self.selection_mode_last_child_index is not None: # Range selection mode: select all mangas between last selected manga and clicked manga walk_index = self.selection_mode_last_child_index last_index = child.get_index() while walk_index != last_index: walk_child = self.flowbox.get_child_at_index(walk_index) walk_overlay = walk_child.get_children()[0] if walk_child and not walk_overlay._selected: self.selection_mode_count += 1 self.flowbox.select_child(walk_child) walk_overlay._selected = True if walk_index < last_index: walk_index += 1 else: walk_index -= 1 self.selection_mode_range = False if overlay._selected: self.selection_mode_count -= 1 self.selection_mode_last_child_index = None self.flowbox.unselect_child(child) overlay._selected = False else: self.selection_mode_count += 1 self.selection_mode_last_child_index = child.get_index() overlay._selected = True if self.selection_mode_count == 0: self.leave_selection_mode() else: self.window.card.init(overlay.manga)
def __drag_begin(self, *args): ok, state = Gtk.get_current_event_state() if ok and state & qltk.get_primary_accel_mod(): self.__force_copy = True else: self.__force_copy = False
def _on_sidebar_clicked(self, gesture, n_press, x, y): success, state = Gtk.get_current_event_state() modifiers = Gtk.accelerator_get_default_mod_mask() if ((state & modifiers) == Gdk.ModifierType.CONTROL_MASK and not self.props.selection_mode): self.props.selection_mode = True