2009-03-16 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / src / hildon-date-selector.c
index 44cf7b1..c2e0f96 100644 (file)
@@ -124,7 +124,8 @@ static GtkTreeModel *_update_day_model (HildonDateSelector * selector);
 static gint _month_days (gint month, gint year);
 static void _init_column_order (HildonDateSelector * selector);
 
-static gchar *_custom_print_func (HildonTouchSelector * selector);
+static gchar *_custom_print_func (HildonTouchSelector * selector,
+                                  gpointer user_data);
 
 /***************************************************************************/
 /* The following date routines are taken from the lib_date package.  Keep
@@ -334,10 +335,6 @@ hildon_date_selector_construct_ui (HildonDateSelector *selector)
       break;
     }
   }
-  /* By default we should select the current day */
-  hildon_date_selector_select_current_date (selector, selector->priv->creation_year,
-                                            selector->priv->creation_month,
-                                            selector->priv->creation_day);
 }
 
 static GObject *
@@ -346,11 +343,21 @@ hildon_date_selector_constructor (GType                  type,
                                   GObjectConstructParam *construct_properties)
 {
   GObject *object;
+  HildonDateSelector *selector;
 
   object = G_OBJECT_CLASS (hildon_date_selector_parent_class)->constructor
     (type, n_construct_properties, construct_properties);
 
-  hildon_date_selector_construct_ui (HILDON_DATE_SELECTOR (object));
+  selector = HILDON_DATE_SELECTOR (object);
+
+  hildon_date_selector_construct_ui (selector);
+
+  g_signal_connect (object, "changed", G_CALLBACK (_manage_selector_change_cb), NULL);
+
+  /* By default we should select the current day */
+  hildon_date_selector_select_current_date (selector, selector->priv->creation_year,
+                                            selector->priv->creation_month,
+                                            selector->priv->creation_day);
 
   return object;
 }
@@ -373,10 +380,6 @@ hildon_date_selector_init (HildonDateSelector * selector)
   _get_real_date (&selector->priv->creation_year,
                   &selector->priv->creation_month, &selector->priv->creation_day);
   selector->priv->current_num_days = 31;
-
-
-  g_signal_connect (G_OBJECT (selector),
-                    "changed", G_CALLBACK (_manage_selector_change_cb), NULL);
 }
 
 static void
@@ -394,7 +397,7 @@ hildon_date_selector_finalize (GObject * object)
 
 /* ------------------------------ PRIVATE METHODS ---------------------------- */
 static gchar *
-_custom_print_func (HildonTouchSelector * touch_selector)
+_custom_print_func (HildonTouchSelector * touch_selector, gpointer user_data)
 {
   HildonDateSelector *selector = NULL;
   gchar *result = NULL;
@@ -594,7 +597,7 @@ _update_day_model (HildonDateSelector * selector)
   guint current_day = 0;
   guint current_year = 0;
   guint current_month = 0;
-  guint num_days = 31;
+  gint num_days = 31;
 
   hildon_date_selector_get_date (selector, &current_year, &current_month,
                                  &current_day);
@@ -690,7 +693,7 @@ _month_days (gint month, gint year)
     {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
   };
 
-  g_return_val_if_fail (month >= 0 && month <= 12, -1);
+  g_return_val_if_fail (month >= 0 && month < 12, -1);
 
   return month_days[_leap (year)][month];
 }
@@ -780,7 +783,7 @@ hildon_date_selector_select_current_date (HildonDateSelector * selector,
   max_year = selector->priv->max_year;
 
   g_return_val_if_fail (min_year <= year && year <= max_year, FALSE);
-  g_return_val_if_fail (month >= 0 && month < 12, FALSE);
+  g_return_val_if_fail (month < 12, FALSE);
 
   num_days = _month_days (month, year);
   g_return_val_if_fail (day > 0 && day <= num_days, FALSE);