aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-12-15 19:39:48 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-12-15 19:39:48 +0800
commit937d719a6a5b880df4b75cfe8318d37fd4a4e814 (patch)
tree6185ecc76c9e1f333d47d2d35dbb8c91021d3fea
parent5674d76445b199855d4d431b6db4c0302f4a932b (diff)
downloadgsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar.gz
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar.bz2
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar.lz
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar.xz
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.tar.zst
gsoc2013-evolution-937d719a6a5b880df4b75cfe8318d37fd4a4e814.zip
Fixes bug #955.
2000-12-14 Federico Mena Quintero <federico@helixcode.com> Fixes bug #955. * gui/weekday-picker.c (WeekdayPickerPrivate): Added a field for the week_start_day, to be used in the same way as calendar-config.h defines it. Removed the week_starts_on_monday flag. (day_event_cb): Use the week_start_day. (colorize_items): Likewise. (configure_items): Likewise. (weekday_picker_set_week_start_day): New function. (weekday_picker_get_week_start_day): New function. (weekday_picker_set_week_starts_on_monday): Removed function. (weekday_picker_get_week_starts_on_monday): Removed function. * gui/widget-util.[ch]: New files with utilities for creating or configuring widgets. * gui/widget-util.c (date_edit_new): New function to create an EDateEdit configured with the calendar's preferences; moved over from event-editor.c. * gui/event-editor.c (make_recur_weekly_special): Use weekday_picker_set_week_start_day() and the corresponding function from calendar-config.h. (init_widgets): Likewise. (make_date_edit_with_time): Removed function. (make_recur_ending_until_special): Use date_edit_new(). (make_date_edit): Likewise. * gui/dialogs/task-editor.c (task_editor_create_date_edit): Likewise. * gui/event-editor-dialog.glade: Removed references to make_date_edit_with_time(); replace them with make_date_edit(). * gui/Makefile.am (evolution_calendar_SOURCES): Added widget-util.[ch] to the list of sources. svn path=/trunk/; revision=7037
-rw-r--r--calendar/ChangeLog39
-rw-r--r--calendar/gui/Makefile.am4
-rw-r--r--calendar/gui/dialogs/task-editor.c6
-rw-r--r--calendar/gui/event-editor-dialog.glade4
-rw-r--r--calendar/gui/event-editor.c33
-rw-r--r--calendar/gui/event-editor.h9
-rw-r--r--calendar/gui/weekday-picker.c111
-rw-r--r--calendar/gui/weekday-picker.h4
-rw-r--r--calendar/gui/widget-util.c57
-rw-r--r--calendar/gui/widget-util.h31
10 files changed, 180 insertions, 118 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 65c701de91..4cd6ddcfc2 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,44 @@
2000-12-14 Federico Mena Quintero <federico@helixcode.com>
+ Fixes bug #955.
+
+ * gui/weekday-picker.c (WeekdayPickerPrivate): Added a field for
+ the week_start_day, to be used in the same way as
+ calendar-config.h defines it. Removed the week_starts_on_monday
+ flag.
+ (day_event_cb): Use the week_start_day.
+ (colorize_items): Likewise.
+ (configure_items): Likewise.
+ (weekday_picker_set_week_start_day): New function.
+ (weekday_picker_get_week_start_day): New function.
+ (weekday_picker_set_week_starts_on_monday): Removed function.
+ (weekday_picker_get_week_starts_on_monday): Removed function.
+
+ * gui/widget-util.[ch]: New files with utilities for creating or
+ configuring widgets.
+
+ * gui/widget-util.c (date_edit_new): New function to create an
+ EDateEdit configured with the calendar's preferences; moved over
+ from event-editor.c.
+
+ * gui/event-editor.c (make_recur_weekly_special): Use
+ weekday_picker_set_week_start_day() and the corresponding function
+ from calendar-config.h.
+ (init_widgets): Likewise.
+ (make_date_edit_with_time): Removed function.
+ (make_recur_ending_until_special): Use date_edit_new().
+ (make_date_edit): Likewise.
+
+ * gui/dialogs/task-editor.c (task_editor_create_date_edit): Likewise.
+
+ * gui/event-editor-dialog.glade: Removed references to
+ make_date_edit_with_time(); replace them with make_date_edit().
+
+ * gui/Makefile.am (evolution_calendar_SOURCES): Added
+ widget-util.[ch] to the list of sources.
+
+2000-12-14 Federico Mena Quintero <federico@helixcode.com>
+
* gui/e-calendar-table.c (E_CALENDAR_TABLE_SPEC): Reset the widths
of the columns with pixbufs to the actual pixbufs' sizes; now
ETable properly computes its column widths so we do not need to
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 2268fa2b3c..32cb4df91f 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -116,7 +116,9 @@ evolution_calendar_SOURCES = \
tag-calendar.c \
tag-calendar.h \
weekday-picker.c \
- weekday-picker.h
+ weekday-picker.h \
+ widget-util.c \
+ widget-util.h
evolution_calendar_LDADD = \
$(top_builddir)/shell/libeshell.a \
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index b5e47cfdb7..6cf73a3a72 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -38,6 +38,7 @@
#include <cal-client/cal-client.h>
#include "task-editor.h"
#include "../calendar-config.h"
+#include "../widget-util.h"
typedef struct {
@@ -328,10 +329,9 @@ task_editor_create_date_edit (void)
{
GtkWidget *dedit;
- dedit = e_date_edit_new ();
- /* FIXME: Set other options. */
- e_date_edit_set_time_popup_range (E_DATE_EDIT (dedit), calendar_config_get_day_start_hour (), calendar_config_get_day_end_hour ());
+ dedit = date_edit_new (TRUE, TRUE);
e_date_edit_set_allow_no_date_set (E_DATE_EDIT (dedit), TRUE);
+
return dedit;
}
diff --git a/calendar/gui/event-editor-dialog.glade b/calendar/gui/event-editor-dialog.glade
index b3b580d1ea..dea912be28 100644
--- a/calendar/gui/event-editor-dialog.glade
+++ b/calendar/gui/event-editor-dialog.glade
@@ -228,7 +228,7 @@
<widget>
<class>Custom</class>
<name>start-time</name>
- <creation_function>make_date_edit_with_time</creation_function>
+ <creation_function>make_date_edit</creation_function>
<string1></string1>
<string2></string2>
<int1>0</int1>
@@ -253,7 +253,7 @@
<widget>
<class>Custom</class>
<name>end-time</name>
- <creation_function>make_date_edit_with_time</creation_function>
+ <creation_function>make_date_edit</creation_function>
<int1>0</int1>
<int2>0</int2>
<last_modification_time>Tue, 16 May 2000 19:11:10 GMT</last_modification_time>
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c
index 6f30b45797..726f29e67d 100644
--- a/calendar/gui/event-editor.c
+++ b/calendar/gui/event-editor.c
@@ -37,6 +37,7 @@
#include "calendar-config.h"
#include "tag-calendar.h"
#include "weekday-picker.h"
+#include "widget-util.h"
@@ -174,7 +175,6 @@ static GtkObjectClass *parent_class;
extern int day_begin, day_end;
extern char *user_name;
extern int am_pm_flag;
-extern int week_starts_on_monday;
static void append_exception (EventEditor *ee, time_t t);
@@ -416,7 +416,7 @@ make_recur_weekly_special (EventEditor *ee)
/* Set the weekdays */
- weekday_picker_set_week_starts_on_monday (wp, week_starts_on_monday);
+ weekday_picker_set_week_start_day (wp, calendar_config_get_week_start_day ());
weekday_picker_set_days (wp, priv->recurrence_weekday_day_mask);
weekday_picker_set_blocked_days (wp, priv->recurrence_weekday_blocked_day_mask);
@@ -669,12 +669,10 @@ make_recur_ending_until_special (EventEditor *ee)
/* Create the widget */
- priv->recurrence_ending_date_edit = e_date_edit_new ();
+ priv->recurrence_ending_date_edit = date_edit_new (TRUE, FALSE);
de = E_DATE_EDIT (priv->recurrence_ending_date_edit);
- e_date_edit_set_show_time (de, FALSE);
gtk_container_add (GTK_CONTAINER (priv->recurrence_ending_special), GTK_WIDGET (de));
-
gtk_widget_show_all (GTK_WIDGET (de));
/* Set the value */
@@ -2030,7 +2028,7 @@ simple_recur_to_comp_object (EventEditor *ee, CalComponent *comp)
r.freq = e_dialog_option_menu_get (priv->recurrence_interval_unit, recur_freq_map);
r.interval = e_dialog_spin_get_int (priv->recurrence_interval_value);
- r.week_start = week_starts_on_monday ? ICAL_MONDAY_WEEKDAY : ICAL_SUNDAY_WEEKDAY;
+ r.week_start = ICAL_SUNDAY_WEEKDAY + calendar_config_get_week_start_day ();
/* Frequency-specific data */
@@ -3188,32 +3186,11 @@ recurrence_exception_delete_cb (GtkWidget *widget, EventEditor *ee)
GtkWidget *
make_date_edit (void)
{
- return date_edit_new (time (NULL), FALSE);
+ return date_edit_new (TRUE, TRUE);
}
GtkWidget *
-make_date_edit_with_time (void)
-{
- return date_edit_new (time (NULL), TRUE);
-}
-
-
-GtkWidget *
-date_edit_new (time_t the_time, int show_time)
-{
- GtkWidget *dedit;
-
- dedit = e_date_edit_new ();
- /* FIXME: Set other options. */
- e_date_edit_set_show_time (E_DATE_EDIT (dedit), show_time);
- e_date_edit_set_time_popup_range (E_DATE_EDIT (dedit), calendar_config_get_day_start_hour (), calendar_config_get_day_end_hour ());
- return dedit;
-}
-
-
-
-GtkWidget *
make_spin_button (int val, int low, int high)
{
GtkAdjustment *adj;
diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h
index 0c7e1f34c7..1be61eb860 100644
--- a/calendar/gui/event-editor.h
+++ b/calendar/gui/event-editor.h
@@ -67,17 +67,8 @@ void event_editor_focus (EventEditor *ee);
void event_editor_update_widgets (EventEditor *ee);
-#if 0
-/* Convenience function to create and show a new event editor for an
- * event that goes from day_begin to day_end of the specified day.
- */
-void event_editor_new_whole_day (GnomeCalendar *owner, time_t day);
-#endif
GtkWidget *make_date_edit (void);
-GtkWidget *make_date_edit_with_time (void);
-GtkWidget *date_edit_new (time_t the_time, int show_time);
-
GtkWidget *make_spin_button (int val, int low, int high);
diff --git a/calendar/gui/weekday-picker.c b/calendar/gui/weekday-picker.c
index 4c0ede2579..7059b14133 100644
--- a/calendar/gui/weekday-picker.c
+++ b/calendar/gui/weekday-picker.c
@@ -41,6 +41,9 @@ struct _WeekdayPickerPrivate {
/* Blocked days; these cannot be modified */
guint8 blocked_day_mask;
+ /* Day that defines the start of the week; 0 = Sunday, ..., 6 = Saturday */
+ int week_start_day;
+
/* Metrics */
int font_ascent, font_descent;
int max_letter_width;
@@ -48,9 +51,6 @@ struct _WeekdayPickerPrivate {
/* Components */
GnomeCanvasItem *boxes[7];
GnomeCanvasItem *labels[7];
-
- /* Whether the week starts on Monday or Sunday */
- guint week_starts_on_monday : 1;
};
@@ -164,12 +164,9 @@ day_event_cb (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
/* Turn on that day */
- if (priv->week_starts_on_monday) {
- if (i == 6)
- i = 0;
- else
- i++;
- }
+ i += priv->week_start_day;
+ if (i >= 7)
+ i -= 7;
if (priv->blocked_day_mask & (0x1 << i))
return TRUE;
@@ -268,65 +265,30 @@ colorize_items (WeekdayPicker *wp)
sel_fill = &GTK_WIDGET (wp)->style->bg[GTK_STATE_SELECTED];
sel_text_fill = &GTK_WIDGET (wp)->style->fg[GTK_STATE_SELECTED];
- if (priv->week_starts_on_monday) {
+ for (i = 0; i < 7; i++) {
+ int day;
GdkColor *f, *t;
- for (i = 1; i < 7; i++) {
- if (priv->day_mask & (0x1 << i)) {
- f = sel_fill;
- t = sel_text_fill;
- } else {
- f = fill;
- t = text_fill;
- }
-
- gnome_canvas_item_set (priv->boxes[i - 1],
- "fill_color_gdk", f,
- "outline_color_gdk", outline,
- NULL);
-
- gnome_canvas_item_set (priv->labels[i - 1],
- "fill_color_gdk", t,
- NULL);
- }
+ day = i + priv->week_start_day;
+ if (day >= 7)
+ day -= 7;
- if (priv->day_mask & (0x1 << 0)) {
+ if (priv->day_mask & (0x1 << day)) {
f = sel_fill;
t = sel_text_fill;
} else {
f = fill;
t = text_fill;
}
-
- gnome_canvas_item_set (priv->boxes[6],
+
+ gnome_canvas_item_set (priv->boxes[i],
"fill_color_gdk", f,
"outline_color_gdk", outline,
NULL);
- gnome_canvas_item_set (priv->labels[6],
+ gnome_canvas_item_set (priv->labels[i],
"fill_color_gdk", t,
NULL);
- } else {
- GdkColor *f, *t;
-
- for (i = 0; i < 7; i++) {
- if (priv->day_mask & (0x1 << i)) {
- f = sel_fill;
- t = sel_text_fill;
- } else {
- f = fill;
- t = text_fill;
- }
-
- gnome_canvas_item_set (priv->boxes[i],
- "fill_color_gdk", f,
- "outline_color_gdk", outline,
- NULL);
-
- gnome_canvas_item_set (priv->labels[i],
- "fill_color_gdk", t,
- NULL);
- }
}
}
@@ -346,14 +308,15 @@ configure_items (WeekdayPicker *wp)
height = GTK_WIDGET (wp)->allocation.height;
box_width = (width - 1) / 7;
-
- if (priv->week_starts_on_monday)
- str = _("MTWTFSS");
- else
- str = _("SMTWTFS");
+ str = _("SMTWTFS");
for (i = 0; i < 7; i++) {
char *c;
+ int day;
+
+ day = i + priv->week_start_day;
+ if (day >= 7)
+ day -= 7;
gnome_canvas_item_set (priv->boxes[i],
"x1", (double) (i * box_width),
@@ -363,7 +326,7 @@ configure_items (WeekdayPicker *wp)
"width_pixels", 0,
NULL);
- c = g_strndup (str + i, 1);
+ c = g_strndup (str + day, 1);
gnome_canvas_item_set (priv->labels[i],
"text", c,
"font_gdk", GTK_WIDGET (wp)->style->font,
@@ -564,43 +527,45 @@ weekday_picker_get_blocked_days (WeekdayPicker *wp)
}
/**
- * weekday_picker_set_week_starts_on_monday:
+ * weekday_picker_set_week_start_day:
* @wp: A weekday picker.
- * @on_monday: Whether weeks start on Monday.
+ * @week_start_day: Index of the day that defines the start of the week; 0 is
+ * Sunday, 1 is Monday, etc.
*
- * Sets whether a weekday picker should display weeks as starting on monday.
- * The default setting is to make Sunday the first day of the week.
+ * Sets the day that defines the start of the week for a weekday picker.
**/
void
-weekday_picker_set_week_starts_on_monday (WeekdayPicker *wp, gboolean on_monday)
+weekday_picker_set_week_start_day (WeekdayPicker *wp, int week_start_day)
{
WeekdayPickerPrivate *priv;
g_return_if_fail (wp != NULL);
g_return_if_fail (IS_WEEKDAY_PICKER (wp));
+ g_return_if_fail (week_start_day >= 0 && week_start_day < 7);
priv = wp->priv;
- priv->week_starts_on_monday = on_monday ? TRUE : FALSE;
+ priv->week_start_day = week_start_day;
configure_items (wp);
}
/**
- * weekday_picker_get_week_starts_on_monday:
+ * weekday_picker_get_week_start_day:
* @wp: A weekday picker.
*
- * Queries whether a weekday picker is set to show weeks as starting on Monday.
+ * Queries the day that defines the start of the week in a weekday picker.
*
- * Return value: TRUE if weeks start on monday, FALSE if on Sunday.
+ * Return value: Index of the day that defines the start of the week. See
+ * weekday_picker_set_week_start_day() to see how this is represented.
**/
-gboolean
-weekday_picker_get_week_starts_on_monday (WeekdayPicker *wp)
+int
+weekday_picker_get_week_start_day (WeekdayPicker *wp)
{
WeekdayPickerPrivate *priv;
- g_return_val_if_fail (wp != NULL, FALSE);
- g_return_val_if_fail (IS_WEEKDAY_PICKER (wp), FALSE);
+ g_return_val_if_fail (wp != NULL, -1);
+ g_return_val_if_fail (IS_WEEKDAY_PICKER (wp), -1);
priv = wp->priv;
- return priv->week_starts_on_monday;
+ return priv->week_start_day;
}
diff --git a/calendar/gui/weekday-picker.h b/calendar/gui/weekday-picker.h
index cf2367c511..00c51b7a62 100644
--- a/calendar/gui/weekday-picker.h
+++ b/calendar/gui/weekday-picker.h
@@ -63,8 +63,8 @@ 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);
+void weekday_picker_set_week_start_day (WeekdayPicker *wp, int week_start_day);
+int weekday_picker_get_week_start_day (WeekdayPicker *wp);
diff --git a/calendar/gui/widget-util.c b/calendar/gui/widget-util.c
new file mode 100644
index 0000000000..9d271d29f3
--- /dev/null
+++ b/calendar/gui/widget-util.c
@@ -0,0 +1,57 @@
+/* Evolution calendar - Widget utilities
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Author: Federico Mena-Quintero <federico@helixcode.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <widgets/misc/e-dateedit.h>
+#include "calendar-config.h"
+#include "widget-util.h"
+
+
+
+/**
+ * date_edit_new:
+ * @show_date: Whether to show a date picker in the widget.
+ * @show_time: Whether to show a time picker in the widget.
+ *
+ * Creates a new #EDateEdit widget, configured using the calendar's preferences.
+ *
+ * Return value: A newly-created #EDateEdit widget.
+ **/
+GtkWidget *
+date_edit_new (gboolean show_date, gboolean show_time)
+{
+ EDateEdit *dedit;
+
+ dedit = E_DATE_EDIT (e_date_edit_new ());
+
+ e_date_edit_set_show_date (dedit, show_date);
+ e_date_edit_set_show_time (dedit, show_time);
+ e_date_edit_set_time_popup_range (dedit,
+ calendar_config_get_day_start_hour (),
+ calendar_config_get_day_end_hour ());
+ e_date_edit_set_week_start_day (dedit, (calendar_config_get_week_start_day () + 6) % 7);
+ e_date_edit_set_show_week_numbers (dedit, calendar_config_get_dnav_show_week_no ());
+
+ return GTK_WIDGET (dedit);
+}
diff --git a/calendar/gui/widget-util.h b/calendar/gui/widget-util.h
new file mode 100644
index 0000000000..930e0f9b6e
--- /dev/null
+++ b/calendar/gui/widget-util.h
@@ -0,0 +1,31 @@
+/* Evolution calendar - Widget utilities
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Author: Federico Mena-Quintero <federico@helixcode.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef WIDGET_UTIL_H
+#define WIDGET_UTIL_H
+
+#include <gtk/gtkwidget.h>
+
+
+GtkWidget *date_edit_new (gboolean show_date, gboolean show_time);
+
+
+#endif