From 2b0e8f0a21169b879c044cf917eee51bede7dca5 Mon Sep 17 00:00:00 2001 From: Fabiano FidĂȘncio Date: Wed, 26 Jun 2013 20:17:27 +0200 Subject: Bug #703053 - Error on setting reminder 'after start of appointment' Check if the client supports setting 'after start' reminder and disable it if necessary (and also disabling 'before end of appoint') --- calendar/gui/dialogs/alarm-dialog.c | 119 ++++++++++++++++++++++++++--------- calendar/gui/dialogs/alarm-dialog.ui | 42 +------------ 2 files changed, 90 insertions(+), 71 deletions(-) diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c index 42411f9af7..71852c50d0 100644 --- a/calendar/gui/dialogs/alarm-dialog.c +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -182,6 +182,34 @@ clear_widgets (Dialog *dialog) gtk_notebook_set_current_page (GTK_NOTEBOOK (dialog->option_notebook), 0); } +static void +populate_relative_time_combobox_widget (GtkWidget *combobox, + ECalClient *cal_client, + const gint *map, + gint prop) +{ + GtkTreeModel *model; + GtkTreeIter iter; + gboolean valid; + gboolean alarm_after_start; + gint i; + + alarm_after_start = !e_client_check_capability ( + E_CLIENT (cal_client), CAL_STATIC_CAPABILITY_NO_ALARM_AFTER_START); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox)); + valid = gtk_tree_model_get_iter_first (model, &iter); + + for (i = 0; valid && map[i] != -1; i++) { + gtk_list_store_set ( + GTK_LIST_STORE (model), + &iter, + 1, + alarm_after_start ? TRUE : (map[i] == prop ? FALSE : TRUE), + -1); + valid = gtk_tree_model_iter_next (model, &iter); + } +} + /* fill_widgets handler for the alarm page */ static void alarm_to_dialog (Dialog *dialog) @@ -205,10 +233,13 @@ alarm_to_dialog (Dialog *dialog) GTK_LIST_STORE (model), &iter, 1, !e_client_check_capability (E_CLIENT (dialog->cal_client), action_map_cap[i]), -1); - valid = gtk_tree_model_iter_next (model, &iter); } + populate_relative_time_combobox_widget (dialog->relative_combo, dialog->cal_client, relative_map, AFTER); + populate_relative_time_combobox_widget ( + dialog->time_combo, dialog->cal_client, time_map, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END); + /* Set a default address if possible */ if (!e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) && !e_cal_component_alarm_has_attendees (dialog->alarm) @@ -775,6 +806,44 @@ dialog_to_alarm (Dialog *dialog) } } +static void +build_combobox_widget (GtkWidget *combobox, + const gchar *actions[]) +{ + GtkComboBox *combo = GTK_COMBO_BOX (combobox); + GtkCellRenderer *cell; + GtkListStore *store; + gint i; + + g_return_val_if_fail (combo != NULL, FALSE); + g_return_val_if_fail (GTK_IS_COMBO_BOX (combo), FALSE); + + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN); + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); + g_object_unref (store); + + gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo)); + + cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); + gtk_cell_layout_set_attributes ( + GTK_CELL_LAYOUT (combo), cell, + "text", 0, + "sensitive", 1, + NULL); + + for (i = 0; actions[i] != NULL; i++) { + GtkTreeIter iter; + + gtk_list_store_append (store, &iter); + gtk_list_store_set ( + store, &iter, + 0, _(actions[i]), + 1, TRUE, + -1); + } +} + /* Gets the widgets from the XML file and returns TRUE if they are all available. */ static gboolean get_widgets (Dialog *dialog) @@ -820,41 +889,31 @@ get_widgets (Dialog *dialog) N_("Pop up an alert"), N_("Play a sound"), N_("Run a program"), - N_("Send an email") + N_("Send an email"), + NULL }; - GtkComboBox *combo = (GtkComboBox *) dialog->action_combo; - GtkCellRenderer *cell; - GtkListStore *store; - gint i; - - g_return_val_if_fail (combo != NULL, FALSE); - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo), FALSE); - - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN); - gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); - g_object_unref (store); + build_combobox_widget (dialog->action_combo, actions); + } - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo)); + if (dialog->relative_combo) { + const gchar *actions[] = { + N_("before"), + N_("after"), + NULL + }; - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); - gtk_cell_layout_set_attributes ( - GTK_CELL_LAYOUT (combo), cell, - "text", 0, - "sensitive", 1, - NULL); + build_combobox_widget (dialog->relative_combo, actions); + } - for (i = 0; i < G_N_ELEMENTS (actions); i++) { - GtkTreeIter iter; + if (dialog->time_combo) { + const gchar *actions[] = { + N_("start of appointmenet"), + N_("end of appointment"), + NULL + }; - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - 0, _(actions[i]), - 1, TRUE, - -1); - } + build_combobox_widget (dialog->time_combo, actions); } return (dialog->action_combo diff --git a/calendar/gui/dialogs/alarm-dialog.ui b/calendar/gui/dialogs/alarm-dialog.ui index ba2d7abbd3..c7c03106f4 100644 --- a/calendar/gui/dialogs/alarm-dialog.ui +++ b/calendar/gui/dialogs/alarm-dialog.ui @@ -42,32 +42,6 @@ - - - - - - before - - - after - - - - - - - - - - start of appointment - - - end of appointment - - - - @@ -256,13 +230,6 @@ True False True - model2 - - - - 0 - - 0 @@ -275,13 +242,6 @@ True False True - model3 - - - - 0 - - 0 @@ -449,7 +409,7 @@ True False True - model4 + model2 -- cgit