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
12 changes: 8 additions & 4 deletions dodo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ def __init__(self) -> None:

# open init_queries and make un-closeable
#
for query in settings.init_queries:
self.open_search(query, keep_open=True)
for entry in settings.init_queries:
if isinstance(entry, tuple):
query, custom_title = entry
else:
query, custom_title = entry, ''
self.open_search(query, keep_open=True, custom_title=custom_title)

def _handle_signal_wakeup(self) -> None:
"""Called when a Unix signal wakes up the Qt event loop via the pipe"""
Expand Down Expand Up @@ -232,7 +236,7 @@ def close_panel(self, to_close: int|panel.Panel|None=None) -> None:
# remove the panel itself
self.tabs.removeTab(index)

def open_search(self, query: str, keep_open: bool=False) -> None:
def open_search(self, query: str, keep_open: bool=False, custom_title: str='') -> None:
"""Open a search panel with the given query

If a panel with this query is already open, switch to it rather than
Expand All @@ -246,7 +250,7 @@ def open_search(self, query: str, keep_open: bool=False) -> None:
self.tabs.setCurrentIndex(i)
return

p = search.SearchPanel(self, query, keep_open=keep_open)
p = search.SearchPanel(self, query, keep_open=keep_open, custom_title=custom_title)
self.add_panel(p)

def open_thread(self, thread_id: str, query: str) -> None:
Expand Down
5 changes: 3 additions & 2 deletions dodo/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ class SearchPanel(panel.Panel):

This is used as the main entry point for the GUI, i.e. a search for "tag:inbox"."""

def __init__(self, a: app.Dodo, q: str, keep_open: bool=False, parent: Optional[QWidget]=None):
def __init__(self, a: app.Dodo, q: str, keep_open: bool=False, custom_title: str='', parent: Optional[QWidget]=None):
super().__init__(a, keep_open, parent)
self.set_keymap(keymap.search_keymap)
self.q = q
self.custom_title = custom_title
self.conf = QSettings("dodo", "dodo")
self.tree = QTreeView()
self.error_view = QLabel()
Expand Down Expand Up @@ -316,7 +317,7 @@ def title(self) -> str:
self.model.refresh_num_threads()
self._dirty_title = False
return settings.search_title_format.format(
query=self.q, num_threads=self.model.num_threads
query=self.custom_title or self.q, num_threads=self.model.num_threads
)

def next_thread(self, unread: bool=False) -> None:
Expand Down
8 changes: 8 additions & 0 deletions dodo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@
init_queries = [ 'tag:inbox' ]
"""List of non closable queries open at startup

Each entry can be a plain query string or a ``(query, title)`` tuple to
set a custom tab title. For example::

init_queries = [
'tag:inbox',
('tag:flagged', 'Flagged'),
]

You can save query with `notmuch config set query:inbox "tag:inbox and not
tag:trash"` and use `query:inbox` as a search term.
"""
Expand Down