[vte] app: Replace GtkBox with GtkGrid



commit 4ef278b94b4414a3ddbb31b460daaec9a88075b2
Author: Christian Persch <chpe src gnome org>
Date:   Sun Oct 25 15:34:55 2020 +0100

    app: Replace GtkBox with GtkGrid
    
    [gtk4 preparation]

 src/app/app.cc    | 19 +++++++++++--------
 src/app/window.ui | 31 +++++++++++++++++++------------
 2 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/src/app/app.cc b/src/app/app.cc
index 82bf9796..6e1668be 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -1135,9 +1135,9 @@ struct _VteappWindow {
         GtkApplicationWindow parent;
 
         /* from GtkWidget template */
-        GtkWidget* window_box;
+        GtkWidget* window_grid;
         GtkScrollbar* scrollbar;
-        /* GtkBox* notifications_box; */
+        /* GtkGrid* notifications_grid; */
         GtkWidget* readonly_emblem;
         /* GtkButton* copy_button; */
         /* GtkButton* paste_button; */
@@ -1216,7 +1216,7 @@ vteapp_window_update_geometry(VteappWindow* window)
          * This includes the terminal's padding in the chrome.
          */
         GtkRequisition contents_req;
-        gtk_widget_get_preferred_size(window->window_box, nullptr, &contents_req);
+        gtk_widget_get_preferred_size(window->window_grid, nullptr, &contents_req);
         int chrome_width = contents_req.width - cell_width * columns;
         int chrome_height = contents_req.height - cell_height * rows;
         g_assert_cmpint(chrome_width, >=, 0);
@@ -1230,7 +1230,7 @@ vteapp_window_update_geometry(VteappWindow* window)
                  */
                 GtkAllocation toplevel, contents;
                 gtk_widget_get_allocation(window_widget, &toplevel);
-                gtk_widget_get_allocation(window->window_box, &contents);
+                gtk_widget_get_allocation(window->window_grid, &contents);
 
                 csd_width = toplevel.width - contents.width;
                 csd_height = toplevel.height - contents.height;
@@ -2014,6 +2014,9 @@ vteapp_window_constructed(GObject *object)
         /* Create terminal and connect scrollbar */
         window->terminal = reinterpret_cast<VteTerminal*>(vteapp_terminal_new());
 
+        gtk_widget_set_hexpand(GTK_WIDGET(window->terminal), true);
+        gtk_widget_set_vexpand(GTK_WIDGET(window->terminal), true);
+
         auto margin = options.extra_margin;
         if (margin >= 0) {
                 gtk_widget_set_margin_start(GTK_WIDGET(window->terminal), margin);
@@ -2158,8 +2161,8 @@ vteapp_window_constructed(GObject *object)
                 vteapp_window_add_dingus(window, options.dingus);
 
         /* Done! */
-        gtk_box_pack_start(GTK_BOX(window->window_box), GTK_WIDGET(window->terminal),
-                           true, true, 0);
+        gtk_grid_attach(GTK_GRID(window->window_grid), GTK_WIDGET(window->terminal),
+                        0, 0, 1, 1);
         gtk_widget_show(GTK_WIDGET(window->terminal));
 
         window_update_paste_sensitivity(window);
@@ -2256,9 +2259,9 @@ vteapp_window_class_init(VteappWindowClass* klass)
         gtk_widget_class_set_template_from_resource(widget_class, "/org/gnome/vte/app/ui/window.ui");
         gtk_widget_class_set_css_name(widget_class, "vteapp-window");
 
-        gtk_widget_class_bind_template_child(widget_class, VteappWindow, window_box);
+        gtk_widget_class_bind_template_child(widget_class, VteappWindow, window_grid);
         gtk_widget_class_bind_template_child(widget_class, VteappWindow, scrollbar);
-        /* gtk_widget_class_bind_template_child(widget_class, VteappWindow, notification_box); */
+        /* gtk_widget_class_bind_template_child(widget_class, VteappWindow, notification_grid); */
         gtk_widget_class_bind_template_child(widget_class, VteappWindow, readonly_emblem);
         /* gtk_widget_class_bind_template_child(widget_class, VteappWindow, copy_button); */
         /* gtk_widget_class_bind_template_child(widget_class, VteappWindow, paste_button); */
diff --git a/src/app/window.ui b/src/app/window.ui
index 0aea16e5..2d706966 100644
--- a/src/app/window.ui
+++ b/src/app/window.ui
@@ -75,9 +75,13 @@
     <property name="role">vte-terminal</property>
     <property name="icon_name">utilities-terminal</property>
     <child>
-      <object class="GtkBox" id="window_box">
+      <object class="GtkGrid" id="window_grid">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="row_spacing">0</property>
+        <property name="column_spacing">0</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
         <child>
           <placeholder/>
         </child>
@@ -88,18 +92,18 @@
             <property name="orientation">vertical</property>
             <property name="restrict_to_fill_level">False</property>
             <property name="fill_level">0</property>
+            <property name="hexpand">False</property>
+            <property name="vexpand">True</property>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">1</property>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
       </object>
     </child>
     <child type="titlebar">
-      <object class="GtkHeaderBar" id="headerbar1">
+      <object class="GtkHeaderBar" id="headerbar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="show_close_button">True</property>
@@ -191,22 +195,25 @@
           </packing>
         </child>
         <child>
-          <object class="GtkBox" id="notifications_box">
+          <object class="GtkGrid" id="notifications_grid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
+            <property name="column_spacing">6</property>
+            <property name="row_spacing">6</property>
+            <property name="hexpand">False</property>
+            <property name="vexpand">True</property>
             <child>
               <object class="GtkImage" id="readonly_emblem">
                 <property name="can_focus">False</property>
                 <property name="tooltip_text" translatable="yes">Read-only</property>
                 <property name="icon_name">emblem-readonly</property>
                 <property name="use_fallback">True</property>
+                <property name="hexpand">False</property>
+                <property name="vexpand">False</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
           </object>


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