[evolution] CompEditor: Check for "one-alarm-only" calendar capability



commit 4c71e5fee491ae4ae15e00ab32e56d6fbcd57060
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 24 11:32:47 2021 +0100

    CompEditor: Check for "one-alarm-only" calendar capability
    
    Do not let add more than one reminder, when the target calendar supports
    only one reminder.

 src/calendar/gui/e-comp-editor-page-reminders.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/calendar/gui/e-comp-editor-page-reminders.c b/src/calendar/gui/e-comp-editor-page-reminders.c
index 85db9a8ef3..1fbc278cd3 100644
--- a/src/calendar/gui/e-comp-editor-page-reminders.c
+++ b/src/calendar/gui/e-comp-editor-page-reminders.c
@@ -184,15 +184,36 @@ ecep_reminders_sanitize_option_widgets (ECompEditorPageReminders *page_reminders
        gboolean any_selected;
        gboolean is_custom;
        gboolean sensitive;
+       gboolean can_only_one = FALSE;
+       gint n_defined;
 
        g_return_if_fail (E_IS_COMP_EDITOR_PAGE_REMINDERS (page_reminders));
 
        any_selected = gtk_tree_selection_count_selected_rows (gtk_tree_view_get_selection (
                GTK_TREE_VIEW (page_reminders->priv->alarms_tree_view))) > 0;
        is_custom = ecep_reminders_get_alarm_index (GTK_COMBO_BOX (page_reminders->priv->alarms_combo)) == -2;
+       n_defined = gtk_tree_model_iter_n_children (gtk_tree_view_get_model (
+               GTK_TREE_VIEW (page_reminders->priv->alarms_tree_view)), NULL);
+
+       if (n_defined >= 1) {
+               ECompEditor *comp_editor;
+
+               comp_editor = e_comp_editor_page_ref_editor (E_COMP_EDITOR_PAGE (page_reminders));
+
+               if (comp_editor) {
+                       ECalClient *target_client;
+
+                       target_client = e_comp_editor_get_target_client (comp_editor);
+
+                       if (target_client)
+                               can_only_one = e_cal_client_check_one_alarm_only (target_client);
+
+                       g_object_unref (comp_editor);
+               }
+       }
 
        gtk_widget_set_sensitive (page_reminders->priv->alarms_tree_view, is_custom);
-       gtk_widget_set_sensitive (page_reminders->priv->alarms_add_button, is_custom);
+       gtk_widget_set_sensitive (page_reminders->priv->alarms_add_button, is_custom && (n_defined < 1 || 
!can_only_one));
        gtk_widget_set_sensitive (page_reminders->priv->alarms_remove_button, any_selected && is_custom);
 
        gtk_widget_set_visible (page_reminders->priv->alarm_setup_hbox, any_selected && is_custom);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]