[epiphany/wip/exalm/gtk4-cleanups-3: 13/23] encoding-dialog: Port to GtkBox




commit 9c389ededfa1a2c9d8782119b8965735602f8fb9
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Dec 2 01:19:52 2021 +0500

    encoding-dialog: Port to GtkBox
    
    There was a period where GtkGrid looked like it's going to be the future,
    along with a misleading mention that boxes are going to be removed. In
    practice, that was about HBox and VBox, not Box. Meanwhile, this layout has
    no reason whatsoever to use grid and it just complicates it.
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1038>

 src/ephy-encoding-dialog.c           | 12 +++----
 src/resources/gtk/encoding-dialog.ui | 65 +++++-------------------------------
 2 files changed, 15 insertions(+), 62 deletions(-)
---
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index 83ad45b40..862d13aed 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -52,8 +52,8 @@ struct _EphyEncodingDialog {
   GtkListBox *list_box;
   GtkListBox *recent_list_box;
   GtkListBox *related_list_box;
-  GtkGrid *recent_grid;
-  GtkGrid *related_grid;
+  GtkWidget *recent_box;
+  GtkWidget *related_box;
 };
 
 enum {
@@ -398,7 +398,7 @@ ephy_encoding_dialog_constructed (GObject *object)
     recent = g_list_sort (recent, (GCompareFunc)sort_encodings);
     g_list_foreach (recent, (GFunc)add_list_item, dialog->recent_list_box);
   } else
-    gtk_widget_hide (GTK_WIDGET (dialog->recent_grid));
+    gtk_widget_hide (dialog->recent_box);
 
   /* related */
   if (dialog->selected_encoding != NULL) {
@@ -412,7 +412,7 @@ ephy_encoding_dialog_constructed (GObject *object)
     related = g_list_sort (related, (GCompareFunc)sort_encodings);
     g_list_foreach (related, (GFunc)add_list_item, dialog->related_list_box);
   } else
-    gtk_widget_hide (GTK_WIDGET (dialog->related_grid));
+    gtk_widget_hide (dialog->related_box);
 
   /* update list_boxes */
   sync_encoding_against_embed (dialog);
@@ -512,8 +512,8 @@ ephy_encoding_dialog_class_init (EphyEncodingDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, list_box);
   gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_list_box);
   gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_list_box);
-  gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_grid);
-  gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_grid);
+  gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_box);
+  gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_box);
 
   gtk_widget_class_bind_template_callback (widget_class, default_switch_toggled_cb);
   gtk_widget_class_bind_template_callback (widget_class, ephy_encoding_dialog_response_cb);
diff --git a/src/resources/gtk/encoding-dialog.ui b/src/resources/gtk/encoding-dialog.ui
index 6f7066456..1fb96fb41 100644
--- a/src/resources/gtk/encoding-dialog.ui
+++ b/src/resources/gtk/encoding-dialog.ui
@@ -23,10 +23,9 @@
           </object>
         </child>
         <child>
-          <object class="GtkGrid">
+          <object class="GtkBox">
             <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="column_spacing">6</property>
+            <property name="spacing">6</property>
             <child>
               <object class="GtkLabel">
                 <property name="visible">True</property>
@@ -36,10 +35,6 @@
                 <property name="label" translatable="yes">Use the encoding specified by the 
document</property>
                 <property name="wrap">True</property>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
             </child>
             <child>
               <object class="GtkSwitch" id="default_switch">
@@ -47,10 +42,6 @@
                 <property name="valign">start</property>
                 <signal name="state-set" handler="default_switch_toggled_cb" swapped="no"/>
               </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
             </child>
           </object>
         </child>
@@ -61,16 +52,15 @@
             <property name="vexpand">True</property>
             <property name="interpolate_size">True</property>
             <child>
-              <object class="GtkGrid" id="suggested_grid">
+              <object class="GtkBox" id="suggested_box">
                 <property name="visible">True</property>
                 <property name="orientation">vertical</property>
-                <property name="row_spacing">16</property>
+                <property name="spacing">16</property>
                 <child>
-                  <object class="GtkGrid" id="recent_grid">
+                  <object class="GtkBox" id="recent_box">
                     <property name="visible">True</property>
-                    <property name="vexpand">True</property>
                     <property name="orientation">vertical</property>
-                    <property name="row_spacing">8</property>
+                    <property name="spacing">8</property>
                     <child>
                       <object class="GtkLabel">
                         <property name="visible">True</property>
@@ -81,16 +71,11 @@
                           <attribute name="weight" value="bold"/>
                         </attributes>
                       </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                      </packing>
                     </child>
                     <child>
                       <object class="GtkFrame">
                         <property name="visible">True</property>
                         <property name="vexpand">True</property>
-                        <property name="hexpand">True</property>
                         <property name="label_xalign">0</property>
                         <property name="shadow_type">in</property>
                         <child>
@@ -99,26 +84,15 @@
                             <signal name="row-activated" handler="row_activated_cb" swapped="no"/>
                           </object>
                         </child>
-                        <child type="label_item">
-                          <placeholder/>
-                        </child>
                       </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                      </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                  </packing>
                 </child>
                 <child>
-                  <object class="GtkGrid" id="related_grid">
+                  <object class="GtkBox" id="related_box">
                     <property name="visible">True</property>
                     <property name="orientation">vertical</property>
-                    <property name="row_spacing">8</property>
+                    <property name="spacing">8</property>
                     <child>
                       <object class="GtkLabel">
                         <property name="visible">True</property>
@@ -129,15 +103,10 @@
                           <attribute name="weight" value="bold"/>
                         </attributes>
                       </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                      </packing>
                     </child>
                     <child>
                       <object class="GtkFrame">
                         <property name="visible">True</property>
-                        <property name="hexpand">True</property>
                         <property name="border_width">6</property>
                         <property name="label_xalign">0</property>
                         <property name="shadow_type">none</property>
@@ -147,37 +116,21 @@
                             <signal name="row-activated" handler="row_activated_cb" swapped="no"/>
                           </object>
                         </child>
-                        <child type="label_item">
-                          <placeholder/>
-                        </child>
                       </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                      </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkButton">
                     <property name="label" translatable="yes">Show all…</property>
                     <property name="visible">True</property>
                     <property name="receives_default">False</property>
-                    <property name="hexpand">True</property>
                     <signal name="clicked" handler="show_all_button_clicked_cb" swapped="no"/>
                   </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">2</property>
-                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="name">suggested_grid</property>
+                <property name="name">suggested_box</property>
               </packing>
             </child>
             <child>


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