evolution r37098 - in trunk/calendar: . gui gui/dialogs



Author: mcrha
Date: Mon Jan 19 14:14:56 2009
New Revision: 37098
URL: http://svn.gnome.org/viewvc/evolution?rev=37098&view=rev

Log:
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.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/calendar-config-keys.h
   trunk/calendar/gui/calendar-config.c
   trunk/calendar/gui/calendar-config.h
   trunk/calendar/gui/dialogs/cal-prefs-dialog.c
   trunk/calendar/gui/dialogs/cal-prefs-dialog.glade
   trunk/calendar/gui/dialogs/cal-prefs-dialog.h

Modified: trunk/calendar/gui/calendar-config-keys.h
==============================================================================
--- trunk/calendar/gui/calendar-config-keys.h	(original)
+++ trunk/calendar/gui/calendar-config-keys.h	Mon Jan 19 14:14:56 2009
@@ -96,6 +96,11 @@
 #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

Modified: trunk/calendar/gui/calendar-config.c
==============================================================================
--- trunk/calendar/gui/calendar-config.c	(original)
+++ trunk/calendar/gui/calendar-config.c	Mon Jan 19 14:14:56 2009
@@ -106,6 +106,22 @@
 	}
 }
 
+/* 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_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_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

Modified: trunk/calendar/gui/calendar-config.h
==============================================================================
--- trunk/calendar/gui/calendar-config.h	(original)
+++ trunk/calendar/gui/calendar-config.h	Mon Jan 19 14:14:56 2009
@@ -270,4 +270,8 @@
 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_ */

Modified: trunk/calendar/gui/dialogs/cal-prefs-dialog.c
==============================================================================
--- trunk/calendar/gui/dialogs/cal-prefs-dialog.c	(original)
+++ trunk/calendar/gui/dialogs/cal-prefs-dialog.c	Mon Jan 19 14:14:56 2009
@@ -49,6 +49,7 @@
 	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 @@
 }
 
 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 @@
 			  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 @@
 	gboolean sensitive, set = FALSE;
 	icalcomponent *icalcomp, *dl_comp;
 	char *location;
+	CalUnits units;
+	int interval;
 
 	/* Timezone. */
 	location = calendar_config_get_timezone ();
@@ -678,6 +714,13 @@
 	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 @@
 	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");

Modified: trunk/calendar/gui/dialogs/cal-prefs-dialog.glade
==============================================================================
--- trunk/calendar/gui/dialogs/cal-prefs-dialog.glade	(original)
+++ trunk/calendar/gui/dialogs/cal-prefs-dialog.glade	Mon Jan 19 14:14:56 2009
@@ -950,6 +950,98 @@
 		      <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>

Modified: trunk/calendar/gui/dialogs/cal-prefs-dialog.h
==============================================================================
--- trunk/calendar/gui/dialogs/cal-prefs-dialog.h	(original)
+++ trunk/calendar/gui/dialogs/cal-prefs-dialog.h	Mon Jan 19 14:14:56 2009
@@ -56,6 +56,9 @@
 	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;



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