From 771c2ef3baa1f5caf8fe290e6610457763725c07 Mon Sep 17 00:00:00 2001
From: Bruce Cowan <bruce@bcowan.eu>
Date: Mon, 1 Jan 2018 13:18:29 +0000
Subject: [PATCH] Better tooltip (closes #4)

Still does things like '1 tries' though
---
 src/rugby-score-store.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/rugby-score-store.c b/src/rugby-score-store.c
index c907f6c..e17933f 100644
--- a/src/rugby-score-store.c
+++ b/src/rugby-score-store.c
@@ -100,15 +100,25 @@ populate_store_foreach (gpointer data,
     gint utries = possiblity->utries;
     gint kicks = possiblity->kicks;
 
-    g_autofree gchar *tooltip = g_strdup_printf ("%d tries, %d converted, %d kicks",
-                                                 tries, utries, kicks);
+    g_autoptr (GString) string = g_string_new (NULL);
+
+    if (tries > 0 || utries > 0)
+        g_string_append_printf (string, "%d tries, %d converted",
+                                tries + utries, tries);
+    if (kicks > 0)
+    {
+        if (string->len == 0)
+            g_string_append_printf (string, "%d kicks", kicks);
+        else
+            g_string_append_printf (string, ", %d kicks", kicks);
+    }
 
     gtk_list_store_append (store, &iter);
     gtk_list_store_set (store, &iter,
                         RUGBY_SCORE_STORE_TRIES, tries,
                         RUGBY_SCORE_STORE_UTRIES, utries,
                         RUGBY_SCORE_STORE_KICKS, kicks,
-                        RUGBY_SCORE_STORE_TOOLTIP, tooltip,
+                        RUGBY_SCORE_STORE_TOOLTIP, string->str,
                         -1);
 }
 
-- 
GitLab