[evolution] I#1382 - Calendar: Fails to create new even with read-only source selected
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1382 - Calendar: Fails to create new even with read-only source selected
- Date: Thu, 25 Feb 2021 11:42:38 +0000 (UTC)
commit 9ea49ed8083a06cec9c7e23137834d63c4bc45ed
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 25 12:40:52 2021 +0100
I#1382 - Calendar: Fails to create new even with read-only source selected
When trying to create a new even with for example Birthdays & Anniversaries
calendar selected the editor does not open, only an error "Invalid object"
is shown.
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1382
src/calendar/gui/comp-util.c | 71 ++++++++++++++++++++------------------------
1 file changed, 33 insertions(+), 38 deletions(-)
---
diff --git a/src/calendar/gui/comp-util.c b/src/calendar/gui/comp-util.c
index f8172f3a21..e931b48a39 100644
--- a/src/calendar/gui/comp-util.c
+++ b/src/calendar/gui/comp-util.c
@@ -299,6 +299,34 @@ cal_comp_is_icalcomp_on_server_sync (ICalComponent *icomp,
return on_server;
}
+static ECalComponent *
+cal_comp_util_ref_default_object (ECalClient *client,
+ ICalComponentKind icomp_kind,
+ ECalComponentVType ecomp_vtype,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ICalComponent *icomp = NULL;
+ ECalComponent *comp;
+
+ /* Simply ignore errors here */
+ if (client && !e_cal_client_get_default_object_sync (client, &icomp, cancellable, NULL))
+ icomp = NULL;
+
+ if (!icomp)
+ icomp = i_cal_component_new (icomp_kind);
+
+ comp = e_cal_component_new ();
+
+ if (!e_cal_component_set_icalcomponent (comp, icomp)) {
+ g_clear_object (&icomp);
+
+ e_cal_component_set_new_vtype (comp, ecomp_vtype);
+ }
+
+ return comp;
+}
+
/**
* cal_comp_event_new_with_defaults_sync:
*
@@ -316,25 +344,16 @@ cal_comp_event_new_with_defaults_sync (ECalClient *client,
GCancellable *cancellable,
GError **error)
{
- ICalComponent *icomp = NULL;
ECalComponent *comp;
ECalComponentAlarm *alarm;
ICalProperty *prop;
ICalDuration *duration;
ECalComponentAlarmTrigger *trigger;
- if (client && !e_cal_client_get_default_object_sync (client, &icomp, cancellable, error))
- return NULL;
-
- if (!icomp)
- icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
-
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icomp)) {
- g_clear_object (&icomp);
+ comp = cal_comp_util_ref_default_object (client, I_CAL_VEVENT_COMPONENT, E_CAL_COMPONENT_EVENT,
cancellable, error);
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
- }
+ if (!comp)
+ return NULL;
if (all_day || !use_default_reminder)
return comp;
@@ -435,20 +454,8 @@ cal_comp_task_new_with_defaults_sync (ECalClient *client,
GError **error)
{
ECalComponent *comp;
- ICalComponent *icomp = NULL;
-
- if (client && !e_cal_client_get_default_object_sync (client, &icomp, cancellable, error))
- return NULL;
-
- if (!icomp)
- icomp = i_cal_component_new (I_CAL_VTODO_COMPONENT);
-
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icomp)) {
- g_object_unref (icomp);
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
- }
+ comp = cal_comp_util_ref_default_object (client, I_CAL_VTODO_COMPONENT, E_CAL_COMPONENT_TODO,
cancellable, error);
return comp;
}
@@ -459,20 +466,8 @@ cal_comp_memo_new_with_defaults_sync (ECalClient *client,
GError **error)
{
ECalComponent *comp;
- ICalComponent *icomp = NULL;
-
- if (client && !e_cal_client_get_default_object_sync (client, &icomp, cancellable, error))
- return NULL;
-
- if (!icomp)
- icomp = i_cal_component_new (I_CAL_VJOURNAL_COMPONENT);
-
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icomp)) {
- g_object_unref (icomp);
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
- }
+ comp = cal_comp_util_ref_default_object (client, I_CAL_VJOURNAL_COMPONENT, E_CAL_COMPONENT_JOURNAL,
cancellable, error);
return comp;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]