[gnome-todo] edit-pane: implement new layout



commit 476a915f5e9afe8e9e663e87b8124ad3ff584610
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Oct 15 16:19:22 2017 -0200

    edit-pane: implement new layout
    
    This new layout consumes less vertical width and fits
    better our new inline editing workflow.

 data/ui/edit-pane.ui |  247 +++++++++++++++++++++++---------------------------
 src/gtd-edit-pane.c  |   20 ----
 2 files changed, 112 insertions(+), 155 deletions(-)
---
diff --git a/data/ui/edit-pane.ui b/data/ui/edit-pane.ui
index f04d9ee..11766df 100644
--- a/data/ui/edit-pane.ui
+++ b/data/ui/edit-pane.ui
@@ -1,36 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.16"/>
-  <object class="GtkPopover" id="date_popover">
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
-    <property name="position">bottom</property>
-    <child>
-      <object class="GtkBox" id="date_popover_box">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkCalendar" id="calendar">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="show_week_numbers">True</property>
-            <signal name="day-selected" handler="date_selected_cb" object="GtdEditPane" swapped="no"/>
-          </object>
-        </child>
-        <child>
-          <object class="GtkButton" id="no_date_button">
-            <property name="label" translatable="yes" context="taskdate">None</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <signal name="clicked" handler="gtd_edit_pane__no_date_button_clicked" object="GtdEditPane" 
swapped="no"/>
-          </object>
-        </child>
-      </object>
-    </child>
-  </object>
   <template class="GtdEditPane" parent="GtkGrid">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -41,12 +11,14 @@
       <object class="GtkGrid" id="main_grid">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="expand">True</property>
         <property name="margin-bottom">12</property>
         <property name="margin-start">12</property>
         <property name="margin-end">12</property>
-        <property name="vexpand">True</property>
         <property name="row_spacing">6</property>
-        <property name="column_spacing">6</property>
+        <property name="column_spacing">12</property>
+
+        <!-- Header separator -->
         <child>
           <object class="GtkSeparator" id="separator">
             <property name="visible">True</property>
@@ -58,14 +30,16 @@
             <property name="width">2</property>
           </packing>
         </child>
+
+        <!-- Notes -->
         <child>
-          <object class="GtkGrid" id="grid">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="vexpand">True</property>
-            <property name="row_spacing">12</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
             <child>
-              <object class="GtkLabel" id="notes_dim_label">
+              <object class="GtkLabel">
                 <property name="label" translatable="yes">_Notes</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">notes_textview</property>
@@ -76,19 +50,14 @@
                   <class name="dim-label"/>
                 </style>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">2</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkScrolledWindow" id="notes_scrolled_window">
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
+                <property name="expand">True</property>
                 <property name="can-focus">True</property>
                 <property name="shadow-type">in</property>
-                <property name="min-content-height">150</property>
-                <property name="max-content-height">400</property>
+                <property name="min-content-height">200</property>
                 <child>
                   <object class="GtkTextView" id="notes_textview">
                     <property name="visible">True</property>
@@ -101,12 +70,21 @@
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">2</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <!-- Due date -->
             <child>
               <object class="GtkLabel" id="due_date_dim_label">
                 <property name="label" translatable="yes">D_ue Date</property>
@@ -119,110 +97,37 @@
                   <class name="dim-label"/>
                 </style>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="priority_dim_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">_Priority</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">priority_combo</property>
-                <property name="xalign">0</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-                <property name="width">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBoxText" id="priority_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="active">0</property>
-                <items>
-                  <item translatable="yes" context="taskpriority">None</item>
-                  <item translatable="yes">Low</item>
-                  <item translatable="yes">Medium</item>
-                  <item translatable="yes">High</item>
-                </items>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">5</property>
-                <property name="width">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="remove_button">
-                <property name="label" translatable="yes">_Delete</property>
-                <property name="use_underline">True</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="halign">start</property>
-                <signal name="clicked" handler="gtd_edit_pane__delete_button_clicked" object="GtdEditPane" 
swapped="no" />
-                <style>
-                  <class name="destructive-action"/>
-                </style>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">6</property>
-                <property name="width">2</property>
-              </packing>
             </child>
+
             <child>
-              <object class="GtkBox" id="date_select_box">
+              <object class="GtkBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkButton" id="gtd_set_date_today">
+                  <object class="GtkButton">
                     <property name="label" translatable="yes">_Today</property>
                     <property name="use_underline">True</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="hexpand">True</property>
                     <signal name="clicked" handler="today_button_clicked" object="GtdEditPane" swapped="no" 
