Commit cd910d71 authored by Jan-Michael Brummer's avatar Jan-Michael Brummer Committed by Christian Hergert

dzl-suggestion-row: Move from box to grid layout

parent c9b7e88b
......@@ -37,7 +37,7 @@ dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > li
color: @theme_fg_color;
}
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row box.vertical .subtitle {
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row.vertical .subtitle {
margin-left: 12px;
}
......@@ -46,7 +46,7 @@ dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > li
margin-right: 12px;
}
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row > box {
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row > grid {
margin: 4px 8px;
}
......@@ -55,7 +55,7 @@ dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > li
margin-bottom: 3px;
}
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row > box > image:first-child {
dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row > grid > image:first-child {
min-width: 16px;
}
......
......@@ -35,7 +35,7 @@ typedef struct
GtkLabel *title;
GtkLabel *separator;
GtkLabel *subtitle;
GtkLabel *box;
GtkGrid *grid;
} DzlSuggestionRowPrivate;
enum {
......@@ -92,6 +92,46 @@ on_notify_icon_cb (DzlSuggestionRow *self,
}
}
static void
dzl_suggestion_set_orientation (DzlSuggestionRowPrivate *priv)
{
const gchar *subtitle;
subtitle = dzl_suggestion_get_subtitle (priv->suggestion);
gtk_widget_set_visible (GTK_WIDGET (priv->separator),
priv->orientation != GTK_ORIENTATION_VERTICAL);
g_object_ref (priv->image);
g_object_ref (priv->title);
g_object_ref (priv->subtitle);
gtk_container_remove (GTK_CONTAINER (priv->grid), GTK_WIDGET (priv->image));
gtk_container_remove (GTK_CONTAINER (priv->grid), GTK_WIDGET (priv->title));
gtk_container_remove (GTK_CONTAINER (priv->grid), GTK_WIDGET (priv->subtitle));
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->image), 0, 0, 1, 1);
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->title), 1, 0, 1, 1);
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->subtitle), 1, 1, 1, 1);
gtk_widget_set_visible (GTK_WIDGET (priv->separator), FALSE);
}
else
{
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->image), 0, 0, 1, 2);
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->title), 1, 0, 1, 1);
gtk_grid_attach (priv->grid, GTK_WIDGET (priv->subtitle), 3, 0, 1, 1);
gtk_widget_set_visible (GTK_WIDGET (priv->separator), !!subtitle);
}
g_object_unref (priv->subtitle);
g_object_unref (priv->title);
g_object_unref (priv->image);
}
static void
dzl_suggestion_row_connect (DzlSuggestionRow *self)
{
......@@ -115,12 +155,7 @@ dzl_suggestion_row_connect (DzlSuggestionRow *self)
subtitle = dzl_suggestion_get_subtitle (priv->suggestion);
gtk_label_set_label (priv->subtitle, subtitle);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
gtk_widget_set_visible (GTK_WIDGET (priv->separator), FALSE);
else
gtk_widget_set_visible (GTK_WIDGET (priv->separator), !!subtitle);
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), priv->orientation);
dzl_suggestion_set_orientation (priv);
}
static void
......@@ -181,9 +216,7 @@ dzl_suggestion_row_set_property (GObject *object,
if (priv->orientation != g_value_get_enum (value))
{
priv->orientation = g_value_get_enum (value);
gtk_widget_set_visible (GTK_WIDGET (priv->separator),
priv->orientation != GTK_ORIENTATION_VERTICAL);
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), priv->orientation);
dzl_suggestion_set_orientation (priv);
}
break;
......@@ -224,7 +257,7 @@ dzl_suggestion_row_class_init (DzlSuggestionRowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, DzlSuggestionRow, title);
gtk_widget_class_bind_template_child_private (widget_class, DzlSuggestionRow, subtitle);
gtk_widget_class_bind_template_child_private (widget_class, DzlSuggestionRow, separator);
gtk_widget_class_bind_template_child_private (widget_class, DzlSuggestionRow, box);
gtk_widget_class_bind_template_child_private (widget_class, DzlSuggestionRow, grid);
}
static void
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<template class="DzlSuggestionRow" parent="DzlListBoxRow">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image">
<property name="pixel-size">16</property>
<property name="hexpand">false</property>
<property name="visible">true</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">False</property>
<property name="pixel_size">16</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box">
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel" id="title">
<property name="hexpand">false</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<property name="use-markup">true</property>
<property name="ellipsize">end</property>
<style>
<class name="title"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="separator">
<property name="hexpand">false</property>
<property name="label"></property>
<property name="visible">true</property>
<style>
<class name="separator"/>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="subtitle">
<property name="hexpand">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<property name="use-markup">true</property>
<property name="ellipsize">end</property>
<style>
<class name="dim-label"/>
<class name="subtitle"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<object class="GtkLabel" id="subtitle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="use_markup">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
<class name="subtitle"/>
</style>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="separator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="label"></property>
<style>
<class name="separator"/>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="use_markup">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<style>
<class name="title"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</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