Release 2.1.96-6
[hildon] / examples / hildon-date-editor-example.c
index 5ed9cc7..0685bfe 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
 #include                                        <stdlib.h>
 #include                                        <glib.h>
 #include                                        <gtk/gtk.h>
-#include                                        "hildon.h"
+#include                                        <hildon/hildon.h>
+
+static gboolean
+on_error (GtkWidget *widget, HildonDateTimeError error_type);
+
+static gboolean
+on_error (GtkWidget *widget, HildonDateTimeError error_type)
+{
+    g_debug ("Error: %d", error_type);
+    return FALSE;
+}
 
 int
-main (int argc, char **args)
+main (int argc, char **argv)
 {
-    gtk_init (&argc, &args);
-    
+    guint y, m, d;
+
+    hildon_gtk_init (&argc, &argv);
+
     GtkDialog *dialog = GTK_DIALOG (gtk_dialog_new ());
     HildonDateEditor *date_editor = HILDON_DATE_EDITOR (hildon_date_editor_new ());
 
-    gtk_box_pack_start (GTK_BOX (dialog->vbox), GTK_WIDGET (date_editor), FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (dialog->vbox), gtk_label_new ("Choose a date"), FALSE, FALSE, 10);
+    gtk_box_pack_start (GTK_BOX (dialog->vbox), GTK_WIDGET (date_editor), FALSE, FALSE, 10);
     gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CANCEL);
 
+    g_signal_connect (G_OBJECT (date_editor), "date_error", G_CALLBACK (on_error), NULL);
+        
     gtk_widget_show_all (GTK_WIDGET (dialog));
     gtk_dialog_run (dialog);
+
+    hildon_date_editor_get_date (date_editor, &y, &m, &d);
+
+    g_debug ("Date: %u-%u-%u", y, m, d);
     
     return 0;
 }