Skip to content

Commit

Permalink
Add command line flag to get tab number/position from UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidy22 committed Apr 28, 2022
1 parent ebcee30 commit 2f5a889
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions guake/dbusiface.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,7 @@ def v_split_current_terminal(self):
@dbus.service.method(DBUS_NAME)
def h_split_current_terminal(self):
self.guake.get_notebook().get_current_terminal().get_parent().split_h()

@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)
7 changes: 7 additions & 0 deletions guake/guake_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,13 @@ def rename_tab_uuid(self, term_uuid, new_text, user_set=True):
)
self.get_notebook().rename_page(page_index, new_text, user_set)

def get_index_from_uuid(self, term_uuid):
term_uuid = uuid.UUID(term_uuid)
for index, t in enumerate(self.get_notebook().iter_terminals()):
if t.get_uuid() == term_uuid:
return index
return -1

def rename_current_tab(self, new_text, user_set=False):
page_num = self.get_notebook().get_current_page()
self.get_notebook().rename_page(page_num, new_text, user_set)
Expand Down
14 changes: 14 additions & 0 deletions guake/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ def main():
help=_("Return the selected tab index."),
)

parser.add_option(
"-x",
"--uuid-index",
dest="uuid_index",
action="store",
default="",
help=_("Return the index of the tab with the given terminal UUID, -1 if not found"),
)

parser.add_option(
"-l",
"--selected-tablabel",
Expand Down Expand Up @@ -527,6 +536,11 @@ def main():
sys.stdout.write(f"{selectedlabel}\n")
only_show_hide = options.show

if options.uuid_index:
selectedIndex = remote_object.get_index_from_uuid(options.uuid_index)
sys.stdout.write(f"{selectedIndex}\n")
only_show_hide = options.show

if options.split_vertical:
remote_object.v_split_current_terminal()
only_show_hide = options.show
Expand Down
3 changes: 3 additions & 0 deletions releasenotes/notes/uuid_index-34baad80fee820d9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
features:
- |
- get tab number/position from UUID #1005

0 comments on commit 2f5a889

Please sign in to comment.