(self, widget, event)
return False
Handler for mouse events
Handler for mouse events
Handler for mouse events
def on_buttonpress(self, widget, event):
        """Handler for mouse events"""
        # Any button event should grab focus
        widget.grab_focus()

        if type(widget) == Gtk.VScrollbar and event.type == Gdk.EventType._2BUTTON_PRESS:
            # Suppress double-click behavior
            return True

        if self.config['putty_paste_style']:
            middle_click = [self.popup_menu, (widget, event)]
            right_click = [self.paste_clipboard, (not self.config['putty_paste_style_source_clipboard'], True)]
        else:
            middle_click = [self.paste_clipboard, (True, True)]
            right_click = [self.popup_menu, (widget, event)]

        # Ctrl-click event here.
        if event.button == self.MOUSEBUTTON_LEFT:
            # Ctrl+leftclick on a URL should open it
            if self.config["link_single_click"] or event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
                # Check new OSC-8 method first
                url = self.vte.hyperlink_check_event(event)
                dbg('url: %s' % url)
                if url:
                    self.open_url(url, prepare=False)
                else:
                    dbg('OSC-8 URL not detected dropping back to regex match')
                    url = self.vte.match_check_event(event)
                    if url[0]:
                        self.open_url(url, prepare=True)
                    else:
                        dbg("No regex match, discard event.")
        elif event.button == self.MOUSEBUTTON_MIDDLE:
            # middleclick should paste the clipboard
            # try to pass it to vte widget first though
            if event.get_state() & Gdk.ModifierType.CONTROL_MASK == 0:
                if event.get_state() & Gdk.ModifierType.SHIFT_MASK == 0:
                    gtk_settings=Gtk.Settings().get_default()
                    primary_state = gtk_settings.get_property('gtk-enable-primary-paste')
                    gtk_settings.set_property('gtk-enable-primary-paste',  False)
                    if not Vte.Terminal.do_button_press_event(self.vte, event):
                        middle_click[0](*middle_click[1])
                    gtk_settings.set_property('gtk-enable-primary-paste', primary_state)
                else:
                    middle_click[0](*middle_click[1])
                return True
            return Vte.Terminal.do_button_press_event(self.vte, event)
        elif event.button == self.MOUSEBUTTON_RIGHT:
            # rightclick should display a context menu if Ctrl is not pressed,
            # plus either the app is not interested in mouse events or Shift is pressed
            if event.get_state() & Gdk.ModifierType.CONTROL_MASK == 0:
                if event.get_state() & Gdk.ModifierType.SHIFT_MASK == 0:
                    if not Vte.Terminal.do_button_press_event(self.vte, event):
                        right_click[0](*right_click[1])
                else:
                    right_click[0](*right_click[1])
                return True
        return False
def on_buttonpress ( self , widget , event ) : # Any button event should grab focus widget . grab_focus ( ) if type ( widget ) == Gtk . VScrollbar and event . type == Gdk . EventType . _2BUTTON_PRESS : # Suppress double-click behavior return True if self . config [ 'putty_paste_style' ] : middle_click = [ self . popup_menu , ( widget , event ) ] right_click = [ self . paste_clipboard , ( not self . config [ 'putty_paste_style_source_clipboard' ] , True ) ] else : middle_click = [ self . paste_clipboard , ( True , True ) ] right_click = [ self . popup_menu , ( widget , event ) ] # Ctrl-click event here. if event . button == self . MOUSEBUTTON_LEFT : # Ctrl+leftclick on a URL should open it if self . config [ "link_single_click" ] or event . get_state ( ) & Gdk . ModifierType . CONTROL_MASK == Gdk . ModifierType . CONTROL_MASK : # Check new OSC-8 method first url = self . vte . hyperlink_check_event ( event ) dbg ( 'url: %s' % url ) if url : self . open_url ( url , prepare = False ) else : dbg ( 'OSC-8 URL not detected dropping back to regex match' ) url = self . vte . match_check_event ( event ) if url [ 0 ] : self . open_url ( url , prepare = True ) else : dbg ( "No regex match, discard event." ) elif event . button == self . MOUSEBUTTON_MIDDLE : # middleclick should paste the clipboard # try to pass it to vte widget first though if event . get_state ( ) & Gdk . ModifierType . CONTROL_MASK == 0 : if event . get_state ( ) & Gdk . ModifierType . SHIFT_MASK == 0 : gtk_settings = Gtk . Settings ( ) . get_default ( ) primary_state = gtk_settings . get_property ( 'gtk-enable-primary-paste' ) gtk_settings . set_property ( 'gtk-enable-primary-paste' , False ) if not Vte . Terminal . do_button_press_event ( self . vte , event ) : middle_click [ 0 ] ( * middle_click [ 1 ] ) gtk_settings . set_property ( 'gtk-enable-primary-paste' , primary_state ) else : middle_click [ 0 ] ( * middle_click [ 1 ] ) return True return Vte . Terminal . do_button_press_event ( self . vte , event ) elif event . button == self . MOUSEBUTTON_RIGHT : # rightclick should display a context menu if Ctrl is not pressed, # plus either the app is not interested in mouse events or Shift is pressed if event . get_state ( ) & Gdk . ModifierType . CONTROL_MASK == 0 : if event . get_state ( ) & Gdk . ModifierType . SHIFT_MASK == 0 : if not Vte . Terminal . do_button_press_event ( self . vte , event ) : right_click [ 0 ] ( * right_click [ 1 ] ) else : right_click [ 0 ] ( * right_click [ 1 ] ) return True return False