[gnome-todo] edit-pane: added buttons today, tomorrow, nextweek to set due-date for tasks
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] edit-pane: added buttons today, tomorrow, nextweek to set due-date for tasks
- Date: Wed, 19 Oct 2016 19:36:40 +0000 (UTC)
commit 3fe693462799d61af6ba4c3c6e83134a09bc6a67
Author: Rohit Kaushik <koushrk7 gmail com>
Date: Mon Oct 10 03:31:54 2016 +0530
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
data/ui/edit-pane.ui | 192 ++++++++++++++++++++++++++++----------------------
src/gtd-edit-pane.c | 60 ++++++++++++++++
2 files changed, 167 insertions(+), 85 deletions(-)
---
diff --git a/data/ui/edit-pane.ui b/data/ui/edit-pane.ui
index f2caa10..4bc94ac 100644
--- a/data/ui/edit-pane.ui
+++ b/data/ui/edit-pane.ui
@@ -1,7 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.1 -->
<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>
+ </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>
@@ -149,50 +178,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>
@@ -245,6 +230,83 @@
<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>
+ <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="today_button_clicked" object="GtdEditPane"
swapped="no" />
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="tomorrow_button">
+ <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="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="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">
+ <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>
+ <property name="width-chars">10</property>
+ </object>
+ </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>
+ </child>
+ </object>
+ </child>
+ </object>
+ </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 +325,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 780b99f..c17c3ac 100644
--- a/src/gtd-edit-pane.c
+++ b/src/gtd-edit-pane.c
@@ -113,6 +113,63 @@ gtd_edit_pane__close_button_clicked (GtkButton *button,
}
static void
+today_button_clicked (GtkButton *button,
+ GtdEditPane *self)
+{
+ GtdEditPanePrivate *priv;
+ GDateTime *new_dt;
+
+ priv = self->priv;
+
+ new_dt = g_date_time_new_now_utc ();
+
+ gtd_task_set_due_date (priv->task, new_dt);
+ gtd_edit_pane_update_date (self);
+
+ g_clear_pointer (&new_dt, g_date_time_unref);
+}
+
+static void
+tomorrow_button_clicked (GtkButton *button,
+ GtdEditPane *self)
+{
+ GtdEditPanePrivate *priv;
+ GDateTime *current_date;
+ GDateTime *new_dt;
+
+ priv = self->priv;
+
+ current_date = g_date_time_new_now_utc ();
+ new_dt = g_date_time_add_days (current_date, 1);
+
+ gtd_task_set_due_date (priv->task, new_dt);
+ gtd_edit_pane_update_date (self);
+
+ g_clear_pointer (¤t_date, g_date_time_unref);
+ g_clear_pointer (&new_dt, g_date_time_unref);
+}
+
+static void
+next_week_button_clicked (GtkButton *button,
+ GtdEditPane *self)
+{
+ GtdEditPanePrivate *priv;
+ GDateTime *current_date;
+ GDateTime *new_dt;
+
+ priv = self->priv;
+
+ current_date = g_date_time_new_now_utc ();
+ new_dt = g_date_time_add_days (current_date, 7);
+
+ gtd_task_set_due_date (priv->task, new_dt);
+ gtd_edit_pane_update_date (self);
+
+ g_clear_pointer (¤t_date, g_date_time_unref);
+ g_clear_pointer (&new_dt, g_date_time_unref);
+}
+
+static void
gtd_edit_pane_update_date (GtdEditPane *pane)
{
GtdEditPanePrivate *priv;
@@ -310,6 +367,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, 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);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]