[gnome-maps/wip/cdavis/post-port-cleanups: 9/13] favoritesPopover: Use libadwaita popover styles




commit 41d918f7166d6d53ef763a3196bc96be30c560be
Author: Christopher Davis <christopherdavis gnome org>
Date:   Sun Aug 21 15:33:32 2022 -0400

    favoritesPopover: Use libadwaita popover styles

 data/gnome-maps.css          |  5 +++++
 data/ui/favorites-popover.ui | 28 +++++++++++++++++-----------
 src/favoritesPopover.js      | 14 ++------------
 3 files changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index 4487b627..6837ec22 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -107,4 +107,9 @@
 
 .suggestions {
     padding-top: 6px;
+}
+
+.dropdown-searchbar {
+  padding: 6px;
+  border-bottom: 1px solid @borders;
 }
\ No newline at end of file
diff --git a/data/ui/favorites-popover.ui b/data/ui/favorites-popover.ui
index 196c49c0..c65df0c9 100644
--- a/data/ui/favorites-popover.ui
+++ b/data/ui/favorites-popover.ui
@@ -2,26 +2,28 @@
 <interface>
   <requires lib="gtk" version="4.0"/>
   <template class="Gjs_FavoritesPopover" parent="GtkPopover">
-    <property name="hexpand">0</property>
     <property name="width-request">320</property>
-    <property name="height-request">400</property>
     <property name="child">
-      <object class="GtkGrid" id="mainGrid">
+      <object class="GtkBox" id="mainBox">
         <property name="orientation">vertical</property>
-        <property name="row_spacing">6</property>
-        <property name="margin-start">6</property>
-        <property name="margin-end">6</property>
-        <property name="margin-top">6</property>
-        <property name="margin-bottom">6</property>
         <child>
-          <object class="GtkEntry" id="entry">
-            <property name="focusable">1</property>
+          <object class="GtkBox" id="entryBox">
+            <child>
+              <object class="GtkEntry" id="entry">
+                <property name="hexpand">True</property>
+                <property name="focusable">1</property>
+              </object>
+            </child>
+            <style>
+              <class name="dropdown-searchbar"/>
+            </style>
           </object>
         </child>
         <child>
           <object class="GtkScrolledWindow" id="scrolledWindow">
             <property name="hscrollbar_policy">never</property>
-            <property name="vexpand">1</property>
+            <property name="max-content-height">400</property>
+            <property name="propagate-natural-height">True</property>
             <property name="child">
               <object class="GtkListBox" id="list">
                 <property name="hexpand">1</property>
@@ -32,5 +34,9 @@
         </child>
       </object>
     </property>
+    <style>
+      <class name="menu"/>
+      <class name="favorites-popover"/>
+    </style>
   </template>
 </interface>
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index 9f3cc98e..0e524fa9 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -46,18 +46,8 @@ export class FavoritesPopover extends Gtk.Popover {
         this._model.connect('row-inserted',
                             this._updateList.bind(this));
 
-        this._list.set_header_func(function(row, before) {
-            let header = before ? new Gtk.Separator() : null;
-            row.set_header(header);
-        });
-
         this.connect('notify::rows', () => {
-            let visible = Math.min(this._rows, _N_VISIBLE);
-            let separators = visible - 1; // separators are 1px
-            let height = PlaceListRow.ROW_HEIGHT * visible + separators;
-
-            this._scrolledWindow.min_content_height = height;
-            this._entry.visible = this._rows > _N_VISIBLE;
+            this._entryBox.visible = this.rows > _N_VISIBLE;
         });
 
         this._entry.connect('changed',
@@ -113,7 +103,7 @@ export class FavoritesPopover extends Gtk.Popover {
 
 GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/favorites-popover.ui',
-    InternalChildren: [ 'mainGrid',
+    InternalChildren: [ 'entryBox',
                         'entry',
                         'scrolledWindow',
                         'list' ],


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