[gnome-todo/wip/gbsneto/subtasks: 15/27] task-row: forbid making a parent task a subtask of a subtask



commit c3fd45853c8deef4e280c761f7d281566d5481aa
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 11 10:21:04 2016 -0300

    task-row: forbid making a parent task a subtask of a subtask
    
    This would create a loop that would make To Do unusable :)

 src/gtd-task-row.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 396a344..4ad24f4 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -535,6 +535,13 @@ gtd_task_row_drag_drop (GtkWidget      *widget,
   row_task = GTD_TASK_ROW (row)->task;
   target_task = GTD_TASK_ROW (widget)->task;
 
+  /* Forbid adding the parent task as a subtask */
+  if (gtd_task_is_subtask (row_task, target_task))
+    {
+      gdk_drag_status (context, 0, time);
+      return FALSE;
+    }
+
   gtd_task_add_subtask (target_task, row_task);
 
   /* Save the task */
@@ -562,6 +569,7 @@ gtd_task_row_drag_motion (GtkWidget      *widget,
                           guint           time)
 {
   GtkWidget *source_widget, *row;
+  GtdTask *row_task, *target_task;
 
   row = NULL;
   source_widget = gtk_drag_get_source_widget (context);
@@ -581,6 +589,16 @@ gtd_task_row_drag_motion (GtkWidget      *widget,
       return FALSE;
     }
 
+  row_task = GTD_TASK_ROW (row)->task;
+  target_task = GTD_TASK_ROW (widget)->task;
+
+  /* Forbid adding the parent task as a subtask */
+  if (gtd_task_is_subtask (row_task, target_task))
+    {
+      gdk_drag_status (context, 0, time);
+      return FALSE;
+    }
+
   gdk_drag_status (context, GDK_ACTION_COPY, time);
   gtk_drag_highlight (widget);
 


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