GNOME Bugzilla – Bug 768536
Easier way to set tasks for today/tomorrow
Last modified: 2016-10-19 19:36:55 UTC
Currently to set a date for a task you need to go into the details pane, and pick the date from the date widget. This gets tiresome when you're setting a bunch of tasks for the next day. It would be easier if there was a way to select multiple tasks and set them for tomorrow, or a specific date. Or maybe a row of buttons in the due date section of the details pane, "Today / Tomorrow / None ". That way it would only be 2 clicks per task.
Created attachment 337358 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks In commit c8db0f0263de9a255e4a50efae065ec80695c199, We have added three Gtk Button today,tomorrow,next_week and added functionality to allow user set due-date using these buttons. In the current set-up,if the user has many tasks that has to be set for today, tomorrow or next week,he/she will have to open the GtkPopover Calender and select date for every task which is unnecessary and is not user-friendly. To fix this we add three Gtk Button in a single row which can be used to set Date to Today,Tomorrow and Next-Week on a single.This reduces the task of user to open the GtkCalendar and select date for multiple tasks and rather to set the task it will now require only single click.This is helpful in scenario where user has to set many tasks for tomorrow. Each Button is connect to a Callback function defined in the gtd-edit-pane.c file which sets the due date for task.
Comment on attachment 337358 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks >From 73af1cbfde7c85db6b11eba0b0f5bae22a8fb37b Mon Sep 17 00:00:00 2001 >From: Rohit Kaushik <koushrk7@gmail.com> >Date: Mon, 10 Oct 2016 03:31:54 +0530 >Subject: [PATCH] edit-pane: added buttons today,tomorrow,nextweek to set > due-date for tasks > >In commit 73af1cb, We have added three Gtk Button today,tomorrow,next_week and added >functionality to allow user set due-date using these buttons. > >In the current set-up,if the user has many tasks that has to be set for today, >tomorrow or next week,he/she will have to open the GtkPopover Calender and select >date for every task which is unnecessary and is not user-friendly. > >To fix this we add three Gtk Button in a single row which can be used to set Date to >Today,Tomorrow and Next-Week on a single.This reduces the task of user to open the GtkCalendar >and select date for multiple tasks and rather to set the task it will now require only >single click.This is helpful in scenario where user has to set many tasks for tomorrow. >Each Button is connect to a Callback function defined in the gtd-edit-pane.c file which >sets the due date for task. > >https://bugzilla.gnome.org/show_bug.cgi?id=768536 >--- > data/ui/edit-pane.ui | 243 ++++++++++++++++++++++++++++++++------------------- > src/gtd-edit-pane.c | 77 ++++++++++++++++ > 2 files changed, 230 insertions(+), 90 deletions(-) > >diff --git a/data/ui/edit-pane.ui b/data/ui/edit-pane.ui >index f2caa10..7ecbabb 100644 >--- a/data/ui/edit-pane.ui >+++ b/data/ui/edit-pane.ui >@@ -1,7 +1,47 @@ > <?xml version="1.0" encoding="UTF-8"?> >-<!-- Generated with glade 3.18.1 --> >+<!-- Generated with glade 3.20.0 --> > <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="gtd_edit_pane__date_selected" object="GtdEditPane" swapped="no"/> >+ </object> >+ <packing> >+ <property name="expand">False</property> >+ <property name="fill">True</property> >+ <property name="position">0</property> >+ </packing> >+ </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> >+ <packing> >+ <property name="expand">False</property> >+ <property name="fill">True</property> >+ <property name="position">1</property> >+ </packing> >+ </child> >+ </object> >+ </child> >+ </object> > <template class="GtdEditPane" parent="GtkGrid"> > <property name="visible">True</property> > <property name="can_focus">False</property> >@@ -118,11 +158,11 @@ > <object class="GtkTextView" id="notes_textview"> > <property name="visible">True</property> > <property name="can_focus">True</property> >+ <property name="pixels_above_lines">6</property> >+ <property name="wrap_mode">word-char</property> >+ <property name="left_margin">6</property> >+ <property name="right_margin">6</property> > <property name="accepts_tab">False</property> >- <property name="left-margin">6</property> >- <property name="right-margin">6</property> >- <property name="pixels-above-lines">6</property> >- <property name="wrap-mode">word-char</property> > </object> > </child> > </object> >@@ -149,50 +189,6 @@ > </packing> > </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="popover">date_popover</property> >- <child> >- <object class="GtkBox" id="date_button_box"> >- <property name="visible">True</property> >- <property name="can_focus">False</property> >- <property name="spacing">6</property> >- <child> >- <object class="GtkLabel" id="date_label"> >- <property name="visible">True</property> >- <property name="can_focus">False</property> >- <property name="hexpand">True</property> >- </object> >- <packing> >- <property name="expand">False</property> >- <property name="fill">True</property> >- <property name="position">0</property> >- </packing> >- </child> >- <child> >- <object class="GtkImage" id="date_button_image"> >- <property name="visible">True</property> >- <property name="can_focus">False</property> >- <property name="icon_name">pan-down-symbolic</property> >- </object> >- <packing> >- <property name="expand">False</property> >- <property name="fill">True</property> >- <property name="position">1</property> >- </packing> >- </child> >- </object> >- </child> >- </object> >- <packing> >- <property name="left_attach">0</property> >- <property name="top_attach">3</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> >@@ -234,7 +230,7 @@ > <property name="receives_default">True</property> > <property name="valign">end</property> > <property name="vexpand">True</property> >- <signal name="clicked" handler="gtd_edit_pane__delete_button_clicked" object="GtdEditPane" swapped="no" /> >+ <signal name="clicked" handler="gtd_edit_pane__delete_button_clicked" object="GtdEditPane" swapped="no"/> > <style> > <class name="destructive-action"/> > </style> >@@ -245,6 +241,113 @@ > <property name="width">2</property> > </packing> > </child> >+ <child> >+ <object class="GtkBox" id="date_select_box"> >+ <property name="visible">True</property> >+ <property name="can_focus">False</property> >+ <property name="homogeneous">True</property> >+ <child> >+ <object class="GtkButton" id="gtd_set_date_today"> >+ <property name="label" translatable="yes">Today</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="gtd_set_date_today_clicked" object="GtdEditPane" swapped="no"/> >+ </object> >+ <packing> >+ <property name="expand">True</property> >+ <property name="fill">True</property> >+ <property name="position">0</property> >+ </packing> >+ </child> >+ <child> >+ <object class="GtkButton" id="gtd_set_date_tomorrow"> >+ <property name="label" translatable="yes">Tomorrow</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="gtd_set_date_tomorrow_clicked" object="GtdEditPane" swapped="no"/> >+ </object> >+ <packing> >+ <property name="expand">True</property> >+ <property name="fill">True</property> >+ <property name="position">1</property> >+ </packing> >+ </child> >+ <child> >+ <object class="GtkButton" id="gtd_set_date_nextweek"> >+ <property name="label" translatable="yes">Next Week</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="gtd_set_date_nextweek_clicked" object="GtdEditPane" swapped="no"/> >+ </object> >+ <packing> >+ <property name="expand">True</property> >+ <property name="fill">True</property> >+ <property name="position">2</property> >+ </packing> >+ </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"> >+ <property name="visible">True</property> >+ <property name="can_focus">False</property> >+ <property name="spacing">7</property> >+ <child> >+ <object class="GtkLabel" id="date_label"> >+ <property name="visible">True</property> >+ <property name="can_focus">False</property> >+ <property name="hexpand">True</property> >+ </object> >+ <packing> >+ <property name="expand">False</property> >+ <property name="fill">True</property> >+ <property name="position">0</property> >+ </packing> >+ </child> >+ <child> >+ <object class="GtkImage" id="date_button_image"> >+ <property name="visible">True</property> >+ <property name="can_focus">False</property> >+ <property name="icon_name">pan-down-symbolic</property> >+ </object> >+ <packing> >+ <property name="expand">False</property> >+ <property name="fill">True</property> >+ <property name="position">1</property> >+ </packing> >+ </child> >+ </object> >+ </child> >+ </object> >+ <packing> >+ <property name="expand">True</property> >+ <property name="fill">True</property> >+ <property name="position">3</property> >+ </packing> >+ </child> >+ <style> >+ <class name="linked"/> >+ </style> >+ </object> >+ <packing> >+ <property name="left_attach">0</property> >+ <property name="top_attach">3</property> >+ </packing> >+ </child> >+ <child> >+ <placeholder/> >+ </child> > </object> > <packing> > <property name="left_attach">0</property> >@@ -263,44 +366,4 @@ > </packing> > </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="gtd_edit_pane__date_selected" object="GtdEditPane" swapped="no"/> >- </object> >- <packing> >- <property name="expand">False</property> >- <property name="fill">True</property> >- <property name="position">0</property> >- </packing> >- </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> >- <packing> >- <property name="expand">False</property> >- <property name="fill">True</property> >- <property name="position">1</property> >- </packing> >- </child> >- </object> >- </child> >- </object> > </interface> >diff --git a/src/gtd-edit-pane.c b/src/gtd-edit-pane.c >index 8a86614..2cbd892 100644 >--- a/src/gtd-edit-pane.c >+++ b/src/gtd-edit-pane.c >@@ -113,6 +113,80 @@ gtd_edit_pane__close_button_clicked (GtkButton *button, > } > > static void >+gtd_set_date_today_clicked(GtkButton *button, >+ gpointer user_data) >+{ >+ GtdEditPanePrivate *priv; >+ GDateTime *new_dt; >+ gchar *text; >+ >+ g_return_if_fail (GTD_IS_EDIT_PANE (user_data)); >+ >+ >+ priv = GTD_EDIT_PANE (user_data)->priv; >+ >+ new_dt = g_date_time_new_now_utc (); >+ >+ text = g_date_time_format (new_dt, "%x"); >+ >+ gtd_task_set_due_date (priv->task, new_dt); >+ gtk_label_set_label (priv->date_label, text); >+ gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); >+ >+ g_date_time_unref (new_dt); >+ g_free (text); >+} >+static void >+gtd_set_date_tomorrow_clicked(GtkButton *button, >+ gpointer user_data) >+{ >+ GtdEditPanePrivate *priv; >+ GDateTime *new_dt; >+ gchar *text; >+ >+ g_return_if_fail (GTD_IS_EDIT_PANE (user_data)); >+ >+ priv = GTD_EDIT_PANE (user_data)->priv; >+ >+ new_dt = g_date_time_new_now_utc(); >+ new_dt = g_date_time_add_days (new_dt,1); >+ >+ text = g_date_time_format (new_dt, "%x"); >+ >+ gtd_task_set_due_date (priv->task, new_dt); >+ gtk_label_set_label (priv->date_label, text); >+ gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); >+ >+ g_date_time_unref (new_dt); >+ g_free (text); >+} >+ >+static void >+gtd_set_date_nextweek_clicked(GtkButton *button, >+ gpointer user_data) >+{ >+ GtdEditPanePrivate *priv; >+ GDateTime *new_dt; >+ gchar *text; >+ >+ g_return_if_fail (GTD_IS_EDIT_PANE (user_data)); >+ >+ priv = GTD_EDIT_PANE (user_data)->priv; >+ >+ new_dt = g_date_time_new_now_utc(); >+ new_dt = g_date_time_add_days (new_dt,7); >+ >+ text = g_date_time_format (new_dt, "%x"); >+ >+ gtd_task_set_due_date (priv->task, new_dt); >+ gtk_label_set_label (priv->date_label, text); >+ gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); >+ >+ g_date_time_unref (new_dt); >+ g_free (text); >+} >+ >+static void > gtd_edit_pane_update_date (GtdEditPane *pane) > { > GtdEditPanePrivate *priv; >@@ -297,6 +371,9 @@ gtd_edit_pane_class_init (GtdEditPaneClass *klass) > gtk_widget_class_bind_template_callback (widget_class, gtd_edit_pane__date_selected); > 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, gtd_set_date_today_clicked); >+ gtk_widget_class_bind_template_callback (widget_class, gtd_set_date_tomorrow_clicked); >+ gtk_widget_class_bind_template_callback (widget_class, gtd_set_date_nextweek_clicked); > } > > static void >-- >2.7.4
Review of attachment 337358 [details] [review]: Still have some work to do. About the commit message: only use uppercase when needed and add a space after the commas. Please, strictly follow the GNU C Code Style (https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en) At last: don't feel overwhelmend or disappointed by the review - this is pretty normal and the more patches you send for review, the better your code gets. It's all part of a learning process :) Thanks! ::: data/ui/edit-pane.ui @@ +1,2 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> Useless change, please remove. @@ +24,3 @@ + <property name="fill">True</property> + <property name="position">0</property> + </packing> This <packing> crap is generated by Glade and completely useless. You can safely remove it. @@ +38,3 @@ + <property name="fill">True</property> + <property name="position">1</property> + </packing> Ditto. @@ +162,3 @@ + <property name="wrap_mode">word-char</property> + <property name="left_margin">6</property> + <property name="right_margin">6</property> This change is unrelated to the feature too. Probably glade again. @@ +231,3 @@ <property name="valign">end</property> <property name="vexpand">True</property> + <signal name="clicked" handler="gtd_edit_pane__delete_button_clicked" object="GtdEditPane" swapped="no"/> Another unrelated change. Please remove. @@ +246,3 @@ + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> I don't think this box is homogeneous. @@ +260,3 @@ + <property name="fill">True</property> + <property name="position">0</property> + </packing> Ditto about Glade crap. @@ +263,3 @@ + </child> + <child> + <object class="GtkButton" id="gtd_set_date_tomorrow"> id='tomorrow_button' @@ +275,3 @@ + <property name="fill">True</property> + <property name="position">1</property> + </packing> Ditto. @@ +278,3 @@ + </child> + <child> + <object class="GtkButton" id="gtd_set_date_nextweek"> id='next_week_button' @@ +290,3 @@ + <property name="fill">True</property> + <property name="position">2</property> + </packing> Ditto. @@ +314,3 @@ + <property name="fill">True</property> + <property name="position">0</property> + </packing> Ditto. @@ +326,3 @@ + <property name="fill">True</property> + <property name="position">1</property> + </packing> Ditto. ::: src/gtd-edit-pane.c @@ +115,2 @@ static void +gtd_set_date_today_clicked(GtkButton *button, Rename to 'today_button_clicked', space between the function name and '(' @@ +115,3 @@ static void +gtd_set_date_today_clicked(GtkButton *button, + gpointer user_data) 'GtdEditPane *self)' @@ +121,3 @@ + gchar *text; + + g_return_if_fail (GTD_IS_EDIT_PANE (user_data)); No need to check it here. @@ +131,3 @@ + + gtd_task_set_due_date (priv->task, new_dt); + gtk_label_set_label (priv->date_label, text); You don't have to set the label here, since gtd_edit_pane_update_date() also updates the label. @@ +132,3 @@ + gtd_task_set_due_date (priv->task, new_dt); + gtk_label_set_label (priv->date_label, text); + gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); Ditto about code style. @@ +135,3 @@ + + g_date_time_unref (new_dt); + g_free (text); Use g_clear_pointer() to free text and new_dt. @@ +137,3 @@ + g_free (text); +} +static void Jump line before. @@ +138,3 @@ +} +static void +gtd_set_date_tomorrow_clicked(GtkButton *button, Rename to 'tomorrow_button_clicked' @@ +139,3 @@ +static void +gtd_set_date_tomorrow_clicked(GtkButton *button, + gpointer user_data) The function argument is misaligned. Also, please no tabs. @@ +145,3 @@ + gchar *text; + + g_return_if_fail (GTD_IS_EDIT_PANE (user_data)); No need to check it here. @@ +149,3 @@ + priv = GTD_EDIT_PANE (user_data)->priv; + + new_dt = g_date_time_new_now_utc(); Again, style. @@ +156,3 @@ + gtd_task_set_due_date (priv->task, new_dt); + gtk_label_set_label (priv->date_label, text); + gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); Ditto about the style. @@ +159,3 @@ + + g_date_time_unref (new_dt); + g_free (text); Ditto about g_clear_pointer. @@ +164,3 @@ +static void +gtd_set_date_nextweek_clicked(GtkButton *button, + gpointer user_data) Ditto. @@ +181,3 @@ + gtd_task_set_due_date (priv->task, new_dt); + gtk_label_set_label (priv->date_label, text); + gtd_edit_pane_update_date(GTD_EDIT_PANE(user_data)); Ditto about the style and label.
Created attachment 337476 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks In this patch, we have added three gtk button today,tomorrow,next_week and added functionality to allow user set due-date using these buttons. In the current set-up,if the user has many tasks that has to be set for today, tomorrow or next week,he/she will have to open the gtk-popover calender and select date for every task which is unnecessary and is not user-friendly. To fix this we add three gtk buttons in a single row which can be used to set date to today,tomorrow and next-week on a single click.This reduces the task of user to open the gtk-calendar and select date for multiple tasks and rather to set the task it will now require only single click.This is helpful in scenario where user has to set many tasks for tomorrow. Each button is connected to a callback function defined in the gtd-edit-pane.c file which sets the due date for task.
Created attachment 337480 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks In this patch, we have added three gtk button today,tomorrow,next_week and added functionality to allow user set due-date using these buttons. In the current set-up,if the user has many tasks that has to be set for today, tomorrow or next week,he/she will have to open the gtk-popover calender and select date for every task which is unnecessary and is not user-friendly. To fix this we add three gtk buttons in a single row which can be used to set date to today,tomorrow and next-week on a single click.This reduces the task of user to open the gtk-calendar and select date for multiple tasks and rather to set the task it will now require only single click.This is helpful in scenario where user has to set many tasks for tomorrow. Each button is connected to a callback function defined in the gtd-edit-pane.c file which sets the due date for task.
Review of attachment 337480 [details] [review]: Minor issue. ::: src/gtd-edit-pane.c @@ +139,3 @@ + priv = self->priv; + + new_dt = g_date_time_new_now_utc (); This line is leaking. Use another variable.
Created attachment 338039 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks fixed memory leak in tomorrow_button_clicked and next_week_button_clicked.
Review of attachment 338039 [details] [review]: Only some minor nitpicks related to the coding style. Good job! ::: src/gtd-edit-pane.c @@ +115,3 @@ static void +today_button_clicked (GtkButton *button, + GtdEditPane *self) Align the 'button' and 'self' arguments. @@ +127,3 @@ + gtd_edit_pane_update_date (self); + + g_clear_pointer (&new_dt, g_date_time_unref); This whole code is indented wrongly. It's only 2 spaces of identation here. @@ +132,3 @@ +static void +tomorrow_button_clicked (GtkButton *button, + GtdEditPane *self) Ditto. @@ +147,3 @@ + + g_clear_pointer (¤t_date, g_date_time_unref); + g_clear_pointer (&new_dt, g_date_time_unref); Ditto about the indentation. @@ +152,3 @@ +static void +next_week_button_clicked (GtkButton *button, + GtdEditPane *self) Ditto. @@ +167,3 @@ + + g_clear_pointer (¤t_date, g_date_time_unref); + g_clear_pointer (&new_dt, g_date_time_unref); Ditto about the indentation. @@ +357,3 @@ + gtk_widget_class_bind_template_callback (widget_class, today_button_clicked); + gtk_widget_class_bind_template_callback (widget_class, tomorrow_button_clicked); + gtk_widget_class_bind_template_callback (widget_class, next_week_button_clicked); Sort by the widget names.
Created attachment 338044 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks https://bugzilla.gnome.org/show_bug.cgi?id=768536 fixed the code style errors
Review of attachment 338044 [details] [review]: Looks good, thanks for working on that.
Created attachment 338046 [details] [review] edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks https://bugzilla.gnome.org/show_bug.cgi?id=768536 set width-chars to 10 for date_label
Thanks for the fix! Attachment 338046 [details] pushed as 3fe6934 - edit-pane: added buttons today,tomorrow,nextweek to set due-date for tasks