[gnome-todo/wip/gbsneto/subtasks] task-row: show completeness percentage of tasks with subtasks
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/gbsneto/subtasks] task-row: show completeness percentage of tasks with subtasks
- Date: Fri, 21 Oct 2016 02:26:04 +0000 (UTC)
commit 314966ca48c8f88d8ce836410ea22a4e6f1eec8f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Oct 21 00:21:21 2016 -0200
task-row: show completeness percentage of tasks with subtasks
data/ui/task-row.ui | 41 ++++++-----------------------------------
src/gtd-task-row.c | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 35 deletions(-)
---
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index 29b899f..deac6c9 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -112,43 +112,14 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="task_extras_box">
- <property name="visible">False</property>
+ <object class="GtkProgressBar" id="percent_progress">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
<property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkButton" id="task_attachment_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <child>
- <object class="GtkImage" id="task_attachment_button_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">text-x-generic-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="task_alarm_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <child>
- <object class="GtkImage" id="task_alarm_button_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">alarm-symbolic</property>
- </object>
- </child>
- </object>
- </child>
+ <property name="no-show-all">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
</child>
<child>
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index f2770ac..3a81811 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -38,6 +38,7 @@ struct _GtdTaskRow
GtkStack *new_task_stack;
/* task widgets */
+ GtkWidget *percent_progress;
GtkEntry *title_entry;
GtkLabel *task_date_label;
GtkLabel *task_list_label;
@@ -273,6 +274,15 @@ depth_changed_cb (GtdTaskRow *self,
self->handle_subtasks ? 32 * gtd_task_get_depth (task) : 0);
}
+static void
+complete_percentage_changed_cb (GtdTaskRow *self,
+ GParamSpec *pspec,
+ GtdTask *task)
+{
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->percent_progress),
+ gtd_task_get_complete_percentage (task));
+}
+
static gboolean
gtd_task_row__date_changed_binding (GBinding *binding,
const GValue *from_value,
@@ -480,6 +490,10 @@ gtd_task_row_dispose (GObject *object)
self);
g_signal_handlers_disconnect_by_func (task,
+ complete_percentage_changed_cb,
+ self);
+
+ g_signal_handlers_disconnect_by_func (task,
gtd_task_row__priority_changed_cb,
self);
}
@@ -678,6 +692,7 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, stack);
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, new_task_entry);
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, new_task_stack);
+ gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, percent_progress);
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, revealer);
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, task_date_label);
gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, task_list_label);
@@ -822,6 +837,12 @@ gtd_task_row_set_task (GtdTaskRow *row,
"visible",
G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
+ g_object_bind_property (task,
+ "has-subtasks",
+ row->percent_progress,
+ "visible",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
g_object_bind_property_full (task,
"due-date",
row->task_date_label,
@@ -853,6 +874,12 @@ gtd_task_row_set_task (GtdTaskRow *row,
"notify::depth",
G_CALLBACK (depth_changed_cb),
row);
+
+ complete_percentage_changed_cb (row, NULL, task);
+ g_signal_connect_swapped (task,
+ "notify::complete-percentage",
+ G_CALLBACK (complete_percentage_changed_cb),
+ row);
}
g_object_notify (G_OBJECT (row), "task");
@@ -941,6 +968,7 @@ gtd_task_row_set_handle_subtasks (GtdTaskRow *self,
self->handle_subtasks = handle_subtasks;
gtk_widget_set_visible (self->dnd_box, handle_subtasks);
+ gtk_widget_set_visible (self->percent_progress, handle_subtasks && gtd_task_has_subtasks (self->task));
depth_changed_cb (self, NULL, self->task);
g_object_notify (G_OBJECT (self), "handle-subtasks");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]