~agroszer/terminator/terminator

« back to all changes in this revision

Viewing changes to terminatorlib/terminal.py

Improve options for adding/removing terminals to/from groups

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
    composite_support = None
108
108
 
109
109
    cnxids = None
 
110
    targets_for_new_group = None
110
111
 
111
112
    def __init__(self):
112
113
        """Class initialiser"""
119
120
        # FIXME: Surely these should happen in Terminator::register_terminal()?
120
121
        self.connect('enumerate', self.terminator.do_enumerate)
121
122
        self.connect('focus-in', self.terminator.focus_changed)
 
123
        self.connect('focus-out', self.terminator.focus_left)
122
124
 
123
125
        self.matches = {}
124
126
        self.cnxids = Signalman()
770
772
    def on_group_button_press(self, widget, event):
771
773
        """Handler for the group button"""
772
774
        if event.button == 1:
773
 
            self.create_popup_group_menu(widget, event)
 
775
            if event.type == gtk.gdk._2BUTTON_PRESS or \
 
776
               event.type == gtk.gdk._3BUTTON_PRESS:
 
777
                # Ignore these, or they make the interaction bad
 
778
                return False
 
779
            # Super key applies interaction to all terms in group
 
780
            include_siblings=event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK
 
781
            if include_siblings:
 
782
                targets=self.terminator.get_sibling_terms(self)
 
783
            else:
 
784
                targets=[self]
 
785
            if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
 
786
                dbg('on_group_button_press: toggle terminal to focused terminals group')
 
787
                focused=self.get_toplevel().get_focussed_terminal()
 
788
                if focused in targets: targets.remove(focused)
 
789
                if self != focused:
 
790
                    if self.group==focused.group:
 
791
                        new_group=None
 
792
                    else:
 
793
                        new_group=focused.group
 
794
                    [term.set_group(None, new_group) for term in targets]
 
795
                    [term.titlebar.update(focused) for term in targets]
 
796
                return True
 
797
            elif event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
 
798
                dbg('on_group_button_press: rename of terminals group')
 
799
                self.targets_for_new_group = targets
 
800
                self.titlebar.create_group()
 
801
                return True
 
802
            elif event.type == gtk.gdk.BUTTON_PRESS:
 
803
                # Single Click gives popup
 
804
                dbg('on_group_button_press: group menu popup')
 
805
                self.create_popup_group_menu(widget, event)
 
806
                return True
 
807
            else:
 
808
                dbg('on_group_button_press: unknown group button interaction')
774
809
        return(False)
775
810
 
776
811
    def on_keypress(self, widget, event):