From 2e87fbdf79b41314ef84b695705e20d5c38ffe31 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Thu, 13 Sep 2018 00:45:27 +0200
Subject: Updated diagram sizes on value updates.

---
 src/gtkext/diagram.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/gtkext/diagram.c b/src/gtkext/diagram.c
index 760e3ae..395d019 100644
--- a/src/gtkext/diagram.c
+++ b/src/gtkext/diagram.c
@@ -642,6 +642,7 @@ static GtkSizeRequestMode gtk_diagram_get_request_mode(GtkWidget *widget)
 
 static void gtk_diagram_get_preferred_width_for_height(GtkWidget *widget, gint height, gint *minimum, gint *natural)
 {
+    GdkWindow *window;                      /* FenĂȘtre du composant        */
     GtkDiagram *diagram;                    /* Autre version du composant  */
     gint text_width;                        /* Plus grande longueur        */
     cairo_surface_t *surface;               /* Espace graphique de support */
@@ -649,6 +650,14 @@ static void gtk_diagram_get_preferred_width_for_height(GtkWidget *widget, gint h
     size_t i;                               /* Boucle de parcours          */
     cairo_text_extents_t extents;           /* Taille de la police         */
 
+    window = gtk_widget_get_window(widget);
+
+    if (window == NULL)
+    {
+        *minimum = 1;
+        goto conclusion;
+    }
+
     diagram = GTK_DIAGRAM(widget);
 
     text_width = 0;
@@ -703,6 +712,8 @@ static void gtk_diagram_get_preferred_width_for_height(GtkWidget *widget, gint h
     cairo_destroy(cr);
     cairo_surface_destroy(surface);
 
+ conclusion:
+
     /* RĂ©percution */
 
     *natural = *minimum;
@@ -738,6 +749,8 @@ void gtk_diagram_clear_stats(GtkDiagram *diagram)
     diagram->stats = NULL;
     diagram->count = 0;
 
+    gtk_widget_queue_resize(GTK_WIDGET(diagram));
+
 }
 
 
@@ -780,4 +793,6 @@ void gtk_diagram_add_stats(GtkDiagram *diagram, const diagram_stat_t *stats, siz
 
     diagram->count += count;
 
+    gtk_widget_queue_resize(GTK_WIDGET(diagram));
+
 }
-- 
cgit v0.11.2-87-g4458