[libdazzle] suggestion: reorient rows when property changes



commit ccfd4078a41717e8fdb1e7373535a3855d33f93f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 25 15:16:25 2019 -0700

    suggestion: reorient rows when property changes

 src/suggestions/dzl-suggestion-popover.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/suggestions/dzl-suggestion-popover.c b/src/suggestions/dzl-suggestion-popover.c
index 70298d7..bce3c47 100644
--- a/src/suggestions/dzl-suggestion-popover.c
+++ b/src/suggestions/dzl-suggestion-popover.c
@@ -1343,9 +1343,35 @@ _dzl_suggestion_popover_set_device (DzlSuggestionPopover *self,
     }
 }
 
+static void
+make_rows_vertical (GtkWidget *row,
+                    gpointer   user_data)
+{
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (row), GTK_ORIENTATION_VERTICAL);
+}
+
+static void
+make_rows_horizontal (GtkWidget *row,
+                      gpointer   user_data)
+{
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (row), GTK_ORIENTATION_HORIZONTAL);
+}
+
 void
 _dzl_suggestion_popover_set_compact (DzlSuggestionPopover *self,
-                                    gboolean              compact)
+                                     gboolean              compact)
 {
-  self->compact = compact;
+  g_return_if_fail (DZL_IS_SUGGESTION_POPOVER (self));
+
+  compact = !!compact;
+
+  if (compact != self->compact)
+    {
+      self->compact = compact;
+
+      if (compact)
+        gtk_container_foreach (GTK_CONTAINER (self->list_box), make_rows_vertical, NULL);
+      else
+        gtk_container_foreach (GTK_CONTAINER (self->list_box), make_rows_horizontal, NULL);
+    }
 }


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