diff options
author | nobody <nobody@localhost> | 1998-03-20 14:24:33 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 1998-03-20 14:24:33 +0800 |
commit | ba83d4bc279507a57f68187af66e3716f411c96c (patch) | |
tree | 8af21104ceace4328f7750b25d14ac6f1b87fda6 | |
parent | 5eaac213873ae075aeafe9d2fb4423afd57ab0b8 (diff) | |
download | gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar.gz gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar.bz2 gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar.lz gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar.xz gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.tar.zst gsoc2013-evolution-ba83d4bc279507a57f68187af66e3716f411c96c.zip |
This commit was manufactured by cvs2svn to create tag 'MC_4_1_29'.MC_4_1_29
svn path=/tags/MC_4_1_29/; revision=74
-rw-r--r-- | calendar/.cvsignore | 6 | ||||
-rw-r--r-- | calendar/ChangeLog | 30 | ||||
-rw-r--r-- | calendar/Makefile.am | 27 | ||||
-rw-r--r-- | calendar/cal_struct.h | 27 | ||||
-rw-r--r-- | calendar/calcs.c | 253 | ||||
-rw-r--r-- | calendar/calcs.h | 53 | ||||
-rw-r--r-- | calendar/gncal.c | 496 | ||||
-rw-r--r-- | calendar/gncal.desktop | 12 | ||||
-rw-r--r-- | calendar/gncal.h | 6 | ||||
-rw-r--r-- | calendar/gui/Makefile.am | 27 | ||||
-rw-r--r-- | calendar/gui/cal_struct.h | 27 | ||||
-rw-r--r-- | calendar/gui/gncal.desktop | 12 | ||||
-rw-r--r-- | calendar/lexer.c | 441 | ||||
-rw-r--r-- | calendar/menus.c | 147 | ||||
-rw-r--r-- | calendar/menus.h | 17 |
15 files changed, 0 insertions, 1581 deletions
diff --git a/calendar/.cvsignore b/calendar/.cvsignore deleted file mode 100644 index 9d3b9d1349..0000000000 --- a/calendar/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -_libs -.libs -gncal diff --git a/calendar/ChangeLog b/calendar/ChangeLog deleted file mode 100644 index b710acc42e..0000000000 --- a/calendar/ChangeLog +++ /dev/null @@ -1,30 +0,0 @@ -1998-03-12 Craig Small <csmall@small.dropbear.id.au> - - * Now linked (in some horrible way) to the gtkcalendar widget. - -Sun Mar 8 16:38:10 1998 Tom Tromey <tromey@cygnus.com> - - * Makefile.am (INCLUDES): Added GNOME_INCLUDEDIR. - (gncal_LDADD): Don't include libsupport.a. - - * gncal.c (main): Use new gnome_init. - -1998-02-19 Federico Mena Quintero <federico@nuclecu.unam.mx> - - * gncal.c (main): Added app_id "gncal". - -1998-02-19 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de> - - * Makefile.am (gncal_LDADD): Added '$(INTLLIBS)' - -1998-02-18 Raja R Harinath <harinath@cs.umn.edu> - - * Makefile.am (gncal_LDADD): Include `libsupport.a'. - - * calcs.c (month_atoi): Replace buggy explicit loop string compare - with strcasecmp. - (day_atoi): Likewise. - -Sun Jan 25 23:38:30 1998 Miguel de Icaza <miguel@nuclecu.unam.mx> - - * menus.c: Replace "Quit" with "Exit". diff --git a/calendar/Makefile.am b/calendar/Makefile.am deleted file mode 100644 index 9cac22c259..0000000000 --- a/calendar/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = \ - -I$(includedir) \ - $(GNOME_INCLUDEDIR) \ - -I../../gcalendar - -bin_PROGRAMS = gncal - -gncal_SOURCES = \ - gncal.c \ - gncal.h \ - calcs.c \ - calcs.h - -gncal_LDADD = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) \ - ../../gcalendar/gtkcalendar.o \ - ../../gcalendar/lib_date.o - -EXTRA_DIST = \ - gncal.desktop - -Productivitydir = $(datadir)/apps/Productivity - -Productivity_DATA = gncal.desktop - diff --git a/calendar/cal_struct.h b/calendar/cal_struct.h deleted file mode 100644 index 411036c7aa..0000000000 --- a/calendar/cal_struct.h +++ /dev/null @@ -1,27 +0,0 @@ -#define MAX_SZ 30 - -enum RepeatType { - Single, - Days, - Months, - WeekDays, - MonthDays -}; - - -struct actionitem { - char date[MAX_SZ]; - int time; /* Minutes past midnight */ -}; - -struct event { - struct actionitem start; - struct actionitem end; - - enum RepeatType repeat; - int repeatcount; - char description[MAX_SZ]; - char subtype[MAX_SZ]; - GList *properties; -}; - 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/gncal.c b/calendar/gncal.c deleted file mode 100644 index dd645ce8c7..0000000000 --- a/calendar/gncal.c +++ /dev/null @@ -1,496 +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 <gtk/gtk.h> -#include <gnome.h> -#include <config.h> - -#include "gncal.h" -#include "calcs.h" -#include "gtkcalendar.h" - -static GtkMenuEntry menu_items[] = -{ - {"File/Exit", "<control>Q", menu_file_quit, NULL}, - {"Help/About", NULL, 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; - -#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_messagebox_new(buf, "error", "OK", NULL, NULL); - - gtk_widget_show(msgbox); -} - - -void menu_file_quit(GtkWidget *widget, gpointer data) -{ - gtk_exit(0); -} - -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); */ -#ifdef 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); - - 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)); - /*get_main_menu(&menubar, &accel); - gtk_window_add_accelerator_table(GTK_WINDOW(window), accel); - gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, FALSE, 0); - gtk_widget_show(menubar);*/ - - 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); - - scrolledwindow = gtk_scrolled_window_new(NULL, NULL); - gtk_box_pack_start(GTK_BOX(right_vbox), scrolledwindow, TRUE, TRUE, 0); - gtk_widget_show(scrolledwindow); - - scroll_hbox = gtk_hbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(scrolledwindow), scroll_hbox); - gtk_widget_show(scroll_hbox); - - hour_list = gtk_list_new(); - gtk_box_pack_start(GTK_BOX(scroll_hbox), hour_list, FALSE, FALSE, 0); - gtk_widget_show(hour_list); - - separator = gtk_vseparator_new(); - gtk_box_pack_start(GTK_BOX(scroll_hbox), separator, FALSE, FALSE, 0); - gtk_widget_show(separator); - - dailylist = gtk_list_new(); - gtk_box_pack_start(GTK_BOX(scroll_hbox), dailylist, TRUE, TRUE, 0); - gtk_widget_show(dailylist); - - for (i=0; i< 24 ; i++) { - sprintf(buf, "%d:00", i); - list_item = gtk_list_item_new_with_label(buf); - gtk_container_add(GTK_CONTAINER(hour_list), list_item); - gtk_widget_show(list_item); - - dailylist_item = gtk_list_item_new(); - gtk_container_add(GTK_CONTAINER(dailylist), dailylist_item); - gtk_signal_connect(GTK_OBJECT(dailylist_item), "selected", GTK_SIGNAL_FUNC(dailylist_item_select), list_item); - gtk_signal_connect_object(GTK_OBJECT(list_item), "selected", GTK_SIGNAL_FUNC(dailylist_item_select), GTK_OBJECT(dailylist_item)); - gtk_widget_show(dailylist_item); - event_label = gtk_label_new("blah"); - gtk_container_add(GTK_CONTAINER(dailylist_item), event_label); - gtk_widget_show(event_label); - } - gtk_widget_show(app); - -} - - -int main(int argc, char *argv[]) -{ - - gnome_init("gncal", NULL, 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(); - - gtk_main(); - - return 0; -} - diff --git a/calendar/gncal.desktop b/calendar/gncal.desktop deleted file mode 100644 index 045553c9de..0000000000 --- a/calendar/gncal.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=Calendar -Name[es]=Calendario -Name[fr]=Calendrier -Name[de]=Kalender -Comment=Calendar application -Comment[fr]=Calendrier Gnome -Comment[de]=Gnome Kalender -Exec=gncal -Icon= -Terminal=0 -Type=Application 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/gui/Makefile.am b/calendar/gui/Makefile.am deleted file mode 100644 index 9cac22c259..0000000000 --- a/calendar/gui/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = \ - -I$(includedir) \ - $(GNOME_INCLUDEDIR) \ - -I../../gcalendar - -bin_PROGRAMS = gncal - -gncal_SOURCES = \ - gncal.c \ - gncal.h \ - calcs.c \ - calcs.h - -gncal_LDADD = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) \ - ../../gcalendar/gtkcalendar.o \ - ../../gcalendar/lib_date.o - -EXTRA_DIST = \ - gncal.desktop - -Productivitydir = $(datadir)/apps/Productivity - -Productivity_DATA = gncal.desktop - diff --git a/calendar/gui/cal_struct.h b/calendar/gui/cal_struct.h deleted file mode 100644 index 411036c7aa..0000000000 --- a/calendar/gui/cal_struct.h +++ /dev/null @@ -1,27 +0,0 @@ -#define MAX_SZ 30 - -enum RepeatType { - Single, - Days, - Months, - WeekDays, - MonthDays -}; - - -struct actionitem { - char date[MAX_SZ]; - int time; /* Minutes past midnight */ -}; - -struct event { - struct actionitem start; - struct actionitem end; - - enum RepeatType repeat; - int repeatcount; - char description[MAX_SZ]; - char subtype[MAX_SZ]; - GList *properties; -}; - diff --git a/calendar/gui/gncal.desktop b/calendar/gui/gncal.desktop deleted file mode 100644 index 045553c9de..0000000000 --- a/calendar/gui/gncal.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=Calendar -Name[es]=Calendario -Name[fr]=Calendrier -Name[de]=Kalender -Comment=Calendar application -Comment[fr]=Calendrier Gnome -Comment[de]=Gnome Kalender -Exec=gncal -Icon= -Terminal=0 -Type=Application 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/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__ */ |