[gnome-todo] task-row, task-list-view: Various dnd fixups
- From: Gitlab Administrative User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task-row, task-list-view: Various dnd fixups
- Date: Sat, 11 Nov 2017 05:23:58 +0000 (UTC)
commit 465167ef4cf0667648e437fc1f3c7275eb3d6aff
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Nov 11 03:23:23 2017 -0200
task-row, task-list-view: Various dnd fixups
src/gtd-dnd-row.c | 17 +++--------------
src/gtd-task-list-view.c | 32 ++++++++++----------------------
src/gtd-task-row.c | 16 ++++++++++++++--
3 files changed, 27 insertions(+), 38 deletions(-)
---
diff --git a/src/gtd-dnd-row.c b/src/gtd-dnd-row.c
index 9207795..ebeabda 100644
--- a/src/gtd-dnd-row.c
+++ b/src/gtd-dnd-row.c
@@ -214,8 +214,6 @@ gtd_dnd_row_drag_motion (GtkWidget *widget,
update_row_padding (self);
- gdk_drag_status (context, GDK_ACTION_COPY, time);
-
return TRUE;
}
@@ -242,10 +240,7 @@ gtd_dnd_row_drag_drop (GtkWidget *widget,
source_widget = gtk_drag_get_source_widget (context);
if (!source_widget)
- {
- gdk_drag_status (context, 0, time);
- return FALSE;
- }
+ return FALSE;
/*
* When the drag operation began, the source row was hidden. Now is the time
@@ -256,10 +251,7 @@ gtd_dnd_row_drag_drop (GtkWidget *widget,
/* Do not allow dropping on itself, nor on the new task row */
if (!row || row == widget || GTD_IS_NEW_TASK_ROW (row))
- {
- gdk_drag_status (context, 0, time);
- return FALSE;
- }
+ return FALSE;
row_task = gtd_task_row_get_task (GTD_TASK_ROW (row));
target_task = get_real_task_for_depth (self);
@@ -268,10 +260,7 @@ gtd_dnd_row_drag_drop (GtkWidget *widget,
{
/* 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;
- }
+ return FALSE;
gtd_task_add_subtask (target_task, row_task);
}
diff --git a/src/gtd-task-list-view.c b/src/gtd-task-list-view.c
index ad49540..3aec962 100644
--- a/src/gtd-task-list-view.c
+++ b/src/gtd-task-list-view.c
@@ -1337,6 +1337,7 @@ listbox_drag_motion (GtkListBox *listbox,
GtkListBoxRow *task_row;
GtkListBoxRow *row_above_dnd;
GtkWidget *source_widget;
+ gboolean success;
gint row_x, row_y, row_height;
priv = gtd_task_list_view_get_instance_private (self);
@@ -1357,6 +1358,8 @@ listbox_drag_motion (GtkListBox *listbox,
gtk_widget_queue_resize (priv->dnd_row);
+ gdk_drag_status (context, GDK_ACTION_MOVE, time);
+
/*
* When not hovering any row, we still have to make sure that the listbox is a valid
* drop target. Otherwise, the user can drop at the space after the rows, and the row
@@ -1424,12 +1427,9 @@ listbox_drag_motion (GtkListBox *listbox,
/* Check if we're not trying to add a subtask */
if (row_above_dnd)
{
- GtkWidget *dnd_widget, *dnd_row;
GtdTask *row_above_task, *dnd_task;
- dnd_widget = gtk_drag_get_source_widget (context);
- dnd_row = gtk_widget_get_ancestor (dnd_widget, GTK_TYPE_LIST_BOX_ROW);
- dnd_task = gtd_task_row_get_task (GTD_TASK_ROW (dnd_row));
+ dnd_task = gtd_task_row_get_task (GTD_TASK_ROW (source_row));
row_above_task = gtd_task_row_get_task (GTD_TASK_ROW (row_above_dnd));
/* Forbid DnD'ing a row into a subtask */
@@ -1450,21 +1450,13 @@ success:
* Also pass the current motion to the DnD row, so it correctly
* adjusts itself - even when the DnD is hovering another row.
*/
- gtd_dnd_row_drag_motion (GTK_WIDGET (priv->dnd_row),
- context,
- x,
- y,
- time);
+ success = gtd_dnd_row_drag_motion (GTK_WIDGET (priv->dnd_row), context, x, y, time);
check_dnd_scroll (self, FALSE, y);
- gdk_drag_status (context, GDK_ACTION_MOVE, time);
-
- return TRUE;
+ return success;
fail:
- gdk_drag_status (context, GDK_ACTION_MOVE, time);
-
return FALSE;
}
@@ -1477,20 +1469,16 @@ listbox_drag_drop (GtkWidget *widget,
GtdTaskListView *self)
{
GtdTaskListViewPrivate *priv;
+ gboolean success;
priv = gtd_task_list_view_get_instance_private (self);
-
- gtd_dnd_row_drag_drop (GTK_WIDGET (priv->dnd_row),
- context,
- x,
- y,
- time);
+ success = gtd_dnd_row_drag_drop (GTK_WIDGET (priv->dnd_row), context, x, y, time);
check_dnd_scroll (self, TRUE, -1);
- gtk_drag_finish (context, TRUE, TRUE, time);
+ gtk_drag_finish (context, success, TRUE, time);
- return TRUE;
+ return success;
}
static void
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 8bf941f..deafa5c 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -85,7 +85,6 @@ enum
static guint signals[NUM_SIGNALS] = { 0, };
-
/*
* Auxiliary methods
*/
@@ -538,8 +537,8 @@ gtd_task_row_set_property (GObject *object,
static void
gtd_task_row_class_init (GtdTaskRowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtd_task_row_dispose;
object_class->finalize = gtd_task_row_finalize;
@@ -874,6 +873,19 @@ gtd_task_row_set_handle_subtasks (GtdTaskRow *self,
gtk_widget_set_visible (self->dnd_event_box, handle_subtasks);
depth_changed_cb (self, NULL, self->task);
+ if (handle_subtasks)
+ {
+ gtk_drag_source_set (self->header_event_box,
+ GDK_BUTTON1_MASK,
+ NULL,
+ 0,
+ GDK_ACTION_MOVE);
+ }
+ else
+ {
+ gtk_drag_source_unset (self->header_event_box);
+ }
+
g_object_notify (G_OBJECT (self), "handle-subtasks");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]