From d63754acb1a37037ce09251c00fefa5e689f780b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 19 Jan 2009 14:14:56 +0000 Subject: ** Part of fix for bug #260853 2009-01-19 Milan Crha ** Part of fix for bug #260853 * gui/calendar-config-keys.h: * gui/calendar-config.h: (calendar_config_get_ba_reminder), (calendar_config_set_ba_reminder): * gui/calendar-config.c: (calendar_config_get_ba_reminder), (calendar_config_set_ba_reminder), (string_to_units), (calendar_config_get_default_reminder_units): * gui/dialogs/cal-prefs-dialog.glade: * gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog): * gui/dialogs/cal-prefs-dialog.c: (ba_reminder_toggled), (ba_reminder_interval_changed), (ba_reminder_units_changed), (setup_changes), (show_config), (calendar_prefs_dialog_construct): User interface and related function to allow use change setup of the alarm for Birthdays and Anniversaries calendar. svn path=/trunk/; revision=37098 --- calendar/gui/dialogs/cal-prefs-dialog.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'calendar/gui/dialogs/cal-prefs-dialog.c') diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 8cec102e4a..21ace5aea4 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -49,6 +49,7 @@ static const int hide_completed_units_map[] = { CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1 }; +/* same is used for Birthdays & Anniversaries calendar */ static const int default_reminder_units_map[] = { CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1 }; @@ -413,6 +414,34 @@ default_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) e_dialog_combo_box_get (prefs->default_reminder_units, default_reminder_units_map)); } +static void +ba_reminder_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) +{ + gboolean enabled = gtk_toggle_button_get_active (toggle); + + calendar_config_set_ba_reminder (&enabled, NULL, NULL); +} + +static void +ba_reminder_interval_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) +{ + const gchar *str; + int value; + + str = gtk_entry_get_text (GTK_ENTRY (widget)); + value = (int) g_ascii_strtod (str, NULL); + + calendar_config_set_ba_reminder (NULL, &value, NULL); +} + +static void +ba_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) +{ + CalUnits units = e_dialog_combo_box_get (prefs->ba_reminder_units, default_reminder_units_map); + + calendar_config_set_ba_reminder (NULL, NULL, &units); +} + static void alarms_selection_changed (ESourceSelector *selector, CalendarPrefsDialog *prefs) { @@ -507,6 +536,11 @@ setup_changes (CalendarPrefsDialog *prefs) G_CALLBACK (default_reminder_interval_changed), prefs); g_signal_connect (G_OBJECT (prefs->default_reminder_units), "changed", G_CALLBACK (default_reminder_units_changed), prefs); + g_signal_connect (G_OBJECT (prefs->ba_reminder), "toggled", G_CALLBACK (ba_reminder_toggled), prefs); + g_signal_connect (G_OBJECT (prefs->ba_reminder_interval), "changed", + G_CALLBACK (ba_reminder_interval_changed), prefs); + g_signal_connect (G_OBJECT (prefs->ba_reminder_units), "changed", G_CALLBACK (ba_reminder_units_changed), prefs); + g_signal_connect (G_OBJECT (prefs->alarm_list_widget), "selection_changed", G_CALLBACK (alarms_selection_changed), prefs); @@ -600,6 +634,8 @@ show_config (CalendarPrefsDialog *prefs) gboolean sensitive, set = FALSE; icalcomponent *icalcomp, *dl_comp; char *location; + CalUnits units; + int interval; /* Timezone. */ location = calendar_config_get_timezone (); @@ -678,6 +714,13 @@ show_config (CalendarPrefsDialog *prefs) e_dialog_toggle_set (prefs->default_reminder, calendar_config_get_use_default_reminder ()); e_dialog_spin_set (prefs->default_reminder_interval, calendar_config_get_default_reminder_interval ()); e_dialog_combo_box_set (prefs->default_reminder_units, calendar_config_get_default_reminder_units (), default_reminder_units_map); + + /* Birthdays & Anniversaries reminder */ + set = calendar_config_get_ba_reminder (&interval, &units); + + e_dialog_toggle_set (prefs->ba_reminder, set); + e_dialog_spin_set (prefs->ba_reminder_interval, interval); + e_dialog_combo_box_set (prefs->ba_reminder_units, units, default_reminder_units_map); } /* plugin meta-data */ @@ -759,6 +802,9 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) prefs->default_reminder = glade_xml_get_widget (gui, "default_reminder"); prefs->default_reminder_interval = glade_xml_get_widget (gui, "default_reminder_interval"); prefs->default_reminder_units = glade_xml_get_widget (gui, "default_reminder_units"); + prefs->ba_reminder = glade_xml_get_widget (gui, "ba_reminder"); + prefs->ba_reminder_interval = glade_xml_get_widget (gui, "ba_reminder_interval"); + prefs->ba_reminder_units = glade_xml_get_widget (gui, "ba_reminder_units"); /* Display tab */ prefs->time_divisions = glade_xml_get_widget (gui, "time_divisions"); -- cgit