[gnome-games/wip/exalm/searchbar: 5/5] search-bar: Make search bar adaptive
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/searchbar: 5/5] search-bar: Make search bar adaptive
- Date: Tue, 4 Dec 2018 09:01:04 +0000 (UTC)
commit 93aeb8b2b9700b3e50c138182f0e60a4019c531d
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Mon Dec 3 18:12:55 2018 +0500
search-bar: Make search bar adaptive
Use Hdy.SearchBar and Hdy.Column to make search bar shrink in narrow
windows.
data/ui/search-bar.ui | 16 +++++++++++-----
src/ui/search-bar.vala | 6 +++++-
2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/search-bar.ui b/data/ui/search-bar.ui
index 3416d49f..2af4e451 100644
--- a/data/ui/search-bar.ui
+++ b/data/ui/search-bar.ui
@@ -1,14 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.16 -->
- <template class="GamesSearchBar" parent="GtkSearchBar">
+ <template class="GamesSearchBar" parent="HdySearchBar">
<property name="visible">True</property>
<child>
- <object class="GtkSearchEntry" id="entry">
+ <object class="HdyColumn">
<property name="visible">True</property>
- <property name="width-chars">40</property>
- <signal name="search-changed" handler="on_search_changed"/>
- <signal name="activate" handler="on_search_activated"/>
+ <property name="maximum-width">400</property>
+ <property name="linear-growth-width">300</property>
+ <child>
+ <object class="GtkSearchEntry" id="entry">
+ <property name="visible">True</property>
+ <signal name="search-changed" handler="on_search_changed"/>
+ <signal name="activate" handler="on_search_activated"/>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/src/ui/search-bar.vala b/src/ui/search-bar.vala
index fa1d61bd..1b45ce44 100644
--- a/src/ui/search-bar.vala
+++ b/src/ui/search-bar.vala
@@ -1,12 +1,16 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/search-bar.ui")]
-private class Games.SearchBar : Gtk.SearchBar {
+private class Games.SearchBar : Hdy.SearchBar {
public string text { get; private set; }
[GtkChild]
private Gtk.SearchEntry entry;
+ construct {
+ connect_entry (entry);
+ }
+
[GtkCallback]
private void on_search_changed () {
text = entry.text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]