⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calender-callbacks.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 4 页
字号:
/* TradeClient <http://tradeclient.sourceforge.net> * $Id: calender-callbacks.c,v 1.39 2001/03/20 22:19:33 ttabner Exp $ * * Copyright (C) 1999-2000 Bynari Inc. * Copyright (C) 2001 Project TradeClient * * LGPL * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Library 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 Library * General Public License for more details. * * You should have received a copy of the GNU Library 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 "puma.h"#include "tcal.h"GtkWidget *calendar_window=NULL;CalendarEvent *cur_event=NULL;guint curyear=-1, curmonth=-1, curday=-1;CalendarView current_view=CALENDAR_VIEW_DAILY;void event_store_updated () {        GtkTCal *tcal;	tcal=GTK_TCAL (lw (calendar_window, "monthly"));	gtk_tcal_event_store_updated (tcal);	tcal=GTK_TCAL (lw (calendar_window, "yearly"));	gtk_tcal_event_store_updated (tcal);}void calendar_set_widget (GtkWidget *widget) {	if (calendar_window && GTK_IS_WIDGET (calendar_window)) {		return;	}	calendar_window=widget;}GtkWidget *calendar_get_widget () {	return calendar_window;}void calendar_destroy () {}int calendar_hide (GtkWidget *widget, GdkEvent *event, gpointer data) {/*	if (!GTK_IS_WIDGET (calendar_window)) {		main_calendar_create (); 	}*/	gtk_widget_hide (calendar_window);	return FALSE;}gint calendar_week_custom_sorter (GtkCList *clist, GtkCListRow *row1,				                                  GtkCListRow *row2) {		    CalendarEvent *event1=(CalendarEvent *)row1->data;			    CalendarEvent *event2=(CalendarEvent *)row2->data;				/*  printf ("event1->time: %lu event2->time: %lu\n",				 *              event1->start->time, event2->start->time);*/				/*  printf ("Row1: [%p] data: [%p]\n", row1, row1->data);				 *      printf ("Row2: [%p] data: [%p]\n", row2, row2->data);*/				    if (event1->start->time > event2->start->time)							        return 1;					    if (event1->start->time < event2->start->time)								        return -1;						    return 0;}void calendar_load_print (GtkWidget *widge, GtkCalendar *cal, EventTime *time)  /* function to load information to print the view */{  FILE *fd;                             /* file pointer */  char *tmpfilename;                    /* temp file name */  char tmpname[4096];					  /* size of tmp file */  GList *seek; 						  /* creates a GList variable seek */  Llist *cseek=event_first ();          /* create cseek and place its value at first event on list */  Schedule *schedule=SCHEDULE (lookup_widget (calendar_window, "schedule"));  char *tmp;                            /* create char temp */  CalendarEvent *event;                 /* create a CalendarEvent named event */  time_t upper;  char am_or_pm;                        /* create a char to hold am or pm for start time */  char am_or_pm2;                       /* create a char to hold am or pm for stop time */  int year=0, month=0, date=0;          /* create int for year, month, date */  int printday;                         /* create int to hold the day selected to print */  int printmonth;                       /* create int to hold the month selected to print */  int printyear;                        /* create int to hold the year selected to print */          int day;                              /* create int to hold day of week */  EventTime etime;   static char *clist_names[7]={"sunday_clist", "monday_clist", "tuesday_clist",			       "wednesday_clist", "thursday_clist", "friday_clist","saturday_clist"};  GtkCList *clist;  char *temp=event_date_to_char (&etime);  time_t t=event_time_to_time_t (&etime);  struct tm *t2=localtime (&t);  t-=(t2->tm_wday+1) * 24 * 60 * 60;  event_time_dump (&etime);  temp=event_date_to_char (&etime);																																  		  tmpfilename = tmpnam(NULL);           /* creates a temp file named tmpfilename */	  insert_message ("Loading information to Print....");  /* inserts a message to the user */  fd=fopen(tmpfilename, "w+");          /* opens the file for writing */  if (fd == (FILE *)NULL)               /* if the file is equal to NULL */    {      insert_message ("Sorry.. not Loading!\n");  /* insert message to user */      return;										/* return */    }  switch (current_view)					/* switch depending on the view */    {    case CALENDAR_VIEW_TODO:      fprintf (fd, "\n\nTODO List for %s\n", getenv("USER"));  /* write to file */      fprintf (fd, "--------------------\n\n");      for (seek=todo_first ();seek;seek=seek->next)      /* seek the GList*/	{	  Todo *todo=seek->data;                     /* seek the information */ 	  fprintf (fd, "Item: %s\n", todo->text);    /* write item to file */	  fprintf (fd, "Due: %s\n\n", todo->due);    /* write due to file */	}      break;                     /* break */						    case CALENDAR_VIEW_DAILY:      year=GTK_CALENDAR (lw (calendar_window, "daily_calendar"))->year;      month=GTK_CALENDAR (lw (calendar_window, "daily_calendar"))->month;      date=GTK_CALENDAR (lw (calendar_window, "daily_calendar"))->selected_day;	      printday = date;                              /* int to hold date selected */      printmonth=month;                             /* int to hold month selected */      printyear=year;                               /* int to hold year selected */						      if (cal->month != curmonth ||	  cal->year != curyear ||	  cal->selected_day != curday)	{	  etime.minute=0;	  etime.hour=0;	  upper=event_time_to_time_t (&etime);	  schedule_destroy_children (schedule);	  schedule_set_upper (schedule, upper);	  curmonth=etime.month=cal->month;	  curyear=etime.year=cal->year;	  curday=etime.date=cal->selected_day;							  fprintf (fd, "\n\nDaily Calendar for %s\n", getenv("USER"));    /* write to file */	  fprintf (fd, "-----------------------------------\n\n");			  event_get_today(&curyear, &curmonth, &curday);	  while (cseek != NULL)                     /* go threw entire list until EOF */	    {	      event=(CalendarEvent *)cseek->data;       	      tmp=rm_crlf (event->subject);		      if (event->start->date == printday)      /* if event date equal to date selected */		{		  if (event->start->month == printmonth)  /* if event month equal to month selected */		    {		      if (event->start->year == printyear) /* if event year equal to year selected */			{			  schedule_add_child (SCHEDULE (lookup_widget (calendar_window, "schedule")),					      tmp, event->start->time, event->stop->time, event);			  free (tmp); 				  			  fprintf (fd, "Date:  %d/%d/%d\n", event->start->month+1, event->start->date, event->start->year); /* write to file*/			  if (event->start->hour <= 11)       /* if start hour less than or equal to 11 */			    am_or_pm = 'a';            /* place a in am or pm */			  else 			    {			      event->start->hour -= 12;           /* if start hour greater than or equal to 12 */			      am_or_pm = 'p';             /* place p in am or pm */			    }			  if (event->stop->hour <= 11)        /* if stop hour less than or equal to 11 */			    am_or_pm2 = 'a';            /* place a in am or pm */			  else			    {			      event->stop->hour -= 12;     /* if stop hour greater than or equal to 12 */			      am_or_pm2 = 'p';             /* place p in am or pm */			    }			  if (event->start->hour == 0)        /* if start hour equal to zero */			    event->start->hour = 12;   /* start hour is 12 */			  if (event->stop->hour == 0)         /* if stop hour equal to zero */			    event->stop->hour = 12;    /* stop hour is 12 */			  fprintf (fd, "Time:     Start:  %d:%.2d%c     End:  %d:%.2d%c\n", event->start->hour, event->start->minute, am_or_pm, event->stop->hour, event->stop->minute, am_or_pm2);     /* write to file  */			  fprintf (fd, "Location:  %s\n", event->location);  /* write to file */			  fprintf (fd, "Subject:  %s\n", event->subject);     /* write to file  */			  fprintf (fd, "Information:  %s\n\n\n", event->information);  /* write to file */			}		    }		}	      cseek=cseek->next;     /* look for next in the list */	    }			    	}      break;				    /* break */					    case CALENDAR_VIEW_WORK:      year=GTK_CALENDAR (lw (calendar_window, "calendar2"))->year;      month=GTK_CALENDAR (lw (calendar_window, "calendar2"))->month;      date=GTK_CALENDAR (lw (calendar_window, "calendar2"))->selected_day;                      printday = date;      printmonth = month;      printyear = year;						   						      fprintf (fd, "\n\nWork Week Calendar for %s\n", getenv("USER"));     /* write to file */      fprintf (fd, "-------------------------------------\n\n");      for (day=1;day<6;day++)	{	  clist=GTK_CLIST (lw (calendar_window, clist_names[day]));	  gtk_clist_set_compare_func (clist, (GtkCListCompareFunc)calendar_week_custom_sorter);	  gtk_clist_freeze (clist);	  for (cseek=event_first();cseek;cseek=cseek->next)	    {	      event=cseek->data;	      if (event->start->date==printday)		{		  if (event->start->month==printmonth)		    {		      if (event->start->year==printyear)			{			  fprintf (fd, "Date:  %d/%d/%d\n", event->start->month+1, event->start->date, event->start->year);			  if (event->start->hour <= 11)			    am_or_pm = 'a';			  else			    {			      event->start->hour -= 12;			      am_or_pm = 'p';			    }			  if (event->stop->hour <= 11)			    am_or_pm2 = 'a';			  else			    {			      event->stop->hour -= 12;			      am_or_pm2 = 'p';			    }			  if (event->start->hour == 0)			    event->start->hour = 12;			  if (event->stop->hour == 0)			    event->stop->hour = 12;			  fprintf (fd, "Time:     Start:  %d:%.2d%c     End:  %d:%.2d%c\n", event->start->hour, event->start->minute, am_or_pm, event->stop->hour, event->stop->minute, am_or_pm2);			  fprintf (fd, "Location:  %s\n", event->location);			  fprintf (fd, "Subject:  %s\n", event->subject);			  fprintf (fd, "Information:  %s\n\n\n", event->information);			}		    }		}	    }	  gtk_clist_sort (clist);	  gtk_clist_thaw (clist);	  printday++;	}      break;																								                                                          					     case CALENDAR_VIEW_WEEK:      year=GTK_CALENDAR (lw (calendar_window, "weekly_calendar"))->year;      month=GTK_CALENDAR (lw (calendar_window, "weekly_calendar"))->month;      date=GTK_CALENDAR (lw (calendar_window, "weekly_calendar"))->selected_day;      printday = date;	      printmonth = month;      printyear = year;						       fprintf (fd, "\n\nWeekly Calendar for %s\n", getenv("USER"));     /* write to file */      fprintf (fd, "-------------------------------------\n\n");								 						       for (day=0;day<7;day++)	{	  clist=GTK_CLIST (lw (calendar_window, clist_names[day]));	  gtk_clist_set_compare_func (clist, (GtkCListCompareFunc)calendar_week_custom_sorter);	  gtk_clist_freeze (clist);																																					   	  for (cseek=event_first();cseek;cseek=cseek->next)	    {	      event=cseek->data;	      if (event->start->date==printday) 		{		  if (event->start->month==printmonth)		    {		      if (event->start->year==printyear)			{ 			  fprintf (fd, "Date:  %d/%d/%d\n", event->start->month+1, event->start->date, event->start->year);			  if (event->start->hour <= 11)			    am_or_pm = 'a';			  else			    {			      event->start->hour -= 12;			      am_or_pm = 'p';			    }			  if (event->stop->hour <= 11)			    am_or_pm2 = 'a';			  else			    {			      event->stop->hour -= 12;			      am_or_pm2 = 'p';			    }			  if (event->start->hour == 0)			    event->start->hour = 12;			  if (event->stop->hour == 0)			    event->stop->hour = 12;			  fprintf (fd, "Time:     Start:  %d:%.2d%c     End:  %d:%.2d%c\n", event->start->hour, event->start->minute, am_or_pm, event->stop->hour, event->stop->minute, am_or_pm2);			  fprintf (fd, "Location:  %s\n", event->location);			  fprintf (fd, "Subject:  %s\n", event->subject);			  fprintf (fd, "Information:  %s\n\n\n", event->information);			} 		    } 		}	    }	  gtk_clist_sort (clist);	  gtk_clist_thaw (clist); 	  printday++; 	}      break;						     case CALENDAR_VIEW_MONTH:      year=GTK_CALENDAR (lw (calendar_window, "calendar2"))->year;      month=GTK_CALENDAR (lw (calendar_window, "calendar2"))->month;      date=GTK_CALENDAR (lw (calendar_window, "calendar2"))->selected_day;      printmonth=month;                            /* int to hold month selected */      printyear=year;                              /* int to hold year selected */						       if (cal->month != curmonth ||	  cal->year != curyear ||	  cal->selected_day != curday)	{	  etime.minute=0;	  etime.hour=0;	  upper=event_time_to_time_t (&etime);	  schedule_destroy_children (schedule);	  schedule_set_upper (schedule, upper);	  curmonth=etime.month=cal->month;	  curyear=etime.year=cal->year;	  curday=etime.date=cal->selected_day;							 	  fprintf (fd, "\n\nMonthly Calendar for %s\n", getenv("USER"));     /* write to file */	  fprintf (fd, "--------------------\n\n"); 	  event_get_today(&curyear, &curmonth, &curday);                         	  while (cseek != NULL)                         /* go threw entire list until EOF */	    {                         	      event=(CalendarEvent *)cseek->data;                         	      tmp=rm_crlf (event->subject);                         	      schedule_add_child (SCHEDULE (lookup_widget (calendar_window, "schedule")),                         tmp, event->start->time, event->stop->time, event);                         	      free (tmp);                                   	      if (event->start->month == printmonth)          /* if event month equal to selected month*/		{		  if (event->start->year == printyear)        /* if event year equal to selected year */		    {					      fprintf (fd, "Date:  %d/%d/%d\n", event->start->month+1, event->start->date, event->start->year);                                     		      if (event->start->hour <= 11)          /* if start hour less than or equal to 11 */			am_or_pm = 'a';               /* place a in am or pm */                      		      else                         			{                         			  event->start->hour -= 12;      /* if start hour greater than or equal to 12 */ 			  am_or_pm = 'p';               /* place p in am or pm */			}                                		      if (event->stop->hour <= 11)           /* if stop hour less than or equal to 11 */            			am_or_pm2 = 'a';              /* place a in am or pm */		      else			{			  event->stop->hour -= 12;       /* if stop hour greater than or equal to 12 */			  am_or_pm2 = 'p';              /* place p in am or pm */			}		      if (event->start->hour == 0)           /* if start hour equal zero */			event->start->hour = 12;           /* hour equals 12 */		      if (event->stop->hour == 0)            /* if stop hour equal to zero */			event->stop->hour = 12;            /* hour equals 12 */		      fprintf (fd, "Time:     Start:  %d:%.2d%c     End:  %d:%.2d%c\n", event->start->hour, event->start->minute, am_or_pm, event->stop->hour, event->stop->minute, am_or_pm2);                                /* write to file */		      fprintf (fd, "Location:  %s\n", event->location);           /* write to file */		      fprintf (fd, "Subject:  %s\n", event->subject);               /* write to file */		      fprintf (fd, "Information:  %s\n\n\n", event->information);   /* write to file */		    }		}	      cseek=cseek->next;                        /* go to the next on the list */	    }	}      break;                      /* break */						     case CALENDAR_VIEW_YEAR:      year=GTK_CALENDAR (lw (calendar_window, "calendar2"))->year;      month=GTK_CALENDAR (lw (calendar_window, "calendar2"))->month;      date=GTK_CALENDAR (lw (calendar_window, "calendar2"))->selected_day;	      printyear=year;                 /* int year to hold selected year */       if (cal->month != curmonth ||	  cal->year != curyear ||	  cal->selected_day != curday)	{	  etime.minute=0;	  etime.hour=0;	  upper=event_time_to_time_t (&etime);	  schedule_destroy_children (schedule);	  schedule_set_upper (schedule, upper);	  curmonth=etime.month=cal->month;	  curyear=etime.year=cal->year;	  curday=etime.date=cal->selected_day;   						 						 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -