aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-19 22:14:56 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-19 22:14:56 +0800
commitd63754acb1a37037ce09251c00fefa5e689f780b (patch)
treefd94473f060473b0918700d0e457b85903b6a3c5
parent2be7cd3b2ab50047820da4a1e873785b53f41acd (diff)
downloadgsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar.gz
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar.bz2
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar.lz
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar.xz
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.tar.zst
gsoc2013-evolution-d63754acb1a37037ce09251c00fefa5e689f780b.zip
** Part of fix for bug #260853
2009-01-19 Milan Crha <mcrha@redhat.com> ** 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
-rw-r--r--calendar/ChangeLog18
-rw-r--r--calendar/gui/calendar-config-keys.h5
-rw-r--r--calendar/gui/calendar-config.c77
-rw-r--r--calendar/gui/calendar-config.h4
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.c46
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.glade92
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.h3
7 files changed, 238 insertions, 7 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 2368ba969c..e60ed7513e 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,23 @@
2009-01-19 Milan Crha <mcrha@redhat.com>
+ ** 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.
+
+2009-01-19 Milan Crha <mcrha@redhat.com>
+
** Fix for bug #225712
* gui/dialogs/comp-editor.h: (CompEditorClass::send_comp),
diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h
index 6706c65cdc..05feb18d00 100644
--- a/calendar/gui/calendar-config-keys.h
+++ b/calendar/gui/calendar-config-keys.h
@@ -96,6 +96,11 @@ G_BEGIN_DECLS
#define CALENDAR_CONFIG_TEMPLATE CALENDAR_CONFIG_PREFIX"/publish/template"
#define CALENDAR_CONFIG_SAVE_DIR CALENDAR_CONFIG_PREFIX"/audio_dir"
+
+/* Birthday & Anniversary reminder */
+#define CALENDAR_CONFIG_BA_REMINDER CALENDAR_CONFIG_PREFIX "/other/use_ba_reminder"
+#define CALENDAR_CONFIG_BA_REMINDER_INTERVAL CALENDAR_CONFIG_PREFIX "/other/ba_reminder_interval"
+#define CALENDAR_CONFIG_BA_REMINDER_UNITS CALENDAR_CONFIG_PREFIX "/other/ba_reminder_units"
G_END_DECLS
#endif
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 4e6f853db0..d8579edd61 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -106,6 +106,22 @@ units_to_string (CalUnits units)
}
}
+/* opposite function to 'units_to_string' */
+static CalUnits
+string_to_units (const char *units)
+{
+ CalUnits res;
+
+ if (units && !strcmp (units, "days"))
+ res = CAL_DAYS;
+ else if (units && !strcmp (units, "hours"))
+ res = CAL_HOURS;
+ else
+ res = CAL_MINUTES;
+
+ return res;
+}
+
/*
* Calendar Settings.
*/
@@ -1454,13 +1470,7 @@ calendar_config_get_default_reminder_units (void)
calendar_config_init ();
units = gconf_client_get_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL);
-
- if (units && !strcmp (units, "days"))
- cu = CAL_DAYS;
- else if (units && !strcmp (units, "hours"))
- cu = CAL_HOURS;
- else
- cu = CAL_MINUTES;
+ cu = string_to_units (units);
g_free (units);
return cu;
@@ -1481,6 +1491,59 @@ calendar_config_set_default_reminder_units (CalUnits units)
}
/**
+ * calendar_config_get_ba_reminder:
+ * Retrieves setup of the Birthdays & Anniversaries reminder.
+ *
+ * @interval: Retrieves the interval setup for the reminder; can be NULL.
+ * @units: Retrieves units for the interval; can be NULL.
+ *
+ * Returns whether the reminder is on or off. The values for interval and/or units
+ * are retrieved even when returns FALSE.
+ **/
+gboolean
+calendar_config_get_ba_reminder (int *interval, CalUnits *units)
+{
+ calendar_config_init ();
+
+ if (interval) {
+ *interval = gconf_client_get_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, NULL);
+ }
+
+ if (units) {
+ char *str;
+
+ str = gconf_client_get_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, NULL);
+ *units = string_to_units (str);
+ g_free (str);
+ }
+
+ return gconf_client_get_bool (config, CALENDAR_CONFIG_BA_REMINDER, NULL);
+}
+
+/**
+ * calendar_config_set_ba_reminder:
+ * Stores new values for Birthdays & Anniversaries reminder to GConf. Only those, which are not NULL.
+ *
+ * @enabled: The enabled state; can be NULL.
+ * @interval: The reminder interval; can be NULL.
+ * @units: The units of the reminder; can be NULL.
+ **/
+void
+calendar_config_set_ba_reminder (gboolean *enabled, int *interval, CalUnits *units)
+{
+ calendar_config_init ();
+
+ if (enabled)
+ gconf_client_set_bool (config, CALENDAR_CONFIG_BA_REMINDER, *enabled, NULL);
+
+ if (interval)
+ gconf_client_set_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, *interval, NULL);
+
+ if (units)
+ gconf_client_set_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, units_to_string (*units), NULL);
+}
+
+/**
* calendar_config_get_hide_completed_tasks_sexp:
*
* @get_completed: Whether to form subexpression that
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 09973e1329..0d79d2050c 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -270,4 +270,8 @@ char * calendar_config_get_day_second_zone (void);
void calendar_config_select_day_second_zone (void);
guint calendar_config_add_notification_day_second_zone (GConfClientNotifyFunc func, gpointer data);
+/* Birthdays & Anniversaries reminder settings */
+gboolean calendar_config_get_ba_reminder (int *interval, CalUnits *units);
+void calendar_config_set_ba_reminder (gboolean *enabled, int *interval, CalUnits *units);
+
#endif /* _CALENDAR_CONFIG_H_ */
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
};
@@ -414,6 +415,34 @@ default_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs)
}
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)
{
ESourceList *source_list = prefs->alarms_list;
@@ -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");
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade
index 9f7f6a8092..b8947b4c44 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.glade
+++ b/calendar/gui/dialogs/cal-prefs-dialog.glade
@@ -950,6 +950,98 @@ Days</property>
<property name="fill">True</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox25">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">4</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="ba_reminder">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show a _reminder</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSpinButton" id="ba_reminder_interval">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">0 0 9999 1 10 10</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="ba_reminder_units">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">Minutes
+Hours
+Days</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="ba_reminder_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">before every anniversary/birthday</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h
index 512d5d06c6..3c006b8711 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.h
+++ b/calendar/gui/dialogs/cal-prefs-dialog.h
@@ -56,6 +56,9 @@ struct _CalendarPrefsDialog {
GtkWidget *default_reminder;
GtkWidget *default_reminder_interval;
GtkWidget *default_reminder_units;
+ GtkWidget *ba_reminder;
+ GtkWidget *ba_reminder_interval;
+ GtkWidget *ba_reminder_units;
/* Display tab */
GtkWidget *time_divisions;