[gnome-games/wip/exalm/searchbar: 2/2] search-bar: Make search bar adaptive



commit 14d99df2f6bdf99d786aa45533ed4796c186e28d
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 |  2 +-
 2 files changed, 12 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..aefcc64a 100644
--- a/src/ui/search-bar.vala
+++ b/src/ui/search-bar.vala
@@ -1,7 +1,7 @@
 // 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]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]