Add tooltips to explain search terms a bit

This commit is contained in:
Daniel Johnson 2024-04-18 18:45:05 -04:00 committed by Mathieu Comandon
parent ce8961fce2
commit 7d38dd032d
3 changed files with 21 additions and 2 deletions

View file

@ -123,12 +123,13 @@ class GameDialogCommon(SavableModelessDialog, DialogInstallUIDelegate):
show_search = current_page_index in self.searchable_page_indices
self.set_search_entry_visibility(show_search)
def set_search_entry_visibility(self, show_search, placeholder_text=None):
def set_search_entry_visibility(self, show_search, placeholder_text=None, tooltip_markup=None):
"""Explicitly shows or hides the search entry; can also update the placeholder text."""
header_bar = self.get_header_bar()
if show_search and self.search_entry:
header_bar.set_custom_title(self.search_entry)
self.search_entry.set_placeholder_text(placeholder_text or self.get_search_entry_placeholder())
self.search_entry.set_tooltip_markup(tooltip_markup)
else:
header_bar.set_custom_title(None)

View file

@ -2,6 +2,7 @@
# pylint: disable=no-member
from gettext import gettext as _
from textwrap import dedent
from gi.repository import GObject, Gtk
@ -91,7 +92,15 @@ class PreferencesDialog(GameDialogCommon):
if stack_id == "system-stack":
self.set_search_entry_visibility(True)
elif stack_id == "runners-stack":
self.set_search_entry_visibility(True, self.runners_box.search_entry_placeholder_text)
tooltip_markup = """
Enter the name or description of a runner to search for, or use search terms:
<b>installed:</b><i>true</i> Only installed runners.
"""
tooltip_markup = dedent(tooltip_markup).strip()
self.set_search_entry_visibility(
True, self.runners_box.search_entry_placeholder_text, tooltip_markup=tooltip_markup
)
else:
self.set_search_entry_visibility(False)

View file

@ -305,6 +305,15 @@
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-markup" translatable="yes">Enter the name of a game to search for, or use search terms:
&lt;b&gt;installed:&lt;/b&gt;&lt;i&gt;true&lt;/i&gt; Only installed games.
&lt;b&gt;hidden:&lt;/b&gt;&lt;i&gt;true&lt;/i&gt; Only hidden games.
&lt;b&gt;favorite:&lt;/b&gt;&lt;i&gt;true&lt;/i&gt; Only favorite games.
&lt;b&gt;category:&lt;/b&gt;&lt;i&gt;x&lt;/i&gt; Only games in cateogry &lt;i&gt;x&lt;/i&gt;.
&lt;b&gt;runner:&lt;/b&gt;&lt;i&gt;wine&lt;/i&gt; Only Wine games
&lt;b&gt;platform:&lt;/b&gt;&lt;i&gt;windows&lt;/i&gt; Only Windows games
&lt;b&gt;playtime:&lt;/b&gt;&lt;i&gt;&amp;gt;2 hours&lt;/i&gt; Only games played for more than 2 hours.</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="width-chars">30</property>