I#1645 - Tasks: Add table column for ESTIMATED-DURATION
Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1645
This commit is contained in:
@ -43,6 +43,7 @@ set(SOURCES
|
||||
e-cal-ops.c
|
||||
e-calendar-view.c
|
||||
e-cell-date-edit-text.c
|
||||
e-cell-estimated-duration.c
|
||||
e-comp-editor.c
|
||||
e-comp-editor-event.c
|
||||
e-comp-editor-memo.c
|
||||
@ -119,6 +120,7 @@ set(HEADERS
|
||||
e-cal-ops.h
|
||||
e-calendar-view.h
|
||||
e-cell-date-edit-text.h
|
||||
e-cell-estimated-duration.h
|
||||
e-comp-editor.h
|
||||
e-comp-editor-event.h
|
||||
e-comp-editor-memo.h
|
||||
|
@ -627,6 +627,36 @@ set_location (ECalModelComponent *comp_data,
|
||||
}
|
||||
}
|
||||
|
||||
static gpointer
|
||||
get_estimated_duration (ECalModelComponent *comp_data)
|
||||
{
|
||||
ICalProperty *prop;
|
||||
gpointer res = NULL;
|
||||
|
||||
prop = i_cal_component_get_first_property (comp_data->icalcomp, I_CAL_ESTIMATEDDURATION_PROPERTY);
|
||||
if (prop) {
|
||||
ICalDuration *duration;
|
||||
gint duration_int;
|
||||
|
||||
duration = i_cal_property_get_estimatedduration (prop);
|
||||
duration_int = duration ? i_cal_duration_as_int (duration) : 0;
|
||||
|
||||
if (duration_int > 0) {
|
||||
gint64 *pvalue;
|
||||
|
||||
pvalue = g_new (gint64, 1);
|
||||
*pvalue = duration_int;
|
||||
|
||||
res = pvalue;
|
||||
}
|
||||
|
||||
g_clear_object (&duration);
|
||||
g_object_unref (prop);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
cal_model_tasks_set_property (GObject *object,
|
||||
guint property_id,
|
||||
@ -766,6 +796,7 @@ cal_model_tasks_store_values_from_model (ECalModel *model,
|
||||
e_cal_model_util_set_value (values, source_model, E_CAL_MODEL_TASKS_FIELD_PRIORITY, row);
|
||||
e_cal_model_util_set_value (values, source_model, E_CAL_MODEL_TASKS_FIELD_URL, row);
|
||||
e_cal_model_util_set_value (values, source_model, E_CAL_MODEL_TASKS_FIELD_LOCATION, row);
|
||||
e_cal_model_util_set_value (values, source_model, E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION, row);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -796,6 +827,7 @@ cal_model_tasks_fill_component_from_values (ECalModel *model,
|
||||
set_priority (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_TASKS_FIELD_PRIORITY));
|
||||
set_url (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_TASKS_FIELD_URL));
|
||||
set_location (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_TASKS_FIELD_LOCATION));
|
||||
/*set_estimated_duration (comp_data, e_cal_model_util_get_value (values, E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION)); - read-only*/
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -847,6 +879,8 @@ cal_model_tasks_value_at (ETableModel *etm,
|
||||
return get_url (comp_data);
|
||||
case E_CAL_MODEL_TASKS_FIELD_LOCATION:
|
||||
return get_location (comp_data);
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
return get_estimated_duration (comp_data);
|
||||
}
|
||||
|
||||
return (gpointer) "";
|
||||
@ -903,6 +937,9 @@ cal_model_tasks_set_value_at (ETableModel *etm,
|
||||
case E_CAL_MODEL_TASKS_FIELD_LOCATION:
|
||||
set_location (comp_data, value);
|
||||
break;
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
/* set_estimated_duration (comp_data, value); - read-only */
|
||||
break;
|
||||
}
|
||||
|
||||
e_cal_model_modify_component (E_CAL_MODEL (model), comp_data, E_CAL_OBJ_MOD_ALL);
|
||||
@ -937,6 +974,8 @@ cal_model_tasks_is_cell_editable (ETableModel *etm,
|
||||
case E_CAL_MODEL_TASKS_FIELD_URL :
|
||||
case E_CAL_MODEL_TASKS_FIELD_LOCATION:
|
||||
return TRUE;
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -968,6 +1007,17 @@ cal_model_tasks_duplicate_value (ETableModel *etm,
|
||||
|
||||
case E_CAL_MODEL_TASKS_FIELD_LOCATION:
|
||||
return g_strdup (value);
|
||||
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
if (value) {
|
||||
gint64 *res = g_new (gint64, 1);
|
||||
const gint64 *pvalue = value;
|
||||
|
||||
*res = *pvalue;
|
||||
|
||||
return res;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -1000,6 +1050,9 @@ cal_model_tasks_free_value (ETableModel *etm,
|
||||
case E_CAL_MODEL_TASKS_FIELD_COMPLETE :
|
||||
case E_CAL_MODEL_TASKS_FIELD_OVERDUE :
|
||||
break;
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
g_free (value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1026,6 +1079,7 @@ cal_model_tasks_initialize_value (ETableModel *etm,
|
||||
case E_CAL_MODEL_TASKS_FIELD_DUE :
|
||||
case E_CAL_MODEL_TASKS_FIELD_COMPLETE :
|
||||
case E_CAL_MODEL_TASKS_FIELD_OVERDUE :
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
return NULL;
|
||||
case E_CAL_MODEL_TASKS_FIELD_PERCENT :
|
||||
return GINT_TO_POINTER (-1);
|
||||
@ -1056,6 +1110,7 @@ cal_model_tasks_value_is_empty (ETableModel *etm,
|
||||
return string_is_empty (value);
|
||||
case E_CAL_MODEL_TASKS_FIELD_COMPLETED :
|
||||
case E_CAL_MODEL_TASKS_FIELD_DUE :
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
return value ? FALSE : TRUE;
|
||||
case E_CAL_MODEL_TASKS_FIELD_PERCENT :
|
||||
return (GPOINTER_TO_INT (value) < 0) ? TRUE : FALSE;
|
||||
@ -1098,6 +1153,12 @@ cal_model_tasks_value_to_string (ETableModel *etm,
|
||||
return g_strdup ("N/A");
|
||||
else
|
||||
return g_strdup_printf ("%i%%", GPOINTER_TO_INT (value));
|
||||
case E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION:
|
||||
if (value) {
|
||||
const gint64 *pvalue = value;
|
||||
return e_cal_util_seconds_to_string (*pvalue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return g_strdup ("");
|
||||
|
@ -66,6 +66,7 @@ typedef enum {
|
||||
E_CAL_MODEL_TASKS_FIELD_URL,
|
||||
E_CAL_MODEL_TASKS_FIELD_STRIKEOUT, /* it's another virtual readonly column */
|
||||
E_CAL_MODEL_TASKS_FIELD_LOCATION,
|
||||
E_CAL_MODEL_TASKS_FIELD_ESTIMATED_DURATION,
|
||||
E_CAL_MODEL_TASKS_FIELD_LAST
|
||||
} ECalModelTasksField;
|
||||
|
||||
|
80
src/calendar/gui/e-cell-estimated-duration.c
Normal file
80
src/calendar/gui/e-cell-estimated-duration.c
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* SPDX-FileCopyrightText: (C) 2021 Red Hat (www.redhat.com)
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "evolution-config.h"
|
||||
|
||||
#include <libecal/libecal.h>
|
||||
|
||||
#include "e-cell-estimated-duration.h"
|
||||
|
||||
G_DEFINE_TYPE (ECellEstimatedDuration, e_cell_estimated_duration, E_TYPE_CELL_TEXT)
|
||||
|
||||
static gchar *
|
||||
eced_get_text (ECellText *cell,
|
||||
ETableModel *model,
|
||||
gint col,
|
||||
gint row)
|
||||
{
|
||||
gint64 *pvalue = e_table_model_value_at (model, col, row);
|
||||
gchar *res;
|
||||
|
||||
if (!pvalue || *pvalue == 0) {
|
||||
e_table_model_free_value (model, col, pvalue);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = e_cal_util_seconds_to_string (*pvalue);
|
||||
|
||||
e_table_model_free_value (model, col, pvalue);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
eced_free_text (ECellText *cell,
|
||||
ETableModel *model,
|
||||
gint col,
|
||||
gchar *text)
|
||||
{
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
e_cell_estimated_duration_class_init (ECellEstimatedDurationClass *klass)
|
||||
{
|
||||
ECellTextClass *ectc = E_CELL_TEXT_CLASS (klass);
|
||||
|
||||
ectc->get_text = eced_get_text;
|
||||
ectc->free_text = eced_free_text;
|
||||
}
|
||||
|
||||
static void
|
||||
e_cell_estimated_duration_init (ECellEstimatedDuration *self)
|
||||
{
|
||||
g_object_set (self, "use-tabular-numbers", TRUE, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cell_estimated_duration_new:
|
||||
* @fontname: (nullable): font to be used to render on the screen
|
||||
* @justify: Justification of the string in the cell.
|
||||
*
|
||||
* Creates a new ECell renderer that can be used to render estimated duration
|
||||
*
|
||||
* Returns: an ECell object that can be used to render estimated duration.
|
||||
*
|
||||
* Since: 3.44
|
||||
*/
|
||||
ECell *
|
||||
e_cell_estimated_duration_new (const gchar *fontname,
|
||||
GtkJustification justify)
|
||||
{
|
||||
ECellEstimatedDuration *self = g_object_new (E_TYPE_CELL_ESTIMATED_DURATION, NULL);
|
||||
|
||||
e_cell_text_construct (E_CELL_TEXT (self), fontname, justify);
|
||||
|
||||
return E_CELL (self);
|
||||
}
|
50
src/calendar/gui/e-cell-estimated-duration.h
Normal file
50
src/calendar/gui/e-cell-estimated-duration.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* SPDX-FileCopyrightText: (C) 2021 Red Hat (www.redhat.com)
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef E_CELL_ESTIMATED_DURATION_H
|
||||
#define E_CELL_ESTIMATED_DURATION_H
|
||||
|
||||
#include <e-util/e-util.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define E_TYPE_CELL_ESTIMATED_DURATION \
|
||||
(e_cell_estimated_duration_get_type ())
|
||||
#define E_CELL_ESTIMATED_DURATION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), E_TYPE_CELL_ESTIMATED_DURATION, ECellEstimatedDuration))
|
||||
#define E_CELL_ESTIMATED_DURATION_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), E_TYPE_CELL_ESTIMATED_DURATION, ECellEstimatedDurationClass))
|
||||
#define E_IS_CELL_ESTIMATED_DURATION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), E_TYPE_CELL_ESTIMATED_DURATION))
|
||||
#define E_IS_CELL_ESTIMATED_DURATION_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), E_TYPE_CELL_ESTIMATED_DURATION))
|
||||
#define E_CELL_ESTIMATED_DURATION_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS \
|
||||
((obj), E_TYPE_CELL_ESTIMATED_DURATION, ECellEstimatedDurationClass))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ECellEstimatedDuration ECellEstimatedDuration;
|
||||
typedef struct _ECellEstimatedDurationClass ECellEstimatedDurationClass;
|
||||
|
||||
struct _ECellEstimatedDuration {
|
||||
ECellText parent;
|
||||
};
|
||||
|
||||
struct _ECellEstimatedDurationClass {
|
||||
ECellTextClass parent_class;
|
||||
};
|
||||
|
||||
GType e_cell_estimated_duration_get_type (void) G_GNUC_CONST;
|
||||
ECell * e_cell_estimated_duration_new (const gchar *fontname,
|
||||
GtkJustification justify);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* E_CELL_ESTIMATED_DURATION_H */
|
@ -42,6 +42,7 @@
|
||||
#include "e-cal-ops.h"
|
||||
#include "e-calendar-view.h"
|
||||
#include "e-cell-date-edit-text.h"
|
||||
#include "e-cell-estimated-duration.h"
|
||||
#include "itip-utils.h"
|
||||
#include "print.h"
|
||||
#include "misc.h"
|
||||
@ -416,6 +417,16 @@ task_table_constructed (GObject *object)
|
||||
E_CELL_DATE_EDIT (popup_cell),
|
||||
e_task_table_get_current_time, task_table, NULL);
|
||||
|
||||
cell = e_cell_estimated_duration_new (NULL, GTK_JUSTIFY_LEFT);
|
||||
g_object_set (
|
||||
cell,
|
||||
"strikeout_column", E_CAL_MODEL_TASKS_FIELD_STRIKEOUT,
|
||||
"bold_column", E_CAL_MODEL_TASKS_FIELD_OVERDUE,
|
||||
"bg_color_column", E_CAL_MODEL_FIELD_COLOR,
|
||||
NULL);
|
||||
e_table_extras_add_cell (extras, "estimatedduration", cell);
|
||||
g_object_unref (cell);
|
||||
|
||||
/*
|
||||
* Combo fields.
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@
|
||||
<ETableColumn model_col="10" _title="Created" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
|
||||
<ETableColumn model_col="11" _title="Last modified" expansion="2.0" minimum_width="10" resizable="true" cell="dateedit" compare="date-compare" priority="-2"/>
|
||||
<ETableColumn model_col="12" _title="Source" expansion="1.0" minimum_width="10" resizable="true" cell="calstring" compare="collate" priority="-2"/>
|
||||
<ETableColumn model_col="25" _title="Estimated duration" expansion="3.0" minimum_width="10" resizable="true" cell="estimatedduration" compare="pointer-integer64" priority="10"/>
|
||||
|
||||
<ETableState>
|
||||
<column source="1"/>
|
||||
|
Reference in New Issue
Block a user