Remove unnecessary function call redundant checks in HildonTimeSelector
[hildon] / hildon / hildon-time-selector.c
index e605d40..bf6ff13 100644 (file)
@@ -214,8 +214,7 @@ hildon_time_selector_constructor (GType type,
 
   column = hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
                                                      selector->priv->hours_model, TRUE);
-  g_object_set (column, "text-column", 0, NULL);
-
+  hildon_touch_selector_column_set_text_column (column, 0);
 
   /* we need initialization parameters in order to create minute models*/
   selector->priv->minutes_step = selector->priv->minutes_step ? selector->priv->minutes_step : 1;
@@ -224,7 +223,7 @@ hildon_time_selector_constructor (GType type,
 
   column = hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
                                                      selector->priv->minutes_model, TRUE);
-  g_object_set (column, "text-column", 0, NULL);
+  hildon_touch_selector_column_set_text_column (column, 0);
 
   if (selector->priv->ampm_format) {
     selector->priv->ampm_model = _create_ampm_model (selector);
@@ -519,14 +518,15 @@ update_format_policy                            (HildonTimeSelector *selector,
                                                  HildonTimeSelectorFormatPolicy new_policy)
 {
   gboolean prev_ampm_format = FALSE;
-  guint hours;
-  guint minutes;
   gint num_columns = -1;
 
   num_columns = hildon_touch_selector_get_num_columns (HILDON_TOUCH_SELECTOR (selector));
   prev_ampm_format = selector->priv->ampm_format;
 
   if (new_policy != selector->priv->format_policy) {
+    guint hours;
+    guint minutes;
+
     selector->priv->format_policy = new_policy;
 
     /* We get the hour previous all the changes, to avoid problems with the
@@ -547,10 +547,10 @@ update_format_policy                            (HildonTimeSelector *selector,
         check_automatic_ampm_format (selector);
         break;
       }
-  }
 
-  if (prev_ampm_format != selector->priv->ampm_format) {
-    update_format_dependant_columns (selector, hours, minutes);
+    if (prev_ampm_format != selector->priv->ampm_format && num_columns >= 2) {
+      update_format_dependant_columns (selector, hours, minutes);
+    }
   }
 }
 
@@ -559,13 +559,6 @@ update_format_dependant_columns                 (HildonTimeSelector *selector,
                                                  guint hours,
                                                  guint minutes)
 {
-  gint num_columns = -1;
-
-  num_columns = hildon_touch_selector_get_num_columns (HILDON_TOUCH_SELECTOR (selector));
-  if (num_columns < 2) {/* we are on the object construction */
-    return;
-  }
-
   /* To avoid an extra and wrong VALUE_CHANGED signal on the model update */
   hildon_touch_selector_block_changed (HILDON_TOUCH_SELECTOR(selector));
 
@@ -622,10 +615,10 @@ hildon_time_selector_new ()
 
 /**
  * hildon_time_selector_new_step:
- *
- * Creates a new #HildonTimeSelector
- * @minutes_step: step between the minutes we are going to show in the
- * selector
+ * @minutes_step: step between the minutes in the selector.
+
+ * Creates a new #HildonTimeSelector, with @minutes_step steps between
+ * the minutes in the minutes column.
  *
  * Returns: a new #HildonTimeSelector
  *