[gnome-todo] task-row: Remove main revealer and reorganize widget tree



commit 26cbf8f5ab7bbe647d1360d13766e3fb83136a3a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Sep 4 23:44:51 2018 -0300

    task-row: Remove main revealer and reorganize widget tree
    
    We don't run an animation when showing the task row anymore, so
    the main revealer was effectively obsolete. Remove it and add a
    vertical GtkBox instead, so the DnD frame can have proper margins.

 data/ui/task-row.ui                     | 32 +++++++++++++++-----------------
 src/task-list-view/gtd-task-list-view.c |  2 --
 src/task-list-view/gtd-task-row.c       | 33 ++++++---------------------------
 src/task-list-view/gtd-task-row.h       |  3 ---
 4 files changed, 21 insertions(+), 49 deletions(-)
---
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index 7be04f9..1291bfc 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -14,14 +14,11 @@
     </child>
 
     <child>
-      <object class="GtkRevealer" id="revealer">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="transition_type">slide-down</property>
-        <property name="transition_duration">200</property>
+      <object class="GtkBox" id="main_box">
+        <property name="orientation">vertical</property>
 
         <child>
-          <object class="GtkBox">
+          <object class="GtkBox" id="content_box">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="orientation">vertical</property>
@@ -140,20 +137,21 @@
               </object>
             </child>
 
-            <!-- Drop indicator -->
-            <child>
-              <object class="GtkBox" id='dnd_frame'>
-                <property name="visible">false</property>
-                <property name="expand">true</property>
-                <property name="margin-start">48</property>
-                <style>
-                  <class name="dnd" />
-                </style>
-              </object>
-            </child>
+          </object>
+        </child>
 
+        <!-- Drop indicator -->
+        <child>
+          <object class="GtkBox" id='dnd_frame'>
+            <property name="visible">false</property>
+            <property name="expand">true</property>
+            <property name="margin-start">48</property>
+            <style>
+              <class name="dnd" />
+            </style>
           </object>
         </child>
+
       </object>
     </child>
   </template>
diff --git a/src/task-list-view/gtd-task-list-view.c b/src/task-list-view/gtd-task-list-view.c
index 29d9390..eb5f81b 100644
--- a/src/task-list-view/gtd-task-list-view.c
+++ b/src/task-list-view/gtd-task-list-view.c
@@ -358,8 +358,6 @@ create_row_for_task_cb (gpointer item,
 
   g_signal_connect (row, "remove-task", G_CALLBACK (on_remove_task_row_cb), self);
 
-  gtd_task_row_reveal (GTD_TASK_ROW (row), FALSE);
-
   listbox_row = gtk_list_box_row_new ();
   gtk_widget_set_halign (listbox_row, GTK_ALIGN_CENTER);
   gtk_container_add (GTK_CONTAINER (listbox_row), row);
diff --git a/src/task-list-view/gtd-task-row.c b/src/task-list-view/gtd-task-row.c
index a24a437..bb3abba 100644
--- a/src/task-list-view/gtd-task-row.c
+++ b/src/task-list-view/gtd-task-row.c
@@ -40,7 +40,8 @@ struct _GtdTaskRow
   GtkBin              parent;
 
   /*<private>*/
-  GtkRevealer        *revealer;
+  GtkWidget          *content_box;
+  GtkWidget          *main_box;
 
   GtkWidget          *done_check;
   GtkWidget          *edit_panel_revealer;
@@ -176,8 +177,6 @@ create_transient_row (GtdTaskRow *self)
   GtdTaskRow *new_row;
 
   new_row = GTD_TASK_ROW (gtd_task_row_new (self->task, self->renderer));
-  gtk_revealer_set_transition_duration (new_row->revealer, 0);
-  gtk_revealer_set_reveal_child (new_row->revealer, TRUE);
 
   gtk_widget_set_size_request (GTK_WIDGET (new_row),
                                gtk_widget_get_allocated_width (GTK_WIDGET (self)),
@@ -308,10 +307,7 @@ on_drag_begin_cb (GtkWidget  *event_box,
    */
   new_row = create_transient_row (self);
 
-  if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
-    x_offset = gtk_widget_get_margin_end (GTK_WIDGET (self->revealer));
-  else
-    x_offset = gtk_widget_get_margin_start (GTK_WIDGET (self->revealer));
+  x_offset = gtk_widget_get_margin_start (self->content_box);
 
   gtk_drag_set_icon_widget (drag,
                             new_row,
@@ -413,7 +409,7 @@ on_depth_changed_cb (GtdTaskRow *self,
   if (self->handle_subtasks)
     margin = 32 * gtd_task_get_depth (task);
 
-  gtk_widget_set_margin_start (GTK_WIDGET (self->revealer), margin);
+  gtk_widget_set_margin_start (self->content_box, margin);
 }
 
 static gboolean
@@ -642,13 +638,14 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/task-row.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, content_box);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, dnd_box);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, dnd_frame);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, dnd_icon);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, done_check);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, edit_panel_revealer);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, header_event_box);
-  gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, revealer);
+  gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, main_box);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, task_date_label);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, task_list_label);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, title_entry);
@@ -750,24 +747,6 @@ gtd_task_row_set_due_date_visible (GtdTaskRow *row,
   gtk_widget_set_visible (GTK_WIDGET (row->task_date_label), show_due_date);
 }
 
-/**
- * gtd_task_row_reveal:
- * @row: a #GtdTaskRow
- *
- * Runs a nifty animation to reveal @row.
- */
-void
-gtd_task_row_reveal (GtdTaskRow *row,
-                     gboolean    animated)
-{
-  g_return_if_fail (GTD_IS_TASK_ROW (row));
-
-  if (!animated)
-    gtk_revealer_set_transition_duration (row->revealer, 0);
-
-  gtk_revealer_set_reveal_child (row->revealer, TRUE);
-}
-
 /**
  * gtd_task_row_destroy:
  * @self: a #GtdTaskRow
diff --git a/src/task-list-view/gtd-task-row.h b/src/task-list-view/gtd-task-row.h
index f145612..5471a05 100644
--- a/src/task-list-view/gtd-task-row.h
+++ b/src/task-list-view/gtd-task-row.h
@@ -41,9 +41,6 @@ void                      gtd_task_row_set_list_name_visible    (GtdTaskRow
 void                      gtd_task_row_set_due_date_visible     (GtdTaskRow          *row,
                                                                  gboolean             show_due_date);
 
-void                      gtd_task_row_reveal                   (GtdTaskRow          *row,
-                                                                 gboolean             animated);
-
 void                      gtd_task_row_destroy                  (GtdTaskRow          *row);
 
 gboolean                  gtd_task_row_get_handle_subtasks      (GtdTaskRow          *self);


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