Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions guake/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,37 @@ def split_h(self, split_percentage: int = 50):
def split_v(self, split_percentage: int = 50):
return self.split(DualTerminalBox.ORIENT_H, split_percentage)

def split_h_n(self, n: int = 2):
return self.split_n_no_save(DualTerminalBox.ORIENT_V, n)

def split_v_n(self, n: int = 2):
return self.split_n_no_save(DualTerminalBox.ORIENT_H, n)


def split_n_no_save(self, orientation, n: int):
if n is None:
return None
if n < 2:
raise ValueError("N must be >= 2")

box_to_split: TerminalBox = self
last_dual = None

for k in range(n, 1, -1):
# Make the NEW pane 1/k of the current box (so repeated splits yield equal sizes)
split_pct_new = max(1, min(99, round(100 / k)))

last_dual = box_to_split.split_no_save(orientation, split_pct_new)
if self.terminal is not None:
# Grabs focus to the original terminal to continue splitting
self.terminal.grab_focus()

# Let GTK update allocations before next split
while Gtk.events_pending():
Gtk.main_iteration_do(False)

return last_dual

def split_h_no_save(self, split_percentage: int = 50):
return self.split_no_save(DualTerminalBox.ORIENT_V, split_percentage)

Expand Down
18 changes: 18 additions & 0 deletions guake/dbusiface.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,21 @@ def h_split_current_terminal_with_command(self, command, split_percentage: int):
@dbus.service.method(DBUS_NAME, in_signature="s", out_signature="i")
def get_index_from_uuid(self, tab_uuid):
return self.guake.get_index_from_uuid(tab_uuid)

@dbus.service.method(DBUS_NAME, in_signature="i")
def v_split_current_terminal_into_n(self, n: int):
self.guake.get_notebook().get_current_terminal().get_parent().split_v_n(n)

@dbus.service.method(DBUS_NAME, in_signature="i")
def h_split_current_terminal_into_n(self, n: int):
self.guake.get_notebook().get_current_terminal().get_parent().split_h_n(n)

@dbus.service.method(DBUS_NAME, in_signature="si")
def v_split_current_terminal_into_n_with_command(self, command, n: int):
self.guake.get_notebook().get_current_terminal().get_parent().split_v_n(n)
self.guake.execute_command(command)

@dbus.service.method(DBUS_NAME, in_signature="si")
def h_split_current_terminal_into_n_with_command(self, command, n: int):
self.guake.get_notebook().get_current_terminal().get_parent().split_h_n(n)
self.guake.execute_command(command)
40 changes: 40 additions & 0 deletions guake/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ def main():
help=_("Split the selected tab vertically. Optional input split percentage for the width."),
)

parser.add_argument(
"--split-vertical-tabs",
dest="split_vertical_tabs",
metavar="N",
action="store",
type=int,
nargs="?",
const=2,
default=None,
help=_("Split the selected tab vertically into N equal tabs"),
)


parser.add_argument(
"--split-horizontal",
dest="split_horizontal",
Expand All @@ -264,6 +277,17 @@ def main():
"Split the selected tab horizontally. Optional input split percentage for the height."
),
)
parser.add_argument(
"--split-horizontal-tabs",
dest="split_horizontal_tabs",
metavar="N",
action="store",
type=int,
nargs="?",
const=2,
default=None,
help=_("Split the selected tab horizontally into N equal tabs"),
)

parser.add_argument(
"-e",
Expand Down Expand Up @@ -562,6 +586,22 @@ def main():
sys.stdout.write(f"{selectedIndex}\n")
only_show_hide = options.show


if options.split_vertical_tabs:
if options.command:
remote_object.v_split_current_terminal_into_n_with_command(options.command, options.split_vertical_tabs)
else:
remote_object.v_split_current_terminal_into_n(options.split_vertical_tabs)
only_show_hide = options.show

if options.split_horizontal_tabs:
if options.command:
remote_object.h_split_current_terminal_into_n_with_command(options.command, options.split_horizontal_tabs)
else:
remote_object.h_split_current_terminal_into_n(options.split_horizontal_tabs)
only_show_hide = options.show


if options.split_vertical:
if options.command:
remote_object.v_split_current_terminal_with_command(
Expand Down