[gnome-text-editor] preferences: use GtkFlowBox for previews



commit f718e98c031f3a092b4dc7ef883b6465b6ac9ad0
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 30 20:38:40 2021 -0800

    preferences: use GtkFlowBox for previews

 src/editor-preferences-dialog.c  | 10 ++++------
 src/editor-preferences-dialog.ui | 13 ++++++-------
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
index ecd76b3..9fec4f3 100644
--- a/src/editor-preferences-dialog.c
+++ b/src/editor-preferences-dialog.c
@@ -29,14 +29,12 @@
 #include "editor-window.h"
 #include "editor-utils-private.h"
 
-#define N_COLUMNS 3
-
 struct _EditorPreferencesDialog
 {
   AdwPreferencesWindow  parent_instance;
   GSettings            *settings;
   GtkSwitch            *use_system_font;
-  GtkGrid              *scheme_group;
+  GtkFlowBox           *scheme_group;
   GtkSourceBuffer      *buffer;
   GtkSourceView        *source_view;
 };
@@ -160,7 +158,8 @@ update_style_scheme_selection (EditorPreferencesDialog *self)
        child;
        child = gtk_widget_get_next_sibling (child))
     {
-      GtkSourceStyleSchemePreview *preview = GTK_SOURCE_STYLE_SCHEME_PREVIEW (child);
+      GtkFlowBoxChild *intermediate = GTK_FLOW_BOX_CHILD (child);
+      GtkSourceStyleSchemePreview *preview = GTK_SOURCE_STYLE_SCHEME_PREVIEW (gtk_flow_box_child_get_child 
(intermediate));
       GtkSourceStyleScheme *scheme = gtk_source_style_scheme_preview_get_scheme (preview);
       const char *scheme_id = gtk_source_style_scheme_get_id (scheme);
       gboolean selected = g_strcmp0 (scheme_id, id) == 0;
@@ -207,8 +206,7 @@ update_style_schemes (EditorPreferencesDialog *self)
           preview = gtk_source_style_scheme_preview_new (scheme);
           gtk_actionable_set_action_name (GTK_ACTIONABLE (preview), "app.style-scheme");
           gtk_actionable_set_action_target (GTK_ACTIONABLE (preview), "s", scheme_ids[i]);
-          gtk_widget_set_hexpand (preview, TRUE);
-          gtk_grid_attach (self->scheme_group, preview, j % N_COLUMNS, j / N_COLUMNS, 1, 1);
+          gtk_flow_box_insert (self->scheme_group, preview, -1);
 
           j++;
         }
diff --git a/src/editor-preferences-dialog.ui b/src/editor-preferences-dialog.ui
index 44192eb..242ad35 100644
--- a/src/editor-preferences-dialog.ui
+++ b/src/editor-preferences-dialog.ui
@@ -28,10 +28,6 @@
                     <property name="show-line-numbers">true</property>
                     <property name="buffer">
                       <object class="GtkSourceBuffer" id="buffer">
-                        <property name="text">
-
-
-</property>
                       </object>
                     </property>
                     <style>
@@ -42,10 +38,13 @@
               </object>
             </child>
             <child>
-              <object class="GtkGrid" id="scheme_group">
+              <object class="GtkFlowBox" id="scheme_group">
                 <property name="hexpand">true</property>
-                <property name="column-spacing">6</property>
-                <property name="row-spacing">6</property>
+                <property name="column-spacing">0</property>
+                <property name="row-spacing">0</property>
+                <property name="max-children-per-line">4</property>
+                <property name="max-children-per-line">4</property>
+                <property name="selection-mode">none</property>
               </object>
             </child>
           </object>


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