[gnome-todo/wip/gbsneto/subtasks] grid-item: consider the depth of the task when creating the icon



commit be89facb49c26e00f665967f4d622245507fb1ef
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Oct 14 13:06:59 2016 -0300

    grid-item: consider the depth of the task when creating the icon

 src/views/gtd-list-selector-grid-item.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/views/gtd-list-selector-grid-item.c b/src/views/gtd-list-selector-grid-item.c
index e614b96..a8debea 100644
--- a/src/views/gtd-list-selector-grid-item.c
+++ b/src/views/gtd-list-selector-grid-item.c
@@ -159,7 +159,9 @@ gtd_list_selector_grid_item__render_thumbnail (GtdListSelectorGridItem *item)
 
       for (l = tasks; l != NULL; l = l->next)
         {
-          gint font_height;
+          GString *string;
+          gchar *formatted_title;
+          gint i, font_height;
 
           /* Don't render completed tasks */
           if (gtd_task_get_complete (l->data))
@@ -168,14 +170,27 @@ gtd_list_selector_grid_item__render_thumbnail (GtdListSelectorGridItem *item)
           /* Hardcoded spacing between tasks */
           y += 4;
 
+          /* Adjust the title according to the subtask hierarchy */
+          string = g_string_new ("");
+
+          for (i = 0; i < gtd_task_get_depth (l->data); i++)
+            g_string_append (string, "    ");
+
+          g_string_append (string, gtd_task_get_title (l->data));
+
+          formatted_title = g_string_free (string, FALSE);
+
+          /* Set the real title */
           pango_layout_set_text (layout,
-                                 gtd_task_get_title (l->data),
+                                 formatted_title,
                                  -1);
 
           pango_layout_get_pixel_size (layout,
                                        NULL,
                                        &font_height);
 
+          g_free (formatted_title);
+
           /*
            * If we reach the last visible row, it should draw a
            * "…" mark and stop drawing anything else


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