From 0a77718be487ce7f737fcdd64b3da744c303d1f7 Mon Sep 17 00:00:00 2001
From: Andrea Zagli <azagli@libero.it>
Date: Fri, 3 Dec 2010 12:48:31 +0100
Subject: [PATCH] Adjustments.

---
 src/gtkcalex.c        | 43 +++++++++++++++++++++++--------------------
 src/gtkcalexviewday.c | 12 +++++++-----
 tests/test.ui         | 13 +++++++++----
 3 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/src/gtkcalex.c b/src/gtkcalex.c
index de61719..89820ed 100644
--- a/src/gtkcalex.c
+++ b/src/gtkcalex.c
@@ -206,9 +206,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type)
 						gtk_widget_destroy (priv->view);
 						priv->view = NULL;
 					}
-				GtkWidget *vd = gtk_calex_view_day_new (priv->date, FALSE);
-				priv->view = vd;
-				gtk_container_add (GTK_CONTAINER (calex), vd);
+				priv->view = gtk_calex_view_day_new (priv->date, FALSE);
 				break;
 
 			case GTK_CALEX_VIEW_TYPE_WORKING_WEEK:
@@ -217,9 +215,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type)
 						gtk_widget_destroy (priv->view);
 						priv->view = NULL;
 					}
-				GtkWidget *vww = gtk_calex_view_day_new (priv->date, TRUE);
-				priv->view = vww;
-				gtk_container_add (GTK_CONTAINER (calex), vww);
+				priv->view = gtk_calex_view_day_new (priv->date, TRUE);
 				break;
 
 			case GTK_CALEX_VIEW_TYPE_WEEK:
@@ -238,9 +234,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type)
 						gtk_widget_destroy (priv->view);
 						priv->view = NULL;
 					}
-				GtkWidget *vm = gtk_calex_view_day_new (priv->date, FALSE);
-				priv->view = vm;
-				gtk_container_add (GTK_CONTAINER (calex), vm);
+				priv->view = gtk_calex_view_day_new (priv->date, FALSE);
 				break;
 
 			case GTK_CALEX_VIEW_TYPE_LIST:
@@ -249,14 +243,18 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type)
 						gtk_widget_destroy (priv->view);
 						priv->view = NULL;
 					}
-				GtkWidget *vl = gtk_calex_view_day_new (priv->date, FALSE);
-				priv->view = vl;
-				gtk_container_add (GTK_CONTAINER (calex), vl);
+				priv->view = gtk_calex_view_day_new (priv->date, FALSE);
 				break;
 
 			default:
 				g_warning ("View type «%d» not available.", priv->view_type);
-				break;
+				return;
+		}
+
+	if (GTK_IS_WIDGET (priv->view))
+		{
+			gtk_container_add (GTK_CONTAINER (calex), priv->view);
+			gtk_widget_show_all (priv->view);
 		}
 }
 
@@ -308,13 +306,17 @@ gtk_calex_forall (GtkContainer *container,
                 GtkCallback callback,
                 gpointer callback_data)
 {
+	GtkBin *bin;
+
 	g_return_if_fail (IS_GTK_CALEX (container));
 	g_return_if_fail (callback != NULL);
 
-	GTK_CONTAINER_CLASS (gtk_calex_parent_class)->forall (container,
-	                     include_internals,
-	                     callback,
-	                     callback_data);
+	bin = GTK_BIN (container);
+
+	if (bin->child)
+		{
+			(* callback) (bin->child, callback_data);
+		}
 }
 
 static void
@@ -423,8 +425,9 @@ gtk_calex_size_request (GtkWidget *widget,
 		}
 
 	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-	requisition->width += border_width * 2;
-	requisition->height += border_width * 2;
+	requisition->width += (border_width * 2);
+	requisition->height += (border_width * 2);
+g_message("gtkcalex requisition %d %d",requisition->width,requisition->height);
 }
 
 static void
@@ -446,7 +449,7 @@ gtk_calex_size_allocate (GtkWidget *widget,
 	bin = GTK_BIN (gtkcalex);
 
 	priv = GTK_CALEX_GET_PRIVATE (gtkcalex);
-
+g_message("gtkcalex allocation %d %d %d %d",allocation->x,allocation->y,allocation->width,allocation->height);
 	gtk_widget_set_allocation (widget, allocation);
 
 	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
diff --git a/src/gtkcalexviewday.c b/src/gtkcalexviewday.c
index 939ee31..02e7b5c 100644
--- a/src/gtkcalexviewday.c
+++ b/src/gtkcalexviewday.c
@@ -447,7 +447,7 @@ static void
 gtk_calex_view_day_size_allocate (GtkWidget *widget,
                          GtkAllocation *allocation)
 {
-	GtkCalExViewDay *gtkcalex;
+	GtkCalExViewDay *gtkcalexvd;
 	GtkCalExViewDayPrivate *priv;
 	GtkBin *bin;
 	GtkAllocation relative_allocation;
@@ -458,11 +458,11 @@ gtk_calex_view_day_size_allocate (GtkWidget *widget,
 	g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (widget));
 	g_return_if_fail (allocation != NULL);
 
-	gtkcalex = GTK_CALEX_VIEW_DAY (widget);
-	bin = GTK_BIN (gtkcalex);
-
-	priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtkcalex);
+	gtkcalexvd = GTK_CALEX_VIEW_DAY (widget);
+	bin = GTK_BIN (gtkcalexvd);
 
+	priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtkcalexvd);
+g_message("gtkcalexviewday allocation %d %d %d %d",allocation->x,allocation->y,allocation->width,allocation->height);
 	gtk_widget_set_allocation (widget, allocation);
 
 	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -479,6 +479,8 @@ gtk_calex_view_day_size_allocate (GtkWidget *widget,
 			child_allocation.height = relative_allocation.height;
 			gtk_widget_size_allocate (bin->child, &child_allocation);
 		}
+
+	gtk_calex_view_day_draw (gtkcalexvd);
 }
 
 static void
diff --git a/tests/test.ui b/tests/test.ui
index 912436b..7428fad 100644
--- a/tests/test.ui
+++ b/tests/test.ui
@@ -87,17 +87,21 @@
           </packing>
         </child>
         <child>
-          <object class="GtkHBox" id="hbox1">
+          <object class="GtkHPaned" id="hpaned1">
             <property name="visible">True</property>
+            <property name="can_focus">True</property>
             <child>
               <object class="GtkCalendar" id="calendar1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="year">2010</property>
+                <property name="month">11</property>
+                <property name="day">3</property>
                 <signal name="day_selected" handler="on_calendar_day_selected"/>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="position">0</property>
+                <property name="resize">False</property>
+                <property name="shrink">True</property>
               </packing>
             </child>
             <child>
@@ -109,7 +113,8 @@
                 </child>
               </object>
               <packing>
-                <property name="position">1</property>
+                <property name="resize">True</property>
+                <property name="shrink">True</property>
               </packing>
             </child>
           </object>
-- 
2.49.0