(self)
Connect all the gtk signals and drag-n-drop mechanics
Connect all the gtk signals and drag-n-drop mechanics
Connect all the gtk signals and drag - n - drop mechanics
def connect_signals(self):
        """Connect all the gtk signals and drag-n-drop mechanics"""

        self.scrollbar.connect('button-press-event', self.on_buttonpress)

        self.cnxids.new(self.vte, 'key-press-event', self.on_keypress)
        self.cnxids.new(self.vte, 'button-press-event', self.on_buttonpress)
        self.cnxids.new(self.vte, 'scroll-event', self.on_mousewheel)
        self.cnxids.new(self.vte, 'popup-menu', self.popup_menu)

        srcvtetargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE)]
        dsttargets = [("vte", Gtk.TargetFlags.SAME_APP, self.TARGET_TYPE_VTE),
                      ('text/x-moz-url', 0, self.TARGET_TYPE_MOZ),
                      ('_NETSCAPE_URL', 0, 0)]
        '''
        The following should work, but on my system it corrupts the returned
        TargetEntry's in the newdstargets with binary crap, causing "Segmentation
        fault (core dumped)" when the later drag_dest_set gets called.
        
        dsttargetlist = Gtk.TargetList.new([])
        dsttargetlist.add_text_targets(0)
        dsttargetlist.add_uri_targets(0)
        dsttargetlist.add_table(dsttargets)
        
        newdsttargets = Gtk.target_table_new_from_list(dsttargetlist)
        '''
        # FIXME: Temporary workaround for the problems with the correct way of doing things
        dsttargets.extend([('text/plain', 0, 0),
                           ('text/plain;charset=utf-8', 0, 0),
                           ('TEXT', 0, 0),
                           ('STRING', 0, 0),
                           ('UTF8_STRING', 0, 0),
                           ('COMPOUND_TEXT', 0, 0),
                           ('text/uri-list', 0, 0)])
        # Convert to target entries
        srcvtetargets = [Gtk.TargetEntry.new(*tgt) for tgt in srcvtetargets]
        dsttargets = [Gtk.TargetEntry.new(*tgt) for tgt in dsttargets]

        dbg('Finalised drag targets: %s' % dsttargets)

        for (widget, mask) in [
            (self.vte, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.BUTTON3_MASK),
            (self.titlebar, Gdk.ModifierType.BUTTON1_MASK)]:
            widget.drag_source_set(mask, srcvtetargets, Gdk.DragAction.MOVE)

        self.vte.drag_dest_set(Gtk.DestDefaults.MOTION |
                Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP,
                dsttargets, Gdk.DragAction.COPY | Gdk.DragAction.MOVE)

        for widget in [self.vte, self.titlebar]:
            self.cnxids.new(widget, 'drag-begin', self.on_drag_begin, self)
            self.cnxids.new(widget, 'drag-data-get', self.on_drag_data_get,
            self)

        self.cnxids.new(self.vte, 'drag-motion', self.on_drag_motion, self)
        self.cnxids.new(self.vte, 'drag-data-received',
            self.on_drag_data_received, self)

        self.cnxids.new(self.vte, 'selection-changed',
            lambda widget: self.maybe_copy_clipboard())

        if self.composite_support:
            self.cnxids.new(self.vte, 'composited-changed', self.reconfigure)

        self.cnxids.new(self.vte, 'window-title-changed', lambda x:
            self.emit('title-change', self.get_window_title()))
        self.cnxids.new(self.vte, 'grab-focus', self.on_vte_focus)
        self.cnxids.new(self.vte, 'focus-in-event', self.on_vte_focus_in)
        self.cnxids.new(self.vte, 'focus-out-event', self.on_vte_focus_out)
        self.cnxids.new(self.vte, 'size-allocate', self.deferred_on_vte_size_allocate)

        self.vte.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK)
        self.cnxids.new(self.vte, 'enter_notify_event',
            self.on_vte_notify_enter)

        self.cnxids.new(self.vte, 'realize', self.reconfigure)
