Removing the bug-fixed entries that were actually resolved as WONTFIX. Removing a...
[hildon] / src / hildon-date-editor.c
index afb53c8..c9ace76 100644 (file)
@@ -8,7 +8,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; version 2.1 of
- * the License.
+ * the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 /**
  * SECTION:hildon-date-editor
  * @short_description: A widget which queries a date from user or opens
- * a HildonCalendarPopup
+ * a HildonCalendarPopup.
  * @see_also: #HildonCalendarPopup, #HildonTimeEditor
  * 
  * HildonDateEditor is a widget with three entry fields (day, month,
  * year) and an icon (button): clicking on the icon opens up a
  * HildonCalendarPopup.
+ *
+ * <example>
+ * <programlisting>
+ * gint y, m, d;
+ * <!-- -->
+ * date_editor = hildon_date_editor_new ();
+ * <!-- -->
+ * hildon_date_editor_get_date(date_editor, &amp;y, &amp;m, &amp;d);
+ * <!-- -->
+ * </programlisting>
+ * </example>
+ *
  */
 
 #ifdef                                          HAVE_CONFIG_H
@@ -40,6 +52,7 @@
 #include                                        "hildon-date-editor.h"
 #include                                        <glib.h>
 #include                                        <gtk/gtk.h>
+#include                                        <gtk/gtkenums.h>
 #include                                        <gdk/gdkkeysyms.h>
 #include                                        <time.h>
 #include                                        <stdlib.h>
@@ -47,8 +60,7 @@
 #include                                        <string.h>
 #include                                        "hildon-calendar-popup.h"
 #include                                        "hildon-defines.h"
-#include                                        "hildon-input-mode-hint.h"
-#include                                        "hildon-composite-widget.h"
+#include                                        "hildon-private.h"
 #include                                        "hildon-marshalers.h"
 #include                                        "hildon-enum-types.h"
 #include                                        "hildon-time-editor.h"
@@ -56,7 +68,9 @@
 #include                                        <libintl.h>
 #include                                        "hildon-date-editor-private.h"
 
-#define                                         _(string) dgettext(PACKAGE, string)
+#define                                         _(string) dgettext("hildon-libs", string)
+
+#define                                         c_(string) dgettext("hildon-common-strings", string)
 
 #define                                         ENTRY_BORDERS 11
 
@@ -70,7 +84,7 @@
 
 #define                                         DEFAULT_MIN_YEAR 1970
 
-#define                                         DEFAULT_MAX_YEAR 2037
+#define                                         DEFAULT_MAX_YEAR 3000
 
 static GtkContainerClass*                       parent_class;
 
