Skip to content

Commit

Permalink
[bug 613] - Shortcut for autosplit h/v depending on active terminal s…
Browse files Browse the repository at this point in the history
…ize gnome-terminator#613

-added auto split feature
-new signal split-auto was added
-currently this uses widget dimensions for the split as rows, cols were having different space and was not consistent, this can be changed if needed
-short cut was also added
-icon for the menu item needs to be added
  • Loading branch information
vssdeo committed Nov 5, 2022
1 parent 1aa437d commit 6bdb0c6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions terminatorlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
'go_right' : '<Alt>Right',
'rotate_cw' : '<Super>r',
'rotate_ccw' : '<Super><Shift>r',
'split_auto' : '<Shift><Control>a',
'split_horiz' : '<Shift><Control>o',
'split_vert' : '<Shift><Control>e',
'close_term' : '<Shift><Control>w',
Expand Down
10 changes: 10 additions & 0 deletions terminatorlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def get_child_metadata(self, widget):
child is .remove()d and .add()ed"""
return None

def split_auto(self, widget, cwd=None):
"""Split this container automatically"""
width = widget.get_allocation().width
height = widget.get_allocation().height
dbg("split as per current dimenstions:(%s %s)" % (width, height))
if width > height:
self.split_axis(widget, False, cwd)
else:
self.split_axis(widget, True , cwd)

def split_horiz(self, widget, cwd=None):
"""Split this container horizontally"""
return(self.split_axis(widget, True, cwd))
Expand Down
1 change: 1 addition & 0 deletions terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=N
widget.force_set_profile(None, profile)

signals = {'close-term': self.wrapcloseterm,
'split-auto': self.split_auto,
'split-horiz': self.split_horiz,
'split-vert': self.split_vert,
'title-change': self.propagate_title_change,
Expand Down
1 change: 1 addition & 0 deletions terminatorlib/paned.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def add(self, widget, metadata=None):
if self.maker.isinstance(widget, 'Terminal'):
top_window = self.get_toplevel()
signals = {'close-term': self.wrapcloseterm,
'split-auto': self.split_auto,
'split-horiz': self.split_horiz,
'split-vert': self.split_vert,
'title-change': self.propagate_title_change,
Expand Down
5 changes: 5 additions & 0 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Terminal(Gtk.VBox):
'group-tab-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
'ungroup-tab': (GObject.SignalFlags.RUN_LAST, None, ()),
'ungroup-all': (GObject.SignalFlags.RUN_LAST, None, ()),
'split-auto': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'split-horiz': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'split-vert': (GObject.SignalFlags.RUN_LAST, None,
Expand Down Expand Up @@ -1853,6 +1855,9 @@ def key_go_left(self):
def key_go_right(self):
self.emit('navigate', 'right')

def key_split_auto(self):
self.emit('split-auto', self.get_cwd())

def key_split_horiz(self):
self.emit('split-horiz', self.get_cwd())

Expand Down
14 changes: 14 additions & 0 deletions terminatorlib/terminal_popup_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ def show(self, widget, event=None):
menu.append(item)

if not terminal.is_zoomed():
item = self.menu_item(Gtk.ImageMenuItem, 'split_auto',
'Split _Auto')
"""
image = Gtk.Image()
image.set_from_icon_name(APP_NAME + '_auto', Gtk.IconSize.MENU)
item.set_image(image)
if hasattr(item, 'set_always_show_image'):
item.set_always_show_image(True)
"""
item.connect('activate', lambda x: terminal.emit('split-auto',
self.terminal.get_cwd()))
menu.append(item)


item = self.menu_item(Gtk.ImageMenuItem, 'split_horiz',
'Split H_orizontally')
image = Gtk.Image()
Expand Down
1 change: 1 addition & 0 deletions terminatorlib/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def add(self, widget, metadata=None):
if maker.isinstance(widget, 'Terminal'):
signals = {'close-term': self.closeterm,
'title-change': self.title.set_title,
'split-auto': self.split_auto,
'split-horiz': self.split_horiz,
'split-vert': self.split_vert,
'resize-term': self.resizeterm,
Expand Down

0 comments on commit 6bdb0c6

Please sign in to comment.