[gnome-calendar/wip/gbsneto/alarms: 6/6] edit-dialog: make already-added alarms' buttons insensitive
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/gbsneto/alarms: 6/6] edit-dialog: make already-added alarms' buttons insensitive
- Date: Wed, 6 Jul 2016 05:39:59 +0000 (UTC)
commit 3a2fd206be937e3d3bbae664180565bd55a61004
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jul 6 02:36:51 2016 -0300
edit-dialog: make already-added alarms' buttons insensitive
Since we only support 1 alarm per time, we have to check and
eventually make insensitive the buttons related to the alarms.
src/gcal-edit-dialog.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index 4d1a815..fb609cb 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -729,6 +729,23 @@ static void
setup_alarms (GcalEditDialog *self)
{
GList *alarms, *l;
+ gint i;
+
+ struct
+ {
+ gint minutes;
+ GtkWidget *button;
+ } minutes_button[] = {
+ { 5, self->five_minutes_button },
+ { 10, self->ten_minutes_button },
+ { 30, self->thirty_minutes_button },
+ { 60, self->one_hour_button },
+ { 1440, self->one_day_button },
+ { 2880, self->two_days_button },
+ { 4320, self->three_days_button },
+ { 10080, self->one_week_button },
+ { 0, NULL }
+ };
gtk_widget_set_visible (self->alarms_listbox, gcal_event_has_alarms (self->event));
@@ -739,15 +756,33 @@ setup_alarms (GcalEditDialog *self)
(GtkCallback) gtk_widget_destroy,
NULL);
+ /*
+ * We start by making all alarm buttons sensitive,
+ * and only insisitive-ize when needed.
+ */
+ for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
+ gtk_widget_set_sensitive (minutes_button[i].button, TRUE);
+
for (l = alarms; l != NULL; l = l->next)
{
GtkWidget *row;
+ gint minutes;
row = create_row_for_alarm (self->event, l->data);
if (!row)
continue;
+ /* Make already-added alarm buttons insensitive */
+ minutes = get_alarm_trigger_minutes (self->event, l->data);
+
+ for (i = 0; i < G_N_ELEMENTS (minutes_button); i++)
+ {
+ if (minutes_button[i].minutes == minutes)
+ gtk_widget_set_sensitive (minutes_button[i].button, FALSE);
+ }
+
+ /* Add the row */
gtk_container_add (GTK_CONTAINER (self->alarms_listbox), row);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]