From a328e9eff89aca6f182429327232e6b73802a67e Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 16 Sep 2022 09:18:10 +0200 Subject: [PATCH] ews-I#153 - ECompEditor: Add API to get property parts That can be used to modify the parts as needed by the extensions. Related to https://gitlab.gnome.org/GNOME/evolution-ews/-/issues/153 --- src/calendar/gui/e-comp-editor-page.c | 33 +++++++++++++++++++++++++++ src/calendar/gui/e-comp-editor-page.h | 3 +++ src/calendar/gui/e-comp-editor.c | 22 ++++++++++++++++++ src/calendar/gui/e-comp-editor.h | 3 +++ 4 files changed, 61 insertions(+) diff --git a/src/calendar/gui/e-comp-editor-page.c b/src/calendar/gui/e-comp-editor-page.c index ccfa085e8d..391ca6797e 100644 --- a/src/calendar/gui/e-comp-editor-page.c +++ b/src/calendar/gui/e-comp-editor-page.c @@ -286,6 +286,39 @@ e_comp_editor_page_add_property_part (ECompEditorPage *page, page->priv->parts = g_slist_append (page->priv->parts, ppd); } +ECompEditorPropertyPart * +e_comp_editor_page_get_property_part (ECompEditorPage *page, + ICalPropertyKind prop_kind) +{ + GSList *link; + + g_return_val_if_fail (E_IS_COMP_EDITOR_PAGE (page), NULL); + + for (link = page->priv->parts; link; link = g_slist_next (link)) { + PropertyPartData *ppd = link->data; + + if (E_IS_COMP_EDITOR_PROPERTY_PART_STRING (ppd->part)) { + ECompEditorPropertyPartStringClass *klass = E_COMP_EDITOR_PROPERTY_PART_STRING_GET_CLASS (ppd->part); + if (klass->prop_kind == prop_kind) + return ppd->part; + } + + if (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME (ppd->part)) { + ECompEditorPropertyPartDatetimeClass *klass = E_COMP_EDITOR_PROPERTY_PART_DATETIME_GET_CLASS (ppd->part); + if (klass->prop_kind == prop_kind) + return ppd->part; + } + + if (E_IS_COMP_EDITOR_PROPERTY_PART_SPIN (ppd->part)) { + ECompEditorPropertyPartSpinClass *klass = E_COMP_EDITOR_PROPERTY_PART_SPIN_GET_CLASS (ppd->part); + if (klass->prop_kind == prop_kind) + return ppd->part; + } + } + + return NULL; +} + void e_comp_editor_page_sensitize_widgets (ECompEditorPage *page, gboolean force_insensitive) diff --git a/src/calendar/gui/e-comp-editor-page.h b/src/calendar/gui/e-comp-editor-page.h index b104efb025..d6198acde7 100644 --- a/src/calendar/gui/e-comp-editor-page.h +++ b/src/calendar/gui/e-comp-editor-page.h @@ -82,6 +82,9 @@ void e_comp_editor_page_add_property_part (ECompEditorPage *page, gint attach_top, gint attach_width, gint attach_height); +ECompEditorPropertyPart * + e_comp_editor_page_get_property_part (ECompEditorPage *page, + ICalPropertyKind prop_kind); void e_comp_editor_page_sensitize_widgets (ECompEditorPage *page, gboolean force_insensitive); void e_comp_editor_page_fill_widgets (ECompEditorPage *page, diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c index 49883a0b24..2192c5f6eb 100644 --- a/src/calendar/gui/e-comp-editor.c +++ b/src/calendar/gui/e-comp-editor.c @@ -3413,6 +3413,28 @@ e_comp_editor_get_page (ECompEditor *comp_editor, return NULL; } +/* The returned pointer is owned by the @comp_editor; returns the first found part, + in order of the addition. */ +ECompEditorPropertyPart * +e_comp_editor_get_property_part (ECompEditor *comp_editor, + ICalPropertyKind prop_kind) +{ + GSList *link; + + g_return_val_if_fail (E_IS_COMP_EDITOR (comp_editor), NULL); + + for (link = comp_editor->priv->pages; link; link = g_slist_next (link)) { + ECompEditorPage *page = link->data; + ECompEditorPropertyPart *part; + + part = e_comp_editor_page_get_property_part (page, prop_kind); + if (part) + return part; + } + + return NULL; +} + /* Free the returned GSList with g_slist_free(), the memebers are owned by the comp_editor */ GSList * e_comp_editor_get_pages (ECompEditor *comp_editor) diff --git a/src/calendar/gui/e-comp-editor.h b/src/calendar/gui/e-comp-editor.h index 1f262d0591..e8b43c965d 100644 --- a/src/calendar/gui/e-comp-editor.h +++ b/src/calendar/gui/e-comp-editor.h @@ -155,6 +155,9 @@ void e_comp_editor_add_page (ECompEditor *comp_editor, ECompEditorPage * e_comp_editor_get_page (ECompEditor *comp_editor, GType page_type); +ECompEditorPropertyPart * + e_comp_editor_get_property_part (ECompEditor *comp_editor, + ICalPropertyKind prop_kind); GSList * e_comp_editor_get_pages (ECompEditor *comp_editor); void e_comp_editor_select_page (ECompEditor *comp_editor, ECompEditorPage *page);