aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-08-25 03:59:25 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-08-25 03:59:25 +0800
commit4d075f28b587361a5014edd4946f30d9ae113e9f (patch)
treec73583c453f4981d652e010f2c620e2997934e4f /calendar
parentabdba7c651a0a04809c8a8a20c72188fbd62d2b9 (diff)
downloadgsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar.gz
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar.bz2
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar.lz
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar.xz
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.tar.zst
gsoc2013-evolution-4d075f28b587361a5014edd4946f30d9ae113e9f.zip
Changed the Properties menu item to Preferences. These are global
1998-08-24 Federico Mena Quintero <federico@nuclecu.unam.mx> * main.c: Changed the Properties menu item to Preferences. These are global application preferences, not a single calendar's properties. * prop.c (prop_apply): Save the week_starts_on_monday flag to the configuration file. (properties): Added a check button for weeks starting on Monday. (properties): Beautified the Preferences dialog. * month-view.c (month_view_init): * goto.c (create_days): Set the month item to start weeks on Monday if appropriate. * main.c (init_calendar): A boolean is not an hour, so don't range_check_hour() on it. (init_calendar): Added a global week_starts_on_monday flag. * main.h: Added global week_starts_on_monday flag. svn path=/trunk/; revision=336
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog21
-rw-r--r--calendar/Makefile.am7
-rw-r--r--calendar/calcs.c253
-rw-r--r--calendar/calcs.h53
-rw-r--r--calendar/clist.c97
-rw-r--r--calendar/clist.h2
-rw-r--r--calendar/gncal.c700
-rw-r--r--calendar/gncal.h6
-rw-r--r--calendar/gnome-cal.c3
-rw-r--r--calendar/gnome-cal.h1
-rw-r--r--calendar/goto.c2
-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
-rw-r--r--calendar/lexer.c441
-rw-r--r--calendar/main.c17
-rw-r--r--calendar/main.h12
-rw-r--r--calendar/menus.c147
-rw-r--r--calendar/menus.h17
-rw-r--r--calendar/month-view.c5
-rw-r--r--calendar/objedit.c88
-rw-r--r--calendar/prop.c321
-rw-r--r--calendar/views.c33
-rw-r--r--calendar/views.h4
29 files changed, 513 insertions, 2085 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 81c9707025..17ff9c0115 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,24 @@
+1998-08-24 Federico Mena Quintero <federico@nuclecu.unam.mx>
+
+ * main.c: Changed the Properties menu item to Preferences. These
+ are global application preferences, not a single calendar's
+ properties.
+
+ * prop.c (prop_apply): Save the week_starts_on_monday flag to the
+ configuration file.
+ (properties): Added a check button for weeks starting on Monday.
+ (properties): Beautified the Preferences dialog.
+
+ * month-view.c (month_view_init):
+ * goto.c (create_days): Set the month item to start weeks on
+ Monday if appropriate.
+
+ * main.c (init_calendar): A boolean is not an hour, so don't
+ range_check_hour() on it.
+ (init_calendar): Added a global week_starts_on_monday flag.
+
+ * main.h: Added global week_starts_on_monday flag.
+
1998-08-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
* calobj.c (ical_object_create_from_vobject): If mail alarm or
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index fb241739ee..069609f38b 100644
--- a/calendar/Makefile.am
+++ b/calendar/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/calcs.c b/calendar/calcs.c
deleted file mode 100644
index d6150f7b35..0000000000
--- a/calendar/calcs.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * calc.c Calculations to work out what day it is etc for the Calendar
- *
- * Most of this stuff was taken from the gcal source by Thomas Esken.
- * <esken@uni-muenster.de>
- * gcal is a text-based calendar program
- */
-
-#include <time.h>
-#include <glib.h>
-#include <ctype.h>
-#include "calcs.h"
-
-#include <config.h>
-
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char * /*s1*/, const char * /*s2*/);
-#endif
-
-/* Number of days in a month */
-static const int dvec[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-/* Number of past days of a month */
-static const int mvec[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
-Greg_struct greg_reform_date[6] = {
-/* {int year, int month, int f_day, int l_day} */
- { 1582, 10, 5, 14 },
- { 1700, 2, 19, 28 },
- { 1752, 9, 3, 13 },
- { 1753, 2, 18, 28 },
-/* must be left with all zeroes */
- { 0,0,0,0 }
-};
-Greg_struct *greg=greg_reform_date;
-
-
-
-/*
- * Computes the number of days in February and returns them,
- */
-int days_of_february(const int year)
-{
- return((year&3) ? 28 : (!(year%100)&&(year%400)) ? 28 : 29);
-}
-
-int is_leap_year(const int year)
-{
- return (days_of_february(year) == 29);
-}
-
-/*
- * Check wether a given date is calid.
- */
-int valid_date(const int day, const int month, const int year)
-{
- if ( day < 1
- || month < MONTH_MIN
- || month > MONTH_MAX
- || ( (month != 2)
- && (day > dvec[month-1]))
- || ( (month == 2)
- && (day > days_of_february (year))))
- return(FALSE);
-
- return(TRUE);
-}
-
-/*
- * Set a date back one day (to yesterday's date)
- */
-void prev_date(int *day, int *month, int *year)
-{
- (*day)--;
- if ( !*day || !valid_date(*day, *month, *year)) {
- (*month)--;
- if (*month < MONTH_MIN) {
- *month = MONTH_MAX;
- (*year)--;
- }
- if (*month ==2)
- *day = days_of_february(*year);
- else
- *day = dvec[*month-1];
- }
-} /* prev_date */
-
-/*
- * Set a date forward one day (to tomorrow's date)
- */
-void next_date(int *day, int *month, int *year)
-{
- (*day)++;
- if (!valid_date(*day, *month, *year)) {
- *day = DAY_MIN;
- if (*month == MONTH_MAX) {
- *month = MONTH_MIN;
- (*year)++;
- } else
- (*month)++;
- }
-} /* next_date */
-
-/*
- * Get date from the system
- */
-void get_system_date(int *day, int *month, int *year)
-{
- auto struct tm *sys_date;
- auto time_t sys_time;
-
-
- sys_time = time((time_t *)NULL);
- sys_date = localtime(&sys_time);
- *day = sys_date->tm_mday;
- *month = sys_date->tm_mon + 1;
- *year = sys_date->tm_year;
- if (*year < CENTURY)
- *year += CENTURY;
-} /* get_system_date */
-
-
-/*
- * Given a string with the name of a month, return 1..12 or 0 if not found
- */
-int month_atoi(const char *string)
-{
- int i;
- for (i = MONTH_MIN; i <= MONTH_MAX; i++)
- if (strcasecmp(string, (char *)get_month_name(i)) == 0)
- return i;
- return 0;
-}
-
-int day_atoi(const char *string)
-{
- int i;
- for (i = DAY_MIN; i <= DAY_MAX; i++)
- if (strcasecmp(string, (char *)get_day_name(i)) == 0)
- return i;
- return 0;
-}
-
-/*
- * Returns ordinal suffix (st, nd, rd, th) for a day
- */
-const char *day_suffix(int day)
-{
- static const char *suffix[]={"th", "st", "nd", "rd"};
- register int i;
-
- i = 0;
-
- if (day > 100)
- day %= 100;
- if (day < 11 || day > 13)
- i = day % 10;
- if (i > 3)
- i = 0;
-
- return(suffix[i]);
-} /* day_suffix */
-
-/*
- * Returns the short name of the day of week, format "%-3s"
- */
-const char *short3_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* short3_day_name */
-
-/*
- * Returns the short name of day of week
- */
-const char *short_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* short_day_name */
-
-/*
- * Returns the complete name of the day
- */
-const char *get_day_name(const int day)
-{
- static const char *name[]={"invalid day", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
-
- return(((day<DAY_MIN)||(day>DAY_MAX)) ? name[0] : name[day]);
-} /* day_name */
-
-/*
- * Returns the short name of the month
- */
-const char *short_month_name(const int month)
-{
- static const char *name[]={ "invalid month", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
- return(((month<MONTH_MIN)||(month>MONTH_MAX)) ? name[0] : name[month]);
-} /* short_month_name() */
-
-/*
- * Returns the name of the month
- */
-const char *get_month_name(const int month)
-{
- static const char *name[]={ "invalid month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
-
- return(((month<MONTH_MIN)||(month>MONTH_MAX)) ? name[0] : name[month]);
-} /* month_name() */
-
-/*
- * Compute the absolute number of days of the given date since 1 Jan 0001
- * respecting the missing period of the Gregorian Reformation
- * I am glad someone else worked this one out!! - cs
- */
-unsigned long int date2num(const int day, const int month, const int year)
-{
- auto unsigned long int julian_days;
-
- julian_days = (unsigned long int)((year-1)*(unsigned long int)(DAY_LAST)+((year-1)>>2));
-
- if (year > greg->year
- || ( (year == greg->year)
- && ( month > greg->month
- || ( (month == greg->month)
- && (day > greg->last_day)))))
- julian_days -= (unsigned long int)(greg->last_day - greg->first_day + 1);
- if (year > greg->year) {
- julian_days += (((year-1) / 400) - (greg->year / 400));
- julian_days -= (((year-1) / 100) - (greg->year / 100));
- if (!(greg->year % 100) && (greg->year % 400))
- julian_days--;
- }
- julian_days += (unsigned long int)mvec[month-1];
- julian_days += day;
- if ( (days_of_february(year) == 29) && (month > 2))
- julian_days++;
-
- return(julian_days);
-} /* date2num */
-
-/*
- * Computes the weekday of a Gregorian/Julian calendar date
- * (month must be 1..12) returns 1..7 (mo..su)
- */
-int weekday_of_date(const int day, const int month, const int year)
-{
- auto unsigned long int julian_days=date2num(day, month,year)%DAY_MAX;
-
- return((julian_days>2) ? (int)julian_days-2 : (int)julian_days+5);
-} /* weekday_of_date() */
-
diff --git a/calendar/calcs.h b/calendar/calcs.h
deleted file mode 100644
index f331bf7335..0000000000
--- a/calendar/calcs.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * function prototypes
- */
-int days_of_february(const int year);
-int is_leap_year(const int year);
-int valid_date(const int day, const int month, const int year);
-void get_system_date(int *day, int *month, int *year);
-void prev_date(int *day, int *month, int *year);
-void next_date(int *day, int *month, int *year);
-int month_atoi(const char *string);
-int day_atoi(const char *string);
-const char *day_suffix(int day);
-const char *short3_day_name(int day);
-const char *short_day_name(int day);
-const char *get_day_name(int day);
-const char *short_month_name(int month);
-const char *get_month_name(int month);
-unsigned long int date2num(const int day, const int month, const int year);
-int weekday_of_date(const int day, const int month, const int year);
-
-
-/*
- * Important preprocessor symbols for the internal ranges.
- */
-#define DAY_LAST 365 /* Last day in a NON leap year */
-#define DAY_MIN 1 /* Minimum day of week/month/year */
-#define DAY_MAX 7 /* Maximum day/amount of days of week */
-#define WEEK_MAX 52 /* Maximum week number of year */
-#define MONTH_LAST 31 /* Highest day number in a month */
-#define MONTH_MIN 1 /* Minimum month of year */
-#define MONTH_MAX 12 /* Maximum month of year */
-#define YEAR_MIN 1 /* Minimum year able to compute */
-#define YEAR_MAX 9999 /* Maximum year able to compute */
-#define EASTER_MIN 30 /* Minimum year for computing Easter Sunday (29+1) */
-#define EASTER_MAX YEAR_MAX /* Maximum year for computing Easter Sunday */
-#define MONTH_COLS 6 /* Maximum number of columns of a month */
-#define VEC_BLOCK 42 /* Maximum number of elements per month (7*6) */
-#define VEC_ELEMS 504 /* Maximum number of elements per year (42*12) */
-#define CENTURY 1900 /* Operating system standard starting century, DON'T change ! */
-
-/*
-* The Gregorian Reformation date record.
-*/
-typedef
- struct greg_type
- {
- int year; /* Year of Gregorian Reformation */
- int month; /* Month of Gregorian Reformation */
- int first_day; /* First missing day of Reformation period */
- int last_day; /* Last missing day of Reformation period */
- }
- Greg_struct;
-
diff --git a/calendar/clist.c b/calendar/clist.c
deleted file mode 100644
index 8491d45174..0000000000
--- a/calendar/clist.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * clist.c: All the good stuf to work with the clists that are used for the
- * tasklist.
- *
- * This file is largely based upon GTT code by Eckehard Berns.
- *
- * 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
- */
-#include <config.h>
-#include <gnome.h>
-
-static void
-select_row(GtkCList *clist, gint row, gint col, GdkEventButton *event)
-{
- if (!event) return;
-
- g_print("select_row, row=%d col=%d button=%d\n", row, col, event->button);
-}
-
-static void
-unselect_row(GtkCList *clist, gint row, gint col, GdkEventButton *event)
-{
- if (!event) return;
-
- g_print("unselect_row, row=%d col=%d button=%d\n", row, col, event->button);
-}
-
-static void
-click_column(GtkCList *clist, gint col)
-{
-
- g_print("click_column, col=%d\n ", col);
-}
-
-
-
-
-GtkWidget * create_clist(void)
-{
- GtkStyle *style;
- GdkGCValues vals;
-
- GtkWidget *clist;
- char *titles[2] = {
- N_("Time"),
- N_("Event")
- };
-
- titles[0] = _(titles[0]);
- titles[1] = _(titles[1]);
- clist = gtk_clist_new_with_titles(2,titles);
- gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 0, GTK_JUSTIFY_CENTER);
- style = gtk_widget_get_style(clist);
- g_return_val_if_fail(style != NULL, NULL);
- gdk_gc_get_values(style->fg_gc[0], &vals);
- gtk_clist_set_column_width(GTK_CLIST(clist), 0, gdk_string_width(vals.font, "00:00"));
- gtk_clist_set_policy(GTK_CLIST(clist),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_signal_connect(GTK_OBJECT(clist), "select_row",
- GTK_SIGNAL_FUNC(select_row), NULL);
- gtk_signal_connect(GTK_OBJECT(clist), "click_column",
- GTK_SIGNAL_FUNC(click_column), NULL);
- gtk_signal_connect(GTK_OBJECT(clist), "unselect_row",
- GTK_SIGNAL_FUNC(unselect_row), NULL);
- return clist;
-}
-
-void
-setup_clist(GtkWidget *clist)
-{
- char buf1[10];
- char buf2[1000] = "Programming GNOME";
- char *tmp[2] = { buf1, buf2 };
- int i, row;
-
- gtk_clist_freeze(GTK_CLIST(clist));
- gtk_clist_clear(GTK_CLIST(clist));
- for (i=0; i < 24; i++) {
- sprintf(buf1, "%d:00", i);
- row = gtk_clist_append(GTK_CLIST(clist), tmp);
- }
- gtk_clist_thaw(GTK_CLIST(clist));
-
-}
diff --git a/calendar/clist.h b/calendar/clist.h
deleted file mode 100644
index 061c1b316c..0000000000
--- a/calendar/clist.h
+++ /dev/null
@@ -1,2 +0,0 @@
-GtkWidget *create_clist(void);
-void setup_clist(GtkWidget *clist);
diff --git a/calendar/gncal.c b/calendar/gncal.c
deleted file mode 100644
index 232aa19135..0000000000
--- a/calendar/gncal.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * gnlp.c: LPQ/LPR stuff
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <time.h>
-#include <string.h>
-
-#include <gnome.h>
-#include <config.h>
-
-#include "gncal.h"
-#include "calcs.h"
-#include "clist.h"
-#include "gncal-week-view.h"
-
-void
-prueba (void)
-{
- GtkWidget *window;
- GtkWidget *wview;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
- gtk_container_border_width (GTK_CONTAINER (window), 6);
-
- wview = gncal_week_view_new (NULL, time (NULL));
- gtk_container_add (GTK_CONTAINER (window), wview);
- gtk_widget_show (wview);
-
- gtk_widget_show (window);
-}
-
-/* Function declarations */
-void parse_args(int argc, char *argv[]);
-static int save_state (GnomeClient *client,
- gint phase,
- GnomeRestartStyle save_style,
- gint shutdown,
- GnomeInteractStyle interact_style,
- gint fast,
- gpointer client_data);
-static void connect_client (GnomeClient *client,
- gint was_restarted,
- gpointer client_data);
-
-void discard_session (gchar *id);
-
-static GtkMenuEntry menu_items[] =
-{
- { N_("File/Exit"), N_("<control>Q"), menu_file_quit, NULL},
- { N_("Help/About"), N_("<control>A"), menu_help_about, NULL},
-};
-
-#define DAY_ARRAY_MAX 35
-/* The naughty global variables */
-int curr_day, old_day;
-int curr_month, old_month;
-int curr_year, old_year;
-GtkWidget *month_label;
-GtkWidget *year_label;
-GtkWidget *dailylist;
-GtkWidget *calendar_days[DAY_ARRAY_MAX];
-GtkWidget *calendar_buttons[DAY_ARRAY_MAX];
-GtkWidget *app;
-GtkWidget *calendar;
-
-int restarted = 0;
-/* Stuff we use for session state */
-int os_x = 0,
- os_y = 0,
- os_w = 0,
- os_h = 0;
-
-
-/* True if parsing determined that all the work is already done. */
-int just_exit = 0;
-
-/* These are the arguments that our application supports. */
-static struct argp_option arguments[] =
-{
-#define DISCARD_KEY -1
- { "discard-session", DISCARD_KEY, N_("ID"), 0, N_("Discard session"), 1 },
- { NULL, 0, NULL, 0, NULL, 0 }
-};
-
-/* Forward declaration of the function that gets called when one of
- our arguments is recognized. */
-static error_t parse_an_arg (int key, char *arg, struct argp_state *state);
-
-/* This structure defines our parser. It can be used to specify some
- options for how our parsing function should be called. */
-static struct argp parser =
-{
- arguments, /* Options. */
- parse_an_arg, /* The parser function. */
- NULL, /* Some docs. */
- NULL, /* Some more docs. */
- NULL, /* Child arguments -- gnome_init fills
- this in for us. */
- NULL, /* Help filter. */
- NULL /* Translation domain; for the app it
- can always be NULL. */
-};
-
-#define ELEMENTS(x) (sizeof (x) / sizeof (x [0]))
-
-GtkMenuFactory *
-create_menu ()
-{
- GtkMenuFactory *subfactory;
- int i;
-
- subfactory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
- gtk_menu_factory_add_entries (subfactory, menu_items, ELEMENTS(menu_items));
-
- return subfactory;
-}
-
-/* place marker until i get get something better */
-void print_error(char *text)
-{
- GtkWidget *msgbox;
- char buf[512];
-
- if (errno == 0)
- sprintf(buf, "%s", text);
- else
- sprintf(buf, "%s (%s)", text, g_strerror(errno));
-
- g_warning("%s\n", buf);
- msgbox = gnome_message_box_new(buf, "error", "OK", NULL, NULL);
-
- gtk_widget_show(msgbox);
-}
-
-
-void menu_file_quit(GtkWidget *widget, gpointer data)
-{
- gtk_main_quit();
-}
-
-void menu_help_about(GtkWidget *widget, gpointer data)
-{
- GtkWidget *about;
- gchar *authors[] = {
- "Craig Small <csmall@small.dropbear.id.au>",
- NULL };
- about = gnome_about_new( _("Gnome Calendar"), VERSION,
- "(C) 1998",
- authors,
- /* Comments */
- _("This program shows a nice pretty "
- "calendar and will do scheduling "
- "real soon now!"),
- NULL);
-
- gtk_widget_show(about);
-}
-
-void dailylist_item_select(GtkWidget *widget, gpointer data)
-{
- int *x = (int*)data;
-
- g_print("Selected %d\n", x);
-}
-
-void update_today_list(void)
-{
- GtkWidget *listitem;
- GtkWidget *list_hbox;
- GtkWidget *hour_label;
- GtkWidget *event_label;
- char buf[50];
- int tmphr, tmpmin,i;
-
-}
-
-/*
- * updates the calendar that appears in the left collumn
- */
-void month_changed(GtkWidget *widget, gpointer data)
-{
- curr_month = GTK_CALENDAR(widget)->month;
- curr_year = GTK_CALENDAR(widget)->year;
-}
-
-void update_calendar()
-{
- int tmpday;
- int i;
- char buf[50];
- int month_changed;
- static int offset;
-
- gtk_calendar_unmark_day(GTK_CALENDAR(calendar),old_day);
- gtk_calendar_mark_day(GTK_CALENDAR(calendar), curr_day);
- printf("Date changed (nothing happens much\n");
-/* gtk_calendar_select_day(GTK_CALENDAR(calendar), curr_day); */
-#if 0
- /* Only update the whole calendar if the year or month has changed */
- tmpday=1;
- month_changed = FALSE;
- if (curr_month != old_month || curr_year != old_year) {
- month_changed = TRUE;
- offset = weekday_of_date(tmpday, curr_month, curr_year) - 1;
- }
-
- for(i=0; i < DAY_ARRAY_MAX; i++) {
- tmpday = i - offset +1;
- if (valid_date(tmpday, curr_month, curr_year)) {
- sprintf(buf, "%2d", tmpday);
- /*if (month_changed) {*/
- gtk_label_set(GTK_LABEL(calendar_days[i]), buf);
- gtk_widget_show(calendar_buttons[i]);
- /*}*/
- if (tmpday == curr_day) {
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 2);
- gtk_widget_show(calendar_buttons[i]);
- } else {
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 0);
- }
- } else if (month_changed) {
- gtk_label_set(GTK_LABEL(calendar_days[i]), "");
- gtk_widget_hide(calendar_buttons[i]);
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i]), 0);
- }
- } /* for i */
-#endif /* 0 */
-}
-
-/*
- * Updates all the main window widgets when the current day of interest is
- * changed
- */
-void update_today(void)
-{
- char buf[50];
-
- /* This needs to be fixed to get the right date order for the country*/
-/* if (curr_month != old_month) {
- gtk_label_set(GTK_LABEL(month_label), month_name(curr_month));
- }
- if (curr_year != old_year) {
- sprintf(buf, "%4d", curr_year);
- gtk_label_set(GTK_LABEL(year_label), buf);
- }*/
- update_today_list();
- update_calendar();
-}
-
-void next_day_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- next_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void prev_day_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- prev_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void today_but_clicked(GtkWidget *widget, gpointer data)
-{
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- get_system_date(&curr_day, &curr_month, &curr_year);
- update_today();
-}
-
-void prev_month_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 0 && curr_month == MONTH_MIN)
- return;
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_month--;
- if (curr_month < MONTH_MIN) {
- curr_month = MONTH_MAX;
- curr_year--;
- }
- update_today();
-}
-
-void next_month_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 3000 && curr_month == MONTH_MAX)
- return;
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_month++;
- if (curr_month > MONTH_MAX ) {
- curr_month = MONTH_MIN;
- curr_year++;
- }
- update_today();
-}
-
-void prev_year_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 0)
- return;
-
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_year--;
- update_today();
-}
-
-
-void next_year_but_clicked(GtkWidget *widget, gpointer data)
-{
- if (curr_year == 3000)
- return;
-
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_year++;
- update_today();
-}
-
-
-void calendar_but_clicked(GtkWidget *widget, gpointer data)
-{
- char *ptr;
- int x;
-
- ptr = GTK_LABEL(GTK_BUTTON(widget)->child)->label;
- x = atoi(ptr);
-
- if (valid_date(x, curr_month, curr_year)) {
- old_day = curr_day;
- old_month = curr_month;
- old_year = curr_year;
- curr_day = x;
- update_today();
- }
-}
-
-void test_foreach(GtkWidget *widget, gpointer data)
-{
- char *ptr;
-
- ptr = GTK_LABEL(GTK_BUTTON(widget)->child)->label;
- g_print("%s\n", ptr);
-}
-
-void show_main_window()
-{
- GtkWidget *main_vbox;
- /*GtkWidget *menubar;
- GtkAcceleratorTable *accel;*/
- GtkMenuFactory *menuf;
- GtkWidget *main_hbox;
- GtkWidget *left_vbox;
- GtkWidget *right_vbox;
- GtkWidget *date_hbox;
- GtkWidget *prev_mth_but;
- GtkWidget *next_mth_but;
- GtkWidget *prev_year_but;
- GtkWidget *next_year_but;
- GtkWidget *day_but_hbox;
- GtkWidget *prev_day_but;
- GtkWidget *today_but;
- GtkWidget *next_day_but;
- GtkWidget *separator;
- GtkWidget *cal_table;
- GtkWidget *day_name_label;
- GtkWidget *scrolledwindow;
- GtkWidget *scroll_hbox;
- GtkWidget *hour_list;
- GtkWidget *list_item;
- GtkWidget *dailylist_item;
- GtkWidget *event_label;
- int i,j;
- struct tm tm;
- char buf[50];
-
- bzero((char*)&tm, sizeof(struct tm));
- app = gnome_app_new("gncal", "Gnome Calendar");
- gtk_widget_realize(app);
- gtk_signal_connect(GTK_OBJECT(app), "delete_event",
- GTK_SIGNAL_FUNC(menu_file_quit), NULL);
- if (restarted) {
- gtk_widget_set_uposition(app, os_x, os_y);
- gtk_widget_set_usize(app, os_w, os_h);
- } else {
- gtk_widget_set_usize(app,300,300);
- }
- main_vbox = gtk_vbox_new(FALSE, 1);
- gnome_app_set_contents(GNOME_APP(app), main_vbox);
- gtk_widget_show(main_vbox);
-
- menuf = create_menu();
- gnome_app_set_menus(GNOME_APP(app), GTK_MENU_BAR(menuf->widget));
-
- main_hbox = gtk_hbox_new(FALSE,1);
- gtk_box_pack_start(GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 0);
- gtk_widget_show(main_hbox);
-
- left_vbox = gtk_vbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(main_hbox), left_vbox, FALSE, TRUE,0);
- gtk_widget_show(left_vbox);
-
- separator = gtk_vseparator_new();
- gtk_box_pack_start(GTK_BOX(main_hbox), separator, FALSE, TRUE, 0);
- gtk_widget_show(separator);
-
- right_vbox = gtk_vbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(main_hbox), right_vbox, TRUE, TRUE, 0);
- gtk_widget_show(right_vbox);
-
- date_hbox = gtk_hbox_new(FALSE, 1);
- gtk_box_pack_start(GTK_BOX(left_vbox), date_hbox, FALSE, FALSE, 0);
- gtk_widget_show(date_hbox);
-/*
- prev_mth_but = gtk_button_new_with_label("<");
- gtk_box_pack_start(GTK_BOX(date_hbox), prev_mth_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_mth_but), "clicked", GTK_SIGNAL_FUNC(prev_month_but_clicked), NULL);
- gtk_widget_show(prev_mth_but);
-
- month_label = gtk_label_new("Fooary");
- gtk_box_pack_start(GTK_BOX(date_hbox), month_label, TRUE, FALSE, 0);
- gtk_widget_show(month_label);
-
- next_mth_but = gtk_button_new_with_label(">");
- gtk_box_pack_start(GTK_BOX(date_hbox), next_mth_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(next_mth_but), "clicked", GTK_SIGNAL_FUNC(next_month_but_clicked), NULL);
- gtk_widget_show(next_mth_but);
-
- prev_year_but = gtk_button_new_with_label("<");
- gtk_box_pack_start(GTK_BOX(date_hbox), prev_year_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_year_but), "clicked", GTK_SIGNAL_FUNC(prev_year_but_clicked), NULL);
- gtk_widget_show(prev_year_but);
-
- year_label = gtk_label_new("1971");
- gtk_box_pack_start(GTK_BOX(date_hbox), year_label, TRUE, FALSE, 0);
- gtk_widget_show(year_label);
-
- next_year_but = gtk_button_new_with_label(">");
- gtk_box_pack_start(GTK_BOX(date_hbox), next_year_but, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(next_year_but), "clicked", GTK_SIGNAL_FUNC(next_year_but_clicked), NULL);
- gtk_widget_show(next_year_but);
-*/
- /* Build up the calendar table */
-/* cal_table = gtk_table_new(7,7,TRUE);
- gtk_box_pack_start(GTK_BOX(left_vbox), cal_table, FALSE, FALSE, 0);
- gtk_widget_show(cal_table);
-
- for(i=DAY_MIN; i <= DAY_MAX; i++) {
- day_name_label = gtk_label_new(short3_day_name(i));
- gtk_table_attach_defaults(GTK_TABLE(cal_table), day_name_label, i-1, i, 0, 1);
- gtk_widget_show(day_name_label);
- }
- for(j=0; j < 5; j++) {
- for(i=0; i < 7; i++) {
- calendar_buttons[i+j*7] = gtk_button_new();
- gtk_container_border_width(GTK_CONTAINER(calendar_buttons[i+j*7]), 0);
- gtk_table_attach_defaults(GTK_TABLE(cal_table), calendar_buttons[i+j*7], i, i+1, j+2, j+3);
- gtk_signal_connect(GTK_OBJECT(calendar_buttons[i+j*7]), "clicked", GTK_SIGNAL_FUNC(calendar_but_clicked), NULL);
- gtk_widget_show(calendar_buttons[i+j*7]);
- calendar_days[i+j*7] = gtk_label_new("");
- gtk_container_add(GTK_CONTAINER(calendar_buttons[i+j*7]), calendar_days[i+j*7]);
- gtk_widget_show(calendar_days[i+j*7]);
- }
- }
-*/
- calendar = gtk_calendar_new();
- gtk_calendar_display_options(GTK_CALENDAR(calendar), GTK_CALENDAR_SHOW_DAY_NAMES | GTK_CALENDAR_SHOW_HEADING);
- gtk_box_pack_start(GTK_BOX(left_vbox), calendar, FALSE, FALSE, 0);
- gtk_signal_connect(GTK_OBJECT(calendar), "month_changed",
- GTK_SIGNAL_FUNC(month_changed), NULL);
- gtk_widget_show(calendar);
-
-
- day_but_hbox = gtk_hbox_new(TRUE, 1);
- gtk_box_pack_start(GTK_BOX(left_vbox), day_but_hbox, FALSE, FALSE, 0);
- gtk_widget_show(day_but_hbox);
-
- prev_day_but = gtk_button_new_with_label("Prev");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), prev_day_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(prev_day_but), "clicked", GTK_SIGNAL_FUNC(prev_day_but_clicked), NULL);
- gtk_widget_show(prev_day_but);
-
- today_but = gtk_button_new_with_label("Today");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), today_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(today_but), "clicked", GTK_SIGNAL_FUNC(today_but_clicked), NULL);
- gtk_widget_show(today_but);
-
- next_day_but = gtk_button_new_with_label("Next");
- gtk_box_pack_start(GTK_BOX(day_but_hbox), next_day_but, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(next_day_but), "clicked", GTK_SIGNAL_FUNC(next_day_but_clicked), NULL);
- gtk_widget_show(next_day_but);
-
-
- dailylist = create_clist();
- gtk_box_pack_start(GTK_BOX(right_vbox), dailylist, TRUE, TRUE, 0);
- gtk_widget_show(dailylist);
- setup_clist(dailylist);
-
- gtk_widget_show(app);
-
-}
-
-
-int
-main(int argc, char *argv[])
-{
- GnomeClient *client;
-
- argp_program_version = VERSION;
-
-
- /* Initialise the i18n stuff */
- bindtextdomain(PACKAGE, GNOMELOCALEDIR);
- textdomain(PACKAGE);
-
- /* This create a default client and arrages for it to parse some
- command line arguments
- */
- client = gnome_client_new_default();
-
- /* Arrange to be told when something interesting happens. */
- gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
- GTK_SIGNAL_FUNC (save_state), (gpointer) argv[0]);
- gtk_signal_connect (GTK_OBJECT (client), "connect",
- GTK_SIGNAL_FUNC (connect_client), NULL);
-
- gnome_init("gncal", &parser, argc, argv, 0, NULL);
-
- show_main_window();
-
- /* Initialse date to the current day */
- old_day = old_month = old_year = 0;
- get_system_date(&curr_day, &curr_month, &curr_year);
- update_today();
-
- prueba ();
-
- gtk_main();
-
- return 0;
-}
-
-static error_t
-parse_an_arg (int key, char *arg, struct argp_state *state)
-{
- if (key == DISCARD_KEY)
- {
- discard_session (arg);
- just_exit = 1;
- return 0;
- }
-
- /* We didn't recognize it. */
- return ARGP_ERR_UNKNOWN;
-}
-
-
-/* Session Management routines */
-
-
-static int
-save_state (GnomeClient *client,
- gint phase,
- GnomeRestartStyle save_style,
- gint shutdown,
- GnomeInteractStyle interact_style,
- gint fast,
- gpointer client_data)
-{
- gchar *session_id;
- gchar *sess;
- gchar *buf;
- gchar *argv[3];
- gint x, y, w, h;
-
- session_id= gnome_client_get_id (client);
-
- /* The only state that gnome-hello has is the window geometry.
- Get it. */
- gdk_window_get_geometry (app->window, &x, &y, &w, &h, NULL);
-
- /* Save the state using gnome-config stuff. */
- sess = g_copy_strings ("/gncal/Saved-Session-",
- session_id,
- NULL);
-
- buf = g_copy_strings ( sess, "/x", NULL);
- gnome_config_set_int (buf, x);
- g_free(buf);
- buf = g_copy_strings ( sess, "/y", NULL);
- gnome_config_set_int (buf, y);
- g_free(buf);
- buf = g_copy_strings ( sess, "/w", NULL);
- gnome_config_set_int (buf, w);
- g_free(buf);
- buf = g_copy_strings ( sess, "/h", NULL);
- gnome_config_set_int (buf, h);
- g_free(buf);
-
- gnome_config_sync();
- g_free(sess);
-
- /* Here is the real SM code. We set the argv to the parameters needed
- to restart/discard the session that we've just saved and call
- the gnome_session_set_*_command to tell the session manager it. */
- argv[0] = (char*) client_data;
- argv[1] = "--discard-session";
- argv[2] = session_id;
- gnome_client_set_discard_command (client, 3, argv);
-
- /* Set commands to clone and restart this application. Note that we
- use the same values for both -- the session management code will
- automatically add whatever magic option is required to set the
- session id on startup. */
- gnome_client_set_clone_command (client, 1, argv);
- gnome_client_set_restart_command (client, 1, argv);
-
- g_print("save state\n");
- return TRUE;
-}
-
-/* Connected to session manager. If restarted from a former session:
- reads the state of the previous session. Sets os_* (prepare_app
- uses them) */
-void
-connect_client (GnomeClient *client, gint was_restarted, gpointer client_data)
-{
- gchar *session_id;
-
- /* Note that information is stored according to our *old*
- session id. The id can change across sessions. */
- session_id = gnome_client_get_previous_id (client);
-
- if (was_restarted && session_id != NULL)
- {
- gchar *sess;
- gchar *buf;
-
- restarted = 1;
-
- sess = g_copy_strings ("/gncal/Saved-Session-", session_id, NULL);
-
- buf = g_copy_strings ( sess, "/x", NULL);
- os_x = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/y", NULL);
- os_y = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/w", NULL);
- os_w = gnome_config_get_int (buf);
- g_free(buf);
- buf = g_copy_strings ( sess, "/h", NULL);
- os_h = gnome_config_get_int (buf);
- g_free(buf);
- }
-
- /* If we had an old session, we clean up after ourselves. */
- if (session_id != NULL)
- discard_session (session_id);
-
- return;
-}
-
-void
-discard_session (gchar *id)
-{
- gchar *sess;
-
- sess = g_copy_strings ("/gncal/Saved-Session-", id, NULL);
-
- /* we use the gnome_config_get_* to work around a bug in gnome-config
- (it's going under a redesign/rewrite, so i didn't correct it) */
- gnome_config_get_int ("/gncal/Bug/work-around=0");
-
- gnome_config_clean_section (sess);
- gnome_config_sync ();
-
- g_free (sess);
- return;
-}
-
diff --git a/calendar/gncal.h b/calendar/gncal.h
deleted file mode 100644
index 8d4790bf07..0000000000
--- a/calendar/gncal.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void menu_file_quit(GtkWidget *widget, gpointer data);
-#define MIN_DAILY_HOUR 8
-#define MAX_DAILY_HOUR 19
-#define DAILY_MINUTE_STEP 15
-void menu_help_about(GtkWidget *widget, gpointer data); \ No newline at end of file
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 67061dd505..e3f1250687 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/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/gnome-cal.h b/calendar/gnome-cal.h
index 7f1534714c..0d6c9525d9 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/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/goto.c b/calendar/goto.c
index 7ba464bd7c..db95fe0b27 100644
--- a/calendar/goto.c
+++ b/calendar/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/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);
}
-
diff --git a/calendar/lexer.c b/calendar/lexer.c
deleted file mode 100644
index e03cb666fb..0000000000
--- a/calendar/lexer.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * lexer.c: Reads in the .calendar files
- */
-#include <stdio.h>
-#include <glib.h>
-#include "cal_struct.h"
-
-
-#define opener "["
-#define closer "]"
-#define VersionMajor 2
-
-GSList *eventlist;
-
-void print_glist(gpointer data, gpointer user_data)
-{
- struct event *myevent = (struct event*)data;
-
- if (data == NULL)
- return;
- printf ("===============================================\nNew event\n");
- printf ("Start: %s %02d:%02d End: %s %02d:%02d\n", myevent->start.date, myevent->start.time / 60, myevent->start.time % 60, myevent->end.date, myevent->end.time / 60, myevent->end.time % 60);
- printf ("Contents: %s\n", myevent->description);
- printf ("Repeat = %d (%d)", (int)(myevent->repeat), myevent->repeatcount);
-}
-
-
-int skip_chars(FILE *fp, char *terminator)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while( (c = fgetc(fp)) != EOF) {
- if (c == terminator[cnt]) {
- cnt++;
- if (terminator[cnt] == '\0')
- return TRUE;
- } else
- cnt = 0;
- }
- return FALSE;
-}
-
-int peek_char(FILE *fp, char *c)
-{
- if ( ((*c) = fgetc(fp)) != EOF) {
- ungetc((*c), fp);
- return TRUE;
- } else
- return FALSE;
-}
-
-int skip_whitespace(FILE *fp)
-{
- int c;
-
- while( (c = fgetc(fp)) != EOF)
- if (!isspace(c)) {
- ungetc(c, fp);
- return TRUE;
- }
- return FALSE;
-}
-
-int get_until(FILE *fp, char terminator, char *buf)
-{
- int c;
-
- while( (c = fgetc(fp)) != EOF) {
- if (c == terminator) {
- *buf = '\0';
- return TRUE;
- }
- *buf = (char)c;
- buf++;
- }
- *buf = '\0';
- return FALSE;
-}
-
-int get_number(FILE *fp, int *x)
-{
- char buf[50];
- int c;
- int cnt;
-
- cnt = 0;
- buf[cnt] = '\0';
- while( (c= fgetc(fp)) != EOF) {
- if (!isdigit(c)) {
- ungetc(c, fp);
- *x = atoi(buf);
- return TRUE;
- }
- buf[cnt++] = (char)c;
- buf[cnt] = '\0';
- }
- *x = atoi(buf);
- return FALSE;
-}
-
-/* Get string until EOF or closer_char */
-int get_string(FILE *fp, char *string)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while ( (c = fgetc(fp)) != EOF) {
- if (c == closer[0]) {
- string[cnt] = '\0';
- ungetc((char)c, fp);
- return TRUE;
- }
- string[cnt++] = (char)c;
- }
- return FALSE;
-}
-
-int get_dates(FILE *fp, char *keyword, struct event *ptr)
-{
- char *c;
- int x;
-
- if (strncmp("Single", keyword, 6) == 0) {
- ptr->repeat = Single;
- /* It's a single date */
- if (! skip_whitespace(fp) || !get_until(fp, ' ', ptr->start.date))
- return FALSE;
- if (! skip_chars(fp, "End"))
- return FALSE;
- return TRUE;
- } else if (strncmp("Days", keyword, 4) == 0) {
- ptr->repeat = Days;
- if (! skip_whitespace(fp) || !get_until(fp, ' ', ptr->start.date))
- return FALSE;
- if (! skip_whitespace(fp) || !get_number(fp, &(ptr->repeatcount)))
- return FALSE;
- if (! skip_chars(fp, "End"))
- return FALSE;
- return TRUE;
- }
-
- return FALSE;
-}
-
-int getid(FILE *fp, char *string)
-{
- int c;
- int cnt;
-
- cnt = 0;
- while( (c =fgetc(fp)) != EOF) {
- if (isalnum(c))
- string[cnt++] = (char)c;
- else {
- string[cnt] = '\0';
- return TRUE;
- }
- }
- string[cnt] = '\0';
- return FALSE;
-}
-
-int parse_appointment(FILE *fp, struct event *ptr, char keyword[])
-{
- char buf[50];
- int x,y,c;
-
- if (strcmp(keyword, "Start") == 0) {
- if ( ! skip_whitespace(fp) || ! get_number(fp, &x) ) {
- g_error("Unable to get start time");
- return FALSE;
- }
- g_print ("Appointment start = %02d:%02d\n", x/60, x % 60);
- ptr->start.time = x;
- return TRUE;
- }
-
- if (strcmp(keyword, "Length") == 0) {
- if ( ! skip_whitespace(fp) || ! get_number(fp, &x) ) {
- g_error("Unable to get length");
- return FALSE;
- }
- g_print ("Appointment length = %d\n", x);
- ptr->end.time = ptr->start.time + x;
- return TRUE;
- }
-
- if (strcmp(keyword, "Alarms") == 0) {
- while(TRUE) {
- skip_whitespace(fp);
- if (!peek_char(fp, (char*)&c)) {
- g_error("Cannot read alarm list");
- return FALSE;
- }
- if (!isdigit(c))
- break;
-
- if (! get_number(fp, &x))
- return FALSE;
-
- g_print("New alarm %d\n", x);
- }
- return TRUE;
- }
-
- g_print("Unknown keyword %s\n", keyword);
- return FALSE;
-}
-
-int parse_item(FILE *fp, struct event *ptr, char keyword[])
-{
- char buf[50];
- int x, y, c;
-
- if (strcmp(keyword, "Remind") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get remind level");
- return FALSE;
- }
- g_print("Remind level = %d\n", x);
- return TRUE;
- }
-
- if (strcmp(keyword, "Owner") == 0) {
- if (!get_string(fp, buf)) {
- g_error("Cannot get owner information");
- return FALSE;
- }
- g_print("Owner = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Uid") == 0) {
- if (!skip_whitespace(fp) || !get_until(fp, *closer, buf)) {
- g_error("Cannot get unique ID");
- return FALSE;
- }
- g_print("UID = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Contents") == 0) {
- if (!get_string(fp, buf)) {
- g_error("Cannot get item text");
- return FALSE;
- }
- g_print("Contents = %s\n", buf);
- strcpy(ptr->description,buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Text") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x) ||
- (x < 0) || ! skip_whitespace(fp) || ! skip_chars(fp, opener) ) {
- g_error("Cannot get item text");
- return FALSE;
- }
- y = 0;
- while(y < x) {
- if ( (c = fgetc(fp)) == EOF) {
- g_error("Short item text");
- return FALSE;
- }
- buf[y++] = (char)c;
- }
- buf[y] = '\0';
- g_print("Text = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Dates") == 0) {
- if ( ! getid(fp, buf)) {
- g_error("Cannot get date");
- return FALSE;
- }
- return get_dates(fp, buf,ptr);
- }
-
- if (strcmp(keyword, "Deleted") == 0) {
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted day");
- return FALSE;
- }
- g_print("%d/", x);
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted month");
- return FALSE;
- }
- g_print("%d/", x);
- if (! skip_whitespace(fp) || ! get_number(fp, &x)) {
- g_error("Cannot get deleted year");
- return FALSE;
- }
- g_print("%d\n", x);
- return TRUE;
- }
-
- if (strcmp(keyword, "Hilite") == 0) {
- if (! get_string(fp, buf) ) {
- g_error("Cannot get hilite data");
- return FALSE;
- }
- g_print("Hilite = %s\n", buf);
- return TRUE;
- }
-
- if (strcmp(keyword, "Todo") == 0) {
- g_print("Todo\n");
- return TRUE;
- }
-
-
- if (strcmp(keyword, "Done") == 0) {
- g_print("Done\n");
- return TRUE;
- }
-
- return FALSE;
-}
-
-void parse_ical_file(char const *file)
-{
- FILE *fp;
- int finished;
- char keyword[50];
- int file_major, file_minor;
- char c;
- int item_type;
- int incomplete_item;
- struct event *myevent;
-
- if ( (fp = fopen(file, "r")) == NULL) {
- g_error("couldn't open file");
- return;
- }
-
- finished = FALSE;
-
- if (!skip_whitespace(fp))
- return;
-
- if (! skip_chars(fp, "Calendar") || ! skip_whitespace(fp) ) {
- g_error("unable to find calendar file");
- fclose(fp);
- return;
- }
-
- if (! skip_chars(fp, opener) || ! skip_chars(fp, "v") ) {
- g_error("Unable to get version line");
- fclose(fp);
- return;
- }
- if (! get_number(fp, &file_major) || ! (file_major >=0) || (file_major > VersionMajor)) {
- g_error("Missing/bad major version");
- fclose(fp);
- return;
- }
-
- if (! skip_chars(fp, ".") || ! get_number(fp, &file_minor) ||
- ! skip_chars(fp, "]") || ! skip_whitespace(fp) ) {
- g_error("Missing minor version");
- fclose(fp);
- return;
- }
- if (file_minor > 0) {
- g_error("Bad minor version");
- fclose(fp);
- return;
- }
-
- while(TRUE) {
- g_print("----------------------------------------\n");
- item_type= 0;
- skip_whitespace(fp);
- if (! getid(fp,keyword) || ! skip_whitespace(fp) ||
- ! skip_chars(fp, opener) || ! skip_whitespace(fp) ) {
- fclose(fp);
- return;
- }
-
- if (strcmp(keyword, "Appt") == 0) {
- g_print("New Appointment\n");
- item_type = 1;
-
- } else if (strcmp(keyword, "Note") == 0) {
- g_print("New Note\n");
- item_type = 2;
- } else
- g_print("New ??? (%s)\n", keyword);
-
- incomplete_item = TRUE;
- myevent = g_malloc0(sizeof(struct event));
- while(incomplete_item) {
- if (! skip_whitespace(fp) || ! peek_char(fp, &c)) {
- g_warning("Incomplete item\n");
- fclose(fp);
- return;
- }
- if (c == closer[0]) {
- (void)fgetc(fp);
- g_print("done!\n");
- incomplete_item = FALSE;
- g_slist_append(eventlist, myevent);
- break;
- }
-
- if (! getid(fp,keyword) || ! skip_whitespace(fp) ||
- ! skip_chars(fp, opener) ) {
- g_error("Error reading item property name");
- fclose(fp);
- return;
- }
- if ( ! parse_item(fp, myevent, keyword) && ! parse_appointment(fp, myevent, keyword) ) {
- g_warning("Unable to parse line\n");
- fclose(fp);
- return;
- }
- if ( ! skip_whitespace(fp) || ! skip_chars(fp, closer)) {
- g_error("Error reading item property");
- fclose(fp);
- return;
- }
- } /* while */
- } /* while */
-}
-
-
-
-
-int main(int argc, char *argv[])
-{
-
- eventlist = g_slist_alloc();
- parse_ical_file("/home/csmall/.calendar");
- g_slist_foreach(eventlist, print_glist, NULL);
- return 0;
-}
-
diff --git a/calendar/main.c b/calendar/main.c
index 9240acdfc1..55aa861e0c 100644
--- a/calendar/main.c
+++ b/calendar/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/main.h b/calendar/main.h
index 374f8199e6..6f22f946f9 100644
--- a/calendar/main.h
+++ b/calendar/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/menus.c b/calendar/menus.c
deleted file mode 100644
index c42a52a981..0000000000
--- a/calendar/menus.c
+++ /dev/null
@@ -1,147 +0,0 @@
-#include <gtk/gtk.h>
-#include <strings.h>
-
-#include "gncal.h"
-
-
-static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
- path);
-static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
-key, gchar modifiers, gchar * path);
-void menus_init(void);
-void menus_create(GtkMenuEntry * entries, int nmenu_entries);
-
-
-/* this is the GtkMenuEntry structure used to create new menus. The
- * first member is the menu definition string. The second, the
- * default accelerator key used to access this menu function with
- * the keyboard. The third is the callback function to call when
- * this menu item is selected (by the accelerator key, or with the
- * mouse.) The member is the data to pass to your callback function.
- */
-
-static GtkMenuEntry menu_items[] =
-{
- {"<Main>/File/Exit", "<control>Q", menu_file_quit, NULL},
- {"<Main>/Help/About", NULL, menu_help_about, NULL},
-
-};
-
-static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
-
-static int initialize = TRUE;
-static GtkMenuFactory *factory = NULL;
-static GtkMenuFactory *subfactory[1];
-static GHashTable *entry_ht = NULL;
-
-void get_main_menu(GtkWidget ** menubar, GtkAcceleratorTable ** table)
-{
- if (initialize)
- menus_init();
-
- if (menubar)
- *menubar = subfactory[0]->widget;
- if (table)
- *table = subfactory[0]->table;
-}
-
-void menus_init(void)
-{
- if (initialize) {
- initialize = FALSE;
-
- factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
- subfactory[0] = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
-
- gtk_menu_factory_add_subfactory(factory, subfactory[0], "<Main>");
- menus_create(menu_items, nmenu_items);
- }
-}
-
-void menus_create(GtkMenuEntry * entries, int nmenu_entries)
-{
- char *accelerator;
- int i;
-
- if (initialize)
- menus_init();
-
- if (entry_ht)
- for (i = 0; i < nmenu_entries; i++) {
- accelerator = g_hash_table_lookup(entry_ht, entries[i].path);
- if (accelerator) {
- if (accelerator[0] == '\0')
- entries[i].accelerator = NULL;
- else
- entries[i].accelerator = accelerator;
- }
- }
- gtk_menu_factory_add_entries(factory, entries, nmenu_entries);
-
-
- for (i = 0; i < nmenu_entries; i++)
- if (entries[i].widget) {
- gtk_signal_connect(GTK_OBJECT(entries[i].widget), "install_accelerator",
- (GtkSignalFunc) menus_install_accel,
- entries[i].path);
- gtk_signal_connect(GTK_OBJECT(entries[i].widget), "remove_accelerator",
- (GtkSignalFunc) menus_remove_accel,
- entries[i].path);
- }
-}
-
-static gint menus_install_accel(GtkWidget * widget, gchar * signal_name, gchar
-key, gchar modifiers, gchar * path)
-{
- char accel[64];
- char *t1, t2[2];
-
- accel[0] = '\0';
- if (modifiers & GDK_CONTROL_MASK)
- strcat(accel, "<control>");
- if (modifiers & GDK_SHIFT_MASK)
- strcat(accel, "<shift>");
- if (modifiers & GDK_MOD1_MASK)
- strcat(accel, "<alt>");
-
- t2[0] = key;
- t2[1] = '\0';
- strcat(accel, t2);
-
- if (entry_ht) {
- t1 = g_hash_table_lookup(entry_ht, path);
- g_free(t1);
- } else
- entry_ht = g_hash_table_new(g_string_hash, g_string_equal);
-
- g_hash_table_insert(entry_ht, path, g_strdup(accel));
-
- return TRUE;
-}
-
-static void menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar *
- path)
-{
- char *t;
-
- if (entry_ht) {
- t = g_hash_table_lookup(entry_ht, path);
- g_free(t);
-
- g_hash_table_insert(entry_ht, path, g_strdup(""));
- }
-}
-
-void menus_set_sensitive(char *path, int sensitive)
-{
- GtkMenuPath *menu_path;
-
- if (initialize)
- menus_init();
-
- menu_path = gtk_menu_factory_find(factory, path);
- if (menu_path)
- gtk_widget_set_sensitive(menu_path->widget, sensitive);
- else
- g_warning("Unable to set sensitivity for menu which doesn't exist: %s", path);
-}
diff --git a/calendar/menus.h b/calendar/menus.h
deleted file mode 100644
index 2cf5ab08e2..0000000000
--- a/calendar/menus.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __MENUS_H__
-#define __MENUS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include <gtk/gtk.h>
-
-void get_main_menu (GtkWidget **menubar, GtkAcceleratorTable **table);
-void menus_create(GtkMenuEntry *entries, int nmenu_entries);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MENUS_H__ */
diff --git a/calendar/month-view.c b/calendar/month-view.c
index a23938b350..de6b89db2b 100644
--- a/calendar/month-view.c
+++ b/calendar/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/objedit.c b/calendar/objedit.c
deleted file mode 100644
index 3a15e76f82..0000000000
--- a/calendar/objedit.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Calendar Object editor.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-
-#include <gnome.h>
-
-/* Day start and day end in hours */
-int day_start, day_end;
-
-typedef struct {
- GtkWidget *property_box;
-
- GtkWidget *general;
-
- GtkTable *general_table;
- GtkWidget *general_time_table;
-} ObjEditor;
-
-GtkWidget *
-calendar_object_editor_setup_time_frame (ObjEditor *oe)
-{
- GtkWidget *frame;
- GtkWidget *start_time, *end_time;
- GtkTable *t;
-
- frame = gtk_frame_new (_("Time"));
- t = GTK_TABLE (oe->general_time_table = gtk_table_new (1, 1, 0));
- gtk_container_add (GTK_CONTAINER (frame), oe->general_time_table);
-
- start_time = gnome_date_edit_new (0);
- end_time = gnome_date_edit_new (0);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) start_time, day_start, day_end);
- gnome_date_edit_set_popup_range ((GnomeDateEdit *) end_time, day_start, day_end);
-
- gtk_table_attach (t, gtk_label_new (_("Start time")), 1, 2, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (t, gtk_label_new (_("End time")), 1, 2, 2, 3, 0, 0, 0, 0);
-
- gtk_table_attach (t, start_time, 2, 3, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (t, end_time, 2, 3, 2, 3, 0, 0, 0, 0);
- return frame;
-}
-
-void
-calendar_general_editor_new (ObjEditor *oe)
-{
- GtkWidget *frame;
-
- oe->general = gtk_hbox_new (0, 0);
- oe->general_table = (GtkTable *) gtk_table_new (1, 1, 0);
-
- gtk_box_pack_start (GTK_BOX (oe->general), (GtkWidget *) oe->general_table, 1, 1, 0);
-
- frame = calendar_object_editor_setup_time_frame (oe);
- gtk_table_attach (oe->general_table, frame,
- 1, 2, 1, 2,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-
- gnome_property_box_append_page (oe->property_box, oe->general, gtk_label_new (_("General")));
-}
-
-ObjEditor *
-calendar_object_editor_new (void)
-{
- ObjEditor *oe;
-
- oe = g_new0 (ObjEditor, 1);
-
- oe->property_box = gnome_property_box_new ();
- calendar_general_editor_new (oe);
-
- return oe;
-}
-
-main (int argc, char *argv [])
-{
- ObjEditor *oe;
-
- day_start = 7;
- day_end = 19;
- gnome_init ("myapp", NULL, argc, argv, 0, NULL);
-
- oe = calendar_object_editor_new ();
- gtk_widget_show_all (oe->property_box);
- gtk_main ();
-}
diff --git a/calendar/prop.c b/calendar/prop.c
index 58abe2f8db..c339230a1a 100644
--- a/calendar/prop.c
+++ b/calendar/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);
}
-
diff --git a/calendar/views.c b/calendar/views.c
deleted file mode 100644
index 5e09b28754..0000000000
--- a/calendar/views.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Calendar views.
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Author: Miguel de Icaza (miguel@kernel.org)
- */
-#include <gnome.h>
-#include "calendar.h"
-#include "gnome-cal.h"
-
-GtkWidget *
-day_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Day View");
-}
-
-GtkWidget *
-week_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Week View");
-}
-
-GtkWidget *
-year_view_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Year View");
-}
-
-GtkWidget *
-tasks_create (GnomeCalendar *gcal)
-{
- return gtk_label_new ("This is supposed to be the Tasks View");
-}
diff --git a/calendar/views.h b/calendar/views.h
deleted file mode 100644
index d7162cfcbd..0000000000
--- a/calendar/views.h
+++ /dev/null
@@ -1,4 +0,0 @@
-GtkWidget *day_view_create (GnomeCalendar *gcal);
-GtkWidget *week_view_create (GnomeCalendar *gcal);
-GtkWidget *year_view_create (GnomeCalendar *gcal);
-GtkWidget *tasks_create (GnomeCalendar *gcal);