[gnome-todo/wip/gbsneto/subtasks: 19/27] dnd-row: improve the behavior when moving DnD



commit 9fa840e2547f95d69a1afb48971951b591f6677e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Oct 14 01:50:06 2016 -0300

    dnd-row: improve the behavior when moving DnD

 data/ui/dnd-row.ui |    2 +-
 src/gtd-dnd-row.c  |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/dnd-row.ui b/data/ui/dnd-row.ui
index c94544f..304785c 100644
--- a/data/ui/dnd-row.ui
+++ b/data/ui/dnd-row.ui
@@ -6,7 +6,7 @@
     <property name="activatable">False</property>
     <property name="selectable">False</property>
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="box">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="margin_start">24</property>
diff --git a/src/gtd-dnd-row.c b/src/gtd-dnd-row.c
index d6aa245..a8f8077 100644
--- a/src/gtd-dnd-row.c
+++ b/src/gtd-dnd-row.c
@@ -28,6 +28,7 @@ struct _GtdDndRow
 {
   GtkListBoxRow       parent;
 
+  GtkWidget          *box;
   GtkWidget          *icon;
 
   GtdTaskRow         *row_above;
@@ -140,9 +141,13 @@ gtd_dnd_row_drag_motion (GtkWidget      *widget,
   if (self->row_above)
     {
       GtdTask *task;
+      gint offset;
 
       task = gtd_task_row_get_task (self->row_above);
-      self->depth = CLAMP (floor (x / 32), 0, gtd_task_get_depth (task) + 1);
+      offset = gtk_widget_get_margin_start (self->box) + gtk_widget_get_allocated_width (self->icon) + 12;
+      self->depth = CLAMP (floor ((x - offset) / 32),
+                           0,
+                           gtd_task_get_depth (task) + 1);
     }
   else
     {
@@ -259,6 +264,7 @@ gtd_dnd_row_class_init (GtdDndRowClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/dnd-row.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, GtdDndRow, box);
   gtk_widget_class_bind_template_child (widget_class, GtdDndRow, icon);
 
   gtk_widget_class_set_css_name (widget_class, "dndrow");


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