def column_clicked(column, *args): # if ctrl is held during the sort click, append a sort key # or change order if already sorted ctrl_held = False event = Gtk.get_current_event() if event: ok, state = event.get_state() if ok and state & qltk.get_primary_accel_mod(): ctrl_held = True self.toggle_column_sort(column, replace=not ctrl_held)
def __block_selection(self, event): x, y = map(int, [event.x, event.y]) try: path, col, cellx, celly = self.get_path_at_pos(x, y) except TypeError: return True selection = self.get_selection() is_selected = selection.path_is_selected(path) mod_active = event.get_state() & ( get_primary_accel_mod() | Gdk.ModifierType.SHIFT_MASK) if is_selected: self.__pending_action = (path, col, mod_active) selection.set_select_function(lambda *args: False, None) else: self.__pending_action = None selection.set_select_function(lambda *args: True, None)
def __block_selection(self, event): x, y = map(int, [event.x, event.y]) try: path, col, cellx, celly = self.get_path_at_pos(x, y) except TypeError: return True self.grab_focus() selection = self.get_selection() is_selected = selection.path_is_selected(path) mod_active = event.get_state() & (get_primary_accel_mod() | Gdk.ModifierType.SHIFT_MASK) if is_selected and not mod_active: self.__pending_event = [x, y] selection.set_select_function(lambda *args: False, None) elif event.type == Gdk.EventType.BUTTON_PRESS: self.__pending_event = None selection.set_select_function(lambda *args: True, None)
def send_button_click(widget, button, primary=False, shift=False, recursive=False): """See send_key_click_event""" state = Gdk.ModifierType(0) if primary: state |= get_primary_accel_mod() if shift: state |= Gdk.ModifierType.SHIFT_MASK assert isinstance(widget, Gtk.Widget) handled = _send_button_click_event(widget, button=button, state=state) if recursive: if isinstance(widget, Gtk.Container): for child in widget.get_children(): handled += send_button_click( child, button, primary, shift, recursive) return handled
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