[gnome-control-center/wip/feborges/new-search-panel] search: Adjust panel height according to num of rows



commit 30ff60d235fa929937ac9258159157d59900139e
Author: Felipe Borges <felipeborges gnome org>
Date:   Sat Apr 29 13:21:05 2017 +0200

    search: Adjust panel height according to num of rows
    
    We cannot benefit here from the cc_list_box_setup_scrolling ()
    list-box helper function because we are also embedding other
    widgets in the scrolled window, such as the box which contains
    the panel usage instructions and the gear button.
    
    In doing so, we manually set the "cc-scrolling-scrolled-window"
    and "cc-max-row-visible" properties in the GtkListBox so the
    cc_list_box_adjust_scrolling () helper function can properly
    calculate the total height of the visible list box rows.
    
    MAX_ROWS_VISIBLE is arbitrarily set to 7 instead of 5 because
    the other children of the scrolled window are not computed in
    the cc_list_box_adjust_scrolling () function. The two lines
    GtkLabel height summed to its vertical margins should equal
    something around the size of two rows (2 + 5 = 7).
    
    This commit should be reverted when the new Control Center
    resizable shell gets introduced.

 panels/search/cc-search-panel.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 5ef7533..e1997c9 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -26,6 +26,8 @@
 #include <gio/gdesktopappinfo.h>
 #include <glib/gi18n.h>
 
+#define MAX_ROWS_VISIBLE 7
+
 CC_PANEL_REGISTER (CcSearchPanel, cc_search_panel)
 
 #define WID(s) GTK_WIDGET (gtk_builder_get_object (self->priv->builder, s))
@@ -556,6 +558,8 @@ search_providers_discover_ready (GObject *source,
       g_object_unref (provider);
     }
 
+  cc_list_box_adjust_scrolling (GTK_LIST_BOX (self->priv->list_box));
+
   /* propagate a write to GSettings, to make sure we always have
    * all the providers in the list.
    */
@@ -761,6 +765,13 @@ cc_search_panel_init (CcSearchPanel *self)
   populate_search_providers (self);
 
   widget = WID ("search_vbox");
+
+  /* For the cc_list_box_adjust_scrolling () helper function. */
+  g_object_set_data (G_OBJECT (self->priv->list_box),
+                     "cc-scrolling-scrolled-window", widget);
+  g_object_set_data (G_OBJECT (self->priv->list_box),
+                     "cc-max-rows-visible", GUINT_TO_POINTER (MAX_ROWS_VISIBLE));
+
   gtk_container_add (GTK_CONTAINER (self), widget);
 }
 


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