/>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkButton" id="tomorrow_button">
+                  <object class="GtkButton">
                     <property name="label" translatable="yes">To_morrow</property>
                     <property name="use_underline">True</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="hexpand">True</property>
                     <signal name="clicked" handler="tomorrow_button_clicked" object="GtdEditPane" 
swapped="no"/>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkButton" id="next_week_button">
-                    <property name="label" translatable="yes">Next _Week</property>
-                    <property name="use_underline">True</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="hexpand">True</property>
-                    <signal name="clicked" handler="next_week_button_clicked" object="GtdEditPane" 
swapped="no"/>
-                  </object>
-                </child>
-                <child>
                   <object class="GtkMenuButton" id="date_button">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="hexpand">True</property>
                     <property name="popover">date_popover</property>
                     <child>
                       <object class="GtkBox" id="date_button_box">
@@ -233,7 +138,6 @@
                           <object class="GtkLabel" id="date_label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="hexpand">True</property>
                             <property name="width-chars">10</property>
                           </object>
                         </child>
@@ -252,22 +156,95 @@
                   <class name="linked"/>
                 </style>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">3</property>
-              </packing>
             </child>
+
+            <!-- Priority -->
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Priority</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">priority_combo</property>
+                <property name="margin-top">12</property>
+                <property name="xalign">0</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+
             <child>
-              <placeholder/>
+              <object class="GtkComboBoxText" id="priority_combo">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="active">0</property>
+                <items>
+                  <item translatable="yes" context="taskpriority">None</item>
+                  <item translatable="yes">Low</item>
+                  <item translatable="yes">Medium</item>
+                  <item translatable="yes">High</item>
+                </items>
+              </object>
             </child>
+
+            <!-- Delete button -->
+            <child>
+              <object class="GtkButton" id="remove_button">
+                <property name="label" translatable="yes">_Delete</property>
+                <property name="use_underline">True</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="vexpand">True</property>
+                <property name="valign">end</property>
+                <property name="halign">end</property>
+                <property name="margin-top">12</property>
+                <signal name="clicked" handler="gtd_edit_pane__delete_button_clicked" object="GtdEditPane" 
swapped="no" />
+                <style>
+                  <class name="destructive-action"/>
+                </style>
+              </object>
+            </child>
+
           </object>
           <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">2</property>
-            <property name="width">2</property>
+            <property name="left_attach">1</property>
+            <property name="top_attach">1</property>
           </packing>
         </child>
+
       </object>
     </child>
   </template>
+  <object class="GtkPopover" id="date_popover">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="position">bottom</property>
+    <child>
+      <object class="GtkBox" id="date_popover_box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkCalendar" id="calendar">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="show_week_numbers">True</property>
+            <signal name="day-selected" handler="date_selected_cb" object="GtdEditPane" swapped="no"/>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton" id="no_date_button">
+            <property name="label" translatable="yes" context="taskdate">None</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <signal name="clicked" handler="gtd_edit_pane__no_date_button_clicked" object="GtdEditPane" 
swapped="no"/>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
 </interface>
diff --git a/src/gtd-edit-pane.c b/src/gtd-edit-pane.c
index 807f2af..c1d1160 100644
--- a/src/gtd-edit-pane.c
+++ b/src/gtd-edit-pane.c
@@ -118,25 +118,6 @@ tomorrow_button_clicked (GtkButton   *button,
 }
 
 static void
-next_week_button_clicked (GtkButton   *button,
-                          GtdEditPane *self)
-{
-  GDateTime *current_date;
-  GDateTime *new_dt;
-
-  current_date = g_date_time_new_now_local ();
-  new_dt = g_date_time_add_days (current_date, 7);
-
-  gtd_task_set_due_date (self->task, new_dt);
-  gtd_edit_pane_update_date (self);
-
-  save_task (self);
-
-  g_clear_pointer (&current_date, g_date_time_unref);
-  g_clear_pointer (&new_dt, g_date_time_unref);
-}
-
-static void
 gtd_edit_pane_update_date (GtdEditPane *self)
 {
   GDateTime *dt;
@@ -318,7 +299,6 @@ gtd_edit_pane_class_init (GtdEditPaneClass *klass)
   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);
-  gtk_widget_class_bind_template_callback (widget_class, next_week_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, today_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, tomorrow_button_clicked);
 


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