aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-12-03 02:10:20 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-12-03 02:10:20 +0800
commitb4680776083616beb63924706995a321622cd1cc (patch)
tree6f61b3b145acd3b533589ee6fc23f0fdc4baed6d
parentf70c74f37110d1bcb23227c720965a058cabf61c (diff)
downloadgsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar.gz
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar.bz2
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar.lz
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar.xz
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.tar.zst
gsoc2013-evolution-b4680776083616beb63924706995a321622cd1cc.zip
Fixes bug #918.
2000-12-01 Federico Mena Quintero <federico@helixcode.com> Fixes bug #918. * gui/weekday-picker.c (WeekdayPickerPrivate): Added a field for a set of blocked days. (weekday_picker_set_blocked_days): New function to configure a set of days that cannot be modified by the user. (weekday_picker_get_blocked_days): Query function for the above. (day_event_cb): Block the appropriate days from being modified. * gui/event-editor.c (get_start_weekday_mask): New function to compute a day mask for the start day of a calendar component. (set_recur_special_defaults): New function to set sane defaults for the recurrence special widgets. (fill_recurrence_widgets): Use set_recur_special_defaults(). (make_recur_weekly_special): Block the appropriate days. svn path=/trunk/; revision=6767
-rw-r--r--calendar/ChangeLog18
-rw-r--r--calendar/gui/event-editor.c50
-rw-r--r--calendar/gui/weekday-picker.c49
-rw-r--r--calendar/gui/weekday-picker.h3
4 files changed, 120 insertions, 0 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index c1dbf721c4..858e4f6e78 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,23 @@
2000-12-01 Federico Mena Quintero <federico@helixcode.com>
+ Fixes bug #918.
+
+ * gui/weekday-picker.c (WeekdayPickerPrivate): Added a field for a
+ set of blocked days.
+ (weekday_picker_set_blocked_days): New function to configure a set
+ of days that cannot be modified by the user.
+ (weekday_picker_get_blocked_days): Query function for the above.
+ (day_event_cb): Block the appropriate days from being modified.
+
+ * gui/event-editor.c (get_start_weekday_mask): New function to
+ compute a day mask for the start day of a calendar component.
+ (set_recur_special_defaults): New function to set sane defaults
+ for the recurrence special widgets.
+ (fill_recurrence_widgets): Use set_recur_special_defaults().
+ (make_recur_weekly_special): Block the appropriate days.
+
+2000-12-01 Federico Mena Quintero <federico@helixcode.com>
+
* gui/control-factory.c (set_prop): Removed debugging message.
(control_factory_init): Ditto.
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c
index c33f5b720d..95ebe40560 100644
--- a/calendar/gui/event-editor.c
+++ b/calendar/gui/event-editor.c
@@ -124,6 +124,7 @@ struct _EventEditorPrivate {
/* For weekly recurrences, created by hand */
GtkWidget *recurrence_weekday_picker;
guint8 recurrence_weekday_day_mask;
+ guint8 recurrence_weekday_blocked_day_mask;
/* For monthly recurrences, created by hand */
GtkWidget *recurrence_month_index_spin;
@@ -401,6 +402,7 @@ make_recur_weekly_special (EventEditor *ee)
weekday_picker_set_week_starts_on_monday (wp, week_starts_on_monday);
weekday_picker_set_days (wp, priv->recurrence_weekday_day_mask);
+ weekday_picker_set_blocked_days (wp, priv->recurrence_weekday_blocked_day_mask);
gtk_signal_connect (GTK_OBJECT (wp), "changed",
GTK_SIGNAL_FUNC (recur_weekday_picker_changed_cb), ee);
@@ -1411,6 +1413,50 @@ fill_exception_widgets (EventEditor *ee)
cal_component_free_exdate_list (list);
}
+/* Computes a weekday mask for the start day of a calendar component, for use in
+ * a WeekdayPicker widget.
+ */
+static guint8
+get_start_weekday_mask (CalComponent *comp)
+{
+ CalComponentDateTime dt;
+ guint8 retval;
+
+ cal_component_get_dtstart (comp, &dt);
+
+ if (dt.value) {
+ time_t t;
+ struct tm tm;
+
+ t = icaltime_as_timet (*dt.value);
+ tm = *localtime (&t);
+
+ retval = 0x1 << tm.tm_wday;
+ } else
+ retval = 0;
+
+ cal_component_free_datetime (&dt);
+
+ return retval;
+}
+
+/* Sets some sane defaults for the data sources for the recurrence special
+ * widgets, even if they will not be used immediately.
+ */
+static void
+set_recur_special_defaults (EventEditor *ee)
+{
+ EventEditorPrivate *priv;
+ guint8 mask;
+
+ priv = ee->priv;
+
+ mask = get_start_weekday_mask (priv->comp);
+
+ priv->recurrence_weekday_day_mask = mask;
+ priv->recurrence_weekday_blocked_day_mask = mask;
+}
+
/* Fills in the recurrence widgets with the values from the calendar component.
* This function is particularly tricky because it has to discriminate between
* recurrences we support for editing and the ones we don't. We only support at
@@ -1435,6 +1481,10 @@ fill_recurrence_widgets (EventEditor *ee)
fill_exception_widgets (ee);
+ /* Set up defaults for the special widgets */
+
+ set_recur_special_defaults (ee);
+
/* No recurrences? */
if (!cal_component_has_rdates (priv->comp)
diff --git a/calendar/gui/weekday-picker.c b/calendar/gui/weekday-picker.c
index 8ebcf1d970..4c0ede2579 100644
--- a/calendar/gui/weekday-picker.c
+++ b/calendar/gui/weekday-picker.c
@@ -38,6 +38,9 @@ struct _WeekdayPickerPrivate {
/* Selected days; see weekday_picker_set_days() */
guint8 day_mask;
+ /* Blocked days; these cannot be modified */
+ guint8 blocked_day_mask;
+
/* Metrics */
int font_ascent, font_descent;
int max_letter_width;
@@ -168,6 +171,9 @@ day_event_cb (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
i++;
}
+ if (priv->blocked_day_mask & (0x1 << i))
+ return TRUE;
+
if (priv->day_mask & (0x1 << i))
day_mask = priv->day_mask & ~(0x1 << i);
else
@@ -515,6 +521,49 @@ weekday_picker_get_days (WeekdayPicker *wp)
}
/**
+ * weekday_picker_set_blocked_days:
+ * @wp: A weekday picker.
+ * @blocked_day_mask: Bitmask with the days to be blocked.
+ *
+ * Sets the days that the weekday picker will prevent from being modified by the
+ * user. The @blocked_day_mask is specified in the same way as in
+ * weekday_picker_set_days().
+ **/
+void
+weekday_picker_set_blocked_days (WeekdayPicker *wp, guint8 blocked_day_mask)
+{
+ WeekdayPickerPrivate *priv;
+
+ g_return_if_fail (wp != NULL);
+ g_return_if_fail (IS_WEEKDAY_PICKER (wp));
+
+ priv = wp->priv;
+ priv->blocked_day_mask = blocked_day_mask;
+}
+
+/**
+ * weekday_picker_get_blocked_days:
+ * @wp: A weekday picker.
+ *
+ * Queries the set of days that the weekday picker prevents from being modified
+ * by the user.
+ *
+ * Return value: Bit mask of blocked days, with the same format as that returned
+ * by weekday_picker_get_days().
+ **/
+guint
+weekday_picker_get_blocked_days (WeekdayPicker *wp)
+{
+ WeekdayPickerPrivate *priv;
+
+ g_return_val_if_fail (wp != NULL, 0);
+ g_return_val_if_fail (IS_WEEKDAY_PICKER (wp), 0);
+
+ priv = wp->priv;
+ return priv->blocked_day_mask;
+}
+
+/**
* weekday_picker_set_week_starts_on_monday:
* @wp: A weekday picker.
* @on_monday: Whether weeks start on Monday.
diff --git a/calendar/gui/weekday-picker.h b/calendar/gui/weekday-picker.h
index cd24bb86e4..cf2367c511 100644
--- a/calendar/gui/weekday-picker.h
+++ b/calendar/gui/weekday-picker.h
@@ -60,6 +60,9 @@ GtkWidget *weekday_picker_new (void);
void weekday_picker_set_days (WeekdayPicker *wp, guint8 day_mask);
guint8 weekday_picker_get_days (WeekdayPicker *wp);
+void weekday_picker_set_blocked_days (WeekdayPicker *wp, guint8 blocked_day_mask);
+guint weekday_picker_get_blocked_days (WeekdayPicker *wp);
+
void weekday_picker_set_week_starts_on_monday (WeekdayPicker *wp, gboolean on_monday);
gboolean weekday_picker_get_week_starts_on_monday (WeekdayPicker *wp);