[gnome-todo] task-row: improve animations even more



commit bdcfed69e00d418b15a614a91281bcc090d706b9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Sep 28 22:20:53 2017 -0300

    task-row: improve animations even more
    
    And this time, we could even simplify the code of
    GtdEditPane

 data/theme/Adwaita.css |   14 +++++---------
 data/ui/edit-pane.ui   |   37 +------------------------------------
 data/ui/task-row.ui    |   36 ++++++++++++++++++++++++++++++++++--
 src/gtd-edit-pane.c    |   37 -------------------------------------
 src/gtd-task-row.c     |   14 +++++++++++---
 5 files changed, 51 insertions(+), 87 deletions(-)
---
diff --git a/data/theme/Adwaita.css b/data/theme/Adwaita.css
index 9309e1d..90076d2 100644
--- a/data/theme/Adwaita.css
+++ b/data/theme/Adwaita.css
@@ -81,6 +81,11 @@ taskrow.priority-hight:dir(rtl)  { border-right: solid 6px #cc0000; padding-righ
 
 taskrow.complete label { text-decoration-line: line-through; }
 
+taskrow entry.title {
+    font-size: 1.1rem;
+    font-weight: bold;
+}
+
 /* dnd row */
 dndrow {
     background-color: rgba(0, 0, 0, 0.1);
@@ -103,15 +108,6 @@ button.circle {
 }
 
 /*
- * Edit Pane
- */
-
-editpane entry.title {
-    font-size: 1.1rem;
-    font-weight: bold;
-}
-
-/*
  * Tasklist view
  */
 tasklistview.dark emptylistwidget label,
diff --git a/data/ui/edit-pane.ui b/data/ui/edit-pane.ui
index 0388749..93f3d12 100644
--- a/data/ui/edit-pane.ui
+++ b/data/ui/edit-pane.ui
@@ -46,48 +46,13 @@
         <property name="row_spacing">6</property>
         <property name="column_spacing">6</property>
         <child>
-          <object class="GtkButton" id="close_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="relief">none</property>
-            <signal name="clicked" handler="close_button_clicked_cb" object="GtdEditPane" swapped="no"/>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="icon-name">window-close-symbolic</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkEntry" id="title_entry">
-            <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="has-frame">False</property>
-            <style>
-              <class name="flat" />
-              <class name="title" />
-            </style>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkSeparator" id="separator">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">1</property>
+            <property name="top_attach">0</property>
             <property name="width">2</property>
           </packing>
         </child>
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index d6b224d..a052e29 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -133,9 +133,42 @@
                 <child>
                   <object class="GtkBox">
                     <property name="visible">True</property>
+                    <property name="margin-end">12</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-top">6</property>
+                    <property name="spacing">6</property>
                     <property name="can_focus">False</property>
 
-                    <!-- TODO: move the title entry to this page -->
+                    <child>
+                      <object class="GtkEntry" id="title_entry">
+                        <property name="visible">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="has-frame">False</property>
+                        <style>
+                          <class name="flat" />
+                          <class name="title" />
+                        </style>
+                      </object>
+                    </child>
+
+                    <child>
+                      <object class="GtkButton" id="close_button">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <signal name="clicked" handler="edit_finished_cb" object="GtdTaskRow" swapped="no"/>
+                        <style>
+                          <class name="flat" />
+                        </style>
+                        <child>
+                          <object class="GtkImage">
+                            <property name="visible">True</property>
+                            <property name="can-focus">False</property>
+                            <property name="icon-name">window-close-symbolic</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
 
                   </object>
                   <packing>
@@ -157,7 +190,6 @@
                   <object class="GtdEditPane" id="edit_panel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <signal name="edit-finished" handler="edit_finished_cb" object="GtdTaskRow" swapped="no" 
/>
                     <signal name="remove-task" handler="remove_task_cb" object="GtdTaskRow" swapped="no" />
                   </object>
                 </child>
diff --git a/src/gtd-edit-pane.c b/src/gtd-edit-pane.c
index e007031..807f2af 100644
--- a/src/gtd-edit-pane.c
+++ b/src/gtd-edit-pane.c
@@ -31,12 +31,10 @@ struct _GtdEditPane
   GtkLabel          *date_label;
   GtkTextView       *notes_textview;
   GtkComboBoxText   *priority_combo;
-  GtkWidget         *title_entry;
 
   /* task bindings */
   GBinding          *notes_binding;
   GBinding          *priority_binding;
-  GBinding          *title_binding;
 
   GtdTask           *task;
 };
@@ -51,7 +49,6 @@ enum {
 
 enum
 {
-  EDIT_FINISHED,
   REMOVE_TASK,
   NUM_SIGNALS
 };
@@ -86,15 +83,6 @@ gtd_edit_pane__delete_button_clicked (GtkButton   *button,
 }
 
 static void
-close_button_clicked_cb (GtkButton   *button,
-                         GtdEditPane *self)
-{
-  save_task (self);
-
-  g_signal_emit (self, signals[EDIT_FINISHED], 0, self->task);
-}
-
-static void
 today_button_clicked (GtkButton   *button,
                       GtdEditPane *self)
 {
@@ -304,22 +292,6 @@ gtd_edit_pane_class_init (GtdEditPaneClass *klass)
                              G_PARAM_READWRITE));
 
   /**
-   * GtdEditPane::edit-finished:
-   *
-   * Emitted when the the user finishes editing the task, i.e. the pane is closed.
-   */
-  signals[EDIT_FINISHED] = g_signal_new ("edit-finished",
-                                         GTD_TYPE_EDIT_PANE,
-                                         G_SIGNAL_RUN_LAST,
-                                         0,
-                                         NULL,
-                                         NULL,
-                                         NULL,
-                                         G_TYPE_NONE,
-                                         1,
-                                         GTD_TYPE_TASK);
-
-  /**
    * GtdEditPane::task-removed:
    *
    * Emitted when the the user finishes wants to remove the task.
@@ -342,9 +314,7 @@ gtd_edit_pane_class_init (GtdEditPaneClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtdEditPane, date_label);
   gtk_widget_class_bind_template_child (widget_class, GtdEditPane, notes_textview);
   gtk_widget_class_bind_template_child (widget_class, GtdEditPane, priority_combo);
-  gtk_widget_class_bind_template_child (widget_class, GtdEditPane, title_entry);
 
-  gtk_widget_class_bind_template_callback (widget_class, close_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, date_selected_cb);
   gtk_widget_class_bind_template_callback (widget_class, gtd_edit_pane__delete_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, gtd_edit_pane__no_date_button_clicked);
@@ -428,13 +398,6 @@ gtd_edit_pane_set_task (GtdEditPane *self,
                                                        "active",
                                                        G_BINDING_BIDIRECTIONAL);
 
-      /* title */
-      self->priority_binding = g_object_bind_property (task,
-                                                       "title",
-                                                       self->title_entry,
-                                                       "text",
-                                                       G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
     }
 
   g_object_notify (G_OBJECT (self), "task");
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index cfa960b..1b908c2 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -37,6 +37,7 @@ struct _GtdTaskRow
   GtkWidget          *done_check;
   GtkWidget          *edit_panel;
   GtkWidget          *edit_panel_revealer;
+  GtkWidget          *title_entry;
   GtkWidget          *stack;
 
   /* task widgets */
@@ -149,10 +150,10 @@ get_dnd_icon (GtdTaskRow *self)
  */
 
 static void
-edit_finished_cb (GtdEditPane *edit_panel,
-                  GtdTask     *task,
-                  GtdTaskRow  *self)
+edit_finished_cb (GtkWidget  *button,
+                  GtdTaskRow *self)
 {
+  gtd_manager_update_task (gtd_manager_get_default (), self->task);
   gtd_task_row_set_active (self, FALSE);
 }
 
@@ -622,6 +623,7 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
   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_label);
+  gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, title_entry);
 
   gtk_widget_class_bind_template_callback (widget_class, button_press_event);
   gtk_widget_class_bind_template_callback (widget_class, complete_check_toggled_cb);
@@ -707,6 +709,12 @@ gtd_task_row_set_task (GtdTaskRow *row,
                               G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
 
       g_object_bind_property (task,
+                              "title",
+                              row->title_entry,
+                              "text",
+                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+      g_object_bind_property (task,
                               "complete",
                               row->done_check,
                               "active",


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