2008-08-28 Alejandro Pinheiro <apinheiro@igalia.com> * src/hildon-touch-selector...
[hildon] / src / hildon-date-editor.c
index 2c60010..8bd4732 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* vim:set sw=4 expandtab cino=(0:
+ *
  * This file is a part of hildon
  *
  * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
  *
  * <example>
  * <programlisting>
- * gint y, m, d;
+ * guint y, m, d;
+ * GtkDialog *dialog;
+ * GtkWidget *date_editor;
  * <!-- -->
+ * dialog = GTK_DIALOG (gtk_dialog_new ());
  * date_editor = hildon_date_editor_new ();
  * <!-- -->
- * hildon_date_editor_get_date(date_editor, &amp;y, &amp;m, &amp;d);
+ * 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), date_editor, FALSE, FALSE, 10);
+ * gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CANCEL);
+ * <!-- -->
+ * gtk_widget_show_all (GTK_WIDGET (dialog));
+ * gtk_dialog_run (dialog);
+ * <!-- -->
+ * hildon_date_editor_get_date (HILDON_DATE_EDITOR (date_editor), &amp;y, &amp;m, &amp;d);
+ * g_debug ("Date: &percnt;u-&percnt;u-&percnt;u", y, m, d);
  * <!-- -->
  * </programlisting>
  * </example>
 #include                                        <config.h>
 #endif
 
-#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>
 #include                                        <stdio.h>
 #include                                        <string.h>
+#include                                        <libintl.h>
+#include                                        <gdk/gdkkeysyms.h>
+
+#include                                        "hildon-date-editor.h"
 #include                                        "hildon-calendar-popup.h"
 #include                                        "hildon-defines.h"
-#include                                        "hildon-private.h"
 #include                                        "hildon-marshalers.h"
 #include                                        "hildon-enum-types.h"
 #include                                        "hildon-time-editor.h"
 #include                                        "hildon-banner.h"
-#include                                        <libintl.h>
 #include                                        "hildon-date-editor-private.h"
+#include                                        "hildon-private.h"
 
 #define                                         _(string) dgettext("hildon-libs", string)
 
@@ -1298,16 +1308,15 @@ hildon_date_editor_size_allocate                (GtkWidget *widget,
     f_alloc.x = img_alloc.x = allocation->x +
         MAX (allocation->width - max_req.width, 0) / 2;
 
-    /* allocate frame */
+    /* calculate allocations */
     if (GTK_WIDGET_VISIBLE (widget)) {
+        /* allocate frame */
         gtk_widget_get_child_requisition (priv->frame, &req);
 
         f_alloc.width = req.width;
         f_alloc.height = max_req.height;
-    }
 
-    /* allocate icon */
-    if (GTK_WIDGET_VISIBLE (widget)) {
+        /* allocate icon */
         gtk_widget_get_child_requisition (priv->d_button_image,
                 &req);
 
@@ -1320,14 +1329,14 @@ hildon_date_editor_size_allocate                (GtkWidget *widget,
             img_alloc.x = f_alloc.x;
             f_alloc.x  += img_alloc.width + HILDON_MARGIN_DEFAULT;
         }
-    }
 
-    if (GTK_WIDGET_VISIBLE (priv->d_button_image)) {
-        gtk_widget_size_allocate (priv->d_button_image, &img_alloc);
-    }
+        if (GTK_WIDGET_VISIBLE (priv->d_button_image)) {
+            gtk_widget_size_allocate (priv->d_button_image, &img_alloc);
+        }
 
-    if (GTK_WIDGET_VISIBLE (priv->frame)) {
-        gtk_widget_size_allocate (priv->frame, &f_alloc);
+        if (GTK_WIDGET_VISIBLE (priv->frame)) {
+            gtk_widget_size_allocate (priv->frame, &f_alloc);
+        }
     }
 
     /* FIXME: We really should not alloc delimeters by hand (since they