[gnome-builder/wip/chergert/headerbar] omnibar: quick example of rendering configuration in popover



commit d1dab7eedb2a6f61d745f0f2e2a2e2c2645d84e9
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 23 13:02:36 2016 -0700

    omnibar: quick example of rendering configuration in popover

 data/theme/Adwaita-shared.css    |    7 ++++++
 libide/workbench/ide-omni-bar.c  |   39 +++++++++++++++++++++++++++++++++++++-
 libide/workbench/ide-omni-bar.ui |    7 +++++-
 3 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/data/theme/Adwaita-shared.css b/data/theme/Adwaita-shared.css
index e36d767..c72fe6e 100644
--- a/data/theme/Adwaita-shared.css
+++ b/data/theme/Adwaita-shared.css
@@ -150,3 +150,10 @@ popover.perspectives-selector list row image {
 omnibar entry {
   background-color: @theme_bg_color;
 }
+
+popover.omnibar list row {
+  border-bottom: 1px solid alpha(@borders, 0.4);
+}
+popover.omnibar list row:last-child {
+  border-bottom: none;
+}
diff --git a/libide/workbench/ide-omni-bar.c b/libide/workbench/ide-omni-bar.c
index 792b24d..240b6ce 100644
--- a/libide/workbench/ide-omni-bar.c
+++ b/libide/workbench/ide-omni-bar.c
@@ -24,6 +24,7 @@
 #include "ide-debug.h"
 
 #include "buildsystem/ide-build-result.h"
+#include "buildsystem/ide-configuration.h"
 #include "projects/ide-project.h"
 #include "util/ide-gtk.h"
 #include "vcs/ide-vcs.h"
@@ -52,11 +53,40 @@ struct _IdeOmniBar
   GtkStack       *message_stack;
   GtkPopover     *popover;
   GtkLabel       *popover_branch_label;
+  GtkListBox     *popover_configuration_list_box;
   GtkLabel       *popover_project_label;
 };
 
 G_DEFINE_TYPE (IdeOmniBar, ide_omni_bar, GTK_TYPE_BOX)
 
+static GtkWidget *
+create_configuration_row (gpointer item,
+                          gpointer user_data)
+{
+  IdeConfiguration *configuration = item;
+  IdeOmniBar *self = user_data;
+  GtkListBoxRow *row;
+  GtkLabel *label;
+
+  g_assert (IDE_IS_CONFIGURATION (configuration));
+  g_assert (IDE_IS_OMNI_BAR (self));
+
+  row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
+                      "visible", TRUE,
+                      NULL);
+
+  label = g_object_new (GTK_TYPE_LABEL,
+                        "xalign", 0.0f,
+                        "visible", TRUE,
+                        NULL);
+  g_object_bind_property (configuration, "display-name",
+                          label, "label",
+                          G_BINDING_SYNC_CREATE);
+  gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (label));
+
+  return GTK_WIDGET (row);
+}
+
 static void
 ide_omni_bar_update (IdeOmniBar *self)
 {
@@ -122,6 +152,12 @@ ide_omni_bar_context_set (GtkWidget  *widget,
       g_object_bind_property (configs, "current-display-name",
                               self->config_name_label, "label",
                               G_BINDING_SYNC_CREATE);
+
+      gtk_list_box_bind_model (self->popover_configuration_list_box,
+                               G_LIST_MODEL (configs),
+                               create_configuration_row,
+                               self,
+                               NULL);
     }
 
   IDE_EXIT;
@@ -325,9 +361,10 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, event_box);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, message_stack);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover);
-  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, project_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_branch_label);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_configuration_list_box);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_project_label);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, project_label);
 }
 
 static void
diff --git a/libide/workbench/ide-omni-bar.ui b/libide/workbench/ide-omni-bar.ui
index 761af6d..302e631 100644
--- a/libide/workbench/ide-omni-bar.ui
+++ b/libide/workbench/ide-omni-bar.ui
@@ -120,6 +120,9 @@
     <property name="relative-to">event_box</property>
     <property name="position">bottom</property>
     <property name="width-request">400</property>
+    <style>
+      <class name="omnibar"/>
+    </style>
     <child>
       <object class="GtkBox">
         <property name="orientation">vertical</property>
@@ -202,9 +205,11 @@
             <child>
               <object class="GtkScrolledWindow">
                 <property name="shadow-type">in</property>
+                <property name="max-content-height">200</property>
+                <property name="max-content-width">500</property>
                 <property name="visible">true</property>
                 <child>
-                  <object class="GtkListBox">
+                  <object class="GtkListBox" id="popover_configuration_list_box">
                     <property name="visible">true</property>
                   </object>
                 </child>


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