[gnome-system-monitor: 1/2] Avoid resizing the CPU usage labels when their text changes




commit 1efb4789550b713f41fe7513706fc1b76758f963
Author: James Legg <lankyleggy gmail com>
Date:   Fri Jun 26 22:55:46 2020 +0100

    Avoid resizing the CPU usage labels when their text changes
    
    As the number of digits in the CPU usage labels vary, their width was
    varying too. When the window was narrow enough to be around the
    natural width of the graphs, this could cause the width of all the
    graphs on the Resources tab to resize.
    
    Set a desired width of 6 characters on these labels. This is hopefully
    enough for all values ("100.0%" is probably the longest), preventing
    the size changing with the value, but it may vary depending on font.
    
    Fixes #149, assuming the other regularly changing labels are not the
    limiting factor in the width of the Resources tab.

 src/interface.cpp | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/interface.cpp b/src/interface.cpp
index 2e3e5d4b..fac941c1 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -244,6 +244,8 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
 
         cpu_label = GTK_LABEL (gtk_label_new (NULL));
 
+        /* Reserve some space to avoid the layout changing with the values. */
+        gtk_label_set_width_chars(cpu_label, 6);
         gtk_widget_set_valign (GTK_WIDGET (cpu_label), GTK_ALIGN_CENTER);
         gtk_widget_set_halign (GTK_WIDGET (cpu_label), GTK_ALIGN_START);
         gtk_box_pack_start (temp_hbox, GTK_WIDGET (cpu_label), FALSE, FALSE, 0);


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