[gnome-todo/wip/gbsneto/subtasks] task-list-view: simplify the drag-motion code
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/gbsneto/subtasks] task-list-view: simplify the drag-motion code
- Date: Tue, 18 Oct 2016 10:58:36 +0000 (UTC)
commit 51bb3a6faca77747e91e48893380025331a6b157
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Oct 15 12:44:49 2016 -0300
task-list-view: simplify the drag-motion code
src/gtd-task-list-view.c | 25 ++++++++++---------------
src/gtd-task-row.c | 22 ----------------------
src/gtd-task-row.h | 3 ---
3 files changed, 10 insertions(+), 40 deletions(-)
---
diff --git a/src/gtd-task-list-view.c b/src/gtd-task-list-view.c
index 5a7bfe2..abf9c30 100644
--- a/src/gtd-task-list-view.c
+++ b/src/gtd-task-list-view.c
@@ -1088,22 +1088,14 @@ gtd_task_list_view_drag_motion (GtkWidget *widget,
*/
if (!hovered_row)
{
- gtd_dnd_row_set_row_above (GTD_DND_ROW (priv->dnd_row), NULL);
gtk_widget_hide (priv->dnd_row);
+ gtd_dnd_row_set_row_above (GTD_DND_ROW (priv->dnd_row), NULL);
- gdk_drag_status (context, GDK_ACTION_COPY, time);
- return TRUE;
- }
-
- task_row = GTD_TASK_ROW (hovered_row);
-
- if (!gtd_task_row_is_drag_valid (task_row, context))
- {
- gdk_drag_status (context, 0, time);
- return FALSE;
+ goto success;
}
row_above_dnd = NULL;
+ task_row = GTD_TASK_ROW (hovered_row);
row_height = gtk_widget_get_allocated_height (GTK_WIDGET (hovered_row));
gtk_widget_translate_coordinates (widget,
GTK_WIDGET (hovered_row),
@@ -1165,11 +1157,10 @@ gtd_task_list_view_drag_motion (GtkWidget *widget,
/* Forbid DnD'ing a row into a subtask */
if (row_above_task && gtd_task_is_subtask (dnd_task, row_above_task))
{
- gtd_dnd_row_set_row_above (GTD_DND_ROW (priv->dnd_row), NULL);
gtk_widget_hide (priv->dnd_row);
+ gtd_dnd_row_set_row_above (GTD_DND_ROW (priv->dnd_row), NULL);
- gdk_drag_status (context, 0, time);
- return FALSE;
+ goto fail;
}
}
@@ -1190,9 +1181,13 @@ gtd_task_list_view_drag_motion (GtkWidget *widget,
y,
time);
+success:
gdk_drag_status (context, GDK_ACTION_COPY, time);
-
return TRUE;
+
+fail:
+ gdk_drag_status (context, 0, time);
+ return FALSE;
}
static gboolean
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 2b0f7b3..2903743 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -922,28 +922,6 @@ gtd_task_row_destroy (GtdTaskRow *self)
}
gboolean
-gtd_task_row_is_drag_valid (GtdTaskRow *self,
- GdkDragContext *context)
-{
- GtdTaskRow *row;
- GtkWidget *source_widget;
- GtdTask *row_task, *target_task;
-
- source_widget = gtk_drag_get_source_widget (context);
-
- if (!source_widget)
- return FALSE;
-
- row = GTD_TASK_ROW (gtk_widget_get_ancestor (source_widget, GTD_TYPE_TASK_ROW));
-
- /* Do not allow dropping on itself, nor on the new task row */
- if (row == self)
- return FALSE;
-
- return TRUE;
-}
-
-gboolean
gtd_task_row_get_handle_subtasks (GtdTaskRow *self)
{
g_return_val_if_fail (GTD_IS_TASK_ROW (self), FALSE);
diff --git a/src/gtd-task-row.h b/src/gtd-task-row.h
index 4d6f053..0394995 100644
--- a/src/gtd-task-row.h
+++ b/src/gtd-task-row.h
@@ -49,9 +49,6 @@ void gtd_task_row_reveal (GtdTaskRow
void gtd_task_row_destroy (GtdTaskRow *row);
-gboolean gtd_task_row_is_drag_valid (GtdTaskRow *self,
- GdkDragContext *context);
-
gboolean gtd_task_row_get_handle_subtasks (GtdTaskRow *self);
void gtd_task_row_set_handle_subtasks (GtdTaskRow *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]