[gnome-builder/wip/gtk4-port: 569/1774] libide/search: additional search popover design work




commit 4c250f2ee4c5d4cf9f41216edeaf985eeb3b9e67
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 13 16:48:25 2022 -0700

    libide/search: additional search popover design work

 src/libide/gui/style.css                |  3 ++
 src/libide/search/ide-search-popover.c  | 29 +++++++++++
 src/libide/search/ide-search-popover.ui | 87 ++++++++++++++++++++++++++++++---
 3 files changed, 112 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/gui/style.css b/src/libide/gui/style.css
index e892ebbe6..ec880e99c 100644
--- a/src/libide/gui/style.css
+++ b/src/libide/gui/style.css
@@ -51,3 +51,6 @@ window popover.global-search contents {
   padding: 0;
   margin: 0;
 }
+window popover.global-search .navigation-sidebar {
+  border-right: 1px solid @borders;
+}
diff --git a/src/libide/search/ide-search-popover.c b/src/libide/search/ide-search-popover.c
index a14836583..dd5ee459e 100644
--- a/src/libide/search/ide-search-popover.c
+++ b/src/libide/search/ide-search-popover.c
@@ -28,7 +28,10 @@
 struct _IdeSearchPopover
 {
   GtkPopover       parent_instance;
+
   IdeSearchEngine *search_engine;
+
+  GtkSearchEntry  *entry;
 };
 
 enum {
@@ -54,6 +57,28 @@ ide_search_popover_set_search_engine (IdeSearchPopover *self,
     }
 }
 
+static void
+ide_search_popover_show (GtkWidget *widget)
+{
+  IdeSearchPopover *self = (IdeSearchPopover *)widget;
+
+  g_assert (IDE_IS_SEARCH_POPOVER (self));
+
+  GTK_WIDGET_CLASS (ide_search_popover_parent_class)->show (widget);
+
+  gtk_widget_grab_focus (GTK_WIDGET (self->entry));
+}
+
+static gboolean
+ide_search_popover_grab_focus (GtkWidget *widget)
+{
+  IdeSearchPopover *self = (IdeSearchPopover *)widget;
+
+  g_assert (IDE_IS_SEARCH_POPOVER (self));
+
+  return gtk_widget_grab_focus (GTK_WIDGET (self->entry));
+}
+
 static void
 ide_search_popover_dispose (GObject *object)
 {
@@ -112,6 +137,9 @@ ide_search_popover_class_init (IdeSearchPopoverClass *klass)
   object_class->get_property = ide_search_popover_get_property;
   object_class->set_property = ide_search_popover_set_property;
 
+  widget_class->grab_focus = ide_search_popover_grab_focus;
+  widget_class->show = ide_search_popover_show;
+
   properties [PROP_SEARCH_ENGINE] =
     g_param_spec_object ("search-engine",
                          "Search Engine",
@@ -124,6 +152,7 @@ ide_search_popover_class_init (IdeSearchPopoverClass *klass)
   g_resources_register (ide_search_get_resource ());
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/libide-search/ide-search-popover.ui");
+  gtk_widget_class_bind_template_child (widget_class, IdeSearchPopover, entry);
 }
 
 static void
diff --git a/src/libide/search/ide-search-popover.ui b/src/libide/search/ide-search-popover.ui
index 7be64cb32..687e59f66 100644
--- a/src/libide/search/ide-search-popover.ui
+++ b/src/libide/search/ide-search-popover.ui
@@ -2,23 +2,96 @@
 <interface>
   <template class="IdeSearchPopover" parent="GtkPopover">
     <property name="has-arrow">false</property>
-    <property name="width-request">500</property>
+    <property name="width-request">700</property>
+    <property name="height-request">400</property>
+    <property name="default-widget">entry</property>
     <style>
       <class name="global-search"/>
     </style>
     <child>
       <object class="GtkBox">
-        <property name="orientation">vertical</property>
-        <property name="vexpand">true</property>
+        <property name="orientation">horizontal</property>
         <child>
-          <object class="GtkHeaderBar">
-            <property name="show-title-buttons">false</property>
+          <object class="GtkBox">
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="AdwHeaderBar">
+                <property name="show-start-title-buttons">false</property>
+                <property name="show-end-title-buttons">false</property>
+                <child type="title">
+                  <object class="GtkLabel">
+                  </object>
+                </child>
+                <child type="end">
+                  <object class="GtkMenuButton">
+                    <property name="icon-name">open-menu-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="vexpand">true</property>
+                <property name="hscrollbar-policy">never</property>
+                <property name="propagate-natural-width">true</property>
+                <child>
+                  <object class="GtkListBox">
+                    <property name="width-request">200</property>
+                    <style>
+                      <class name="navigation-sidebar"/>
+                    </style>
+                    <child>
+                      <object class="GtkListBoxRow">
+                        <child>
+                          <object class="GtkBox">
+                            <property name="orientation">horizontal</property>
+                            <property name="spacing">12</property>
+                            <child>
+                              <object class="GtkImage">
+                                <property name="icon-name">edit-find-symbolic</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="xalign">0</property>
+                                <property name="hexpand">true</property>
+                                <property name="label" translatable="yes">_Top Results</property>
+                                <property name="use-underline">true</property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
         </child>
         <child>
           <object class="GtkBox">
-            <property name="orientation">horizontal</property>
-            <property name="vexpand">true</property>
+            <property name="orientation">vertical</property>
+            <property name="hexpand">true</property>
+            <child>
+              <object class="AdwHeaderBar">
+                <property name="show-start-title-buttons">false</property>
+                <property name="show-end-title-buttons">false</property>
+                <child type="title">
+                  <object class="GtkSearchEntry" id="entry">
+                    <property name="width-chars">40</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="vexpand">true</property>
+                <property name="hscrollbar-policy">never</property>
+                <property name="propagate-natural-height">true</property>
+                <property name="min-content-height">400</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>


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