def connect_signals ( self ) : self . scrollbar . connect ( 'button-press-event' , self . on_buttonpress ) self . cnxids . new ( self . vte , 'key-press-event' , self . on_keypress ) self . cnxids . new ( self . vte , 'button-press-event' , self . on_buttonpress ) self . cnxids . new ( self . vte , 'scroll-event' , self . on_mousewheel ) self . cnxids . new ( self . vte , 'popup-menu' , self . popup_menu ) srcvtetargets = [ ( "vte" , Gtk . TargetFlags . SAME_APP , self . TARGET_TYPE_VTE ) ] dsttargets = [ ( "vte" , Gtk . TargetFlags . SAME_APP , self . TARGET_TYPE_VTE ) , ( 'text/x-moz-url' , 0 , self . TARGET_TYPE_MOZ ) , ( '_NETSCAPE_URL' , 0 , 0 ) ] '''
        The following should work, but on my system it corrupts the returned
        TargetEntry's in the newdstargets with binary crap, causing "Segmentation
        fault (core dumped)" when the later drag_dest_set gets called.
        
        dsttargetlist = Gtk.TargetList.new([])
        dsttargetlist.add_text_targets(0)
        dsttargetlist.add_uri_targets(0)
        dsttargetlist.add_table(dsttargets)
        
        newdsttargets = Gtk.target_table_new_from_list(dsttargetlist)
        ''' # FIXME: Temporary workaround for the problems with the correct way of doing things dsttargets . extend ( [ ( 'text/plain' , 0 , 0 ) , ( 'text/plain;charset=utf-8' , 0 , 0 ) , ( 'TEXT' , 0 , 0 ) , ( 'STRING' , 0 , 0 ) , ( 'UTF8_STRING' , 0 , 0 ) , ( 'COMPOUND_TEXT' , 0 , 0 ) , ( 'text/uri-list' , 0 , 0 ) ] ) # Convert to target entries srcvtetargets = [ Gtk . TargetEntry . new ( * tgt ) for tgt in srcvtetargets ] dsttargets = [ Gtk . TargetEntry . new ( * tgt ) for tgt in dsttargets ] dbg ( 'Finalised drag targets: %s' % dsttargets ) for ( widget , mask ) in [ ( self . vte , Gdk . ModifierType . CONTROL_MASK | Gdk . ModifierType . BUTTON3_MASK ) , ( self . titlebar , Gdk . ModifierType . BUTTON1_MASK ) ] : widget . drag_source_set ( mask , srcvtetargets , Gdk . DragAction . MOVE ) self . vte . drag_dest_set ( Gtk . DestDefaults . MOTION | Gtk . DestDefaults . HIGHLIGHT | Gtk . DestDefaults . DROP , dsttargets , Gdk . DragAction . COPY | Gdk . DragAction . MOVE ) for widget in [ self . vte , self . titlebar ] : self . cnxids . new ( widget , 'drag-begin' , self . on_drag_begin , self ) self . cnxids . new ( widget , 'drag-data-get' , self . on_drag_data_get , self ) self . cnxids . new ( self . vte , 'drag-motion' , self . on_drag_motion , self ) self . cnxids . new ( self . vte , 'drag-data-received' , self . on_drag_data_received , self ) self . cnxids . new ( self . vte , 'selection-changed' , lambda widget : self . maybe_copy_clipboard ( ) ) if self . composite_support : self . cnxids . new ( self . vte , 'composited-changed' , self . reconfigure ) self . cnxids . new ( self . vte , 'window-title-changed' , lambda x : self . emit ( 'title-change' , self . get_window_title ( ) ) ) self . cnxids . new ( self . vte , 'grab-focus' , self . on_vte_focus ) self . cnxids . new ( self . vte , 'focus-in-event' , self . on_vte_focus_in ) self . cnxids . new ( self . vte , 'focus-out-event' , self . on_vte_focus_out ) self . cnxids . new ( self . vte , 'size-allocate' , self . deferred_on_vte_size_allocate ) self . vte . add_events ( Gdk . EventMask . ENTER_NOTIFY_MASK ) self . cnxids . new ( self . vte , 'enter_notify_event' , self . on_vte_notify_enter ) self . cnxids . new ( self . vte , 'realize' , self . reconfigure )