GtkCalendar issues [PATCH]



Hi chaps,

Been playing with the Calendar widget, and have noticed the
following:

1. The variable calendar->num_marked_dates isn't being used.
	Not sure if it should be removed or implemented, so
	I implemented it in the enclosed patch.

2. Selecting the previous month results in two day_selected
	signals being emitted. Also fixed in enclosed patch.

3. There seems to be a resize issue which I haven't worked out.
	To recreate, run the example code, select a combination
	of "Show Day Names" and "Show Week Numbers" and then
	toggle "Show Heading" off. In some option combinations
	(seems dependent upon font as well) the Calendar does
	not shrink properly.

Anyway I will commit the enclosed patch to fix 1 and 2 if
no one objects.

-tony

*** gtkcalendar.c.orig	Tue Feb 22 20:51:30 2000
--- gtkcalendar.c	Wed Feb 23 10:48:03 2000
***************
*** 453,458 ****
--- 453,459 ----
    
    for (i=0;i<31;i++)
      calendar->marked_date[i] = FALSE;
+   calendar->num_marked_dates = 0;
    calendar->selected_day = 1;
    
    calendar->display_flags = ( GTK_CALENDAR_SHOW_HEADING | 
***************
*** 661,671 ****
      {
        if (calendar->selected_day < 0)
  	calendar->selected_day = calendar->selected_day + 1 + month_length[leap (calendar->year)][calendar->month + 1];
!       else
! 	gtk_calendar_select_day (calendar, calendar->selected_day);
      }
    
-   gtk_calendar_select_day (calendar, calendar->selected_day);
    gtk_calendar_paint (GTK_WIDGET (calendar), NULL);
    gtk_calendar_thaw (calendar);
  }
--- 662,670 ----
      {
        if (calendar->selected_day < 0)
  	calendar->selected_day = calendar->selected_day + 1 + month_length[leap (calendar->year)][calendar->month + 1];
!       gtk_calendar_select_day (calendar, calendar->selected_day);
      }
    
    gtk_calendar_paint (GTK_WIDGET (calendar), NULL);
    gtk_calendar_thaw (calendar);
  }
***************
*** 2220,2226 ****
      {
        calendar->marked_date[day] = FALSE;
      }
!   
    if (GTK_WIDGET_DRAWABLE (calendar))
      {
        gtk_calendar_paint_main (GTK_WIDGET (calendar));
--- 2219,2227 ----
      {
        calendar->marked_date[day] = FALSE;
      }
!  
!   calendar->num_marked_dates = 0;
!  
    if (GTK_WIDGET_DRAWABLE (calendar))
      {
        gtk_calendar_paint_main (GTK_WIDGET (calendar));
***************
*** 2234,2242 ****
    g_return_val_if_fail (calendar != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE);
    
!   if (day >= 1 && day <= 31)
!     calendar->marked_date[day - 1] = TRUE;
!   
    if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
      {
        gtk_calendar_paint_main (GTK_WIDGET (calendar));
--- 2235,2245 ----
    g_return_val_if_fail (calendar != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE);
    
!   if (day >= 1 && day <= 31 && calendar->marked_date[day-1] == FALSE)
!     {
!       calendar->marked_date[day - 1] = TRUE;
!       calendar->num_marked_dates++;
!     }
    if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
      {
        gtk_calendar_paint_main (GTK_WIDGET (calendar));
***************
*** 2252,2259 ****
    g_return_val_if_fail (calendar != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE);
    
!   if (day >= 1 && day <= 31)
!     calendar->marked_date[day - 1] = FALSE;
    
    if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
      {
--- 2255,2265 ----
    g_return_val_if_fail (calendar != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE);
    
!   if (day >= 1 && day <= 31 && calendar->marked_date[day-1] == TRUE)
!     {
!       calendar->marked_date[day - 1] = FALSE;
!       calendar->num_marked_dates--;
!     }
    
    if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar)))
      {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]