[gnome-builder/wip/gtk4-port: 289/1774] libide/gui: improve size/position of omnibar




commit c8af09e2df06b99f581f628a0d4aa0fdaaf590b5
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 31 23:25:49 2022 -0700

    libide/gui: improve size/position of omnibar

 src/libide/gui/ide-omni-bar.c           | 23 +++++++++++++++++++++++
 src/libide/gui/ide-primary-workspace.ui | 21 ++++++++++++++-------
 2 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/gui/ide-omni-bar.c b/src/libide/gui/ide-omni-bar.c
index 844b0e2a8..3af22a161 100644
--- a/src/libide/gui/ide-omni-bar.c
+++ b/src/libide/gui/ide-omni-bar.c
@@ -246,6 +246,28 @@ ide_omni_bar_notification_row_activated (IdeOmniBar                *self,
     gtk_widget_activate_action_variant (GTK_WIDGET (list_box), default_action, default_target);
 }
 
+static void
+ide_omni_bar_measure (GtkWidget      *widget,
+                      GtkOrientation  orientation,
+                      int             for_size,
+                      int            *minimum,
+                      int            *natural,
+                      int            *minimum_baseline,
+                      int            *natural_baseline)
+{
+  g_assert (IDE_IS_OMNI_BAR (widget));
+
+  GTK_WIDGET_CLASS (ide_omni_bar_parent_class)->measure (widget, orientation, for_size,
+                                                         minimum, natural,
+                                                         minimum_baseline, natural_baseline);
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      if (*natural < 500)
+        *natural = 500;
+    }
+}
+
 static void
 ide_omni_bar_dispose (GObject *object)
 {
@@ -267,6 +289,7 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   object_class->dispose = ide_omni_bar_dispose;
 
   widget_class->query_tooltip = ide_omni_bar_query_tooltip;
+  widget_class->measure = ide_omni_bar_measure;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/libide-gui/ui/ide-omni-bar.ui");
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, notification_stack);
diff --git a/src/libide/gui/ide-primary-workspace.ui b/src/libide/gui/ide-primary-workspace.ui
index cce61d03f..902c1d69c 100644
--- a/src/libide/gui/ide-primary-workspace.ui
+++ b/src/libide/gui/ide-primary-workspace.ui
@@ -17,13 +17,20 @@
           </object>
         </child>
         <child type="title">
-          <object class="IdeOmniBar" id="omni_bar">
-            <property name="icon-name">builder-build-symbolic</property>
-            <property name="action-name">build-manager.build</property>
-            <child type="placeholder">
-              <object class="GtkLabel" id="project_title">
-                <property name="ellipsize">end</property>
-                <property name="xalign">0.0</property>
+          <object class="AdwClamp">
+            <property name="orientation">horizontal</property>
+            <property name="maximum-size">500</property>
+            <child>
+              <object class="IdeOmniBar" id="omni_bar">
+                <property name="icon-name">builder-build-symbolic</property>
+                <property name="action-name">build-manager.build</property>
+                <child type="placeholder">
+                  <object class="GtkLabel" id="project_title">
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0.0</property>
+                    <property name="width-chars">5</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>


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