[sysprof/wip/gtk4-port: 103/132] memprofpage: use Adwaita and cleanup usage




commit 3c76b8a20dd810b3f2fba13628b32e0358e029a4
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 1 13:37:29 2021 -0700

    memprofpage: use Adwaita and cleanup usage

 src/libsysprof-ui/sysprof-memprof-page.c  |  24 ++++---
 src/libsysprof-ui/sysprof-memprof-page.ui | 109 +++++++++++++-----------------
 2 files changed, 64 insertions(+), 69 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-memprof-page.c b/src/libsysprof-ui/sysprof-memprof-page.c
index 1e459292..352e72a8 100644
--- a/src/libsysprof-ui/sysprof-memprof-page.c
+++ b/src/libsysprof-ui/sysprof-memprof-page.c
@@ -67,6 +67,10 @@ typedef struct
   GtkLabel                 *leaked_allocs;
   GtkLabel                 *peak_allocs;
   GtkListBox               *by_size;
+  GtkWidget                *callgraph;
+  GtkWidget                *summary_page;
+  GtkWidget                *loading_state;
+  GtkWidget                *empty_state;
 
   GCancellable             *cancellable;
 
@@ -307,7 +311,7 @@ sysprof_memprof_page_load (SysprofMemprofPage    *self,
 
   if (sysprof_memprof_profile_is_empty (profile))
     {
-      gtk_stack_set_visible_child_name (priv->stack, "summary");
+      gtk_stack_set_visible_child (priv->stack, priv->summary_page);
       return;
     }
 
@@ -342,7 +346,7 @@ sysprof_memprof_page_load (SysprofMemprofPage    *self,
       gtk_tree_selection_select_iter (selection, &iter);
     }
 
-  gtk_stack_set_visible_child_name (priv->stack, "callgraph");
+  gtk_stack_set_visible_child (priv->stack, priv->callgraph);
 
   g_clear_object (&functions);
 }
@@ -354,7 +358,7 @@ _sysprof_memprof_page_set_failed (SysprofMemprofPage *self)
 
   g_return_if_fail (SYSPROF_IS_MEMPROF_PAGE (self));
 
-  gtk_stack_set_visible_child_name (priv->stack, "empty-state");
+  gtk_stack_set_visible_child (priv->stack, priv->empty_state);
 }
 
 static void
@@ -373,7 +377,7 @@ sysprof_memprof_page_unload (SysprofMemprofPage *self)
   gtk_tree_view_set_model (priv->functions_view, NULL);
   gtk_tree_view_set_model (priv->descendants_view, NULL);
 
