[gnome-software: 1/2] shell: Make the search bar adaptive




commit 6229e68fc7181c2f31329500852f804936439a78
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon Jun 14 12:36:38 2021 +0200

    shell: Make the search bar adaptive
    
    This uses HdySearchBar and a HdyClamp to let the search bar reasch much
    narrower widths without changing anything else visually or functionally.
    By extension, this allows the whole window to reach narrower widths.

 src/gs-shell.c  | 10 +++++-----
 src/gs-shell.ui | 21 +++++++++++++--------
 2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 2d7a908d3..26ff1a8ed 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -440,7 +440,7 @@ update_header_widgets (GsShell *shell)
        g_signal_handlers_block_by_func (shell->search_button_sidebar, search_button_clicked_cb, shell);
 
        /* hide unless we're going to search */
-       gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (shell->search_bar),
+       hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (shell->search_bar),
                                        mode == GS_SHELL_MODE_SEARCH);
 
        g_signal_handlers_unblock_by_func (shell->search_button_sidebar, search_button_clicked_cb, shell);
@@ -847,18 +847,18 @@ window_keypress_handler (GtkWidget *window, GdkEvent *event, GsShell *shell)
                GdkEventKey *e = (GdkEventKey *) event;
                if ((e->state & GDK_CONTROL_MASK) > 0 &&
                    e->keyval == GDK_KEY_f) {
-                       if (!gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (shell->search_bar))) {
-                               gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (shell->search_bar), TRUE);
+                       if (!hdy_search_bar_get_search_mode (HDY_SEARCH_BAR (shell->search_bar))) {
+                               hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (shell->search_bar), TRUE);
                                gtk_widget_grab_focus (shell->entry_search);
                        } else {
-                               gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (shell->search_bar), FALSE);
+                               hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (shell->search_bar), FALSE);
                        }
                        return GDK_EVENT_STOP;
                }
        }
 
        /* pass to search bar */
-       return gtk_search_bar_handle_event (GTK_SEARCH_BAR (shell->search_bar), event);
+       return hdy_search_bar_handle_event (HDY_SEARCH_BAR (shell->search_bar), event);
 }
 
 static void
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index e0d5f04c5..b72b2903a 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -462,18 +462,23 @@
                                     <property name="orientation">vertical</property>
 
                                     <child>
-                                      <object class="GtkSearchBar" id="search_bar">
+                                      <object class="HdySearchBar" id="search_bar">
                                         <property name="visible">True</property>
                                         <child>
-                                          <object class="GtkSearchEntry" id="entry_search">
+                                          <object class="HdyClamp">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="activates_default">True</property>
-                                            <property name="width_request">500</property>
-                                            <property name="max_length">100</property>
                                             <property name="hexpand">True</property>
-                                            <property name="halign">center</property>
-                                            <signal name="search-changed" handler="search_changed_handler"/>
+                                            <property name="maximum_size">500</property>
+                                            <property name="tightening_threshold">500</property>
+                                            <child>
+                                              <object class="GtkSearchEntry" id="entry_search">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="activates_default">True</property>
+                                                <property name="max_length">100</property>
+                                                <signal name="search-changed" 
handler="search_changed_handler"/>
+                                              </object>
+                                            </child>
                                           </object>
                                         </child>
                                       </object>


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