aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am7
-rw-r--r--calendar/gui/gnome-cal.c3
-rw-r--r--calendar/gui/gnome-cal.h1
-rw-r--r--calendar/gui/goto.c2
-rw-r--r--calendar/gui/main.c17
-rw-r--r--calendar/gui/main.h12
-rw-r--r--calendar/gui/month-view.c5
-rw-r--r--calendar/gui/prop.c321
8 files changed, 246 insertions, 122 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index fb241739ee..069609f38b 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -48,10 +48,8 @@ gnomecal_SOURCES = \
timeutil.c \
timeutil.h \
view-utils.h \
- view-utils.c \
- views.h \
- views.c
-
+ view-utils.c
+
LINK_FLAGS = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
@@ -59,7 +57,6 @@ LINK_FLAGS = \
#gncal_LDADD = $(LINK_FLAGS)
-#objedit_LDADD = $(LINK_FLAGS)
gnomecal_LDADD = $(LINK_FLAGS)
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 67061dd505..e3f1250687 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -17,7 +17,6 @@
#include "gncal-year-view.h"
#include "month-view.h"
#include "timeutil.h"
-#include "views.h"
#include "main.h"
GnomeApp *parent_class;
@@ -54,13 +53,11 @@ setup_widgets (GnomeCalendar *gcal)
gcal->week_view = gncal_week_view_new (gcal, now);
gcal->month_view = month_view_new (gcal);
gcal->year_view = gncal_year_view_new (gcal, now);
- gcal->task_view = tasks_create (gcal);
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->month_view, gtk_label_new (_("Month View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
-/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
gtk_widget_show_all (gcal->notebook);
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 7f1534714c..0d6c9525d9 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -30,7 +30,6 @@ typedef struct {
GtkWidget *week_view;
GtkWidget *month_view;
GtkWidget *year_view;
- GtkWidget *task_view;
void *event_editor;
} GnomeCalendar;
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index 7ba464bd7c..db95fe0b27 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -9,6 +9,7 @@
#include <gnome.h>
#include "gnome-cal.h"
#include "gnome-month-item.h"
+#include "main.h"
#include "timeutil.h"
@@ -232,6 +233,7 @@ create_days (GtkWidget *dialog, GnomeCalendar *gcal, int day, int month, int yea
gnome_canvas_item_set (mitem,
"month", month,
"year", year,
+ "start_on_monday", week_starts_on_monday,
NULL);
highlight_current_day (GNOME_MONTH_ITEM (mitem));
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 9240acdfc1..55aa861e0c 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -38,6 +38,9 @@ char *calendar_settings;
/* Day begin, day end parameters */
int day_begin, day_end;
+/* Whether weeks starts on Sunday or Monday */
+int week_starts_on_monday;
+
/* Number of calendars active */
int active_calendars = 0;
@@ -107,7 +110,8 @@ init_calendar (void)
gnome_config_push_prefix (calendar_settings);
day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8"));
day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17"));
- am_pm_flag = range_check_hour (gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"));
+ am_pm_flag = gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0");
+ week_starts_on_monday = gnome_config_get_bool ("/calendar/Calendar/Week starts on Monday=0");
if (day_end < day_begin){
day_begin = 8;
@@ -184,14 +188,13 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
gtk_main_quit ();
}
-/*
- * Updates all of the open calendars when the day_begin/day_end values have changed
- */
void
-day_range_changed (void)
+time_format_changed (void)
{
GList *l;
+ /* FIXME: update all the calendars and stuff */
+
for (l = all_calendars; l; l = l->next){
GnomeCalendar *cal = GNOME_CALENDAR (l->data);
@@ -358,8 +361,8 @@ static GnomeUIInfo gnome_cal_edit_menu [] = {
{ GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit },
{ GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today },
GNOMEUIINFO_SEPARATOR,
- { GNOME_APP_UI_ITEM, N_("Properties..."), NULL, properties, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP },
+ { GNOME_APP_UI_ITEM, N_("Preferences..."), NULL, properties, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF },
GNOMEUIINFO_END
};
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 374f8199e6..6f22f946f9 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -1,12 +1,22 @@
#ifndef MAIN_H
#define MAIN_H
+/* Global preferences */
+
extern int day_begin, day_end;
extern char *user_name;
extern int am_pm_flag;
+extern int week_starts_on_monday;
+/* Creates and runs the preferences dialog box */
void properties (void);
-void day_range_changed (void);
+
+/* Asks for all the time-related displays to be updated when the user changes the time format
+ * preferences.
+ */
+void time_format_changed (void);
+
+/* Creates and runs the Go-to date dialog */
void goto_dialog (GnomeCalendar *gcal);
#endif
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index a23938b350..de6b89db2b 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -7,6 +7,7 @@
#include <config.h>
#include "month-view.h"
+#include "main.h"
static void month_view_class_init (MonthViewClass *class);
@@ -65,9 +66,7 @@ month_view_init (MonthView *mv)
"y", 0.0,
"anchor", GTK_ANCHOR_NW,
"day_anchor", GTK_ANCHOR_NE,
-#if 0
- "start_on_monday", TRUE,
-#endif
+ "start_on_monday", week_starts_on_monday,
NULL);
}
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index 58abe2f8db..c339230a1a 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -2,153 +2,270 @@
* Calendar properties dialog box
* (C) 1998 the Free Software Foundation
*
- * Author: Miguel de Icaza <miguel@kernel.org>
+ * Authors: Miguel de Icaza <miguel@kernel.org>
+ * Federico Mena <federico@nuclecu.unam.mx>
*/
#include <config.h>
+#include <langinfo.h>
#include <gnome.h>
#include "gnome-cal.h"
#include "main.h"
-static GtkWidget *prop_win, *r1;
-static GtkObject *sa, *ea;
+static GtkWidget *prop_win; /* The preferences dialog */
+static GtkWidget *time_format_12; /* Radio button for 12-hour format */
+static GtkWidget *time_format_24; /* Radio button for 24-hour format */
+static GtkWidget *start_on_sunday; /* Check button for weeks starting on Sunday */
+static GtkWidget *start_on_monday; /* Check button for weeks starting on Monday */
+static GtkWidget *start_omenu; /* Option menu for start of day */
+static GtkWidget *end_omenu; /* Option menu for end of day */
+static GtkWidget *start_items[24]; /* Menu items for start of day menu */
+static GtkWidget *end_items[24]; /* Menu items for end of day menu */
+/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
+static int
+prop_cancel (void)
+{
+ prop_win = NULL;
+ return FALSE;
+}
+
+/* Returns the index of the active item in a menu */
+static int
+get_active_index (GtkWidget *menu)
+{
+ GtkWidget *active;
+
+ active = gtk_menu_get_active (GTK_MENU (menu));
+ return GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (active)));
+}
+
+/* Callback used when the Apply button is clicked. */
static void
-start_changed (GtkAdjustment *sa, GtkAdjustment *ea)
+prop_apply (GtkWidget *w, int page)
{
- if (sa->value > 23.0){
- sa->value = 23.0;
- ea->value = 24.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- } else if (sa->value >= ea->value){
- ea->value = sa->value + 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- }
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
+ if (page != -1)
+ return;
+
+ /* Day begin/end */
+
+ day_begin = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
+ day_end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
+ gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
+ gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
+
+ /* Time format */
+
+ am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active;
+ gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
+
+ /* Week start */
+
+ week_starts_on_monday = GTK_TOGGLE_BUTTON (start_on_monday)->active;
+ gnome_config_set_bool ("/calendar/Calendar/Week starts on Monday", week_starts_on_monday);
+
+ gnome_config_sync ();
+ time_format_changed ();
}
+/* Notifies the property box that the data has changed */
static void
-end_changed (GtkAdjustment *ea, GtkAdjustment *sa)
+toggled (GtkWidget *widget, gpointer data)
{
- if (ea->value < 1.0){
- ea->value = 1.0;
- sa->value = 0.0;
- gtk_signal_emit_by_name (GTK_OBJECT (ea), "value_changed");
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- } else if (ea->value < sa->value){
- sa->value = ea->value - 1.0;
- gtk_signal_emit_by_name (GTK_OBJECT (sa), "value_changed");
- }
gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
}
-/* justifies the text */
+/* Builds and returns a two-element radio button group surrounded by a frame. The radio buttons are
+ * stored in the specified variables, and the first radio button's state is set according to the
+ * specified flag value. The buttons are connected to the toggled() function to update the property
+ * box's dirty state.
+ */
static GtkWidget *
-align (GtkWidget *w, float side)
+build_two_radio_group (char *title,
+ char *radio_1_title, GtkWidget **radio_1_widget,
+ char *radio_2_title, GtkWidget **radio_2_widget,
+ int radio_1_value)
{
- GtkWidget *a;
+ GtkWidget *frame;
+ GtkWidget *vbox;
- a = gtk_alignment_new (side, 0.5, 1.0, 1.0);
- gtk_container_add (GTK_CONTAINER (a), w);
+ frame = gtk_frame_new (title);
- return a;
-}
+ vbox = gtk_vbox_new (TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
-static int
-prop_cancel (void)
-{
- prop_win = 0;
- return FALSE;
+ *radio_1_widget = gtk_radio_button_new_with_label (NULL, radio_1_title);
+ gtk_box_pack_start (GTK_BOX (vbox), *radio_1_widget, FALSE, FALSE, 0);
+
+ *radio_2_widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (*radio_1_widget),
+ radio_2_title);
+ gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0);
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value);
+
+ gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled",
+ (GtkSignalFunc) toggled,
+ NULL);
+
+ return frame;
}
+/* Callback invoked when a menu item from the start/end time option menus is selected. It adjusts
+ * the other menu to the proper time, if needed.
+ */
static void
-prop_apply (GtkWidget *w, int page)
+hour_activated (GtkWidget *widget, gpointer data)
{
- if (page != -1)
- return;
-
- day_begin = GTK_ADJUSTMENT (sa)->value;
- day_end = GTK_ADJUSTMENT (ea)->value;
- gnome_config_set_int ("/calendar/Calendar/Day start", day_begin);
- gnome_config_set_int ("/calendar/Calendar/Day end", day_end);
+ int start, end;
- am_pm_flag = (GTK_TOGGLE_BUTTON (r1)->active) == 0;
- gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag);
+ if (data == start_omenu) {
+ /* Adjust the end menu */
- gnome_config_sync ();
+ start = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
+ end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu)));
+
+ if (end < start)
+ gtk_option_menu_set_history (GTK_OPTION_MENU (end_omenu), start);
+ } else if (data == end_omenu) {
+ /* Adjust the start menu */
- day_range_changed ();
+ end = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget)));
+ start = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu)));
+
+ if (start > end)
+ gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end);
+ } else
+ g_assert_not_reached ();
}
-static void
-toggled ()
+/* Builds an option menu of 24 hours */
+static GtkWidget *
+build_hours_menu (GtkWidget **items, int active)
{
- gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win));
+ GtkWidget *omenu;
+ GtkWidget *menu;
+ int i;
+ char buf[100];
+ struct tm tm;
+
+ omenu = gtk_option_menu_new ();
+ menu = gtk_menu_new ();
+
+ memset (&tm, 0, sizeof (tm));
+
+ for (i = 0; i < 24; i++) {
+ tm.tm_hour = i;
+ strftime (buf, 100, "%I:%M %p", &tm);
+
+ items[i] = gtk_menu_item_new_with_label (buf);
+ gtk_object_set_user_data (GTK_OBJECT (items[i]), GINT_TO_POINTER (i));
+ gtk_signal_connect (GTK_OBJECT (items[i]), "activate",
+ (GtkSignalFunc) hour_activated,
+ omenu);
+
+ gtk_menu_append (GTK_MENU (menu), items[i]);
+ gtk_widget_show (items[i]);
+ }
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active);
+ return omenu;
}
+/* Creates and displays the preferences dialog for the whole application */
void
properties (void)
{
- GtkWidget *t, *l, *ds, *de;
- GtkWidget *r2;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *frame;
+ GtkWidget *hbox2;
+ GtkWidget *hbox3;
+ GtkWidget *w;
if (prop_win)
return;
+
+ /* Main window and hbox for property page */
prop_win = gnome_property_box_new ();
+ gtk_window_set_title (GTK_WINDOW (prop_win), _("Preferences"));
- t = gtk_table_new (0, 0, 0);
- gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), t,
- gtk_label_new (_("Calendar global parameters")));
-
- l = gtk_label_new (_("Day start:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 0, 1, 0, 0, 0, 0);
- sa = gtk_adjustment_new (day_begin, 0.0, 25.00, 1.0, 1.0, 1.0);
- ds = gtk_hscale_new (GTK_ADJUSTMENT (sa));
- gtk_scale_set_digits (GTK_SCALE (ds), 0);
- gtk_table_attach (GTK_TABLE (t), ds,
- 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- l = gtk_label_new (_("Day end:"));
- gtk_table_attach (GTK_TABLE (t), l,
- 0, 1, 1, 2, 0, 0, 0, 0);
- ea = gtk_adjustment_new (day_end, 0.0, 25.00, 1.0, 1.0, 1.0);
- de = gtk_hscale_new (GTK_ADJUSTMENT (ea));
- gtk_scale_set_digits (GTK_SCALE (de), 0);
- gtk_table_attach (GTK_TABLE (t), de,
- 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
-
- gtk_signal_connect (sa, "value_changed",
- GTK_SIGNAL_FUNC (start_changed), ea);
- gtk_signal_connect (ea, "value_changed",
- GTK_SIGNAL_FUNC (end_changed), sa);
-
- /* Nice spacing :-) */
- gtk_table_attach (GTK_TABLE (t), gtk_label_new (""),
- 0, 1, 2, 3, 0, 0, 0, 0);
-
- r1 = gtk_radio_button_new_with_label (NULL, _("24 hour format"));
- r2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (r1),
- _("12 hour format"));
- if (am_pm_flag)
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r2), 1);
-
- gtk_signal_connect (GTK_OBJECT (r1), "toggled",
- GTK_SIGNAL_FUNC (toggled), NULL);
-
- gtk_table_attach (GTK_TABLE (t), align (r1, 0.0), 0, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (t), align (r2, 0.0), 0, 2, 4, 5, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_container_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), hbox,
+ gtk_label_new (_("Time display")));
- gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
+ /* Time format */
+
+ vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ w = build_two_radio_group (_("Time format"),
+ _("12-hour (AM/PM)"), &time_format_12,
+ _("24-hour"), &time_format_24,
+ am_pm_flag);
+ gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
+
+ /* Weeks start on */
+
+ w = build_two_radio_group (_("Weeks start on"),
+ _("Sunday"), &start_on_sunday,
+ _("Monday"), &start_on_monday,
+ !week_starts_on_monday);
+ gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
+
+ /* Day range */
+
+ frame = gtk_frame_new (_("Day range"));
+ gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+
+ vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_container_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ w = gtk_label_new (_("Please select the start and end hours you want\n"
+ "to be displayed in the day view and week view.\n"
+ "Times outside this range will not be displayed\n"
+ "by default."));
+ gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
+
+ hbox2 = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
+
+ /* Day start */
+
+ hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
+
+ w = gtk_label_new (_("Day start:"));
+ gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
+
+ start_omenu = build_hours_menu (start_items, day_begin);
+ gtk_box_pack_start (GTK_BOX (hbox3), start_omenu, FALSE, FALSE, 0);
+
+ /* Day end */
+
+ hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0);
+
+ w = gtk_label_new (_("Day end:"));
+ gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0);
+
+ end_omenu = build_hours_menu (end_items, day_end);
+ gtk_box_pack_start (GTK_BOX (hbox3), end_omenu, FALSE, FALSE, 0);
+
+ /* Done! */
+ gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
+ (GtkSignalFunc) prop_cancel, NULL);
+
gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event",
- GTK_SIGNAL_FUNC (prop_cancel), NULL);
-
+ (GtkSignalFunc) prop_cancel, NULL);
+
gtk_signal_connect (GTK_OBJECT (prop_win), "apply",
- GTK_SIGNAL_FUNC (prop_apply), NULL);
-
+ (GtkSignalFunc) prop_apply, NULL);
+
gtk_widget_show_all (prop_win);
}
-