-  gtk_stack_set_visible_child_name (priv->stack, "empty-state");
+  gtk_stack_set_visible_child (priv->stack, priv->empty_state);
 }
 
 /**
@@ -971,7 +975,7 @@ sysprof_memprof_page_load_async (SysprofPage             *page,
   else
     g_set_object (&priv->cancellable, cancellable);
 
-  gtk_stack_set_visible_child_name (priv->stack, "loading");
+  gtk_stack_set_visible_child (priv->stack, priv->loading_state);
 
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_source_tag (task, sysprof_memprof_page_load_async);
@@ -1149,6 +1153,10 @@ sysprof_memprof_page_class_init (SysprofMemprofPageClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, leaked_allocs);
   gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, leaked_allocs_button);
   gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, peak_allocs);
+  gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, loading_state);
+  gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, empty_state);
+  gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, summary_page);
+  gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, callgraph);
 
   gtk_widget_class_install_action (widget_class, "page.copy", NULL, sysprof_memprof_page_copy_cb);
 
@@ -1170,7 +1178,7 @@ sysprof_memprof_page_init (SysprofMemprofPage *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  gtk_stack_set_visible_child_name (priv->stack, "empty-state");
+  gtk_stack_set_visible_child (priv->stack, priv->empty_state);
 
   gtk_list_box_set_header_func (priv->by_size, sep_header_func, NULL, NULL);
 
@@ -1530,7 +1538,7 @@ _sysprof_memprof_page_set_loading (SysprofMemprofPage *self,
     priv->loading--;
 
   if (priv->loading)
-    gtk_stack_set_visible_child_name (priv->stack, "loading");
+    gtk_stack_set_visible_child (priv->stack, priv->loading_state);
   else
-    gtk_stack_set_visible_child_name (priv->stack, "callgraph");
+    gtk_stack_set_visible_child (priv->stack, priv->callgraph);
 }
diff --git a/src/libsysprof-ui/sysprof-memprof-page.ui b/src/libsysprof-ui/sysprof-memprof-page.ui
index 08cb8758..ef72bfb5 100644
--- a/src/libsysprof-ui/sysprof-memprof-page.ui
+++ b/src/libsysprof-ui/sysprof-memprof-page.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="SysprofMemprofPage" parent="SysprofPage">
     <child>
@@ -67,7 +68,7 @@
           <object class="GtkStack" id="stack">
             <property name="visible">true</property>
             <child>
-              <object class="GtkScrolledWindow">
+              <object class="GtkScrolledWindow" id="summary_page">
                 <property name="hscrollbar-policy">never</property>
                 <property name="visible">true</property>
                 <child>
@@ -79,7 +80,7 @@
                     <property name="orientation">vertical</property>
                     <property name="visible">true</property>
                     <child>
-                      <object class="DzlThreeGrid">
+                      <object class="EggThreeGrid">
                         <property name="expand">true</property>
                         <property name="row-spacing">6</property>
                         <property name="column-spacing">18</property>
@@ -92,22 +93,22 @@
                             <style>
                               <class name="dim-label"/>
                             </style>
+                            <layout>
+                              <property name="column">left</property>
+                              <property name="row">0</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">left</property>
-                            <property name="row">0</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="peak_allocs">
                             <property name="xalign">0</property>
                             <property name="selectable">true</property>
                             <property name="visible">false</property>
+                            <layout>
+                              <property name="column">center</property>
+                              <property name="row">0</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">center</property>
-                            <property name="row">0</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel">
@@ -117,22 +118,22 @@
                             <style>
                               <class name="dim-label"/>
                             </style>
+                            <layout>
+                              <property name="column">left</property>
+                              <property name="row">1</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">left</property>
-                            <property name="row">1</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="num_allocs">
                             <property name="xalign">0</property>
                             <property name="selectable">true</property>
                             <property name="visible">true</property>
+                            <layout>
+                              <property name="column">center</property>
+                              <property name="row">1</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">center</property>
-                            <property name="row">1</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel">
@@ -142,22 +143,22 @@
                             <style>
                               <class name="dim-label"/>
                             </style>
+                            <layout>
+                              <property name="column">left</property>
+                              <property name="row">2</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">left</property>
-                            <property name="row">2</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="leaked_allocs">
                             <property name="xalign">0</property>
                             <property name="selectable">true</property>
                             <property name="visible">false</property>
+                            <layout>
+                              <property name="column">center</property>
+                              <property name="row">2</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">center</property>
-                            <property name="row">2</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel">
@@ -167,11 +168,11 @@
                             <style>
                               <class name="dim-label"/>
                             </style>
+                            <layout>
+                              <property name="column">left</property>
+                              <property name="row">3</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">left</property>
-                            <property name="row">3</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="temp_allocs_count">
@@ -179,11 +180,11 @@
                             <property name="selectable">true</property>
                             <property name="width-chars">50</property>
                             <property name="visible">true</property>
+                            <layout>
+                              <property name="column">center</property>
+                              <property name="row">3</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">center</property>
-                            <property name="row">3</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkLabel">
@@ -194,11 +195,11 @@
                             <style>
                               <class name="dim-label"/>
                             </style>
+                            <layout>
+                              <property name="column">left</property>
+                              <property name="row">4</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">left</property>
-                            <property name="row">4</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkFrame">
@@ -208,23 +209,20 @@
                                 <property name="visible">true</property>
                               </object>
                             </child>
+                            <layout>
+                              <property name="column">center</property>
+                              <property name="row">4</property>
+                            </layout>
                           </object>
-                          <packing>
-                            <property name="column">center</property>
-                            <property name="row">4</property>
-                          </packing>
                         </child>
                       </object>
                     </child>
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="name">summary</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkPaned">
+              <object class="GtkPaned" id="callgraph">
                 <property name="orientation">horizontal</property>
                 <property name="position">450</property>
                 <property name="expand">true</property>
@@ -424,31 +422,20 @@
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="name">callgraph</property>
-              </packing>
             </child>
             <child>
-              <object class="DzlEmptyState">
+              <object class="AdwStatusPage" id="loading_state">
                 <property name="icon-name">content-loading-symbolic</property>
                 <property name="title" translatable="yes">Analyzing Memory Allocations</property>
-                <property name="subtitle" translatable="yes">Sysprof is busy analyzing memory 
allocations.</property>
-                <property name="visible">true</property>
+                <property name="description" translatable="yes">Sysprof is busy analyzing memory 
allocations.</property>
               </object>
-              <packing>
-                <property name="name">loading</property>
-              </packing>
             </child>
             <child>
-              <object class="DzlEmptyState">
+              <object class="AdwStatusPage" id="empty_state">
                 <property name="icon-name">computer-fail-symbolic</property>
                 <property name="title" translatable="yes">Not Enough Samples</property>
-                <property name="subtitle" translatable="yes">More samples are necessary to display a 
callgraph.</property>
-                <property name="visible">false</property>
+                <property name="description" translatable="yes">More samples are necessary to display a 
callgraph.</property>
               </object>
-              <packing>
-                <property name="name">empty-state</property>
-              </packing>
             </child>
           </object>
         </child>


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