mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
window: Put SearchBar on a separate top widget
This allows the search bar to have enough space in mobile mode. We need to remove the strict centering-policy for the title to fit on the headerbar. Fixes: https://gitlab.gnome.org/World/Authenticator/-/issues/440
This commit is contained in:
parent
4312aba925
commit
c43ac99d3d
2 changed files with 20 additions and 53 deletions
|
@ -168,7 +168,6 @@
|
|||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="centering-policy">strict</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="action-name">win.add_account</property>
|
||||
|
@ -176,44 +175,11 @@
|
|||
<property name="tooltip-text" translatable="yes">New Account</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="title">
|
||||
<object class="GtkStack" id="title_stack">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">title</property>
|
||||
<property name="child">
|
||||
<object class="AdwWindowTitle" id="window_title">
|
||||
<property name="title" bind-source="Window" bind-property="title" bind-flags="bidirectional|sync-create" />
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">search</property>
|
||||
<property name="child">
|
||||
<object class="AdwClamp">
|
||||
<property name="tightening-threshold">300</property>
|
||||
<property name="maximum-size">400</property>
|
||||
<property name="child">
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="placeholder-text" translatable="yes">Search…</property>
|
||||
<signal name="search-started" handler="on_search_started" swapped="true" />
|
||||
<signal name="search-changed" handler="on_search_changed" swapped="true" />
|
||||
<signal name="stop-search" handler="on_search_stopped" swapped="true" />
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle" id="window_title">
|
||||
<property name="title" bind-source="Window" bind-property="title" bind-flags="bidirectional|sync-create" />
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton">
|
||||
<property name="menu-model">menu</property>
|
||||
|
@ -226,7 +192,22 @@
|
|||
<object class="GtkToggleButton" id="search_btn">
|
||||
<property name="icon-name">system-search-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Search</property>
|
||||
<signal name="toggled" handler="on_search_btn_toggled" swapped="true" />
|
||||
<property name="active" bind-source="search_bar" bind-property="search-mode-enabled" bind-flags="sync-create|bidirectional" />
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="top">
|
||||
<object class="GtkSearchBar" id="search_bar">
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="placeholder-text" translatable="yes">Search…</property>
|
||||
<signal name="search-started" handler="on_search_started" swapped="true" />
|
||||
<signal name="search-changed" handler="on_search_changed" swapped="true" />
|
||||
<signal name="stop-search" handler="on_search_stopped" swapped="true" />
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -61,8 +61,6 @@ mod imp {
|
|||
#[template_child]
|
||||
pub empty_status_page: TemplateChild<adw::StatusPage>,
|
||||
#[template_child]
|
||||
pub title_stack: TemplateChild<gtk::Stack>,
|
||||
#[template_child]
|
||||
pub unlock_button: TemplateChild<gtk::Button>,
|
||||
#[template_child]
|
||||
pub toast_overlay: TemplateChild<adw::ToastOverlay>,
|
||||
|
@ -356,16 +354,4 @@ impl Window {
|
|||
fn on_search_stopped(&self, _entry: >k::SearchEntry) {
|
||||
self.imp().search_btn.set_active(false);
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn on_search_btn_toggled(&self, btn: >k::ToggleButton) {
|
||||
let imp = self.imp();
|
||||
if btn.is_active() {
|
||||
imp.title_stack.set_visible_child_name("search");
|
||||
imp.search_entry.grab_focus();
|
||||
} else {
|
||||
imp.search_entry.set_text("");
|
||||
imp.title_stack.set_visible_child_name("title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue