Commit 772f90a4 authored by Christian Hergert's avatar Christian Hergert
Browse files

omnibar: quick example of rendering configuration in popover

parent 350c6374
......@@ -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;
}
......@@ -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
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment