[gnome-todo/wip/gbsneto/row-header-improvements: 4/4] task-row: Reorganize header



commit 53c3ea5709bb2a848c3e65141e96542be573d3b2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Oct 29 17:04:03 2017 -0200

    task-row: Reorganize header
    
    This commit removes the GtkStack from GtdTaskRow, and exposes
    the title entry (that is now a GtdExpandableEntry) directly
    in the title.
    
    This effectively implements the proposed behavior of #107

 data/theme/Adwaita.css |   4 ++
 data/ui/task-row.ui    | 106 +++++++++++++++++++------------------------------
 src/gtd-task-row.c     |  24 ++---------
 3 files changed, 48 insertions(+), 86 deletions(-)
---
diff --git a/data/theme/Adwaita.css b/data/theme/Adwaita.css
index 967c21e..5b658e6 100644
--- a/data/theme/Adwaita.css
+++ b/data/theme/Adwaita.css
@@ -81,6 +81,10 @@ taskrow.priority-medium:dir(rtl) { border-right: solid 6px #f57900; padding-righ
 taskrow.priority-hight:dir(ltr)  { border-left:  solid 6px #cc0000; padding-left:  0; }
 taskrow.priority-hight:dir(rtl)  { border-right: solid 6px #cc0000; padding-right: 0; }
 
+/* task title entry */
+taskrow:not(.new-task-row) entry                   { border: solid 1px transparent; }
+taskrow:not(.new-task-row) entry:hover:not(:focus) { border: solid 1px @borders; }
+
 taskrow.complete label { text-decoration-line: line-through; }
 
 taskrow .close-button.active > image { transition: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94); 
-gtk-icon-transform: rotate(-0.5turn); }
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index ac6d6b5..874e536 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -76,83 +76,57 @@
                 </child>
 
                 <child>
-                  <object class="GtkStack" id="stack">
+                  <object class="GtkEventBox">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="interpolate-size">True</property>
-                    <property name="homogeneous">False</property>
-                    <property name="transition-type">crossfade</property>
-                    <property name="transition-duration">200</property>
-
-                    <!-- Main page, visible when the task row is unfocused -->
+                    <signal name="enter-notify-event" handler="mouse_over_event_cb" object="GtdTaskRow" 
swapped="no" />
+                    <signal name="leave-notify-event" handler="mouse_out_event_cb" object="GtdTaskRow" 
swapped="no" />
                     <child>
-                      <object class="GtkEventBox">
+                      <object class="GtkBox">
                         <property name="visible">True</property>
-                        <signal name="enter-notify-event" handler="mouse_over_event_cb" object="GtdTaskRow" 
swapped="no" />
-                        <signal name="leave-notify-event" handler="mouse_out_event_cb" object="GtdTaskRow" 
swapped="no" />
+                        <property name="can_focus">False</property>
+
+                        <!-- Task title entry -->
                         <child>
-                          <object class="GtkBox">
+                          <object class="GtdExpandableEntry" id="title_entry">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-
-                            <child>
-                              <object class="GtkLabel" id="title_label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="hexpand">True</property>
-                                <property name="ellipsize">end</property>
-                                <property name="margin-start">6</property>
-                                <property name="xalign">0.0</property>
-                              </object>
-                            </child>
-
-                            <child>
-                              <object class="GtkLabel" id="task_date_label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1.0</property>
-                                <style>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="task_list_label">
-                                <property name="visible">False</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
-                                <property name="max_width_chars">18</property>
-                                <property name="ellipsize">middle</property>
-                                <style>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                            </child>
+                            <property name="hexpand">True</property>
+                            <property name="halign">start</property>
+                            <property name="width-chars">5</property>
+                            <property name="propagate-natural-width">True</property>
+                            <property name="has-frame">False</property>
+                            <style>
+                              <class name="flat" />
+                              <class name="title" />
+                            </style>
+                          </object>
+                        </child>
 
+                        <child>
+                          <object class="GtkLabel" id="task_date_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">1.0</property>
+                            <property name="margin-start">6</property>
+                            <style>
+                              <class name="dim-label"/>
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="task_list_label">
+                            <property name="visible">False</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="max_width_chars">18</property>
+                            <property name="ellipsize">middle</property>
+                            <style>
+                              <class name="dim-label"/>
+                            </style>
                           </object>
                         </child>
-                      </object>
-                      <packing>
-                        <property name="name">unfocused</property>
-                      </packing>
-                    </child>
 
-                    <!-- Edit header 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>
-                      <packing>
-                        <property name="name">edit</property>
-                      </packing>
                     </child>
-
                   </object>
                 </child>
 
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 64c2869..84a1c83 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -17,6 +17,7 @@
  */
 
 #include "gtd-edit-pane.h"
+#include "gtd-expandable-entry.h"
 #include "gtd-manager.h"
 #include "gtd-provider.h"
 #include "gtd-rows-common-private.h"
@@ -40,10 +41,8 @@ struct _GtdTaskRow
   GtkWidget          *edit_panel_revealer;
   GtkWidget          *title_entry;
   GtkWidget          *toggle_button;
-  GtkWidget          *stack;
 
   /* task widgets */
-  GtkEntry           *title_label;
   GtkLabel           *task_date_label;
   GtkLabel           *task_list_label;
 
@@ -532,6 +531,8 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
   widget_class->key_press_event = gtd_task_row__key_press_event;
   widget_class->get_preferred_width = gtd_row_get_preferred_width_with_max;
 
+  g_type_ensure (GTD_TYPE_EXPANDABLE_ENTRY);
+
   /**
    * GtdTaskRow::handle-subtasks:
    *
@@ -614,10 +615,8 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, edit_panel);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, edit_panel_revealer);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, revealer);
-  gtk_widget_class_bind_template_child (widget_class, GtdTaskRow, stack);
   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_child (widget_class, GtdTaskRow, toggle_button);
 
@@ -701,12 +700,6 @@ gtd_task_row_set_task (GtdTaskRow *row,
 
       g_object_bind_property (task,
                               "title",
-                              row->title_label,
-                              "label",
-                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
-      g_object_bind_property (task,
-                              "title",
                               row->title_entry,
                               "text",
                               G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -889,16 +882,7 @@ gtd_task_row_set_active (GtdTaskRow *self,
   /* And the listbox */
   gtk_revealer_set_reveal_child (GTK_REVEALER (self->edit_panel_revealer), active);
 
-  if (active)
-    {
-      gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "edit");
-      g_signal_emit (self, signals[ENTER], 0);
-    }
-  else
-    {
-      gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "unfocused");
-      g_signal_emit (self, signals[EXIT], 0);
-    }
+  g_signal_emit (self, active ? signals[ENTER] : signals[EXIT], 0);
 }
 
 void


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