@@ -116,7 +130,7 @@ hildon_date_editor_entry_focus_out              (GtkWidget *widget,
 
 static gboolean
 hildon_date_editor_date_error                   (HildonDateEditor *editor, 
-                                                HildonDateTimeError type);
+                                                 HildonDateTimeError type);
 
 static gboolean 
 hildon_date_editor_entry_focus_in               (GtkWidget *widget,
@@ -173,6 +187,13 @@ enum
 
 static guint                                    date_editor_signals[LAST_SIGNAL] = { 0 };
 
+/**
+ * hildon_date_editor_get_type:
+ *
+ * Initializes and returns the type of a hildon date editor.
+ *
+ * @Returns: GType of #HildonDateEditor
+ */
 GType G_GNUC_CONST
 hildon_date_editor_get_type                     (void)
 {
@@ -213,7 +234,7 @@ hildon_date_editor_class_init                   (HildonDateEditorClass *editor_c
     gobject_class->get_property             = hildon_date_editor_get_property;
     widget_class->size_request              = hildon_date_editor_size_request;
     widget_class->size_allocate             = hildon_date_editor_size_allocate;
-    widget_class->focus                     = hildon_composite_widget_focus;
+    widget_class->focus                     = hildon_private_composite_focus;
 
     container_class->forall                 = hildon_child_forall;
     GTK_OBJECT_CLASS(editor_class)->destroy = hildon_date_editor_destroy;
@@ -238,8 +259,8 @@ hildon_date_editor_class_init                   (HildonDateEditorClass *editor_c
             g_param_spec_uint ("year",
                 "Current year",
                 "Current year",
-                1, 2100,
-                2005,
+                1, 10000,
+                2007,
                 G_PARAM_READABLE | G_PARAM_WRITABLE));
 
     /**
@@ -277,7 +298,7 @@ hildon_date_editor_class_init                   (HildonDateEditorClass *editor_c
             g_param_spec_uint ("min-year",
                 "Minimum valid year",
                 "Minimum valid year",
-                1, 2100,
+                1, 10000,
                 DEFAULT_MIN_YEAR,
                 G_PARAM_READWRITE));
 
@@ -290,7 +311,7 @@ hildon_date_editor_class_init                   (HildonDateEditorClass *editor_c
             g_param_spec_uint ("max-year",
                 "Maximum valid year",
                 "Maximum valid year",
-                1, 2100,
+                1, 10000,
                 DEFAULT_MAX_YEAR,
                 G_PARAM_READWRITE));
 }
@@ -304,7 +325,7 @@ real_set_calendar_icon_state                    (HildonDateEditorPrivate *priv,
     g_assert (priv);
 
     gtk_image_set_from_icon_name (GTK_IMAGE (priv->calendar_icon),
-            pressed ? "qgn_widg_datedit_pr" : "qgn_widg_datedit", HILDON_ICON_SIZE_WIDG);
+            pressed ? "qgn_widg_datedit_pr" : "qgn_widg_datedit", HILDON_ICON_SIZE_SMALL);
 
     priv->calendar_icon_pressed = pressed;
 }
@@ -428,12 +449,14 @@ hildon_date_editor_init                         (HildonDateEditor *editor)
     priv->m_entry = gtk_entry_new ();
     priv->y_entry = gtk_entry_new ();
 
-    g_object_set (G_OBJECT(priv->d_entry), "input-mode", 
-            HILDON_INPUT_MODE_HINT_NUMERIC, NULL);
-    g_object_set (G_OBJECT(priv->m_entry), "input-mode", 
-            HILDON_INPUT_MODE_HINT_NUMERIC, NULL);
-    g_object_set (G_OBJECT(priv->y_entry), "input-mode", 
-            HILDON_INPUT_MODE_HINT_NUMERIC, NULL);
+#ifdef MAEMO_GTK
+    g_object_set (G_OBJECT(priv->d_entry), "hildon-input-mode", 
+            HILDON_GTK_INPUT_MODE_NUMERIC, NULL);
+    g_object_set (G_OBJECT(priv->m_entry), "hildon-input-mode", 
+            HILDON_GTK_INPUT_MODE_NUMERIC, NULL);
+    g_object_set (G_OBJECT(priv->y_entry), "hildon-input-mode", 
+            HILDON_GTK_INPUT_MODE_NUMERIC, NULL);
+#endif
 
     /* set entry look */
     gtk_entry_set_width_chars (GTK_ENTRY (priv->d_entry), DAY_ENTRY_WIDTH);
@@ -560,8 +583,6 @@ hildon_date_editor_set_property                 (GObject *object,
 
         case PROP_MIN_YEAR:
             val = g_value_get_uint (value);
-            g_return_if_fail (val > priv->max_year);
-            priv->min_year = val;
             /* Clamp current year */
             if (hildon_date_editor_get_year (editor) < priv->min_year)
                 hildon_date_editor_set_year (editor, priv->min_year);
@@ -569,7 +590,6 @@ hildon_date_editor_set_property                 (GObject *object,
 
         case PROP_MAX_YEAR:
             val = g_value_get_uint (value);
-            g_return_if_fail (val < priv->min_year);
             priv->max_year = val;
             /* Clamp current year */
             if (hildon_date_editor_get_year (editor) > priv->max_year)
@@ -619,7 +639,8 @@ hildon_date_editor_get_property                 (GObject *object,
     }
 }
 
-static void hildon_child_forall                 (GtkContainer *container,
+static void 
+hildon_child_forall                             (GtkContainer *container,
                                                  gboolean include_internals,
                                                  GtkCallback callback,
                                                  gpointer callback_data)
@@ -757,9 +778,10 @@ hildon_date_editor_set_date                     (HildonDateEditor *editor,
  * @month: month
  * @day: day
  *
- * Returns: the year, month, and day currently on the
- * date editor. You can pass NULL to any of the pointers if
+ * Gets the date represented by the date editor.
+ * You can pass NULL to any of the pointers if
  * you're not interested in obtaining it. 
+ *
  */
 void 
 hildon_date_editor_get_date                     (HildonDateEditor *date,
@@ -1029,6 +1051,19 @@ hildon_date_editor_entry_validate               (GtkWidget *widget,
     return error_code;
 }
 
+/* Idle callback */
+static gboolean
+hildon_date_editor_entry_select_all             (GtkWidget *widget)
+{
+    GDK_THREADS_ENTER ();
+
+    gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
+
+    GDK_THREADS_LEAVE ();
+
+    return FALSE;
+}
+
 /* When entry becomes full, we move the focus to the next field.
    If we are on the last field, the whole contents are validated. */
 static void
@@ -1207,7 +1242,7 @@ hildon_date_editor_date_error                   (HildonDateEditor *editor,
             break;
 
         case HILDON_DATE_TIME_ERROR_INVALID_CHAR:
-            hildon_banner_show_information (GTK_WIDGET (editor), NULL, _("ckct_ib_illegal_character"));
+            hildon_banner_show_information (GTK_WIDGET (editor), NULL, c_("ckct_ib_illegal_character"));
             break;
 
         case HILDON_DATE_TIME_ERROR_INVALID_DATE:
@@ -1325,7 +1360,7 @@ hildon_date_editor_size_allocate                (GtkWidget *widget,
  *
  * Sets the year shown in the editor. 
  *
- * Returns: TRUE if the year is valid
+ * Returns: TRUE if the year is valid and has been set.
  */
 gboolean 
 hildon_date_editor_set_year                     (HildonDateEditor *editor, 
@@ -1366,7 +1401,7 @@ hildon_date_editor_set_year                     (HildonDateEditor *editor,
  *
  * Sets the month shown in the editor. 
  *
- * Returns: TRUE if the month is valid
+ * Returns: TRUE if the month is valid and has been set.
  */
 gboolean 
 hildon_date_editor_set_month                    (HildonDateEditor *editor, 
@@ -1407,7 +1442,7 @@ hildon_date_editor_set_month                    (HildonDateEditor *editor,
  *
  * Sets the day shown in the editor. 
  *
- * Returns: TRUE if the day is valid
+ * Returns: TRUE if the day is valid and has been set.
  */
 gboolean 
 hildon_date_editor_set_day                      (HildonDateEditor *editor, 
@@ -1500,15 +1535,3 @@ hildon_date_editor_get_day                      (HildonDateEditor *editor)
     return (guint) atoi (gtk_entry_get_text (GTK_ENTRY (priv->d_entry)));
 }
 
-/* Idle callback */
-static gboolean
-hildon_date_editor_entry_select_all             (GtkWidget *widget)
-{
-    GDK_THREADS_ENTER ();
-
-    gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
-
-    GDK_THREADS_LEAVE ();
-
-    return FALSE;
-}