Beispiel #1
0
    def on_key_press_event(self, widget, event):

        keycode = event.hardware_keycode

        if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
            if keycode in keyval_to_hardware_keycode(Gdk.KEY_w) or \
               keycode in keyval_to_hardware_keycode(Gdk.KEY_F4):
                # Ctrl+W and Ctrl+F4: close current tab

                page = self.get_nth_page(self.get_current_page())
                tab_label, menu_label = self.get_labels(page)
                tab_label.onclose(widget)
                return True

        return False
Beispiel #2
0
    def on_key_press_event(self, widget, event):

        self.select_files()

        if event.get_state() & Gdk.ModifierType.CONTROL_MASK and \
                event.hardware_keycode in keyval_to_hardware_keycode(Gdk.KEY_c):
            self.copy_selected_path(is_file=(widget == self.FileTreeView))
        else:
            # No key match, continue event
            return False

        widget.stop_emission_by_name("key_press_event")
        return True
Beispiel #3
0
    def on_key_press_event(self, widget, event):

        keycode = event.hardware_keycode
        self.select_transfers()

        if keycode in keyval_to_hardware_keycode(Gdk.KEY_t):
            self.abort_transfers()

        elif keycode in keyval_to_hardware_keycode(Gdk.KEY_r):
            self.retry_transfers()

        elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and \
                keycode in keyval_to_hardware_keycode(Gdk.KEY_c):
            self.on_copy_file_path()

        elif keycode in keyval_to_hardware_keycode(Gdk.KEY_Delete):
            self.abort_transfers(clear=True)

        else:
            # No key match, continue event
            return False

        widget.stop_emission_by_name("key_press_event")
        return True
Beispiel #4
0
    def on_key_press(self, widget, event):

        if event.get_state() & Gdk.ModifierType.CONTROL_MASK and \
                event.hardware_keycode in keyval_to_hardware_keycode(Gdk.KEY_f):
            self.show_search_bar()
Beispiel #5
0
    def on_key_press(self, widget, event):

        keycode = event.hardware_keycode

        if keycode not in keyval_to_hardware_keycode(Gdk.KEY_Tab):
            if keycode not in keyval_to_hardware_keycode(Gdk.KEY_Shift_L) and \
                    keycode not in keyval_to_hardware_keycode(Gdk.KEY_Shift_R):
                self.midwaycompletion = False
            return False

        config_words = config.sections["words"]
        if not config_words["tab"]:
            return False

        # "Hello there Miss<tab> how are you doing"
        # "0  3  6  9  12 15      18 21 24 27 30 33
        #   1  4  7  10 13      16 19 22 25 28 31
        #    2  5  8  11 14      17 20 23 26 29 32
        #
        # ix = 16
        # text = Miss
        # preix = 12
        ix = widget.get_position()
        text = widget.get_text()[:ix].split(" ")[-1]
        preix = ix - len(text)

        if not config_words["cycle"]:
            completion, single = self.get_completion(text,
                                                     self.completion_list)
            if completion:
                if single and ix == len(text) and text[:1] != "/":
                    completion += ": "
                widget.delete_text(preix, ix)
                widget.insert_text(completion, preix)
                widget.set_position(preix + len(completion))
        else:

            if not self.midwaycompletion:
                self.completions['completions'] = self.get_completions(
                    text, self.completion_list)
                if self.completions['completions']:
                    self.midwaycompletion = True
                    self.completions['currentindex'] = -1
                    currentnick = text
            else:
                currentnick = self.completions['completions'][
                    self.completions['currentindex']]

            if self.midwaycompletion:

                widget.delete_text(ix - len(currentnick), ix)
                direction = 1  # Forward cycle

                if event.get_state() & Gdk.ModifierType.SHIFT_MASK:
                    direction = -1  # Backward cycle

                self.completions['currentindex'] = (
                    self.completions['currentindex'] + direction) % len(
                        self.completions['completions'])

                newnick = self.completions['completions'][
                    self.completions['currentindex']]
                widget.insert_text(newnick, preix)
                widget.set_position(preix + len(newnick))

        widget.stop_emission_by_name("key_press_event")
        return True