[gnome-todo] task-row: fix animation on remove
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task-row: fix animation on remove
- Date: Thu, 6 Oct 2016 14:12:41 +0000 (UTC)
commit fd86c54875227710b7d6bcc0d2d1781173604585
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Oct 6 11:12:51 2016 -0300
task-row: fix animation on remove
src/gtd-task-list-view.c | 6 ++--
src/gtd-task-row.c | 61 +++++++++++++++++++++++++++-------------------
src/gtd-task-row.h | 2 +
3 files changed, 41 insertions(+), 28 deletions(-)
---
diff --git a/src/gtd-task-list-view.c b/src/gtd-task-list-view.c
index 292aef0..4344954 100644
--- a/src/gtd-task-list-view.c
+++ b/src/gtd-task-list-view.c
@@ -516,7 +516,7 @@ remove_task (GtdTaskListView *view,
g_signal_handlers_disconnect_by_func (gtd_task_row_get_task (l->data),
gtd_task_list_view__task_completed,
view);
- gtk_widget_destroy (l->data);
+ gtd_task_row_destroy (l->data);
}
}
@@ -595,7 +595,7 @@ gtd_task_list_view__remove_row_for_task (GtdTaskListView *view,
if (!gtd_task_row_get_new_task_mode (l->data) &&
gtd_task_row_get_task (l->data) == task)
{
- gtk_widget_destroy (l->data);
+ gtd_task_row_destroy (l->data);
}
}
@@ -1286,7 +1286,7 @@ gtd_task_list_view_set_show_completed (GtdTaskListView *view,
if (!gtd_task_row_get_new_task_mode (l->data) &&
gtd_task_get_complete (gtd_task_row_get_task (l->data)))
{
- gtk_widget_destroy (l->data);
+ gtd_task_row_destroy (l->data);
}
}
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 25db7f6..bbfa799 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -27,7 +27,7 @@ struct _GtdTaskRow
{
GtkListBoxRow parent;
- /*<selfate>*/
+ /*<private>*/
GtkRevealer *revealer;
GtkStack *stack;
@@ -47,6 +47,8 @@ struct _GtdTaskRow
/* data */
gboolean new_task_mode;
GtdTask *task;
+
+ gint destroy_row_timeout_id;
};
#define PRIORITY_ICON_SIZE 8
@@ -183,10 +185,12 @@ gtd_task_row__create_task_for_name (const gchar *name)
return task;
}
-static void
-gtd_task_row__destroy_cb (GtkWidget *widget)
+static gboolean
+gtd_task_row__destroy_cb (GtkWidget *row)
{
- GTK_WIDGET_CLASS (gtd_task_row_parent_class)->destroy (widget);
+ gtk_widget_destroy (row);
+
+ return G_SOURCE_REMOVE;
}
GtkWidget*
@@ -350,26 +354,6 @@ gtd_task_row_activate (GtkListBoxRow *row)
}
static void
-gtd_task_row_destroy (GtkWidget *widget)
-{
- GtdTaskRow *row = GTD_TASK_ROW (widget);
-
- if (!gtk_revealer_get_child_revealed (row->revealer))
- {
- gtd_task_row__destroy_cb (GTK_WIDGET (row));
- }
- else
- {
- g_signal_connect_swapped (row->revealer,
- "notify::child-revealed",
- G_CALLBACK (gtk_widget_destroy),
- row);
-
- gtk_revealer_set_reveal_child (row->revealer, FALSE);
- }
-}
-
-static void
gtd_task_row_class_init (GtdTaskRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -380,7 +364,6 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
object_class->get_property = gtd_task_row_get_property;
object_class->set_property = gtd_task_row_set_property;
- widget_class->destroy = gtd_task_row_destroy;
widget_class->focus_in_event = gtd_task_row__focus_in;
widget_class->key_press_event = gtd_task_row__key_press_event;
@@ -672,3 +655,31 @@ gtd_task_row_reveal (GtdTaskRow *row)
gtk_revealer_set_reveal_child (row->revealer, TRUE);
}
+
+/**
+ * gtd_task_row_destroy:
+ * @self: a #GtdTaskRow
+ *
+ * Destroy @self after hiding it.
+ */
+void
+gtd_task_row_destroy (GtdTaskRow *self)
+{
+ g_return_if_fail (GTD_IS_TASK_ROW (self));
+
+ if (!gtk_revealer_get_child_revealed (self->revealer))
+ {
+ gtk_widget_destroy (GTK_WIDGET (self));
+ }
+ else if (self->destroy_row_timeout_id == 0)
+ {
+ guint duration;
+
+ duration = gtk_revealer_get_transition_duration (self->revealer);
+
+ gtk_revealer_set_reveal_child (self->revealer, FALSE);
+ self->destroy_row_timeout_id = g_timeout_add (duration,
+ (GSourceFunc) gtd_task_row__destroy_cb,
+ self);
+ }
+}
diff --git a/src/gtd-task-row.h b/src/gtd-task-row.h
index 7bfe200..4d536d1 100644
--- a/src/gtd-task-row.h
+++ b/src/gtd-task-row.h
@@ -47,6 +47,8 @@ void gtd_task_row_set_list_name_visible (GtdTaskRow
void gtd_task_row_reveal (GtdTaskRow *row);
+void gtd_task_row_destroy (GtdTaskRow *row);
+
G_END_DECLS
#endif /* GTD_TASK_ROW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]