[gnome-todo] task-row: Bring back DnD frame



commit c5cf88403e88a494807948b20f91f239a1e6cda0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Feb 20 00:32:35 2020 -0300

    task-row: Bring back DnD frame
    
    It doesn't really work, due to GTK not reporting
    the correct sizes for the source row.

 src/task-list-view/gtd-task-list-view.c |  2 +-
 src/task-list-view/gtd-task-row.c       | 16 +++++-----------
 src/task-list-view/gtd-task-row.h       |  2 +-
 3 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/src/task-list-view/gtd-task-list-view.c b/src/task-list-view/gtd-task-list-view.c
index 10ee7b9..89af6e6 100644
--- a/src/task-list-view/gtd-task-list-view.c
+++ b/src/task-list-view/gtd-task-list-view.c
@@ -853,7 +853,7 @@ on_drop_target_drag_motion_cb (GtkDropTarget   *drop_target,
                                     &x_offset,
                                     NULL);
 
-  gtd_task_row_set_drag_offset (highlighted_task_row, drag, x_offset);
+  gtd_task_row_set_drag_offset (highlighted_task_row, source_task_row, x_offset);
   priv->highlighted_row = highlighted_row;
 
 success:
diff --git a/src/task-list-view/gtd-task-row.c b/src/task-list-view/gtd-task-row.c
index a2947c5..a89a836 100644
--- a/src/task-list-view/gtd-task-row.c
+++ b/src/task-list-view/gtd-task-row.c
@@ -874,12 +874,10 @@ gtd_task_row_get_x_offset (GtdTaskRow *self)
 
 void
 gtd_task_row_set_drag_offset (GtdTaskRow *self,
-                              GdkDrag    *drag,
+                              GtdTaskRow *source_row,
                               gint        x_offset)
 {
-#if 0
-  GtkWidget *source_widget;
-  GtkWidget *source_row;
+  GtkRequisition min_size;
   gint current_task_depth;
   gint depth;
 
@@ -889,20 +887,16 @@ gtd_task_row_set_drag_offset (GtdTaskRow *self,
   x_offset = MAX (x_offset, 0);
 
   /* Make the DnD frame match the height of the dragged row */
-  source_widget = gtk_drag_get_source_widget (drag);
-  source_row = gtk_widget_get_ancestor (source_widget, GTD_TYPE_TASK_ROW);
-  gtk_widget_set_size_request (self->dnd_frame, -1, gtk_widget_get_height (source_row));
+  gtk_widget_get_preferred_size (GTK_WIDGET (source_row), &min_size, NULL);
+  gtk_widget_set_size_request (self->dnd_frame, -1, min_size.height);
 
   current_task_depth = gtd_task_get_depth (self->task);
   depth = CLAMP (x_offset / 32, 0, current_task_depth + 1);
   gtk_widget_set_margin_start (self->dnd_frame, depth * 32 + 12);
 
-  GTD_TRACE_MSG ("DnD frame height: %d, depth: %d",
-                 gtk_widget_get_height (source_row),
-                 depth);
+  GTD_TRACE_MSG ("DnD frame height: %d, depth: %d", min_size.height, depth);
 
   gtk_widget_show (self->dnd_frame);
-#endif
 }
 
 void
diff --git a/src/task-list-view/gtd-task-row.h b/src/task-list-view/gtd-task-row.h
index 5471a05..939ae34 100644
--- a/src/task-list-view/gtd-task-row.h
+++ b/src/task-list-view/gtd-task-row.h
@@ -60,7 +60,7 @@ void                      gtd_task_row_set_sizegroups           (GtdTaskRow
 gint                      gtd_task_row_get_x_offset             (GtdTaskRow          *self);
 
 void                      gtd_task_row_set_drag_offset          (GtdTaskRow          *self,
-                                                                 GdkDrag             *drag,
+                                                                 GtdTaskRow          *source_row,
                                                                  gint                 x_offset);
 
 void                      gtd_task_row_unset_drag_offset        (GtdTaskRow          *self);


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