[gnome-todo] task: Add 'important' property
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task: Add 'important' property
- Date: Sat, 2 May 2020 21:28:33 +0000 (UTC)
commit 5ba3e3666adc7292280dc4eb76bc7d6758739938
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat May 2 18:14:38 2020 -0300
task: Add 'important' property
https://gitlab.gnome.org/GNOME/gnome-todo/-/issues/272
src/gtd-task.c | 83 +++++++++++++++++++++++++++++++++++++++++-
src/gtd-task.h | 11 +++++-
src/plugins/eds/gtd-task-eds.c | 22 ++++++++++-
3 files changed, 113 insertions(+), 3 deletions(-)
---
diff --git a/src/gtd-task.c b/src/gtd-task.c
index cf46f3f..03a1467 100644
--- a/src/gtd-task.c
+++ b/src/gtd-task.c
@@ -1,6 +1,6 @@
/* gtd-task.c
*
- * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2015-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,6 +59,7 @@ typedef struct
gint32 priority;
gint64 position;
gboolean complete;
+ gboolean important;
} GtdTaskPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GtdTask, gtd_task, GTD_TYPE_OBJECT)
@@ -71,6 +72,7 @@ enum
PROP_DESCRIPTION,
PROP_CREATION_DATE,
PROP_DUE_DATE,
+ PROP_IMPORTANT,
PROP_LIST,
PROP_PARENT,
PROP_POSITION,
@@ -489,6 +491,26 @@ gtd_task_real_set_due_date (GtdTask *self,
priv->due_date = g_date_time_ref (due_date);
}
+static gboolean
+gtd_task_real_get_important (GtdTask *self)
+{
+ GtdTaskPrivate *priv = gtd_task_get_instance_private (self);
+
+ return priv->important;
+}
+
+static void
+gtd_task_real_set_important (GtdTask *self,
+ gboolean important)
+{
+ GtdTaskPrivate *priv = gtd_task_get_instance_private (self);
+
+ if (priv->important == important)
+ return;
+
+ priv->important = important;
+}
+
static gint64
gtd_task_real_get_position (GtdTask *self)
{
@@ -578,6 +600,10 @@ gtd_task_get_property (GObject *object,
g_clear_pointer (&date, g_date_time_unref);
break;
+ case PROP_IMPORTANT:
+ g_value_set_boolean (value, gtd_task_get_important (self));
+ break;
+
case PROP_LIST:
g_value_set_object (value, priv->list);
break;
@@ -625,6 +651,10 @@ gtd_task_set_property (GObject *object,
gtd_task_set_due_date (self, g_value_get_boxed (value));
break;
+ case PROP_IMPORTANT:
+ gtd_task_set_important (self, g_value_get_boolean (value));
+ break;
+
case PROP_LIST:
gtd_task_set_list (self, g_value_get_object (value));
break;
@@ -657,6 +687,8 @@ gtd_task_class_init (GtdTaskClass *klass)
klass->set_description = gtd_task_real_set_description;
klass->get_due_date = gtd_task_real_get_due_date;
klass->set_due_date = gtd_task_real_set_due_date;
+ klass->get_important = gtd_task_real_get_important;
+ klass->set_important = gtd_task_real_set_important;
klass->get_position = gtd_task_real_get_position;
klass->set_position = gtd_task_real_set_position;
klass->get_title = gtd_task_real_get_title;
@@ -742,6 +774,20 @@ gtd_task_class_init (GtdTaskClass *klass)
G_TYPE_DATE_TIME,
G_PARAM_READWRITE));
+ /**
+ * GtdTask::important:
+ *
+ * @TRUE if the task is important, @FALSE otherwise.
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_IMPORTANT,
+ g_param_spec_boolean ("important",
+ "Whether the task is important or not",
+ "Whether the task is important or not",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
/**
* GtdTask::list:
*
@@ -1037,6 +1083,41 @@ gtd_task_set_due_date (GtdTask *task,
g_object_notify (G_OBJECT (task), "due-date");
}
+/**
+ * gtd_task_get_important:
+ * @self: a #GtdTask
+ *
+ * Retrieves whether @self is @important or not.
+ *
+ * Returns: %TRUE if @self is important, %FALSE otherwise
+ */
+gboolean
+gtd_task_get_important (GtdTask *self)
+{
+ g_return_val_if_fail (GTD_IS_TASK (self), FALSE);
+
+ return GTD_TASK_GET_CLASS (self)->get_important (self);
+}
+
+/**
+ * gtd_task_set_important:
+ * @self: a #GtdTask
+ * @important: whether @self is important or not
+ *
+ * Sets whether @self is @important or not.
+ */
+void
+gtd_task_set_important (GtdTask *self,
+ gboolean important)
+{
+ g_return_if_fail (GTD_IS_TASK (self));
+
+ important = !!important;
+
+ GTD_TASK_GET_CLASS (self)->set_important (self, important);
+ g_object_notify (G_OBJECT (self), "important");
+}
+
/**
* gtd_task_get_list:
*
diff --git a/src/gtd-task.h b/src/gtd-task.h
index 59edf8c..2390e26 100644
--- a/src/gtd-task.h
+++ b/src/gtd-task.h
@@ -1,6 +1,6 @@
/* gtd-task.h
*
- * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2015-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,6 +53,10 @@ struct _GtdTaskClass
void (*set_due_date) (GtdTask *self,
GDateTime *due_date);
+ gboolean (*get_important) (GtdTask *self);
+ void (*set_important) (GtdTask *self,
+ gboolean important);
+
gint64 (*get_position) (GtdTask *task);
void (*set_position) (GtdTask *task,
gint64 position);
@@ -96,6 +100,11 @@ GDateTime* gtd_task_get_due_date (GtdTask *tas
void gtd_task_set_due_date (GtdTask *task,
GDateTime *dt);
+gboolean gtd_task_get_important (GtdTask *self);
+
+void gtd_task_set_important (GtdTask *self,
+ gboolean important);
+
GtdTaskList* gtd_task_get_list (GtdTask *task);
void gtd_task_set_list (GtdTask *task,
diff --git a/src/plugins/eds/gtd-task-eds.c b/src/plugins/eds/gtd-task-eds.c
index be9a247..2fb3a5c 100644
--- a/src/plugins/eds/gtd-task-eds.c
+++ b/src/plugins/eds/gtd-task-eds.c
@@ -1,6 +1,6 @@
/* gtd-task-eds.c
*
- * Copyright (C) 2017 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2017-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -400,6 +400,23 @@ gtd_task_eds_set_due_date (GtdTask *task,
g_clear_pointer (¤t_dt, g_date_time_unref);
}
+static gboolean
+gtd_task_eds_get_important (GtdTask *task)
+{
+ GtdTaskEds *self = GTD_TASK_EDS (task);
+
+ return e_cal_component_get_priority (self->new_component) > 0;
+}
+
+static void
+gtd_task_eds_set_important (GtdTask *task,
+ gboolean important)
+{
+ GtdTaskEds *self = GTD_TASK_EDS (task);
+
+ e_cal_component_set_priority (self->new_component, important ? 3 : -1);
+}
+
static gint64
gtd_task_eds_get_position (GtdTask *task)
{
@@ -596,6 +613,8 @@ gtd_task_eds_class_init (GtdTaskEdsClass *klass)
task_class->set_description = gtd_task_eds_set_description;
task_class->get_due_date = gtd_task_eds_get_due_date;
task_class->set_due_date = gtd_task_eds_set_due_date;
+ task_class->get_important = gtd_task_eds_get_important;
+ task_class->set_important = gtd_task_eds_set_important;
task_class->get_position = gtd_task_eds_get_position;
task_class->set_position = gtd_task_eds_set_position;
task_class->get_title = gtd_task_eds_get_title;
@@ -659,6 +678,7 @@ gtd_task_eds_set_component (GtdTaskEds *self,
g_object_notify (object, "creation-date");
g_object_notify (object, "description");
g_object_notify (object, "due-date");
+ g_object_notify (object, "important");
g_object_notify (object, "position");
g_object_notify (object, "title");
g_object_notify_by_pspec (object, properties[PROP_COMPONENT]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]