* hildon-widgets/hildon-calendar-popup.c * hildon-widgets/hildon-color-button.c ...
authorLuc Pionchon <luc.pionchon@nokia.com>
Tue, 3 Jan 2006 20:32:03 +0000 (20:32 +0000)
committerLuc Pionchon <luc.pionchon@nokia.com>
Tue, 3 Jan 2006 20:32:03 +0000 (20:32 +0000)
31 files changed:
ChangeLog
hildon-widgets/hildon-calendar-popup.c
hildon-widgets/hildon-color-button.c
hildon-widgets/hildon-color-popup.c
hildon-widgets/hildon-color-selector.c
hildon-widgets/hildon-composite-widget.c
hildon-widgets/hildon-controlbar.c
hildon-widgets/hildon-date-editor.c
hildon-widgets/hildon-dialoghelp.c
hildon-widgets/hildon-file-details-dialog.c
hildon-widgets/hildon-font-selection-dialog.c
hildon-widgets/hildon-get-password-dialog.c
hildon-widgets/hildon-grid-item.c
hildon-widgets/hildon-grid.c
hildon-widgets/hildon-hvolumebar.c
hildon-widgets/hildon-name-password-dialog.c
hildon-widgets/hildon-note.c
hildon-widgets/hildon-number-editor.c
hildon-widgets/hildon-range-editor.c
hildon-widgets/hildon-scroll-area.c
hildon-widgets/hildon-seekbar.c
hildon-widgets/hildon-set-password-dialog.c
hildon-widgets/hildon-sort-dialog.c
hildon-widgets/hildon-time-editor.c
hildon-widgets/hildon-time-picker.c
hildon-widgets/hildon-volumebar-private.h
hildon-widgets/hildon-volumebar-range.c
hildon-widgets/hildon-volumebar.c
hildon-widgets/hildon-vvolumebar.c
hildon-widgets/hildon-weekday-picker.c
hildon-widgets/hildon-wizard-dialog.c

index 037492f..28eef04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2006-01-03  Luc Pionchon  <luc.pionchon@nokia.com>
+
+       * hildon-widgets/hildon-calendar-popup.c
+       * hildon-widgets/hildon-color-button.c
+       * hildon-widgets/hildon-color-popup.c
+       * hildon-widgets/hildon-color-selector.c
+       * hildon-widgets/hildon-composite-widget.c
+       * hildon-widgets/hildon-controlbar.c
+       * hildon-widgets/hildon-date-editor.c
+       * hildon-widgets/hildon-dialoghelp.c
+       * hildon-widgets/hildon-file-details-dialog.c
+       * hildon-widgets/hildon-font-selection-dialog.c
+       * hildon-widgets/hildon-get-password-dialog.c
+       * hildon-widgets/hildon-grid-item.c
+       * hildon-widgets/hildon-grid.c
+       * hildon-widgets/hildon-hvolumebar.c
+       * hildon-widgets/hildon-name-password-dialog.c
+       * hildon-widgets/hildon-note.c
+       * hildon-widgets/hildon-number-editor.c
+       * hildon-widgets/hildon-range-editor.c
+       * hildon-widgets/hildon-scroll-area.c
+       * hildon-widgets/hildon-seekbar.c
+       * hildon-widgets/hildon-set-password-dialog.c
+       * hildon-widgets/hildon-sort-dialog.c
+       * hildon-widgets/hildon-time-editor.c
+       * hildon-widgets/hildon-time-picker.c
+       * hildon-widgets/hildon-volumebar-private.h
+       * hildon-widgets/hildon-volumebar-range.c
+       * hildon-widgets/hildon-volumebar.c
+       * hildon-widgets/hildon-vvolumebar.c
+       * hildon-widgets/hildon-weekday-picker.c
+       * hildon-widgets/hildon-wizard-dialog.c
+         commented code
+
 2005-12-28  Luc Pionchon  <luc.pionchon@nokia.com>
 
        * configure.ac: 0.10.0
index 7f1e040..60b56b1 100644 (file)
@@ -45,7 +45,7 @@
 #include <time.h>
 #include <libintl.h>
 #include <hildon-widgets/hildon-calendar-popup.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include ? */
 
 #define _(String) dgettext(PACKAGE, String)
 
@@ -140,6 +140,7 @@ GtkWidget *hildon_calendar_popup_new(GtkWindow * parent, guint year,
 
     init_dmy(year, month, day, &dtmp, &mtmp, &ytmp);
 
+    /* Create new HildonCalendarPopup */
     cal = HILDON_CALENDAR_POPUP(g_object_new(HILDON_CALENDAR_POPUP_TYPE,
                                              NULL));
     priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
@@ -175,8 +176,11 @@ hildon_calendar_popup_set_date(HildonCalendarPopup * cal,
     g_return_if_fail(HILDON_IS_CALENDAR_POPUP(cal));
 
     priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
+
+    /* Remove all visual markers */
     gtk_calendar_clear_marks(GTK_CALENDAR(priv->cal));
 
+    /* Set a new date */
     gtk_calendar_select_month(GTK_CALENDAR(priv->cal), month - 1, year);
     gtk_calendar_select_day(GTK_CALENDAR(priv->cal), day);
 }
@@ -221,6 +225,7 @@ hildon_calendar_popup_class_init(HildonCalendarPopupClass * cal_class)
     g_type_class_add_private(cal_class,
                              sizeof(HildonCalendarPopupPrivate));
 
+    /* Install new properties for the GObject_class */
     g_object_class_install_property(object_class, PROP_MIN_YEAR,
                                     g_param_spec_uint("min-year",
                                                       "Minimum valid year",
@@ -273,6 +278,7 @@ static void hildon_calendar_popup_init(HildonCalendarPopup * cal)
 
     priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
 
+    /* set the domain directory for different language */
     if (set_domain) {
         (void) bindtextdomain(PACKAGE, LOCALEDIR);
         set_domain = 0;
@@ -341,12 +347,14 @@ hildon_key_pressed(GtkWidget * widget, GdkEventKey * event, gpointer data)
     cal = HILDON_CALENDAR_POPUP(data);
     priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
 
+    /* Handle Return_key press as OK response */ 
     if (event->keyval == GDK_Return) {
         priv->can_exit = TRUE;
         gtk_dialog_response(GTK_DIALOG(cal), GTK_RESPONSE_OK);
         return TRUE;
     }
 
+    /* Handle Esc and F1-8 key press as CANCEL response */
     if ((event->keyval == GDK_Escape) || (event->keyval == GDK_F1) ||
         (event->keyval == GDK_F2) || (event->keyval == GDK_F3) ||
         (event->keyval == GDK_F4) || (event->keyval == GDK_F5) ||
@@ -365,11 +373,14 @@ init_dmy(guint year, guint month, guint day, guint * d, guint * m,
 {
     GDate date;
 
+    /* Initialize the date with a valid selected date */ 
     if (g_date_valid_dmy(day, month, year)) {
         *d = day;
         *m = month;
         *y = year;
-    } else {
+    } else { 
+
+      /* If selected date is invalid initialize the date with current date */ 
         g_date_clear(&date, 1);
         g_date_set_time(&date, time(NULL));
 
@@ -414,20 +425,20 @@ static void hildon_calendar_popup_set_property(GObject * object, guint property_
 
     switch (property_id) {
     case PROP_DAY:
-         g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     case PROP_MONTH:
-         g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     case PROP_YEAR:
-         g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     case PROP_MIN_YEAR:
-      g_object_set_property(G_OBJECT(priv->cal), "min-year", value);
-      break;
+        g_object_set_property(G_OBJECT(priv->cal), "min-year", value);
+        break;
     case PROP_MAX_YEAR:
-      g_object_set_property(G_OBJECT(priv->cal), "max-year", value);
-      break;
+        g_object_set_property(G_OBJECT(priv->cal), "max-year", value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
         break;
@@ -443,13 +454,13 @@ static void hildon_calendar_popup_get_property(GObject * object, guint property_
 
     switch (property_id) {
     case PROP_DAY:
-          g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     case PROP_MONTH:
-          g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     case PROP_YEAR:
-          g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+        g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
index 100747c..e542c39 100644 (file)
@@ -191,6 +191,7 @@ hildon_color_button_init(HildonColorButton *cb)
   gtk_widget_set_size_request(GTK_WIDGET(cb->priv->drawing_area),
                               COLOR_FIELD_WIDTH, COLOR_FIELD_HEIGHT);
 
+  /* Connect the callback function for exposure event */
   g_signal_connect(G_OBJECT(cb->priv->drawing_area), "expose-event",
                    G_CALLBACK(hildon_color_field_expose_event), cb);
 
@@ -204,6 +205,7 @@ hildon_color_button_init(HildonColorButton *cb)
   gtk_widget_pop_composite_child();
 }
 
+/* Free memory used by HildonColorButton */
 static void
 hildon_color_button_finalize(GObject *object)
 {
@@ -237,12 +239,14 @@ hildon_color_button_realize(GtkWidget *widget)
 
   GTK_WIDGET_CLASS(parent_class)->realize(widget);
 
+  /* Create new graphics context if it doesn't exist */
   if (!cb->priv->gc)
     cb->priv->gc = gdk_gc_new(widget->window);
 
   hildon_color_button_recolor_pixbuf(cb);
 }
 
+/* Make the widget sensitive with the keyboard event */
 static gboolean
 hildon_color_button_mnemonic_activate( GtkWidget *widget,
                                        gboolean group_cycling )
@@ -260,6 +264,7 @@ hildon_color_button_recolor_pixbuf(HildonColorButton *cb)
   GdkPixbuf *pb = cb->priv->pixbuf;
   GdkColor *color = &cb->priv->color;
   
+  /* Initialize the base color */
   r = (color->red >> 8);
   g = (color->green >> 8);
   b = (color->blue >> 8);
@@ -267,16 +272,18 @@ hildon_color_button_recolor_pixbuf(HildonColorButton *cb)
   pixels = gdk_pixbuf_get_pixels(pb);
   rowstride = gdk_pixbuf_get_rowstride(pb);
   
+  /* Queue drawing of the widget */
   for (j=0; j<COLOR_FIELD_HEIGHT; j++)
     for (i=0; i<COLOR_FIELD_WIDTH; i++)
     {
-      *(j * rowstride + pixels + i * 3)     = r;
-      *(j * rowstride + pixels + i * 3 + 1) = g;
-      *(j * rowstride + pixels + i * 3 + 2) = b;
+      *(rowstride * j + pixels + i * 3)     = r;
+      *(rowstride * j + pixels + i * 3 + 1) = g;
+      *(rowstride * j + pixels + i * 3 + 2) = b;
     }
   gtk_widget_queue_draw(GTK_WIDGET(cb));
 }
 
+/* Popup a color selector dialog on button click */
 static void
 hildon_color_button_clicked(GtkButton *button)
 {
@@ -284,6 +291,7 @@ hildon_color_button_clicked(GtkButton *button)
   HildonColorButton *cb = HILDON_COLOR_BUTTON(button);
   HildonColorSelector *csd = HILDON_COLOR_SELECTOR(cb->priv->dialog);
 
+  /* Popup the color selector dialog */
   if (!csd)
   {
     GtkWidget *parent = gtk_widget_get_toplevel(GTK_WIDGET(cb));
@@ -294,9 +302,12 @@ hildon_color_button_clicked(GtkButton *button)
       gtk_window_set_transient_for(GTK_WINDOW(csd), GTK_WINDOW(parent));
   }
   
+  /* Set the initial color for the color selector dialog */
   hildon_color_selector_set_color(csd, &cb->priv->color);
   
   result = gtk_dialog_run(GTK_DIALOG(csd));
+
+  /* Update the color for color button if selection was made */
   if (result == GTK_RESPONSE_OK)
   {
     cb->priv->color = *hildon_color_selector_get_color(csd);
@@ -305,6 +316,7 @@ hildon_color_button_clicked(GtkButton *button)
   gtk_widget_hide(GTK_WIDGET(csd));
 }
 
+/* Set_property function for HildonColorButtonClass initialization */
 static void
 hildon_color_button_set_property(GObject *object, guint param_id,
                                                   const GValue *value, GParamSpec *pspec)
@@ -323,6 +335,7 @@ hildon_color_button_set_property(GObject *object, guint param_id,
     }
 }
 
+/* Get_property function for HildonColorButtonClass initialization */
 static void
 hildon_color_button_get_property(GObject *object, guint param_id,
                                                   GValue *value, GParamSpec *pspec)
index b95726e..fbecfcc 100644 (file)
@@ -52,7 +52,7 @@
 #define HILDON_COLOR_CONTROLBAR_MIN        0 
 #define HILDON_COLOR_LABELS_LEFT_PAD      35
 #define HILDON_COLOR_PALETTE_POS_PAD      45
-#define HILDON_COLOR_BAR_WIDTH 449
+#define HILDON_COLOR_BAR_WIDTH           449
 
 /* 
  * Private function prototype definitions 
@@ -89,12 +89,14 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
 
   current_color = initial_color;
 
+  /* Create control bars for HildonColorPopup */
   popup_data->ctrlbar_red   = hildon_controlbar_new (); 
   popup_data->ctrlbar_green = hildon_controlbar_new ();
   popup_data->ctrlbar_blue  = hildon_controlbar_new ();
   area = gtk_drawing_area_new();
   layout = GTK_TABLE(gtk_table_new(12, 2, FALSE));
 
+  /* Set widgets' size */
   gtk_widget_set_size_request (area, 
                                HILDON_COLOR_PALETTE_SIZE, 
                                HILDON_COLOR_PALETTE_SIZE);
@@ -105,6 +107,7 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
   gtk_widget_set_size_request(popup_data->ctrlbar_blue,
                                HILDON_COLOR_BAR_WIDTH, -1); 
 
+  /* Create labels for three kinds of color */
   l_red = gtk_label_new( _("Ecdg_fi_5bit_colour_selector_red"));
   l_green = gtk_label_new(_("Ecdg_fi_5bit_colour_selector_green"));
   l_blue = gtk_label_new(_("Ecdg_fi_5bit_colour_selector_blue"));
@@ -114,6 +117,7 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
   gtk_misc_set_alignment(GTK_MISC(l_green), 0.08f, 0.5f);  
   gtk_misc_set_alignment(GTK_MISC(l_blue), 0.08f, 0.5f);
 
+  /* Add labels and control bars to the layout table */
   gtk_table_attach_defaults(layout, l_red, 0, 1, 0, 2);
   gtk_table_attach_defaults(layout, popup_data->ctrlbar_red, 0, 1, 2, 4);
   gtk_table_attach_defaults(layout, l_green, 0, 1, 4, 6);
@@ -122,7 +126,7 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
   gtk_table_attach_defaults(layout, popup_data->ctrlbar_blue, 0, 1, 10, 12);
   gtk_table_attach(layout, area, 1, 2, 3, 11, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
-  /* control bars */
+  /* Give the maximum and minimum limits for each control bar */
   hildon_controlbar_set_range (HILDON_CONTROLBAR(popup_data->ctrlbar_red),
                                  HILDON_COLOR_CONTROLBAR_MIN, 
                                  HILDON_COLOR_CONTROLBAR_MAX);
@@ -133,6 +137,7 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
                                  HILDON_COLOR_CONTROLBAR_MIN, 
                                  HILDON_COLOR_CONTROLBAR_MAX);
 
+  /* Give the initial values for each control bar */
   hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_red),   
                                  (current_color->red >> 11)&0x1F);
   hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_green),
@@ -140,7 +145,7 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
   hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_blue),
                                  (current_color->blue >> 11)&0x1F);
 
-  /* controlbars callbacks */
+  /* Register controlbar callbacks */
   g_signal_connect_swapped(popup_data->ctrlbar_red, "value-changed",
                       G_CALLBACK(gtk_widget_queue_draw), area);
   g_signal_connect_swapped(popup_data->ctrlbar_green, "value-changed",
@@ -148,10 +153,12 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
   g_signal_connect_swapped(popup_data->ctrlbar_blue, "value-changed",
                       G_CALLBACK(gtk_widget_queue_draw), area);
 
+  /* Attach expose_event callback function to drawing area */
   g_signal_connect (area,  "expose_event",
                       G_CALLBACK(hildon_popup_palette_expose), 
                       popup_data);
   
+  /* Create popup dialog */
   popup = gtk_dialog_new_with_buttons (_("ecdg_ti_5bit_colour_selector"), 
                                        GTK_WINDOW(parent),
                                        GTK_DIALOG_DESTROY_WITH_PARENT |
@@ -162,8 +169,12 @@ hildon_color_popup_new(GtkWindow *parent, GdkColor *initial_color,
                                        NULL);
 
   gtk_dialog_set_default_response(GTK_DIALOG(popup), GTK_RESPONSE_OK);
+
+  /* Add layout table to the Vbox of the popup dialog */
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(popup)->vbox), 
                         GTK_WIDGET(layout), TRUE, TRUE, 0);
+
+  /* Show thw Vbox of the popup dialog */
   gtk_widget_show_all(GTK_DIALOG(popup)->vbox);             
 
   return popup;
@@ -193,6 +204,7 @@ hildon_color_popup_set_color_from_sliders(GdkColor *color,
         HILDON_CONTROLBAR(popup_data->ctrlbar_blue)) <<  11;
 }
 
+/* expose_event callback function */
 static gboolean 
 hildon_popup_palette_expose (GtkWidget * widget,
                              GdkEventExpose *event, gpointer data)
@@ -202,10 +214,11 @@ hildon_popup_palette_expose (GtkWidget * widget,
     GdkColor color;
     GdkGC * gc = gdk_gc_new (widget->window); 
 
+    /* Get the current color value */
     hildon_color_popup_set_color_from_sliders(&color, data);
     gdk_gc_set_rgb_fg_color(gc, &color);
                          
-    /* draw the color */
+    /* draw the color area */
     gdk_draw_rectangle( widget->window, gc, TRUE /* filled */,  
                         1, 1, widget->allocation.width - 2, 
                         widget->allocation.height - 2);    
@@ -213,11 +226,12 @@ hildon_popup_palette_expose (GtkWidget * widget,
     color.pixel = color.red = color.green = color.blue = 0;
     gdk_gc_set_rgb_fg_color(gc, &color);
 
-    /* frames on color box */
+    /* Draw frames on color box */
     gdk_draw_rectangle( widget->window, gc, FALSE, 
                         0, 0, widget->allocation.width - 1, 
                         widget->allocation.height - 1); 
 
+    /* Free memory used by the graphics contexts */
     g_object_unref(gc);
   }
 
index 691355d..b63cc20 100644 (file)
@@ -250,14 +250,16 @@ hildon_color_selector_set_custom_colors(
 
   g_assert(HILDON_IS_COLOR_SELECTOR(selector));
 
-  /* We have to be really carefull. At least gconftool's
+  /* We have to be really careful. At least gconftool's
      stress test may generate unexpected value setups */
-  if (value == NULL || value->type != GCONF_VALUE_LIST ||
-    gconf_value_get_list_type(value) != GCONF_VALUE_STRING)
+  if (value == NULL
+      || value->type != GCONF_VALUE_LIST
+      || gconf_value_get_list_type(value) != GCONF_VALUE_STRING)
     list = NULL;
   else
     list = gconf_value_get_list(value);
 
+  /* Use list to fill in the selector's color property */
   for ( i = 0; i < HILDON_CUSTOM_COLOR_NUM; ++i)
   {
     const gchar *color_string = NULL;
@@ -318,6 +320,7 @@ hildon_color_selector_init(HildonColorSelector * selector)
                               GCONF_CLIENT_PRELOAD_NONE,
                               NULL);
     
+    /* Use the value directed by GConfValue to set the color */
     value = gconf_client_get(selector->priv->client, 
       HILDON_COLOR_GCONF_KEYS, NULL);    
 
@@ -354,6 +357,7 @@ hildon_color_selector_init(HildonColorSelector * selector)
     gtk_widget_add_events (selector->priv->drawing_area,
                           GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
 
+    /* Arrange size of the drawing area */ 
     gtk_widget_set_size_request (selector->priv->drawing_area,
                                  (HILDON_COLOR_SELECTOR_BOX_W *
                                   HILDON_COLOR_SELECTOR_COLS) +
@@ -369,6 +373,7 @@ hildon_color_selector_init(HildonColorSelector * selector)
     gtk_box_pack_start (GTK_BOX(hbox), selector->priv->drawing_area,
                        FALSE, FALSE, 0);
 
+    /* Register callback functions for the drawing area */
     g_signal_connect (selector->priv->drawing_area, "expose_event",
                       G_CALLBACK(hildon_color_selector_expose), selector);
     g_signal_connect (selector->priv->drawing_area, "button_press_event", 
@@ -504,6 +509,7 @@ void hildon_color_selector_set_color(HildonColorSelector * selector,
     g_return_if_fail(HILDON_IS_COLOR_SELECTOR(selector));
     g_return_if_fail(color);
 
+    /* Select the specified color */
     for (i = 0; 
          i < (HILDON_BASE_COLOR_NUM + HILDON_CUSTOM_COLOR_NUM);
          ++i) 
@@ -513,13 +519,18 @@ void hildon_color_selector_set_color(HildonColorSelector * selector,
             selector->priv->color[i].blue  == color->blue) 
         {
             selector->priv->index = i;
+
+            /* The modify button is active if the color index is bigger than
+             * the number of base colours.
+             */
             gtk_widget_set_sensitive(selector->priv->modify_button,
                                      selector->priv->index >= HILDON_BASE_COLOR_NUM);
             gtk_widget_queue_draw(selector->priv->drawing_area);
             break;
         }
     }
+
+    /* Notify the color selector that the color has changed */  
     g_object_notify (G_OBJECT (selector), "color");
 }
 
@@ -531,6 +542,7 @@ color_pressed(GtkWidget * widget, GdkEventButton * event,
     return TRUE;
 }
 
+/* Handle key press of right, left, up, down and return */
 static gboolean key_pressed(GtkWidget * widget,
                             GdkEventKey * event)
 {
@@ -546,8 +558,9 @@ static gboolean key_pressed(GtkWidget * widget,
     if (GTK_WIDGET_HAS_FOCUS(selector->priv->drawing_area) == FALSE)
         return GTK_WIDGET_CLASS(parent_class)->key_press_event(widget, event);
 
-    /* go for if available index otherwise stop keypress handler because
-       wrapping around is not allowed. */
+    /* Since wrapping is not allowed,
+     * move only if the next index is a valid one.
+     */
     switch (event->keyval) {
     case GDK_KP_Right:
     case GDK_Right:
@@ -610,6 +623,9 @@ static gboolean key_pressed(GtkWidget * widget,
         selector->priv->index = 
             HILDON_BASE_COLOR_NUM + HILDON_CUSTOM_COLOR_NUM - 1;
     }
+    /* The modify button is active if the color index is bigger than
+     * the number of base colours.
+     */
     gtk_widget_set_sensitive(selector->priv->modify_button,
                              selector->priv->index >= HILDON_BASE_COLOR_NUM);
 
@@ -626,6 +642,7 @@ select_color(HildonColorSelector * selector, int event_x, int event_y,
 
     g_return_if_fail(HILDON_IS_COLOR_SELECTOR(selector));
 
+    /* Get the selection coordinates */ 
     x = ( (event_x - HILDON_COLOR_SELECTOR_BOX_BORDER) /
           (HILDON_COLOR_SELECTOR_BOX_BORDER * 2 +
            HILDON_COLOR_SELECTOR_BOX_W)
@@ -636,6 +653,7 @@ select_color(HildonColorSelector * selector, int event_x, int event_y,
            HILDON_COLOR_SELECTOR_BOX_H)
         );
 
+    /* Get the row and column numbers for the selected color */ 
     if (x > (HILDON_COLOR_SELECTOR_COLS + HILDON_CUSTOM_COLOR_NUM - 1)) 
     {
         x = HILDON_COLOR_SELECTOR_COLS + HILDON_CUSTOM_COLOR_NUM - 1;
@@ -653,6 +671,7 @@ select_color(HildonColorSelector * selector, int event_x, int event_y,
         y = 0;
     }
 
+    /* If a custom colour is selected, open a popup to modify the colour */ 
     if (!motion &&
         selector->priv->index >= HILDON_BASE_COLOR_NUM &&
         selector->priv->index == (x + y * HILDON_COLOR_SELECTOR_COLS))
@@ -689,6 +708,7 @@ modify_selected(HildonColorSelector * colselector)
     HildonColorPopup popupdata;
     GtkWidget *popup;
     
+    /* Create a HildonColorPopup dialog */     
     popup = hildon_color_popup_new(GTK_WINDOW(colselector), 
                    hildon_color_selector_get_color(colselector), &popupdata);
     
@@ -705,6 +725,8 @@ modify_selected(HildonColorSelector * colselector)
       }
 
       color = hildon_color_selector_get_color(colselector);
+
+      /* Get the current color value */
       hildon_color_popup_set_color_from_sliders(color, &popupdata);
 
       /* If we modified a base color we just accept the dialog */      
@@ -750,6 +772,7 @@ modify_selected(HildonColorSelector * colselector)
     gtk_widget_destroy (popup); 
     gtk_window_present (GTK_WINDOW(colselector));
 }
+
 static void
 hildon_color_selector_set_property(GObject *object, guint param_id,
                                                   const GValue *value, GParamSpec *pspec)
index cf1e75a..1990ab2 100644 (file)
@@ -31,11 +31,12 @@ hildon_composite_widget_focus (GtkWidget *widget, GtkDirectionType direction)
   GtkWidget *toplevel = NULL;
   GtkWidget *focus_widget = NULL;
   
+  /* Get the topmost parent widget */  
   toplevel = gtk_widget_get_toplevel (widget);
   if (!GTK_IS_WINDOW(toplevel))
     return GTK_WIDGET_CLASS (g_type_class_peek_parent (
                      GTK_WIDGET_GET_CLASS (widget)))->focus (widget, direction);
-
+  /* Get focus widget in the topmost parent widget */
   focus_widget = GTK_WINDOW (toplevel)->focus_widget;
 
   if (!GTK_IS_WIDGET (focus_widget))
index b1dde96..850ced2 100644 (file)
@@ -216,6 +216,7 @@ static void hildon_controlbar_init(HildonControlbar * controlbar)
     GtkRange *range;
     HildonControlbarPrivate *priv;
 
+    /* Initialize the private property */
     priv = HILDON_CONTROLBAR_GET_PRIVATE(controlbar);
     priv->button_press = FALSE;
     priv->old_value = 0;
@@ -242,6 +243,7 @@ static GObject *hildon_controlbar_constructor(GType type,
    
   gtk_scale_set_draw_value (GTK_SCALE (obj), FALSE);
 
+  /* Initialize the GtkAdjustment of the controlbar*/
   adj = GTK_RANGE(obj)->adjustment;
   adj->step_increment = HILDON_CONTROLBAR_STEP_INCREMENT;
   adj->page_increment = HILDON_CONTROLBAR_PAGE_INCREMENT;
@@ -306,6 +308,9 @@ hildon_controlbar_value_changed( GtkAdjustment *adj, GtkRange *range )
 {
   HildonControlbarPrivate *priv = HILDON_CONTROLBAR_GET_PRIVATE(range);
 
+  /* Change the controlbar value if the adjusted value is large enough 
+   * otherwise, keep the old value
+   */
   if( ABS(ceil(adj->value) - priv->old_value) >= 1 )
   {
     priv->old_value = ceil(adj->value);
@@ -566,6 +571,7 @@ hildon_controlbar_change_value( GtkRange *range, GtkScrollType scroll,
 
   priv = HILDON_CONTROLBAR_GET_PRIVATE(range);
 
+  /* Emit a signal when upper or lower limit is reached */
   switch (scroll)
   {
     case GTK_SCROLL_STEP_FORWARD :
index e84f8a7..fa6912d 100644 (file)
@@ -130,6 +130,7 @@ static void hildon_date_editor_get_property( GObject *object, guint param_id,
                                          GValue *value, GParamSpec *pspec );
 static void hildon_date_editor_set_property (GObject *object, guint param_id,
                                        const GValue *value, GParamSpec *pspec);
+
 static gboolean
 hildon_date_editor_mnemonic_activate(GtkWidget *widget, gboolean group_cycling);
 
@@ -137,7 +138,9 @@ static void
 hildon_child_forall(GtkContainer * container,
                     gboolean include_internals,
                     GtkCallback callback, gpointer callback_data);
+
 static void hildon_date_editor_destroy(GtkObject * self);
+
 static void
 hildon_date_editor_size_allocate(GtkWidget * widget,
                                  GtkAllocation * allocation);
@@ -154,6 +157,7 @@ static void hildon_date_editor_finalize(GObject * object);
 static gboolean
 _hildon_date_editor_entry_select_all(GtkWidget *widget);
 
+/* Property indices */
 enum
 {
   PROP_DAY = 1,
@@ -164,23 +168,23 @@ enum
 };
 
 struct _HildonDateEditorPrivate {
-    guint year; /* current year in the entry */
-    guint month;        /* current month in the entry */
-    guint day;  /* current day in the entry */
+    /* Cache of values in the entries, used in setting only parts of the date */
+    guint year;   /* current year  in the entry */
+    guint month;  /* current month in the entry */
+    guint day;    /* current day   in the entry */
 
-    guint y_orig;       /* roll back value for year (if entry has illegal
-                           value) */
+    guint y_orig;       /* roll back value for year (if entry has illegal value) */
     guint m_orig;       /* roll back value for month */
     guint d_orig;       /* roll back value for day */
 
     gint button_press;  /* wheter to show pressed image */
 
-    gboolean editor_pressed;
-    gboolean valid_value;
+    gboolean editor_pressed; /* user activated picker using return */
+    gboolean valid_value;    /* FIXME: XXX This is always true, not used */
 
-    GtkWidget *frame;   /* borders around the date */
-    GtkWidget *d_event_box_image;       /* icon */
-    GtkWidget *d_box_date;      /* hbox for date */
+    GtkWidget *frame;             /* borders around the date */
+    GtkWidget *d_event_box_image; /* icon */
+    GtkWidget *d_box_date;        /* hbox for date */
 
     GtkWidget *d_entry; /* GtkEntry for day */
     GtkWidget *m_entry; /* GtkEntry for month */
@@ -190,13 +194,13 @@ struct _HildonDateEditorPrivate {
     GtkWidget *my_delim;  /* Delimeter between month and year entries */
 
     GtkWidget *d_image; /* normal icon image */
-    GtkWidget *d_image_pressed;
-    guint locale_type;
+    GtkWidget *d_image_pressed; /* icon while button held down */
+    guint locale_type; /* Locale used (day, month, year order) */
 
-    gboolean skip_validation;
+    gboolean skip_validation; /* don't validate date at all */
 
-    gint min_year;
-    gint max_year;
+    gint min_year; /* minimum year allowed */
+    gint max_year; /* maximum year allowed */
 };
 
 enum {
@@ -555,6 +559,7 @@ static void hildon_date_editor_set_property (GObject *object, guint param_id,
       if (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);
         }
@@ -567,6 +572,7 @@ static void hildon_date_editor_set_property (GObject *object, guint param_id,
       if (val >= priv->min_year)
         {
           priv->max_year = val;
+          /* Clamp current year */
           if (hildon_date_editor_get_year (editor) > priv->max_year)
             hildon_date_editor_set_year (editor, priv->max_year);
         }
@@ -614,6 +620,7 @@ static void hildon_date_editor_get_property( GObject *object, guint param_id,
   }
 }
 
+/* FIXME: Mnemonics aren't used */
 static gboolean
 hildon_date_editor_mnemonic_activate(GtkWidget *widget, gboolean group_cycling)
 
@@ -621,6 +628,7 @@ hildon_date_editor_mnemonic_activate(GtkWidget *widget, gboolean group_cycling)
   GtkWidget *entry;
   HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(widget);
 
+  /* Set focus to first entry */
   if( priv->locale_type == MONTH_DAY_YEAR )
     entry = priv->m_entry;
   else
@@ -641,6 +649,7 @@ static void hildon_date_editor_finalize(GObject * object)
       G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
+/* Extract day, month, year order from date format string */
 static guint
 hildon_date_editor_check_locale_settings(HildonDateEditor * editor)
 {
@@ -698,7 +707,7 @@ static void hildon_date_editor_destroy(GtkObject * self)
 /**
  * hildon_date_editor_new:
  *
- * This function creates a new time editor. The current system date
+ * Creates a new time editor. The current system date
  * is shown in the editor.
  *
  * Return value: Pointer to a new @HildonDateEditor widget.
@@ -715,9 +724,7 @@ GtkWidget *hildon_date_editor_new(void)
  * @month: month
  * @day: day
  *
- * This function sets the date shown in the editor. The function returns 
- * if the date specified by the arguments is not valid, the
- * function returns.
+ * Sets the date shown in the editor. 
  **/
 void hildon_date_editor_set_date(HildonDateEditor * date,
                                  guint year, guint month, guint day)
@@ -737,7 +744,7 @@ void hildon_date_editor_set_date(HildonDateEditor * date,
  * @month: month
  * @day: day
  *
- * This function returns the year, month, and day currently on the
+ * Returns the year, month, and day currently on the
  * date editor.
  **/
 void hildon_date_editor_get_date(HildonDateEditor * date,
@@ -753,8 +760,7 @@ void hildon_date_editor_get_date(HildonDateEditor * date,
 
     priv = HILDON_DATE_EDITOR_GET_PRIVATE(date);
 
-    /*dont know why these variable are used, i think it makes more
-     * sense to directly get the content from the current text entry field*/
+    /* FIXME: XXX This should use the commented out values, really */
     *year = /*priv->year;*/
       (guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
     *month = /*priv->month;*/
@@ -778,6 +784,7 @@ static gboolean hildon_date_editor_icon_press(GtkWidget * widget,
     priv = HILDON_DATE_EDITOR_GET_PRIVATE(ed);
 
     if (event->button == 1 && !priv->button_press) {
+       /* Show pressed image */
         gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
                              priv->d_image);
         gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
@@ -799,8 +806,7 @@ static gboolean hildon_date_editor_entry_released(GtkWidget * widget,
     priv = HILDON_DATE_EDITOR_GET_PRIVATE(ed);
 
     if (priv->valid_value && event->button == 1) {
-
-        /* We might not get focus because unvalid values in entries */
+        /* We might not get focus because of invalid values in entries */
         if (GTK_WIDGET_HAS_FOCUS(widget))
                        g_idle_add((GSourceFunc)
                                        _hildon_date_editor_entry_select_all, GTK_ENTRY(widget));
@@ -842,11 +848,13 @@ static gboolean idle_popup(gpointer data)
     popup = hildon_calendar_popup_new(GTK_WINDOW(parent), y, m, d);
 
     g_value_init(&val, G_TYPE_INT);
+    /* Set max/min year in calendar popup to date editor values */
     g_object_get_property(G_OBJECT(data), "min-year", &val);
     g_object_set_property(G_OBJECT(popup), "min-year", &val);
     g_object_get_property(G_OBJECT(data), "max-year", &val);
     g_object_set_property(G_OBJECT(popup), "max-year", &val);
 
+    /* Pop up calendar */
     result = gtk_dialog_run(GTK_DIALOG(popup));
     switch (result) {
     case GTK_RESPONSE_OK:
@@ -901,7 +909,7 @@ hildon_date_editor_entry_validate(GtkEditable *widget, gpointer data)
     HildonDateEditorPrivate *priv;
 
     gint d, m, y;
-    gboolean r; /*return value storage needed, but no real use*/
+    gboolean r; /* temp return values for signals */
 
     g_return_if_fail(data);
     g_return_if_fail(widget);
@@ -919,10 +927,13 @@ hildon_date_editor_entry_validate(GtkEditable *widget, gpointer data)
         m = atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)));
         y = atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
 
-        /*NOTICE we could/should use hildon_date_editor_set_year and such functions
-         * to set the date, instead of use gtk_entry_set_text, and then change the priv member
-         * but hildon_date_editor_set_year and such functions check if the date is valid,
-         * we do want to do date validation check here according to spec*/
+        /* We could/should use hildon_date_editor_set_year and such functions
+         * to set the date, instead of use gtk_entry_set_text, and then change
+        * the priv member but hildon_date_editor_set_year and such functions
+        * check if the date is valid, we do want to do date validation check
+        * here according to spec */
+
+       /* Validate day */
         if(GTK_WIDGET(widget) == priv->d_entry)
         {
             if(d > 0 && d < 32) {
@@ -944,10 +955,12 @@ hildon_date_editor_entry_validate(GtkEditable *widget, gpointer data)
             g_idle_add ((GSourceFunc)
                     _hildon_date_editor_entry_select_all, 
                     priv->d_entry);
+           /* Set focus back to invalid entry */
             gtk_widget_grab_focus(priv->d_entry);
             return;
         }
 
+       /* Validate month */
         if(GTK_WIDGET(widget) == priv->m_entry)
         {
             if(m > 0 && m < 13)
@@ -974,10 +987,12 @@ hildon_date_editor_entry_validate(GtkEditable *widget, gpointer data)
             g_idle_add ((GSourceFunc) 
                     _hildon_date_editor_entry_select_all, 
                     priv->m_entry);
+           /* Set focus back to invalid entry */
             gtk_widget_grab_focus(priv->m_entry);
             return;
         }
 
+       /* Validate year */
         if(GTK_WIDGET(widget) == priv->y_entry)
         {
             if(y >= priv->min_year && y <= priv->max_year) {
@@ -1006,6 +1021,7 @@ hildon_date_editor_entry_validate(GtkEditable *widget, gpointer data)
             g_idle_add ((GSourceFunc) 
                     _hildon_date_editor_entry_select_all, 
                     priv->y_entry);
+           /* Set focus back to invalid entry */
             gtk_widget_grab_focus(priv->y_entry);
             return;
         }
@@ -1017,6 +1033,7 @@ hildon_date_editor_d_entry_changed(GtkEditable *ed, gpointer data)
 {
   HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
 
+  /* If day entry is full, move to next entry or validate */
   if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == DAY_ENTRY_WIDTH)
     {
       if (priv->locale_type == DAY_MONTH_YEAR)
@@ -1033,6 +1050,7 @@ hildon_date_editor_m_entry_changed(GtkEditable *ed, gpointer data)
 {
   HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
 
+  /* If month entry is full, move to next entry */
   if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == MONTH_ENTRY_WIDTH)
     {
       if (priv->locale_type == DAY_MONTH_YEAR)
@@ -1048,6 +1066,7 @@ hildon_date_editor_y_entry_changed(GtkEditable *ed, gpointer data)
 {
   HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
 
+  /* If year entry is full, move to next entry or validate */
   if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == YEAR_ENTRY_WIDTH)
     {
       if (priv->locale_type == YEAR_MONTH_DAY)
@@ -1073,6 +1092,7 @@ static gboolean hildon_date_editor_keyrelease(GtkWidget * widget,
     if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return ||
         event->keyval == GDK_ISO_Enter) {
         if (priv->editor_pressed) {
+            /* Show normal icon instead of pressed */
             gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
                                  priv->d_image_pressed);
             gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
@@ -1107,6 +1127,7 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
 
     if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter) {
         if (!priv->editor_pressed) {
+            /* Show pressed icon */
             gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
                                  priv->d_image);
             gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
@@ -1147,6 +1168,7 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
             gint pos =
                 gtk_editable_get_position(GTK_EDITABLE(priv->d_entry));
             if (pos == 0) {
+                /* Switch to previous entry */
                 gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0,
                                            0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
@@ -1166,8 +1188,8 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
             gint pos =
                 gtk_editable_get_position(GTK_EDITABLE(priv->m_entry));
 
-            /* switch to day entry */
             if (pos == 0) {
+                /* Switch to previous entry */
                 gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0,
                                            0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
@@ -1186,8 +1208,8 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
             gint pos =
                 gtk_editable_get_position(GTK_EDITABLE(priv->y_entry));
 
-            /* switch to month entry */
             if (pos == 0) {
+                /* Switch to previous entry */
                 gtk_editable_select_region(GTK_EDITABLE(priv->y_entry), 0,
                                            0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
@@ -1214,18 +1236,15 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
                 g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->d_entry)),
                               len);
 
-            /* switch to month entry */
             if ((pos == len) || (pos > chars)) {
-                gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0,
-                                           0);
+                /* Switch to next entry */
+                gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0, 0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
                     gtk_widget_grab_focus(priv->m_entry);
-                    gtk_editable_set_position(GTK_EDITABLE(priv->m_entry),
-                                              0);
+                    gtk_editable_set_position(GTK_EDITABLE(priv->m_entry), 0);
                 } else {
                     gtk_widget_grab_focus(priv->y_entry);
-                    gtk_editable_set_position(GTK_EDITABLE(priv->y_entry),
-                                              0);
+                    gtk_editable_set_position(GTK_EDITABLE(priv->y_entry), 0);
                 }
                 return TRUE;
             }
@@ -1239,8 +1258,8 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
                 g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)),
                               len);
 
-            /* switch to year entry */
             if ((pos == len) || (pos > chars)) {
+                /* Switch to next entry */
                 gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0,
                                            0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
@@ -1264,8 +1283,8 @@ static gboolean hildon_date_editor_keypress(GtkWidget * widget,
                 g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)),
                               len);
 
-            /* switch to day entry */
             if ((pos == len) || (pos > chars)) {
+                /* Switch to next entry */
                 gtk_editable_select_region(GTK_EDITABLE(priv->y_entry), 0,
                                            0);
                 if (priv->locale_type == DAY_MONTH_YEAR) {
@@ -1357,20 +1376,21 @@ static gboolean hildon_date_editor_entry_focus_out(GtkWidget * widget,
       return FALSE;
     }
 
+  /* The first "validation" */
   hildon_date_editor_entry_validate(GTK_EDITABLE(widget), ed);
 
-  /*date validation starts*/
+  /*date validation starts */
   d = atoi(gtk_entry_get_text(GTK_ENTRY(priv->d_entry)));
   m = atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)));
   y = atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
 
-  /*the only reason why a date is not valid is because that 
-   * some months dont have 31st 30th or even 29th(since we 
+  /* The only reason why a date is not valid is because that 
+   * some months don't have 31st 30th or even 29th (since we 
    * have done max and min range checking for each field), for 
    * now we will only fix day field, if trying to fix day
    * field fails to make the date valid, we will set the 
    * date to be current date, if any value is 0, that means
-   * this entry is empty, therefore skip validation*/
+   * this entry is empty, therefore skip validation */
    
   if(d != 0 && m != 0 && y != 0 && !g_date_valid_dmy(d, m, y))
     {
@@ -1383,6 +1403,7 @@ static gboolean hildon_date_editor_entry_focus_out(GtkWidget * widget,
       
       max_d = g_date_get_days_in_month(m,y);
        
+      /* Clamp to max day */
       if(priv->d_orig <= max_d && priv->d_orig > 0)
        new_d = priv->d_orig;
       else
@@ -1403,6 +1424,7 @@ static gboolean hildon_date_editor_entry_focus_out(GtkWidget * widget,
          y = g_date_get_day(&gd);
        }
       
+      /* Set focus back to day entry */
       gtk_widget_grab_focus(priv->d_entry);
       g_idle_add((GSourceFunc)
                 _hildon_date_editor_entry_select_all, priv->d_entry);
@@ -1514,9 +1536,11 @@ static void hildon_date_editor_size_allocate(GtkWidget * widget,
 
     gtk_widget_get_child_requisition(widget, &max_req);
 
+    /* Center vertically */
     f_alloc.y = img_alloc.y = allocation->y +
             MAX(allocation->height - max_req.height, 0) / 2;
 
+    /* Center horizontally */
     f_alloc.x = img_alloc.x = allocation->x +
             MAX(allocation->width - max_req.width, 0) / 2;
 
@@ -1530,7 +1554,7 @@ static void hildon_date_editor_size_allocate(GtkWidget * widget,
             gtk_widget_size_allocate(priv->frame, &f_alloc);
         }
 
-    /* allocate entry box */
+    /* allocate icon */
     if (priv->d_event_box_image)
         if (GTK_WIDGET_VISIBLE(priv->d_event_box_image)) {
             gtk_widget_get_child_requisition(priv->d_event_box_image,
@@ -1542,6 +1566,7 @@ static void hildon_date_editor_size_allocate(GtkWidget * widget,
             gtk_widget_size_allocate(priv->d_event_box_image, &img_alloc);
         }
 
+    /* Allocate delimiters between entries */
     priv->dm_delim->allocation.height = max_req.height; 
     priv->my_delim->allocation.height = max_req.height; 
     priv->my_delim->allocation.y = priv->d_entry->allocation.y-5;
@@ -1575,7 +1600,7 @@ static int hildon_date_editor_get_font_width(GtkWidget * widget)
  * @editor: the @HildonDateEditor widget
  * @year: year
  *
- * This function sets the year shown in the editor. 
+ * Sets the year shown in the editor. 
  *
  * Return: Returns TRUE if the year is valid.
  **/
@@ -1605,7 +1630,7 @@ gboolean hildon_date_editor_set_year(HildonDateEditor *editor, guint year)
  * @editor: the @HildonDateEditor widget
  * @month: month
  *
- * This function sets the month shown in the editor. 
+ * Sets the month shown in the editor. 
  *
  * Return: Returns TRUE if the month is valid.
  **/
@@ -1636,7 +1661,7 @@ gboolean hildon_date_editor_set_month(HildonDateEditor *editor, guint month)
  * @editor: the @HildonDateEditor widget
  * @day: day
  *
- * This function sets the day shown in the editor. 
+ * Sets the day shown in the editor. 
  *
  * Return: Returns TRUE if the day is valid.
  **/
@@ -1667,7 +1692,7 @@ gboolean hildon_date_editor_set_day(HildonDateEditor *editor, guint day)
  * hildon_date_editor_get_year:
  * @editor: the @HildonDateEditor widget
  *
- * This function gets the year shown in the editor. 
+ * Gets the year shown in the editor. 
  *
  * Return: Returns the current year shown in the editor.
  **/
@@ -1684,7 +1709,7 @@ guint hildon_date_editor_get_year(HildonDateEditor *editor)
  * hildon_date_editor_get_month:
  * @editor: the @HildonDateEditor widget
  *
- * This function gets the month shown in the editor. 
+ * Gets the month shown in the editor. 
  *
  * Return: Returns the current month shown in the editor.
  **/
@@ -1701,7 +1726,7 @@ guint hildon_date_editor_get_month(HildonDateEditor *editor)
  * hildon_date_editor_get_day:
  * @editor: the @HildonDateEditor widget
  *
- * This function gets the day shown in the editor. 
+ * Gets the day shown in the editor. 
  *
  * Return: Returns the current day shown in the editor.
  **/
@@ -1714,6 +1739,7 @@ guint 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)
 {
index d8d7f97..8bf5081 100644 (file)
@@ -87,6 +87,7 @@ void gtk_dialog_help_enable(GtkDialog * dialog)
     int i = 0;
     int help_enabled = 0;
     
+    /* Create help signal if it didn't exist */   
     if (help_signal == 0) {
         help_signal = g_signal_new("help", GTK_TYPE_DIALOG,
                                    G_SIGNAL_ACTION, (guint) - 1, NULL,
@@ -100,12 +101,14 @@ void gtk_dialog_help_enable(GtkDialog * dialog)
     window = GTK_WIDGET(dialog)->window;
     display = gdk_drawable_get_display (window);
 
+    /* Create a list of atoms stored in GdkWindow */
     XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
                    &list, &amount);
     
     protocols = (Atom *) malloc ((amount+1) * sizeof (Atom));
     helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
 
+    /* Enable the dialoghelp if help_atom is in the atoms' list */
     for (i=0; i<amount; i++)
     {
            protocols[n++] = list[i];
@@ -116,14 +119,17 @@ void gtk_dialog_help_enable(GtkDialog * dialog)
     }
     XFree (list);
 
+    /* Add the help_atom to the atoms' list if it was not in it */ 
     if (!help_enabled)
     {
            protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
     }
     
+    /* Replace the protocol property of the GdkWindow with the new atoms' list */
     XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
     free (protocols);
     
+    /* Add a callback function as event filter */ 
     gdk_window_add_filter(window, handle_xevent, dialog);
 }
 
@@ -150,12 +156,14 @@ void gtk_dialog_help_disable(GtkDialog * dialog)
     window = GTK_WIDGET(dialog)->window;
     display = gdk_drawable_get_display (window);
 
+    /* Create a list of atoms stored in GdkWindow */
     XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
                    &list, &amount);
     
     helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
     protocols = (Atom *) malloc (amount * sizeof (Atom));
 
+    /* Remove the help_atom if it is in the atoms' list */
     for (i=0; i<amount; i++)
     {
            if (list[i] != helpatom)
@@ -165,9 +173,11 @@ void gtk_dialog_help_disable(GtkDialog * dialog)
     }
     XFree (list);
     
+    /* Replace the protocol property of the GdkWindow with the new atoms' list */
     XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
     free (protocols);
 
+    /* Remove the event filter */
     gdk_window_remove_filter(window, handle_xevent, dialog);
 }
 
index 4e64f39..b735dd8 100644 (file)
@@ -130,9 +130,12 @@ static gboolean write_access(const gchar *uri)
   GnomeVFSFileInfo *info;
   gboolean result = FALSE;
 
+  /* Get information about file */
   info = gnome_vfs_file_info_new ();
   if (gnome_vfs_get_file_info(uri, info, 
     GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) == GNOME_VFS_OK)
+
+    /* Detect that the file is writable or not */
     result = ((info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) 
               == GNOME_VFS_PERM_ACCESS_WRITABLE);
 
@@ -169,6 +172,7 @@ static void change_state(HildonFileDetailsDialog *self, gboolean readonly)
     GnomeVFSFileInfo *info;
     GnomeVFSResult result;
 
+    /* Get the value of cells referenced by a tree_modle */
     gtk_tree_model_get(GTK_TREE_MODEL(self->priv->model), &iter, 
       HILDON_FILE_SYSTEM_MODEL_COLUMN_URI, &uri, -1);    
 
@@ -176,6 +180,7 @@ static void change_state(HildonFileDetailsDialog *self, gboolean readonly)
     result = gnome_vfs_get_file_info(uri, info, 
       GNOME_VFS_FILE_INFO_DEFAULT);
 
+    /* Change the file information */
     if (result == GNOME_VFS_OK)
     {
       if (readonly)
@@ -187,7 +192,6 @@ static void change_state(HildonFileDetailsDialog *self, gboolean readonly)
           GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
     }
 
-    /* No errors are defined in the specs, but the previous operations can still fail */
     if (result != GNOME_VFS_OK)
       gtk_infoprint(GTK_WINDOW(self), gnome_vfs_result_to_string(result));
     
@@ -227,14 +231,19 @@ hildon_file_details_dialog_map(GtkWidget *widget)
 
   priv = HILDON_FILE_DETAILS_DIALOG(widget)->priv;
 
+  /* Map the GtkWidget */ 
   GTK_WIDGET_CLASS(file_details_dialog_parent_class)->map(widget);
 
+  /* Set the first page as default and
+   * make the GtkNotebook focusable if it shows tabs */ 
   if (gtk_notebook_get_show_tabs(priv->notebook))
   {
     gtk_notebook_set_current_page(priv->notebook, 0);
     gtk_widget_grab_focus(GTK_WIDGET(priv->notebook));
   }
   else
+    /* Otherwise make one GtkButton in the dialog
+     * sensitive with the keyboard event */
     gtk_widget_grab_focus(priv->ok_button);
 }
 
@@ -245,6 +254,7 @@ hildon_file_details_dialog_class_init(HildonFileDetailsDialogClass * klass)
 
     file_details_dialog_parent_class = g_type_class_peek_parent(klass);
     gobject_class = G_OBJECT_CLASS(klass);
+
     gobject_class->finalize = hildon_file_details_dialog_finalize;
     gobject_class->get_property = hildon_file_details_dialog_get_property;
     gobject_class->set_property = hildon_file_details_dialog_set_property;
@@ -304,6 +314,7 @@ hildon_file_details_dialog_init(HildonFileDetailsDialog *self)
 
     HildonFileDetailsDialogPrivate *priv;
 
+    /* Initialize the private property */
     self->priv = priv =
       G_TYPE_INSTANCE_GET_PRIVATE(self, \
           HILDON_TYPE_FILE_DETAILS_DIALOG, HildonFileDetailsDialogPrivate);
@@ -338,7 +349,7 @@ hildon_file_details_dialog_init(HildonFileDetailsDialog *self)
     gtk_box_pack_start(GTK_BOX(hbox_device), priv->file_device_image, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(hbox_device), priv->file_device, TRUE, TRUE, 0);
 
-    /* Tab one */
+    /* Create captions for the dialog */
     caption_name = hildon_caption_new(group, _("ckdg_fi_properties_name_prompt"), 
       priv->file_name, NULL, HILDON_CAPTION_OPTIONAL);
     caption_type = hildon_caption_new(group, _("ckdg_fi_properties_type_prompt"), 
@@ -367,6 +378,7 @@ hildon_file_details_dialog_init(HildonFileDetailsDialog *self)
 
     g_object_unref(group);
 
+    /* Pack captions to the dialog */
     gtk_box_pack_start(GTK_BOX(vbox), caption_name, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(vbox), caption_type, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(vbox), caption_location, FALSE, TRUE, 0);
index e7c08e0..e1c3208 100644 (file)
@@ -575,6 +575,7 @@ hildon_font_selection_dialog_class_init(HildonFontSelectionDialogClass *
   gobject_class->get_property = hildon_font_selection_dialog_get_property;
   gobject_class->set_property = hildon_font_selection_dialog_set_property;
 
+  /* Install property to the class */
   g_object_class_install_property(gobject_class, PROP_FAMILY,
                                  g_param_spec_string("family",
                                  "Font family", "String defines"
@@ -760,7 +761,7 @@ hildon_font_selection_dialog_construct_notebook (HildonFontSelectionDialog
   group =
     GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
   
-  /*Tab one*/
+  /* Build the first page of the GtkNotebook: font style */
   priv->cbx_font_type = gtk_combo_box_new_text();
   hildon_font_selection_dialog_show_available_fonts(fontsel);
   caption_control = hildon_caption_new(group,
@@ -802,7 +803,7 @@ hildon_font_selection_dialog_construct_notebook (HildonFontSelectionDialog
   gtk_box_pack_start(GTK_BOX(vbox_tab[0]), caption_control,
                     FALSE, FALSE, 0);
 
-  /*Tab two*/
+  /* Build the second page of the GtkNotebook: font formatting */ 
   priv->chk_bold = gtk_check_button_new();
   caption_control = hildon_caption_new(group,
                                       _("ecdg_fi_font_bold"),
@@ -834,7 +835,7 @@ hildon_font_selection_dialog_construct_notebook (HildonFontSelectionDialog
   g_signal_connect(G_OBJECT(priv->chk_underline), "clicked", 
                   G_CALLBACK(toggle_clicked), NULL);
 
-  /*Tab three*/
+  /* Build the third page of the GtkNotebook: other font properties */
   priv->chk_strikethrough = gtk_check_button_new();
   caption_control =
     hildon_caption_new(group, _("ecdg_fi_font_strikethrough"),
@@ -1209,7 +1210,8 @@ void check_tags(gpointer data, gpointer user_data)
               "rise", &p_rise, "rise-set", & r_s,
               NULL);
   
-  /*settings*/
+  /* Check that the given values are valid. 
+   * If not, set the combobox row indicator to 'inconsistent' */
   if(ff_s)
     {
       gint new_f = -1;
@@ -1314,6 +1316,8 @@ void check_attrs(gpointer data, gpointer user_data)
   gint size, weight, style, underline, strikethrough, rise;
   gint new_f = -1, new_size = -1, new_rise = -1;
 
+  /* Check that the given values are valid.
+   * If not, set the combobox row indicator to 'inconsistent' */
   switch(attr->klass->type)
     {
     case PANGO_ATTR_FAMILY:
@@ -1792,7 +1796,9 @@ hildon_font_selection_dialog_set_buffer (HildonFontSelectionDialog *fsd,
   settings_init(&settings, fsd);
   
   iter = begin;
-  if(gtk_text_iter_compare(&iter, &end) == 0)/*if no selection*/
+
+  /* Keep original settings if the selection includes nothing */ 
+  if(gtk_text_iter_compare(&iter, &end) == 0)
     {
       GSList *slist;
       
@@ -1801,6 +1807,7 @@ hildon_font_selection_dialog_set_buffer (HildonFontSelectionDialog *fsd,
       g_slist_free(slist);
     }
 
+  /* Apply the user settings to the selected text */
   while(gtk_text_iter_compare(&iter, &end) < 0)
     {
       GSList *slist;
index c059c39..f672a99 100644 (file)
  *
  */
 
-/*
- * HILDON DOC
- * @shortdesc: GetPasswordDialog is a dialog for getting the user
- * password.
- * @longdesc: GetPasswordDialog implements two specified dialogs,
- * which are pretty much functionally the same, but have 
- * different outlooks.
- */
 #include <glib.h>
 
 #include <errno.h>
@@ -39,6 +31,8 @@
 #include <stdio.h>
 
 #include <gtk/gtk.h>
+
+/* FIXME: These two includes are broken */
 #include <hildon-lgpl/hildon-widgets/gtk-infoprint.h>
 #include <hildon-lgpl/hildon-widgets/hildon-input-mode-hint.h>
 
@@ -73,10 +67,8 @@ struct _HildonGetPasswordDialogPrivate {
 static void
 hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass *
                                       class);
-
 static void hildon_get_password_dialog_init(HildonGetPasswordDialog *
                                             widget);
-
 static void hildon_get_password_set_property(GObject * object,
                                              guint prop_id,
                                              const GValue * value,
@@ -84,7 +76,6 @@ static void hildon_get_password_set_property(GObject * object,
 static void hildon_get_password_get_property(GObject * object,
                                              guint prop_id, GValue * value,
                                              GParamSpec * pspec);
-
 void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog, 
                                           gchar *domain);
 
@@ -112,7 +103,8 @@ hildon_get_password_set_property(GObject * object,
   priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
   
   switch (prop_id) {
-  case PROP_DOMAIN: /* Implemented othervise, here just for completeness */
+  case PROP_DOMAIN:
+    /* Set label text representing password domain */
     gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
     break;
   case PROP_PASSWORD:
@@ -121,6 +113,7 @@ hildon_get_password_set_property(GObject * object,
                       g_value_get_string(value));
     break;
   case PROP_NUMBERS_ONLY:
+    /* FIXME: This is broken, property value is not used in any way */
     g_object_set( G_OBJECT
                  (gtk_bin_get_child(GTK_BIN(priv->passwordEntry))),
                   "input-mode", HILDON_INPUT_MODE_HINT_NUMERIC, NULL );
@@ -129,6 +122,7 @@ hildon_get_password_set_property(GObject * object,
     hildon_get_password_dialog_set_caption(dialog, g_value_get_string(value));
     break;
   case PROP_MAX_CHARS:
+    /* FIXME: This is broken. set_max_characters wants an int, not string */
     hildon_get_password_dialog_set_max_characters(dialog, 
                                                  g_value_get_string(value));
     break;
@@ -181,9 +175,12 @@ hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass * class)
   
   parent_class = g_type_class_peek_parent(class);
   
+  /* Override virtual functions */
   object_class->set_property = hildon_get_password_set_property;
   object_class->get_property = hildon_get_password_get_property;
   
+  /* Install new properties */
+  /* FIXME: Why this is not READWRITE */
   g_object_class_install_property 
     (object_class, 
      PROP_DOMAIN, 
@@ -193,7 +190,6 @@ hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass * class)
                          NULL,
                          G_PARAM_WRITABLE));
   
-  
   g_object_class_install_property
     (object_class, 
      PROP_PASSWORD,
@@ -203,6 +199,7 @@ hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass * class)
                          "DEFAULT",
                          G_PARAM_READWRITE));
 
+  /* FIXME: Why this is not READWRITE?? */
   g_object_class_install_property
     (object_class, 
      PROP_NUMBERS_ONLY,
@@ -233,6 +230,7 @@ hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass * class)
                       0,
                       G_PARAM_READWRITE));
 
+    /* Install private structure */
     g_type_class_add_private(class,
                              sizeof(HildonGetPasswordDialogPrivate));
 }
@@ -242,22 +240,25 @@ hildon_get_password_dialog_init(HildonGetPasswordDialog * dialog)
 {
     GtkSizeGroup * group;
     GtkWidget *control;
-  
+
+    /* Cache private pointer for faster member access */  
     HildonGetPasswordDialogPrivate *priv =
       HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+    /* Sizegroup for captions */
     group = GTK_SIZE_GROUP(gtk_size_group_new
                           (GTK_SIZE_GROUP_HORIZONTAL));
 
+    /* Initial properties for the dialog */
     gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-
     gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
-    
     gtk_window_set_title(GTK_WINDOW(dialog), 
                         _(HILDON_GET_PASSWORD_DIALOG_TITLE));
 
+    /* Optional password domain label */
     priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
     
+    /* Create buttons */
     priv->okButton =
       GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
                                        _(HILDON_GET_PASSWORD_DIALOG_OK),
@@ -267,6 +268,7 @@ hildon_get_password_dialog_init(HildonGetPasswordDialog * dialog)
                                        _(HILDON_GET_PASSWORD_DIALOG_CANCEL),
                                        GTK_RESPONSE_CANCEL));
 
+    /* Create password text entry */
     control = gtk_entry_new();
     gtk_entry_set_visibility(GTK_ENTRY(control), FALSE);
     priv->passwordEntry = HILDON_CAPTION
@@ -276,6 +278,8 @@ hildon_get_password_dialog_init(HildonGetPasswordDialog * dialog)
                          HILDON_CAPTION_OPTIONAL));
     hildon_caption_set_separator(HILDON_CAPTION(priv->passwordEntry), "");
     
+
+    /* Do the basic layout */
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                        GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
@@ -283,7 +287,8 @@ hildon_get_password_dialog_init(HildonGetPasswordDialog * dialog)
     gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
     
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-  
+
+    /* FIXME: Do not leak group */
 }
 
 /* Public functions */
@@ -339,6 +344,9 @@ GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
 
     if (get_old_password_title == FALSE) {
       HildonGetPasswordDialogPrivate *priv;
+
+      /* Override "get old password" defaults set in dialog_init */
+      /* FIXME: This behaviour is confusing */
       gtk_window_set_title(GTK_WINDOW(dialog), 
                             _(HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE));
                priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
@@ -349,7 +357,7 @@ GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
        hildon_caption_set_label(priv->passwordEntry,
                                 _(HILDON_GET_PASSWORD_VERIFY_DIALOG_PASSWORD)
                                 );
-    } /* The other logical strings are set in class init */
+    }
 
     if (parent != NULL) {
         gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
@@ -403,6 +411,7 @@ const gchar
 
     priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
 
+    /* Retrieve the password entry widget */
     entry1 = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(
                        priv->passwordEntry)));
 
@@ -440,10 +449,10 @@ void hildon_get_password_dialog_set_title(HildonGetPasswordDialog *dialog,
                                          gchar *new_title)
 
 {
+  /* FIXME: This method is completely useless, should be deprecated/removed */
   g_return_if_fail (new_title !=NULL);
   gtk_window_set_title(GTK_WINDOW(dialog), 
                       new_title);
-
 }
 
 /**
@@ -489,11 +498,13 @@ void hildon_get_password_dialog_set_max_characters (HildonGetPasswordDialog *dia
   g_return_if_fail(max_characters >0);
   g_return_if_fail(dialog);
 
+  /* Apply the given length to password entry */
   gtk_entry_set_max_length(GTK_ENTRY
                           (hildon_caption_get_control
                            (priv->passwordEntry)),
                           max_characters);
 
+  /* Connect callback to show error banner if the limit is exceeded */
   g_signal_connect(GTK_ENTRY
                   (hildon_caption_get_control
                    (priv->passwordEntry)),
index 48e56b8..7390cec 100644 (file)
@@ -662,6 +662,7 @@ hildon_grid_item_expose(GtkWidget *widget, GdkEventExpose *event)
             focused = priv->icon;
         }
 
+       /* Determine the coordinates and size of clip */ 
         switch (priv->label_pos) {
         case HILDON_GRID_ITEM_LABEL_POS_BOTTOM:
             clip.x = focused->allocation.x - priv->focus_margin;
@@ -688,6 +689,7 @@ hildon_grid_item_expose(GtkWidget *widget, GdkEventExpose *event)
             break;
         }
 
+       /* Build painting box for the exposure event */
         gtk_paint_box(focused->style,
                       gtk_widget_get_toplevel(focused)->window,
                       GTK_STATE_SELECTED,
@@ -766,6 +768,7 @@ hildon_grid_item_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
         l_req.width = l_req.height = 0;
     }
 
+    /* Determine icon and label allocation based on label position */
     switch (priv->label_pos) {
     case HILDON_GRID_ITEM_LABEL_POS_BOTTOM:
         i_alloc.x = (allocation->width - priv->icon_width) / 2 +
@@ -845,6 +848,7 @@ hildon_grid_item_forall(GtkContainer    *container,
     item = HILDON_GRID_ITEM(container);
     priv = HILDON_GRID_ITEM_GET_PRIVATE(item);
 
+    /* Connect callback functions to the item */
     if (priv->icon != NULL) {
         (*callback) (priv->icon, callback_data);
     }
index 56a72a3..f6c801f 100644 (file)
@@ -282,6 +282,7 @@ static void hildon_grid_class_init(HildonGridClass * klass)
     container_class->child_type = hildon_grid_child_type;
     container_class->set_focus_child = hildon_grid_set_focus_child;
 
+    /* Install properties to the class */
     g_object_class_install_property(gobject_class, PROP_EMPTY_LABEL,
         g_param_spec_string("empty_label",
                             "Empty label",
@@ -490,6 +491,7 @@ hildon_grid_set_label_pos(HildonGrid * grid,
 
     priv->label_pos = label_pos;
 
+    /* Set label position to each HildonGridItem */
     for (list = priv->children; list != NULL; list = list->next) {
         child = ((HildonGridChild *) list->data)->widget;
 
@@ -844,6 +846,8 @@ hildon_grid_expose(GtkWidget * widget, GdkEventExpose * event)
     priv = HILDON_GRID_GET_PRIVATE(grid);
     container = GTK_CONTAINER(grid);
 
+    /* If grid has no children,
+     * propagate the expose event to the label is one exists */ 
     if (priv->children == NULL || g_list_length(priv->children) == 0) {
         if (priv->empty_label != NULL) {
             gtk_container_propagate_expose(container,
@@ -1113,14 +1117,12 @@ static void hildon_grid_add(GtkContainer * container, GtkWidget * widget)
     }
     child->widget = widget;
 
-    _hildon_grid_item_set_label_pos(HILDON_GRID_ITEM(widget),
-                                    priv->label_pos);
-    _hildon_grid_item_set_focus_margin(HILDON_GRID_ITEM(widget),
-                                       priv->focus_margin);
-    _hildon_grid_item_set_icon_width(HILDON_GRID_ITEM(widget),
-                                     priv->icon_width);
-    _hildon_grid_item_set_emblem_size(HILDON_GRID_ITEM(widget),
-                                      priv->emblem_size);
+    _hildon_grid_item_set_label_pos   (HILDON_GRID_ITEM(widget), priv->label_pos);
+    _hildon_grid_item_set_focus_margin(HILDON_GRID_ITEM(widget), priv->focus_margin);
+    _hildon_grid_item_set_icon_width  (HILDON_GRID_ITEM(widget), priv->icon_width);
+    _hildon_grid_item_set_emblem_size (HILDON_GRID_ITEM(widget), priv->emblem_size);
+
+    /* Add the new item to the grid */
     priv->children = g_list_append(priv->children, child);
     gtk_widget_set_parent(widget, GTK_WIDGET(grid));
 
@@ -1185,6 +1187,8 @@ hildon_grid_remove(GtkContainer * container, GtkWidget * widget)
          list != NULL; list = list->next, index++) {
         child = (HildonGridChild *) list->data;
         child_widget = child->widget;
+
+       /* Remove the Item if it is found in the grid */
         if (child_widget == widget) {
             gtk_widget_unparent(child_widget);
             priv->children = g_list_remove_link(priv->children, list);
@@ -1197,6 +1201,7 @@ hildon_grid_remove(GtkContainer * container, GtkWidget * widget)
         }
     }
 
+    /* Emit warning if the item is not found */
     if (!deleted) {
         g_warning("tried to remove unexisting item");
         return;
@@ -1264,6 +1269,7 @@ set_focus(HildonGrid * grid, GtkWidget * widget, gboolean refresh_view)
     priv = HILDON_GRID_GET_PRIVATE(grid);
     container = GTK_CONTAINER(grid);
 
+    /* If widget is NULL -> unfocus */ 
     if (widget == NULL && container->focus_child != NULL)
         GTK_WIDGET_UNSET_FLAGS(container->focus_child, GTK_HAS_FOCUS);
 
@@ -1273,6 +1279,7 @@ set_focus(HildonGrid * grid, GtkWidget * widget, gboolean refresh_view)
         return;
     }
 
+    /* Get the child index which the user wanted to focus */
     priv->focus_index = get_child_index(priv, widget);
 
     gtk_widget_grab_focus(widget);
@@ -1304,6 +1311,7 @@ hildon_grid_forall(GtkContainer * container,
     grid = HILDON_GRID(container);
     priv = HILDON_GRID_GET_PRIVATE(grid);
 
+    /* Connect callback functions */
     if (include_internals) {
         if (priv->scrollbar != NULL) {
             (*callback) (priv->scrollbar, callback_data);
@@ -1372,8 +1380,10 @@ static void hildon_grid_finalize(GObject * object)
  * . 1 # 2      . 1 # #     1 # # #     1 # # #
  * . . .        . . 2       . . .       . 2 .
  *
- * '.' = item, '#' = dimmed item, 
- * '1' = starting position, '2' = final position
+ * '.' = item,
+ * '#' = dimmed item, 
+ * '1' = starting position,
+ * '2' = final position
  *
  * ...although only the first example is implemented right now.
  *
@@ -1791,6 +1801,7 @@ static gboolean jump_scrollbar_to_focused(HildonGrid * grid)
     empty_grids = priv->num_columns * priv->area_rows - child_count +
         priv->first_index;
 
+    /* Determine the position of the new row */ 
     if (priv->focus_index < priv->first_index) {
         new_row = priv->focus_index / priv->num_columns;
     } else if (priv->focus_index >= priv->first_index +
index c5522bb..3ae7d97 100644 (file)
 #include "hildon-volumebar-private.h"
 
 /* Defines for normal version of HVolumebar */
+/* Toggle button */
 #define DEFAULT_TBUTTON_WIDTH  26
 #define DEFAULT_TBUTTON_HEIGHT 26
+/* Volume bar */
 #define MINIMUM_BAR_WIDTH     147
 #define DEFAULT_BAR_HEIGHT     58
 #define DEFAULT_ENDING_SIZE    20
 
+/* Gap to leave for mute button */
 #define VERTICAL_MUTE_GAP      16
 #define HORIZONTAL_MUTE_GAP     6
 
+/* Sizes inside a toolbar */
+/* Toggle button */
 #define TOOL_DEFAULT_TBUTTON_WIDTH  26
 #define TOOL_DEFAULT_TBUTTON_HEIGHT 26
+/* Volumebar */
 #define TOOL_MINIMUM_BAR_WIDTH     121
 #define TOOL_DEFAULT_BAR_HEIGHT     40
 #define TOOL_DEFAULT_ENDING_SIZE     0
@@ -60,7 +66,6 @@ static void hvolumebar_init(HildonHVolumebar * hvolumebar);
 static void
 hildon_hvolumebar_mute(GtkWidget * widget, HildonHVolumebar * self);
 
-/* new */
 static gboolean hildon_hvolumebar_expose(GtkWidget * widget,
                                          GdkEventExpose * event);
 static void hildon_hvolumebar_size_request(GtkWidget * widget,
@@ -161,6 +166,7 @@ static void hildon_hvolumebar_map(GtkWidget * widget)
 
     parent = gtk_widget_get_ancestor(GTK_WIDGET(widget), GTK_TYPE_TOOLBAR);
 
+    /* Check if the volumebar is in a toolbar */
     if (parent)
         priv->is_toolbar = TRUE;
 
@@ -174,6 +180,7 @@ static gboolean hildon_hvolumebar_expose(GtkWidget * widget,
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
     
     if (GTK_WIDGET_DRAWABLE(widget)) {
+        /* Paint background */
         gtk_paint_box(widget->style, widget->window,
                       GTK_WIDGET_STATE(priv->volumebar), GTK_SHADOW_OUT,
                       NULL, widget, "background",
@@ -182,6 +189,7 @@ static gboolean hildon_hvolumebar_expose(GtkWidget * widget,
                       widget->allocation.width,
                       widget->allocation.height);
 
+       /* The contents of the widget can paint themselves */
         (*GTK_WIDGET_CLASS(parent_class)->expose_event) (widget, event);
     }
 
@@ -196,6 +204,7 @@ hildon_hvolumebar_size_request(GtkWidget * widget,
 
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
 
+    /* Volumebar has different dimensions in toolbar */
     requisition->width = (priv->is_toolbar
                           ? TOOL_MINIMUM_BAR_WIDTH
                           : MINIMUM_BAR_WIDTH);
@@ -218,11 +227,11 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
     button_allocation.x = 0;
     button_allocation.width = 0;
     
+    /* Center the widget vertically */
     if (priv->is_toolbar && allocation->height > TOOL_DEFAULT_BAR_HEIGHT) {
         allocation->y += (allocation->height - TOOL_DEFAULT_BAR_HEIGHT) / 2;
         allocation->height = TOOL_DEFAULT_BAR_HEIGHT;
     }
-
     if (!priv->is_toolbar && allocation->height > DEFAULT_BAR_HEIGHT) {
         allocation->y += (allocation->height - DEFAULT_BAR_HEIGHT) / 2;
         allocation->height = DEFAULT_BAR_HEIGHT;
@@ -232,6 +241,7 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
 
     if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton)) {
 
+        /* Allocate space for the mute button */
         if (priv->is_toolbar) {
             button_allocation.x = allocation->x;
             button_allocation.y = allocation->y + TOOL_VERTICAL_MUTE_GAP;
@@ -248,16 +258,19 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
     }
     if (priv->volumebar && GTK_WIDGET_VISIBLE(priv->volumebar)) {
 
+        /* Allocate space for the slider */
         range_allocation.y = allocation->y;
         
         if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton))
         {
+           /* Leave room for the mute button */
             range_allocation.x = button_allocation.x
                                  + button_allocation.width
                                  + HORIZONTAL_MUTE_GAP;
         
             if (priv->is_toolbar) 
             {
+               /* In toolbar with mute button */
                 range_allocation.width = MAX(0,
                                            allocation->width
                                            - 2 * TOOL_DEFAULT_ENDING_SIZE
@@ -270,6 +283,7 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
             
             else 
             {
+               /* Standalone with mute button */
                 range_allocation.width = MAX(0,
                                              allocation->width
                                              - 2 * DEFAULT_ENDING_SIZE
@@ -285,6 +299,7 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
         {
             if (priv->is_toolbar) 
             {
+                /* In toolbar without mute button */
                 range_allocation.x = allocation->x;
                 
                 range_allocation.width = MAX(0,
@@ -297,7 +312,7 @@ hildon_hvolumebar_size_allocate(GtkWidget * widget,
             
             else 
             {
-                
+                /* Standalone without mute button */
                 range_allocation.x = allocation->x + DEFAULT_ENDING_SIZE;
                 
                 range_allocation.width = MAX(0,
index b1b05a2..e5bd67a 100644 (file)
  *
  */
 
-/* HILDON DOC
- * @shortdesc: NamePasswordDialog is a dialog for getting the user name
- * and password.
- * @longdesc: NamePasswordDialog is a simple dummy dialog for getting
- * name&password from the user.
- */
-
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <errno.h>
@@ -61,6 +54,7 @@ struct _HildonNamePasswordDialogPrivate {
   HildonCaption *passwordEntry;
 };
 
+/* Macro to access the private data of the object instance */
 #define HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(o)  \
    (G_TYPE_INSTANCE_GET_PRIVATE ((o), HILDON_TYPE_NAME_PASSWORD_DIALOG,\
     HildonNamePasswordDialogPrivate))
@@ -83,6 +77,7 @@ static void hildon_name_password_dialog_get_property(GObject * object,
                                                      guint prop_id,
                                                      GValue * value, 
                                                     GParamSpec * pspec);
+
 static void
 hildon_name_password_dialog_set_property(GObject * object,
                                          guint prop_id,
@@ -95,15 +90,23 @@ hildon_name_password_dialog_set_property(GObject * object,
     
     switch (prop_id) {
     case PROP_CONTENT:
+
+    /* Set the password domain text
+       FIXME: Why this is labeled as CONTENT?? */
        gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
        break;
     case PROP_NAME:
+
+      /* Set the current username displayed in the dialog */
+      /* FIXME: Remove the combination of tabs/spaces to make the code look nice */
       gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child
                                   (GTK_BIN(
                                            priv->nameEntry))), 
                         g_value_get_string(value));
       break;
     case PROP_PASSWORD:
+
+      /* Set the currently entered password */
       gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child
                                   (GTK_BIN(
                                            priv->passwordEntry))), 
@@ -132,6 +135,7 @@ hildon_name_password_dialog_get_property(GObject * object,
       g_value_set_string(value, string);
       break;
     case PROP_NAME:
+      /* FIXME: 1) intendation, 2) use g_object_get_property for entry */
       string = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child
                                            (GTK_BIN(
                                                     priv->nameEntry))));
@@ -139,6 +143,7 @@ hildon_name_password_dialog_get_property(GObject * object,
       g_value_set_string(value, string);
       break;
     case PROP_PASSWORD:
+     /* FIXME: 1) intendation, 2) use g_object_get_property for entry */
      string = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child
                                            (GTK_BIN(
                                                     priv->passwordEntry))));
@@ -156,10 +161,11 @@ hildon_name_password_dialog_class_init(HildonNamePasswordDialogClass *class)
     
     parent_class = g_type_class_peek_parent(class);
     
+    /* Override virtual functions */
     object_class->set_property = hildon_name_password_dialog_set_property;
     object_class->get_property = hildon_name_password_dialog_get_property;
     
-    /* properties */
+    /* Install new properties */
     g_object_class_install_property(object_class, 
                    PROP_CONTENT, 
                    g_param_spec_string ("content",
@@ -184,6 +190,7 @@ hildon_name_password_dialog_class_init(HildonNamePasswordDialogClass *class)
                             "DEFAULT",
                             G_PARAM_READWRITE));
 
+    /* Install private data structure */
     g_type_class_add_private(class,
                              sizeof(HildonNamePasswordDialogPrivate));
 }
@@ -191,17 +198,23 @@ hildon_name_password_dialog_class_init(HildonNamePasswordDialogClass *class)
 static void
 hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
 {
+    /* Access private structure */
     HildonNamePasswordDialogPrivate *priv =
         HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+    /* Size group for captions */
     GtkSizeGroup *group =
         GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
     GtkWidget *control;
     
+    /* Initialize dialog */
     gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
     gtk_window_set_title(GTK_WINDOW(dialog), _(HILDON_NAME_PASSWORD_DIALOG_TITLE));
-    
+
+    /* Optional domain name label */    
     priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
-    
+
+    /* Create buttons */    
     priv->okButton =
       GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
                                        _(HILDON_NAME_PASSWORD_DIALOG_OK),
@@ -211,6 +224,7 @@ hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
                                        _(HILDON_NAME_PASSWORD_DIALOG_CANCEL),
                                        GTK_RESPONSE_CANCEL));
 
+    /* Setup user name entry */
     control = gtk_entry_new();
     priv->nameEntry = HILDON_CAPTION(hildon_caption_new
                                     (group,
@@ -219,6 +233,7 @@ hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
                                      HILDON_CAPTION_OPTIONAL));
     hildon_caption_set_separator(priv->nameEntry, "");
 
+    /* Setup password entry */
     control = gtk_entry_new();
     gtk_entry_set_visibility(GTK_ENTRY(control), FALSE);
     priv->passwordEntry =
@@ -229,6 +244,7 @@ hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
                                         HILDON_CAPTION_OPTIONAL));
     hildon_caption_set_separator(priv->passwordEntry, "");
 
+    /* Build layout */
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), 
          GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), 
@@ -240,7 +256,9 @@ hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
     gtk_widget_show_all(GTK_DIALOG(dialog)->action_area);
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
     
+    /* FIXME: Do not leak group */
 }
+
 GType hildon_name_password_dialog_get_type(void)
 {
     static GType dialog_type = 0;
@@ -325,6 +343,8 @@ const gchar *hildon_name_password_dialog_get_name(HildonNamePasswordDialog
 {
     HildonNamePasswordDialogPrivate *priv =
         HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+    /* FIXME: Intendation */
     return gtk_entry_get_text(GTK_ENTRY(
                              (gtk_bin_get_child
                               (GTK_BIN(
@@ -344,6 +364,8 @@ const gchar *hildon_name_password_dialog_get_password(HildonNamePasswordDialog
 {
     HildonNamePasswordDialogPrivate *priv =
         HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+    /* FIXME: Intendation */
     return gtk_entry_get_text(GTK_ENTRY
                              (gtk_bin_get_child
                               (GTK_BIN(
index ed42385..d6f8b25 100644 (file)
 /* 
  * @file hildon-note.c
  *
- * This file contains API for conformation, information
- * and cancel notes. 
- * 
- * 9/2004 Removed animation type of cancel note as separate task.
+ * This file contains API for confirmation, information and cancel notes. 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -51,7 +48,7 @@
 #include <unistd.h>
 #include <signal.h>
 
-/* Can these be included from somewhere? */
+/* FIXME: Can these be included from somewhere? */
 
 #define CONFIRMATION_SOUND_PATH "/usr/share/sounds/ui-confirmation_note.wav"
 #define INFORMATION_SOUND_PATH "/usr/share/sounds/ui-information_note.wav"
@@ -125,6 +122,7 @@ enum {
 
 /* This function is just a modified version of two_lines_truncate
  * in gtk-infoprint.c */
+/* FIXME: factor this code, we now have _one, _two, _three, _five _line _truncate (...) */
 static void
 hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
 {
@@ -140,6 +138,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
     if (priv->original_description != NULL)
         g_free(priv->original_description);
 
+    /* Save original text */
     priv->original_description = g_strdup(text);
 
     if (text == NULL) {
@@ -157,10 +156,12 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
 
         layout = pango_layout_new(context);
         pango_layout_set_text(layout, str, -1);
+        /* Set wrapping options */
         pango_layout_set_width(layout, max_width * PANGO_SCALE);
         pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
         last_line = MIN(4, pango_layout_get_line_count(layout) - 1);
 
+        /* Copy first 5 lines */
         for (current_line = 0;
              current_line <= last_line;
              current_line++) {
@@ -179,6 +180,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
 
         g_object_unref(layout);
 
+        /* Create new layout starting from last line */
         layout = pango_layout_new(context);
         pango_layout_set_text(layout, lines[last_line], -1);
 
@@ -186,7 +188,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
             PangoLayoutLine *line;
             gint index = 0;
 
-            /* Here we ellipsize the last line... */
+            /* Cut text, add ellipsis to last line */
             if (pango_layout_get_line_count(layout) > 1) {
                 gchar *templine = NULL;
 
@@ -197,6 +199,8 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
                 g_free(templine);
             }
 
+            /* Find point where to add ellipsis so it would fit, 
+               if it doesn't already */
             if (pango_layout_xy_to_index(layout,
                                          max_width * PANGO_SCALE, 0,
                                          &index, NULL) == TRUE) {
@@ -211,6 +215,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
                                          ellipsiswidth, 0, &index,
                                          NULL);
                 g_object_unref(G_OBJECT(ellipsis));
+                /* Cut text from that point and add ellipsis */
                 tempresult = g_strndup(lines[last_line], index);
                 lines[last_line] = g_strconcat(tempresult,
                                                ELLIPSATION_STRING,
@@ -219,9 +224,11 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
             }
         }
 
+        /* Remove newlines */
         for (current_line = 0; current_line <= last_line; current_line++)
             g_strchomp(lines[current_line]);
 
+        /* Get resulting string */
         result = g_strconcat(lines[0], "\n",
                              lines[1], "\n",
                              lines[2], "\n",
@@ -261,6 +268,7 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
     if (priv->original_description != NULL)
         g_free(priv->original_description);
 
+    /* Save original text */
     priv->original_description = g_strdup(text);
 
     str = g_strdup(text == NULL ? "" : text);
@@ -268,9 +276,11 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
 
     layout = pango_layout_new(context);
     pango_layout_set_text(layout, str, -1);
+    /* Set wrapping options */
     pango_layout_set_width(layout, max_width * PANGO_SCALE);
     pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
 
+    /* Cut string and add ellipsis if more than one line */
     if (pango_layout_get_line_count(layout) > 1) {
         gchar *templine = NULL;
 
@@ -281,6 +291,8 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
         g_free(templine);
     }
 
+    /* Find point where to add ellipsis so it would fit, 
+       if it doesn't already */
     if (pango_layout_xy_to_index(layout,
                                  max_width * PANGO_SCALE, 0,
                                  &index, NULL) == TRUE) {
@@ -295,6 +307,7 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
                                  ellipsiswidth, 0, &index,
                                  NULL);
         g_object_unref(G_OBJECT(ellipsis));
+       /* Cut text from that point and add ellipsis (again) */
         tempresult = g_strndup(str, index);
         str = g_strconcat(tempresult,
                           ELLIPSATION_STRING,
@@ -395,21 +408,11 @@ GType hildon_note_type_get_type (void)
   static GType notetype = 0;
   if (notetype == 0) {
     static const GEnumValue values[] = {
-      { HILDON_NOTE_CONFIRMATION_TYPE,
-        "HILDON_NOTE_CONFIRMATION_TYPE", 
-        "confirmation" },
-      { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
-        "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE",
-        "confirmation-button" },
-      { HILDON_NOTE_INFORMATION_TYPE,
-        "HILDON_NOTE_INFORMATION_TYPE",
-        "note-information" },
-      { HILDON_NOTE_INFORMATION_THEME_TYPE,
-        "HILDON_NOTE_INFORMATION_THEME_TYPE",
-        "note-information-theme" },
-      { HILDON_NOTE_PROGRESSBAR_TYPE,
-        "HILDON_NOTE_PROGRESSBAR_TYPE",
-        "note-progressbar" },
+      { HILDON_NOTE_CONFIRMATION_TYPE,        "HILDON_NOTE_CONFIRMATION_TYPE",        "confirmation" },
+      { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE, "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE", "confirmation-button" },
+      { HILDON_NOTE_INFORMATION_TYPE,         "HILDON_NOTE_INFORMATION_TYPE",         "note-information" },
+      { HILDON_NOTE_INFORMATION_THEME_TYPE,   "HILDON_NOTE_INFORMATION_THEME_TYPE",   "note-information-theme" },
+      { HILDON_NOTE_PROGRESSBAR_TYPE,         "HILDON_NOTE_PROGRESSBAR_TYPE",         "note-progressbar" },
       { 0, NULL, NULL }
     };
     notetype = g_enum_register_static ("HildonNoteType", values);
@@ -516,13 +519,13 @@ static void hildon_note_class_init(HildonNoteClass * class)
   /**
    * HildonNote:progressbar:
    *
-   * Progresbar for note.
+   * Progressbar for note.
    */
     g_object_class_install_property(object_class,
         PROP_HILDON_NOTE_PROGRESSBAR,
         g_param_spec_object("progressbar",
                             "Progressbar widget",
-                            "The progressbar that appear in the note dialog",
+                            "The progressbar that appears in the note dialog",
                             GTK_TYPE_PROGRESS_BAR,
                             G_PARAM_READWRITE));
 }
@@ -564,6 +567,7 @@ hildon_note_realize (GtkWidget *widget)
 {
     GTK_WIDGET_CLASS (parent_class)->realize (widget);
 
+    /* Add border */
     gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
 }
 
@@ -600,12 +604,12 @@ hildon_note_create (HildonNote *note)
         priv->note_n == HILDON_NOTE_INFORMATION_TYPE) {
 
         if (priv->note_n == HILDON_NOTE_CONFIRMATION_TYPE) {
-            /* ok button clickable with mouse or whatever */
+            /* Add clickable OK button */
             priv->okButton = 
                 gtk_dialog_add_button(GTK_DIALOG(note),
                                       _("Ecdg_bd_confirmation_note_ok"),
                                       GTK_RESPONSE_OK);
-            /* cancel button clickable with mouse or whatever */
+            /* Add clickable Cancel button */
             priv->cancelButton =
                 gtk_dialog_add_button(GTK_DIALOG(note),
                                       _("Ecdg_bd_confirmation_note_cancel"),
@@ -614,7 +618,8 @@ hildon_note_create (HildonNote *note)
         } else if (priv->note_n == HILDON_NOTE_INFORMATION_TYPE || 
                   priv->note_n == HILDON_NOTE_INFORMATION_THEME_TYPE ) {
             priv->okButton = NULL;
-            /* cancel button clickable with mouse or whatever */
+            /* Add clickable OK button (cancel really,
+              but doesn't matter since this is info) */
             priv->cancelButton =
                 gtk_dialog_add_button(GTK_DIALOG(note),
                                       _("Ecdg_bd_information_note_ok"),
@@ -625,10 +630,12 @@ hildon_note_create (HildonNote *note)
             priv->note_n == HILDON_NOTE_INFORMATION_THEME_TYPE) && 
                  priv->icon)
         {
+           /* Information with custom icon */
             item = gtk_image_new_from_icon_name(priv->icon,
                                             HILDON_ICON_SIZE_BIG_NOTE);
         }
         else {
+         /* Use default icon */
           if (priv->note_n == HILDON_NOTE_CONFIRMATION_TYPE ||
             priv->note_n == HILDON_NOTE_CONFIRMATION_BUTTON_TYPE)
           {
@@ -671,6 +678,7 @@ hildon_note_create_form(GtkDialog * dialog, GtkWidget * item,
     }
 
     if (IsHorizontal) {
+        /* Pack item with label horizontally */
         priv->box = gtk_hbox_new(FALSE, BOX_SPACING);
         gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
 
@@ -683,6 +691,7 @@ hildon_note_create_form(GtkDialog * dialog, GtkWidget * item,
         gtk_box_pack_start(GTK_BOX(priv->box), priv->label, FALSE, FALSE, 0);
 
     } else {
+        /* Pack item with label vertically */
         priv->box = gtk_vbox_new(FALSE, BOX_SPACING);
         gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
         gtk_box_pack_start(GTK_BOX(priv->box), priv->label, FALSE, FALSE, 0);
@@ -713,6 +722,10 @@ hildon_note_create_form(GtkDialog * dialog, GtkWidget * item,
  *
  * Return value: A #GtkWidget pointer of the note.
  */
+
+/* FIXME: XXX This doc seems to be wrong, the two buttons aren't added so it
+ * would only contain the "additional" buttons? */
+
 GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow * parent,
                                                     const gchar *
                                                     description, ...)
@@ -733,6 +746,7 @@ GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow * parent,
     if (parent != NULL)
         gtk_window_set_transient_for(GTK_WINDOW(conf_note), parent);
 
+    /* Add the buttons from varargs */
     va_start(args, description);
 
     while (TRUE) {
index eb24107..3ccd2d9 100644 (file)
@@ -55,6 +55,7 @@
 #define SPACE_BORDER 6
 #define NUMBER_EDITOR_HEIGHT 30
 
+/* Size of plus and minus buttons */
 #define BUTTON_HEIGHT 30
 #define BUTTON_WIDTH 30
 
@@ -146,6 +147,7 @@ static void hildon_number_editor_get_property(GObject * object,
                                      guint prop_id,
                                      GValue * value, GParamSpec * pspec);
 
+/* Signal indices */
 enum
 {
   RANGE_ERROR,
@@ -153,6 +155,7 @@ enum
   LAST_SIGNAL
 };
 
+/* Property indices */
 enum {
     PROP_0,
     PROP_VALUE
@@ -164,19 +167,22 @@ static guint HildonNumberEditor_signal[LAST_SIGNAL] = {0};
 
 struct _HildonNumberEditorPrivate
 {
+    /* Child widgets */
     GtkWidget *num_entry;
     GtkWidget *plus;
     GtkWidget *minus;
 
-    gint start;
-    gint end;
+    gint start; /* Minimum */
+    gint end;   /* Maximum */
     gint default_val;
-    gint button_type;
+    gint button_type; /* Type of button pressed: 1 = plus, -1 = minus */
 
-    guint button_event_id;
-    guint select_all_idle_id;
+    /* Timer IDs */
+    guint button_event_id; /* Repeat change when button is held */
+    guint select_all_idle_id; /* Selection repaint hack
+                                see hildon_number_editor_select_all */
 
-    gboolean negative;
+    gboolean negative; /* FIXME: XXX This is unused */
 };
 
 
@@ -261,6 +267,7 @@ hildon_number_editor_forall(GtkContainer *container, gboolean include_internals,
     if (!include_internals)
         return;
 
+    /* Enumerate child widgets */
     (*callback) (priv->minus, callback_data);
     (*callback) (priv->num_entry, callback_data);
     (*callback) (priv->plus, callback_data);
@@ -273,6 +280,7 @@ hildon_number_editor_destroy(GtkObject *self)
 
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(self);
 
+    /* Free child widgets */
     if (priv->minus)
       {
         gtk_widget_unparent(priv->minus);
@@ -300,7 +308,7 @@ hildon_number_editor_finalize (GObject *self)
 
    priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(self);
 
-   /* Free timer */
+   /* Free timers */
    if (priv->button_event_id)
      g_source_remove (priv->button_event_id);
 
@@ -320,6 +328,7 @@ hildon_number_editor_init (HildonNumberEditor *editor)
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
     GTK_WIDGET_SET_FLAGS(GTK_WIDGET(editor), GTK_NO_WINDOW);
 
+    /* Create child widgets */
     priv->num_entry = gtk_entry_new();
     priv->minus = gtk_button_new();
     priv->plus = gtk_button_new();
@@ -340,6 +349,7 @@ hildon_number_editor_init (HildonNumberEditor *editor)
     gtk_widget_set_parent(priv->num_entry, GTK_WIDGET(editor));
     gtk_widget_set_parent(priv->plus, GTK_WIDGET(editor));
 
+    /* Connect child widget signals */
     g_signal_connect(GTK_OBJECT(priv->num_entry), "changed",
                      G_CALLBACK(hildon_number_editor_entry_changed),
                      editor);
@@ -395,6 +405,7 @@ hildon_number_editor_mnemonic_activate (GtkWidget *widget,
                                         gboolean group_cycle)
 {
   HildonNumberEditorPrivate *priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(widget);
+  /* Focus and select all of number entry on activation */
   gtk_widget_grab_focus(priv->num_entry);
   gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
   return TRUE;
@@ -416,6 +427,7 @@ hildon_number_editor_button_released (GtkWidget *widget, GdkEvent *event,
     HildonNumberEditorPrivate *priv =
         HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
         
+    /* Stop repetition timer */
     if (priv->button_event_id)
       {
         g_source_remove(priv->button_event_id);
@@ -428,6 +440,7 @@ static gboolean
 hildon_number_editor_button_pressed (GtkWidget *widget, GdkEventButton *event,
                                      gpointer data)
 {
+    /* FIXME: XXX Why aren't we using hildon_number_editor_start_timer here? XXX */
     /* Need to fetch current value from entry and increment or decrement
        it */
     HildonNumberEditor *editor;
@@ -440,11 +453,13 @@ hildon_number_editor_button_pressed (GtkWidget *widget, GdkEventButton *event,
     settings = gtk_settings_get_default();
     g_object_get(settings, "gtk-initial-timeout", &timeout, NULL);
 
+    /* Save type of button pressed */
     if (GTK_BUTTON(widget) == GTK_BUTTON(priv->plus))
         priv->button_type = 1;
     else
         priv->button_type = -1;
 
+    /* Start repetition timer */
     if (!priv->button_event_id)
       {
         do_mouse_timeout(editor);
@@ -482,6 +497,7 @@ do_mouse_timeout (HildonNumberEditor *editor)
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
     success = TRUE;
 
+    /* Update value based on button held */
     if (priv->button_type == 1)
       {
         if (change_numbers(editor, 1, -1) == FALSE)
@@ -510,6 +526,7 @@ change_numbers (HildonNumberEditor *editor, gint type, gint cursor_pos)
         HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
     nvalue = atoi(GTK_ENTRY(priv->num_entry)->text);
 
+    /* Update value */
     if (type == 1)
       {
         if (nvalue < priv->end)
@@ -534,7 +551,7 @@ change_numbers (HildonNumberEditor *editor, gint type, gint cursor_pos)
           }
       }
 
-    /* write value to num_entry */
+    /* Write updated value to num_entry */
     snvalue = integer_to_string(nvalue);
     gtk_entry_set_text(GTK_ENTRY(priv->num_entry), snvalue);
 
@@ -582,9 +599,12 @@ hildon_number_editor_entry_changed (GtkWidget *widget, gpointer data)
   if (strlen(tmpstr) > 0)
     {
       tmpstr = NULL;
+      /* Try to convert entry text to number */
       value = strtol(GTK_ENTRY(priv->num_entry)->text, &tail, 10);
+      /* Check if conversion succeeded or value contains minus sign */
       if (!strncmp(tail, "\0", 1) || !strncmp(tail, "-", 1))
        {    
+         /* Check if value isn't in allowed range */
          if (atoi(GTK_ENTRY(priv->num_entry)->text) > priv->end)
            {
              g_signal_emit(editor,HildonNumberEditor_signal[RANGE_ERROR], 
@@ -629,6 +649,7 @@ hildon_number_editor_size_request (GtkWidget *widget,
     editor = HILDON_NUMBER_EDITOR(widget);
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
 
+    /* Requested size is size of all child widgets plus border space */
     gtk_widget_size_request(priv->minus, &req);
     requisition->width = req.width;
 
@@ -639,9 +660,12 @@ hildon_number_editor_size_request (GtkWidget *widget,
     requisition->width += req.width;
 
     requisition->width += SPACE_BORDER * 2;
+
+    /* FIXME: XXX Height is fixed */
     requisition->height = NUMBER_EDITOR_HEIGHT;
 }
 
+/* Update @alloc->width so widget fits, update @alloc->x to point to free space */
 static void
 set_widget_allocation (GtkWidget *widget, GtkAllocation *alloc,
                       GtkAllocation *allocation)
@@ -650,6 +674,7 @@ set_widget_allocation (GtkWidget *widget, GtkAllocation *alloc,
 
     gtk_widget_get_child_requisition(widget, &child_requisition);
 
+    /* Fit to widget width */
     if (allocation->width + allocation->x >
         alloc->x + child_requisition.width)
         alloc->width = child_requisition.width;
@@ -661,6 +686,7 @@ set_widget_allocation (GtkWidget *widget, GtkAllocation *alloc,
       }
 
     gtk_widget_size_allocate(widget, alloc);
+    /* Update x position */
     alloc->x += alloc->width;
 }
 
@@ -677,9 +703,10 @@ hildon_number_editor_size_allocate (GtkWidget *widget,
 
   widget->allocation = *allocation;
 
-/*Init start values*/
+  /* Add upper border */
   alloc.y = widget->allocation.y + widget->style->ythickness;
 
+  /* Fix height */
   if (widget->allocation.height > NUMBER_EDITOR_HEIGHT)
     {
       alloc.height = NUMBER_EDITOR_HEIGHT - widget->style->ythickness * 2;
@@ -687,14 +714,14 @@ hildon_number_editor_size_allocate (GtkWidget *widget,
     }
   else
       alloc.height = widget->allocation.height - widget->style->ythickness * 2;
-
-
   
   if (alloc.height < 0)
     alloc.height = 0;
 
+  /* Add left border */
   alloc.x = allocation->x + widget->style->xthickness;
 
+  /* Allocate positions for widgets (left-to-right) */
   set_widget_allocation(priv->minus, &alloc, &widget->allocation);
   alloc.x += SPACE_BORDER;
 
@@ -716,12 +743,12 @@ hildon_number_editor_entry_focusout (GtkWidget *widget, GdkEventFocus *event,
     editor = HILDON_NUMBER_EDITOR(data);
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
     
-    /* empty entry, must infoprint error message */
+    /* If entry is empty, emit error signal */
     if (!strlen(GTK_ENTRY(priv->num_entry)->text))
       {
        g_signal_emit(editor, HildonNumberEditor_signal[RANGE_ERROR], 
                      0, ERRONEOUS_VALUE, &r);
-        /* Changing to default value */
+        /* Change to default value */
         str = integer_to_string(priv->default_val);
         gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
         gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
@@ -743,6 +770,7 @@ hildon_number_editor_entry_keypress (GtkWidget *widget, GdkEventKey *event,
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(data);
     tmp_pos = gtk_editable_get_position( GTK_EDITABLE(priv->num_entry) );
     
+    /* Change value when left or right key pressed and cursor is at boundary */
     if( (event->keyval == GDK_Left) || (event->keyval == GDK_Right) )
     {
       if( ((event->keyval == GDK_Left) && tmp_pos == 0 ) ||
@@ -774,6 +802,7 @@ hildon_number_editor_entry_keypress (GtkWidget *widget, GdkEventKey *event,
       return FALSE;
     }
    
+    /* Allow numbers, minus key and editing keys */
     scnd_chr = gtk_editable_get_chars( GTK_EDITABLE(priv->num_entry),
                                               0, 1 );
     if (event->keyval == GDK_minus || event->keyval == GDK_KP_Subtract)
@@ -786,13 +815,13 @@ hildon_number_editor_entry_keypress (GtkWidget *widget, GdkEventKey *event,
     else if ((event->keyval == GDK_Up) || (event->keyval == GDK_Down)
         || (event->keyval == GDK_KP_Up) || (event->keyval == GDK_KP_Down))
         ret_val = FALSE;
-    else if (((event->keyval >= GDK_0) && (event->keyval <= GDK_9)) ||
-             ((event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9))
+    else if (   ( (event->keyval >= GDK_0)    && (event->keyval <= GDK_9)    )
+             || ( (event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9) )
              || (event->keyval == GDK_BackSpace)
              || (event->keyval == GDK_Delete)
              || (event->keyval == GDK_Return)
-             || (((event->keyval == GDK_minus)
-             || (event->keyval == GDK_KP_Subtract))))
+             || (((event->keyval == GDK_minus) || (event->keyval == GDK_KP_Subtract)))
+            )
         ret_val = FALSE;
     else
       ret_val = TRUE;
@@ -814,7 +843,7 @@ hildon_number_editor_error_handler(HildonNumberEditor *editor,
   min = priv->start;
   max = priv->end;
 
-  /* Construct different error message */
+  /* Construct error message */
   switch (type)
     {
     case MAXIMUM_VALUE_EXCEED:
@@ -829,6 +858,7 @@ hildon_number_editor_error_handler(HildonNumberEditor *editor,
       break;
     }
   
+  /* Infoprint error */
   if (err_msg)
     {
       gtk_infoprint(GTK_WINDOW(gtk_widget_get_ancestor(GTK_WIDGET(editor),
@@ -845,7 +875,7 @@ hildon_number_editor_error_handler(HildonNumberEditor *editor,
  * @min: Minimum accepted value
  * @max: Maximum accepted value
  * 
- * This function creates new number editor
+ * Creates new number editor
  *
  * Return value: a new #HildonNumberEditor widget.
  */
@@ -867,7 +897,7 @@ hildon_number_editor_new (gint min, gint max)
  * @min: Minimum accepted value
  * @max: Maximum accepted value
  *
- * This function set accepted number range for editor
+ * Sets accepted number range for editor
  */
 void
 hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
@@ -878,6 +908,7 @@ hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
 
     g_return_if_fail(HILDON_IS_NUMBER_EDITOR(editor));
 
+    /* Sort min and max */
     if (min > max)
       {
         gint temp = min;
@@ -888,13 +919,14 @@ hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
 
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
 
-    /* we need to store user inputted values */
+    /* Set preferences */
     priv->start = min;
     priv->end = max;
     priv->default_val = min;
 
     priv->negative = min < 0 ? TRUE : FALSE;
 
+    /* Find maximum allowed length of value */
     str = integer_to_string(max);
     str2 = integer_to_string(min);
     a = strlen(str);
@@ -906,6 +938,7 @@ hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
         entry_len = b;
     
 
+    /* Set maximum size of entry */
     gtk_entry_set_width_chars(GTK_ENTRY(priv->num_entry), entry_len);
 
     gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
@@ -921,8 +954,6 @@ hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
  * hildon_number_editor_get_value:
  * @editor: pointer to #HildonNumberEditor
  *
- * This function returns current value of number editor
- *
  * Return value: Current NumberEditor value
  */
 gint
@@ -945,7 +976,7 @@ hildon_number_editor_get_value (HildonNumberEditor *editor)
  * @editor: pointer to #HildonNumberEditor
  * @value: numeric value for number editor
  *
- * This function sets numeric value to number editor
+ * Sets numeric value for number editor
  */
 void
 hildon_number_editor_set_value (HildonNumberEditor *editor, gint value)
@@ -961,7 +992,8 @@ hildon_number_editor_set_value (HildonNumberEditor *editor, gint value)
     g_return_if_fail(value >= priv->start);
 
     priv->default_val = value;
-        
+    
+    /* Update text in entry to new value */
     str = integer_to_string(value);
     gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
     if (str)
index 9248857..0bccd0c 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 /* HILDON DOC
- * @desc: Range Editor is used to define the range some attribute. Accepted
+ * @desc: Range Editor is used to define the range of some attribute. Accepted
  * number type is integer and '-' character is also acceptable. Range can
  * be used in application area and in dialog.  
  * 
@@ -65,7 +65,7 @@
 #define DEFAULT_PADDING 3
 
 #define DEFAULT_START -999
-#define DEFAULT_END 999
+#define DEFAULT_END    999
 #define DEFAULT_LENGTH 4
 
 #define HILDON_RANGE_EDITOR_GET_PRIVATE(obj) \
@@ -74,6 +74,7 @@
 
 typedef struct _HildonRangeEditorPrivate HildonRangeEditorPrivate;
 
+/* Property indices */
 enum
 {
   PROP_LOWER = 1,
@@ -83,7 +84,6 @@ enum
   PROP_SEPARATOR
 };
 
-/*our parent class*/
 static GtkContainerClass *parent_class = NULL;
 
 /*Init functions*/
@@ -134,12 +134,15 @@ static void hildon_range_editor_get_property( GObject *object, guint param_id,
 /* Private struct */
 struct _HildonRangeEditorPrivate
 {
-    GtkWidget *start_entry;
-    GtkWidget *end_entry;
+    GtkWidget *start_entry; /* Entry for lower  value */
+    GtkWidget *end_entry;   /* Entry for higher value */
+
     GtkWidget *label;
-    gint range_limits_start;
-    gint range_limits_end;
-    gboolean bp;
+
+    gint range_limits_start; /* Minimum value allowed for range start/end */
+    gint range_limits_end;   /* Maximum value allowed for range start/end */
+
+    gboolean bp; /* Button pressed, don't overwrite selection */
 };
 
 /* Private functions */
@@ -150,10 +153,8 @@ hildon_range_editor_class_init  (HildonRangeEditorClass *editor_class)
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(editor_class);
     GtkContainerClass *container_class = GTK_CONTAINER_CLASS(editor_class);
 
-    /* set the global parent_class */
     parent_class = g_type_class_peek_parent(editor_class);
 
-    /* now the object stuff */
     g_type_class_add_private(editor_class,
                              sizeof(HildonRangeEditorPrivate));
 
@@ -419,6 +420,7 @@ hildon_range_editor_entry_focus_out (GtkEditable *editable,
                                     HildonRangeEditor *editor)
 {
   HildonRangeEditorPrivate *priv = HILDON_RANGE_EDITOR_GET_PRIVATE(editor);
+  /* Update internal value */
   hildon_range_editor_set_range( editor,
                             g_strtod(GTK_ENTRY(priv->start_entry)->text, NULL),
                             g_strtod(GTK_ENTRY(priv->end_entry)->text, NULL));
@@ -434,6 +436,7 @@ hildon_range_editor_press (GtkEditable *editable, GdkEventButton *event,
   return FALSE;
 }
 
+/* FIXME: XXX Mnemonics aren't used */
 static gboolean
 hildon_range_editor_mnemonic_activate (GtkWidget *widget,
                                        gboolean group_cycling)
@@ -504,9 +507,12 @@ hildon_range_editor_size_request(GtkWidget *widget,
     gtk_widget_size_request(priv->end_entry, &mreq);
     gtk_widget_size_request(priv->label, &lab_req);
 
+    /* Width for entries and separator label and border */
     requisition->width = mreq.width * 2 + lab_req.width +
                          widget->style->xthickness * 2;
+    /* Add vertical border */
     requisition->height = mreq.height + widget->style->ythickness * 2;
+    /* Fit label height */
     requisition->height = MAX (requisition->height, lab_req.height);
 }
 
@@ -521,6 +527,7 @@ hildon_range_editor_size_allocate(GtkWidget *widget,
 
     widget->allocation = *allocation;
 
+    /* Allocate entries, left-to-right */
     if (priv->start_entry && GTK_WIDGET_VISIBLE(priv->start_entry))
       {
         GtkRequisition child_requisition;
@@ -545,6 +552,7 @@ hildon_range_editor_size_allocate(GtkWidget *widget,
 
         child2_allocation.x = child1_allocation.x + child1_allocation.width;
         child2_allocation.y = allocation->y;
+       /* Add spacing */
         child2_allocation.width = child_requisition.width + 4;
         child2_allocation.height = allocation->height;
 
@@ -567,6 +575,7 @@ hildon_range_editor_size_allocate(GtkWidget *widget,
       }
 }
 
+/* Button released inside entries */
 static gboolean
 hildon_range_editor_released(GtkEditable *editable, GdkEventButton *event,
                              HildonRangeEditor *editor)
@@ -584,7 +593,7 @@ hildon_range_editor_entry_keypress(GtkWidget *widget, GdkEventKey *event,
                                    HildonRangeEditor *editor)
 {
     HildonRangeEditorPrivate *priv;
-    GtkWidget *wdgt;
+    GtkWidget *wdgt; /* Next widget */
     gint pos;
     gchar *str;
 
@@ -608,25 +617,32 @@ hildon_range_editor_entry_keypress(GtkWidget *widget, GdkEventKey *event,
         (event->keyval == GDK_ISO_Left_Tab|| (pos == 0 &&
         (event->keyval == GDK_Left || event->keyval == GDK_KP_Left)))))
     {
+      /* Set focus to next widget */
       gtk_widget_grab_focus(wdgt);
       if (widget == priv->start_entry)
       {
+       /* Select all, move cursor to end */
         gtk_editable_set_position(GTK_EDITABLE(wdgt), -1);
         gtk_editable_select_region(GTK_EDITABLE(wdgt), 0, -1);
       }
       else
       {
+       /* Select none (or all??), move cursor to beginning */
         gtk_editable_set_position(GTK_EDITABLE(wdgt), 0);
         gtk_editable_select_region(GTK_EDITABLE(wdgt), -1, 0);
       }
     }
-    else if ((event->keyval >= GDK_0 && event->keyval <= GDK_9) ||
+    else if ((event->keyval >= GDK_0    && event->keyval <= GDK_9)    ||
              (event->keyval >= GDK_KP_0 && event->keyval <= GDK_KP_9) ||
              (event->keyval == GDK_minus || event->keyval == GDK_KP_Subtract) ||
-             event->keyval == GDK_Up || event->keyval == GDK_Down ||
-             event->keyval == GDK_Right || event->keyval == GDK_KP_Right ||
-             event->keyval == GDK_Left || event->keyval == GDK_KP_Left ||
-             event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)
+             event->keyval == GDK_Up        ||
+             event->keyval == GDK_Down      ||
+             event->keyval == GDK_Right     ||
+             event->keyval == GDK_KP_Right  ||
+             event->keyval == GDK_Left      ||
+             event->keyval == GDK_KP_Left   ||
+             event->keyval == GDK_BackSpace ||
+             event->keyval == GDK_Delete)
     {
       return FALSE;
     }
@@ -639,7 +655,7 @@ hildon_range_editor_entry_keypress(GtkWidget *widget, GdkEventKey *event,
  * hildon_range_editor_get_type:
  * @Returns : GType of #HildonRangeEditor.
  *
- * Initialises, and returns the type of a hildon range editor.
+ * Initializes, and returns the type of a hildon range editor.
  */
 GType
 hildon_range_editor_get_type (void)
@@ -778,6 +794,7 @@ hildon_range_editor_set_lower (HildonRangeEditor *editor, gint value)
     else
       g_sprintf (range, "%d", priv->range_limits_start);
 
+    /* Update entry text with new value */
     gtk_entry_set_text (GTK_ENTRY (priv->start_entry), range);
     g_object_notify (G_OBJECT (editor), "lower");
 }
@@ -796,6 +813,7 @@ hildon_range_editor_set_higher (HildonRangeEditor *editor, gint value)
     else
       g_sprintf (range, "%d", priv->range_limits_end);
 
+    /* Update entry text with new value */
     gtk_entry_set_text (GTK_ENTRY (priv->end_entry), range);
     g_object_notify (G_OBJECT (editor), "higher");
 }
@@ -842,6 +860,7 @@ hildon_range_editor_set_min (HildonRangeEditor *editor, gint value)
       hildon_range_editor_set_max (editor, value);
     else
     {
+      /* Calculate length of entry so minimum would fit */
       g_sprintf (end_range, "%d", priv->range_limits_end);
       end_entry = GTK_ENTRY (priv->end_entry);
       length = MAX (strlen (start_range), strlen (end_range));
@@ -852,6 +871,7 @@ hildon_range_editor_set_min (HildonRangeEditor *editor, gint value)
       gtk_entry_set_max_length (end_entry, length);
     }
 
+    /* Update lower value if it isn't in range */
     if (hildon_range_editor_get_lower (editor) < value)
       gtk_entry_set_text (start_entry, start_range);
 
@@ -879,6 +899,7 @@ hildon_range_editor_set_max (HildonRangeEditor *editor, gint value)
       hildon_range_editor_set_min (editor, value);
     else
     {
+      /* Calculate length of entry so maximum would fit */
       g_sprintf (start_range, "%d", priv->range_limits_start);
       start_entry = GTK_ENTRY (priv->start_entry);
       length = MAX (strlen (end_range), strlen (start_range));
@@ -889,6 +910,7 @@ hildon_range_editor_set_max (HildonRangeEditor *editor, gint value)
       gtk_entry_set_max_length (end_entry, length);
     }
 
+    /* Update higher value if it isn't in range */
     if (hildon_range_editor_get_higher (editor) > value)
       gtk_entry_set_text (end_entry, end_range);
 
index eab32e3..759c373 100644 (file)
  *
  */
 
-/* hildon-scroll-area.c
- *
- */
-
 #include "hildon-scroll-area.h"
 #include <gtk/gtkscrolledwindow.h>
 #include <gtk/gtkfixed.h>
 typedef struct
   {
     GtkWidget *fixed;
+
+    /* Scrolled windows */
     GtkWidget *swouter;
     GtkWidget *swinner;
+
+    /* Widget that's being contained */
     GtkWidget *child;
 
+    /* Vertical adjustment for scrolled windows */
     GtkAdjustment *outadj;
     GtkAdjustment *inadj;
 
@@ -143,8 +144,10 @@ static void hildon_scroll_area_child_requisition (GtkWidget *widget,
                                                  GtkRequisition *req,
                                                  HildonScrollArea *sc)
 {
+  /* Limit height to fixed height */
   gint new_req = MAX (req->height, sc->fixed->allocation.height);
   gtk_widget_set_size_request (sc->fixed, -1, req->height);
+  /* Request inner scrolled window at most page size */
   gtk_widget_set_size_request (sc->swinner, -1,
                               MIN (sc->outadj->page_size, new_req));
 }
@@ -155,6 +158,7 @@ static void hildon_scroll_area_outer_value_changed (GtkAdjustment *adjustment,
   GtkRequisition req;
   gtk_widget_size_request (sc->child, &req);
 
+  /* Update inner adjustment position based on outer one, update fixed position */
   if ((sc->outadj->value + sc->outadj->page_size) > sc->fixed->allocation.y
       && sc->outadj->value < (sc->fixed->allocation.y + req.height))
     {
@@ -172,6 +176,7 @@ static void hildon_scroll_area_outer_value_changed (GtkAdjustment *adjustment,
 static void hildon_scroll_area_inner_value_changed (GtkAdjustment *adjustment,
                                                    HildonScrollArea *sc)
 {
+  /* Update outer adjustment based on inner adjustment position */
   if (sc->outadj->value != sc->fixed->allocation.y + adjustment->value)
     gtk_adjustment_set_value (sc->outadj,
                              sc->fixed->allocation.y + adjustment->value);
index 39dac07..e1c3110 100644 (file)
@@ -85,15 +85,10 @@ static gboolean hildon_seekbar_button_release_event(GtkWidget * widget,
 static gboolean hildon_seekbar_keypress(GtkWidget * widget,
                                         GdkEventKey * event);
 
-/* private stuff */
 
-/*
- * Some constants
- * These should be named so that they are quite self
- * explanatory
- */
 #define MINIMUM_WIDTH 115
 #define DEFAULT_HEIGHT 58
+
 /* Toolbar width and height defines */
 #define TOOL_MINIMUM_WIDTH 75
 #define TOOL_DEFAULT_HEIGHT 40
@@ -104,9 +99,10 @@ static gboolean hildon_seekbar_keypress(GtkWidget * widget,
 #define TOOL_EXTRA_SIDE_BORDER 0
 
 /* the number of steps it takes to move from left to right */
-#define SECONDS_PER_MINUTE 60
 #define NUM_STEPS 20
 
+#define SECONDS_PER_MINUTE 60
+
 /* the number of digits precision for the internal range.
  * note, this needs to be enough so that the step size for
  * small total_times doesn't get rounded off. Currently set to 3
@@ -115,7 +111,7 @@ static gboolean hildon_seekbar_keypress(GtkWidget * widget,
  * add one for safety */
 #define MAX_ROUND_DIGITS 3
 
-/* enum for properties */
+/* Property indices */
 enum {
     PROP_TOTAL_TIME = 1,
     PROP_POSITION,
@@ -124,9 +120,11 @@ enum {
 
 /* private variables */
 struct _HildonSeekbarPrivate {
-    GtkWidget *label;
-    gboolean draw_value;
-    gboolean is_toolbar;
+    GtkWidget *label; /* FIXME: XXX This is unused */
+    gboolean draw_value; /* FIXME: XXX This is unused */
+
+    gboolean is_toolbar; /* TRUE if this widget is inside a toolbar */
+
     guint fraction; /* This is the amount of time that has progressed from
                        the beginning. It should be an integer between the
                        minimum and maximum values of the corresponding
@@ -167,12 +165,10 @@ static void hildon_seekbar_class_init(HildonSeekbarClass * seekbar_class)
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(seekbar_class);
     GObjectClass *object_class = G_OBJECT_CLASS(seekbar_class);
 
-    /* set the global parent_class */
     parent_class = g_type_class_peek_parent(seekbar_class);
 
     g_type_class_add_private(seekbar_class, sizeof(HildonSeekbarPrivate));
 
-    /* setup our widgets v-table */
     widget_class->size_request = hildon_seekbar_size_request;
     widget_class->size_allocate = hildon_seekbar_size_allocate;
     widget_class->expose_event = hildon_seekbar_expose;
@@ -181,12 +177,10 @@ static void hildon_seekbar_class_init(HildonSeekbarClass * seekbar_class)
         hildon_seekbar_button_release_event;
     widget_class->key_press_event = hildon_seekbar_keypress;
 
-    /* now the object stuff */
     object_class->set_property = hildon_seekbar_set_property;
     object_class->get_property = hildon_seekbar_get_property;
     object_class->finalize = hildon_seekbar_finalize;
 
-    /* install the properties */
     g_object_class_install_property(object_class, PROP_TOTAL_TIME,
         g_param_spec_double("total_time",
                             "total time",
@@ -224,6 +218,7 @@ static void hildon_seekbar_init(HildonSeekbar * seekbar)
 
     priv = HILDON_SEEKBAR_GET_PRIVATE(seekbar);
 
+    /* Initialize range widget */
     range->orientation = GTK_ORIENTATION_HORIZONTAL;
     range->flippable = TRUE;
     range->has_stepper_a = TRUE;
@@ -233,7 +228,7 @@ static void hildon_seekbar_init(HildonSeekbar * seekbar)
     gtk_scale_set_draw_value (GTK_SCALE (seekbar), FALSE);
 }
 
-/* is this even necessary? */
+/* FIXME: XXX This isn't necessary */
 static void hildon_seekbar_finalize( GObject *obj_self )       
 {      
     HildonSeekbar *self;       
@@ -247,7 +242,6 @@ static void hildon_seekbar_finalize( GObject *obj_self )
 }
 
 
-/* handle keypress events */
 static gboolean hildon_seekbar_keypress(GtkWidget * widget,
                                         GdkEventKey * event)
 {
@@ -257,7 +251,6 @@ static gboolean hildon_seekbar_keypress(GtkWidget * widget,
                                                                event));
 }
 
-/* handle setting of seekbar properties */
 static void
 hildon_seekbar_set_property(GObject * object, guint prop_id,
                             const GValue * value, GParamSpec * pspec)
@@ -307,13 +300,12 @@ hildon_seekbar_get_property(GObject * object, guint prop_id,
 /**
  * hildon_seekbar_new:
  *
- * Creates a new #HildonSeekbar widget.
+ * Create a new #HildonSeekbar widget.
  * 
  * Return value: A #GtkWidget pointer of #HildonSeekbar widget.
  */
 GtkWidget *hildon_seekbar_new(void)
 {
-    /* return a new object */
     return g_object_new(HILDON_TYPE_SEEKBAR, NULL);
 }
 
@@ -321,8 +313,7 @@ GtkWidget *hildon_seekbar_new(void)
  * hildon_seekbar_get_total_time:
  * @seekbar: Pointer to #HildonSeekbar widget.
  *
- * Accessor method for getting total playing time of stream
- * in seconds.
+ * Get total playing time of stream in seconds.
  *
  * Returns: Total time as gint.
  **/
@@ -340,8 +331,7 @@ gint hildon_seekbar_get_total_time(HildonSeekbar *seekbar)
  * @seekbar: Pointer to #HildonSeekbar widget.
  * @time: Time within range of > 0 && < G_MAXINT
  *
- * Accessor method for setting total playing time of stream
- * in seconds.
+ * Set total playing time of stream in seconds.
  *
  **/
 void hildon_seekbar_set_total_time(HildonSeekbar *seekbar, gint time)
@@ -362,16 +352,19 @@ void hildon_seekbar_set_total_time(HildonSeekbar *seekbar, gint time)
     adj = GTK_RANGE(widget)->adjustment;
     adj->upper = time;
 
+    /* Clamp position to total time */
     if (adj->value > time) {
         adj->value = time;
         value_changed = TRUE;
     }
 
+    /* Calculate new step value */
     adj->step_increment = adj->upper / NUM_STEPS;
     adj->page_increment = adj->step_increment;
 
     gtk_adjustment_changed(adj);
 
+    /* Update range widget position/fraction */
     if (value_changed) {
         gtk_adjustment_value_changed(adj);
         hildon_seekbar_set_fraction(seekbar,
@@ -394,8 +387,7 @@ void hildon_seekbar_set_total_time(HildonSeekbar *seekbar, gint time)
  * hildon_seekbar_get_fraction:
  * @seekbar: Pointer to #HildonSeekbar widget.
  *
- * Accessor method for getting current fraction related to the progress indicator.
- * It should be between min and max of seekbar range.
+ * Get current fraction related to the progress indicator.
  *
  * Returns: Current fraction.
  **/
@@ -411,7 +403,7 @@ guint hildon_seekbar_get_fraction( HildonSeekbar *seekbar )
  * @seekbar: Pointer to #HildonSeekbar widget.
  * @fraction: The new position of the progress indicator.
  *
- * Method for setting current value related to the progress indicator.
+ * Set current fraction value related to the progress indicator.
  * It should be between the minimal and maximal values of the range in seekbar.
  **/
 void hildon_seekbar_set_fraction( HildonSeekbar *seekbar, guint fraction )
@@ -430,6 +422,7 @@ void hildon_seekbar_set_fraction( HildonSeekbar *seekbar, guint fraction )
   fraction = CLAMP(fraction, range->adjustment->lower,
                    range->adjustment->upper);
   
+  /* Update stream position of range widget */
   osso_gtk_range_set_stream_position( range, fraction );
   
   if (fraction < hildon_seekbar_get_position(seekbar))
@@ -442,9 +435,7 @@ void hildon_seekbar_set_fraction( HildonSeekbar *seekbar, guint fraction )
  * hildon_seekbar_get_position:
  * @seekbar: Pointer to #HildonSeekbar widget.
  *
- * Accessor method for getting current position in stream
- * in seconds.
- *
+ * Get current position in stream in seconds.
  *
  * Returns: Current position in stream in seconds.
  **/
@@ -461,8 +452,7 @@ gint hildon_seekbar_get_position(HildonSeekbar *seekbar)
  * @seekbar: Pointer to #HildonSeekbar widget.
  * @time: Time within range of >= 0 && < G_MAXINT
  *
- * Accessor method for setting current position in stream
- * in seconds.
+ * Set current position in stream in seconds.
  **/
 void hildon_seekbar_set_position(HildonSeekbar *seekbar, gint time)
 {
@@ -508,6 +498,8 @@ static void hildon_seekbar_size_request(GtkWidget * widget,
     if (GTK_WIDGET_CLASS(parent_class)->size_request)
         GTK_WIDGET_CLASS(parent_class)->size_request(widget, req);
 
+    /* Request minimum size, depending on whether the widget is in a
+     * toolbar or not */
     req->width = priv->is_toolbar ? TOOL_MINIMUM_WIDTH : MINIMUM_WIDTH;
     req->height = priv->is_toolbar ? TOOL_DEFAULT_HEIGHT : DEFAULT_HEIGHT;
 }
@@ -519,6 +511,7 @@ static void hildon_seekbar_size_allocate(GtkWidget * widget,
 
     priv = HILDON_SEEKBAR_GET_PRIVATE(HILDON_SEEKBAR(widget));
 
+    /* Center vertically */
     if (priv->is_toolbar == TRUE)
       {
         if (allocation->height > TOOL_DEFAULT_HEIGHT) {
@@ -536,6 +529,7 @@ static void hildon_seekbar_size_allocate(GtkWidget * widget,
           }
       }
 
+    /* Add space for border */
     if (priv->is_toolbar == TRUE)
       {
         allocation->x += TOOL_EXTRA_SIDE_BORDER;
@@ -563,6 +557,7 @@ static gboolean hildon_seekbar_expose(GtkWidget * widget,
                                             EXTRA_SIDE_BORDER;
 
     if (GTK_WIDGET_DRAWABLE(widget)) {
+       /* Paint border */
         gtk_paint_box(widget->style, widget->window,
                       GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
                       NULL, widget, "seekbar",
@@ -577,9 +572,6 @@ static gboolean hildon_seekbar_expose(GtkWidget * widget,
     return FALSE;
 }
 
-/*
- * Event handler for button_press_event
- */
 static gboolean
 hildon_seekbar_button_press_event(GtkWidget * widget,
                                   GdkEventButton * event)
@@ -592,6 +584,7 @@ hildon_seekbar_button_press_event(GtkWidget * widget,
     self = HILDON_SEEKBAR(widget);
     priv = HILDON_SEEKBAR_GET_PRIVATE(self);
 
+    /* hack, translate first mouse button to second? */
     event->button = event->button == 1 ? 2 : event->button;
 
     /* call the parent handler */
@@ -602,9 +595,6 @@ hildon_seekbar_button_press_event(GtkWidget * widget,
     return result;
 }
 
-/*
- * Event handler for button_release_event
- */
 static gboolean
 hildon_seekbar_button_release_event(GtkWidget * widget,
                                     GdkEventButton * event)
index da5b0bd..07b0203 100644 (file)
@@ -58,7 +58,7 @@
 #include <stdio.h>
 
 #include <hildon-widgets/hildon-caption.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include? */
 #include <hildon-widgets/hildon-set-password-dialog.h>
 #include <hildon-widgets/hildon-note.h>
 #include <hildon-widgets/hildon-defines.h>
@@ -103,30 +103,24 @@ static void hildon_set_password_get_property(GObject * object,
                                              GParamSpec * pspec);
 
 /* Private struct */
-
 struct _HildonSetPasswordDialogPrivate {
-    /* Checkbox tab */
     GtkWidget *checkboxCaption;
     GtkWidget *checkbox;
 
     GtkLabel *domainLabel;
 
-    /* Tab one */
     GtkWidget *pwd1stEntry;
     GtkWidget *pwd1stCaption;
     gchar *pwd1stCaption_string;
 
-    /* Tab two */
     GtkWidget *pwd2ndEntry;
     GtkWidget *pwd2ndCaption;
     gchar *pwd2ndCaption_string;
 
-    /* OK/Cancel buttons */
     GtkWidget *okButton;
     GtkWidget *cancelButton;
 
     gboolean protection;
-
 };
 
 enum {
@@ -149,12 +143,15 @@ hildon_set_password_set_property(GObject * object,
     
     switch (prop_id) {
     case PROP_DOMAIN:
+        /* Update domain label to display new value */
         gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
        break;
     case PROP_PASSWORD:
+        /* Update password entry to display new value */
         gtk_entry_set_text(GTK_ENTRY(priv->pwd1stEntry), g_value_get_string(value));
         break;
     case PROP_HILDON_PASSWORD_DIALOG:
+        /* FIXME: UI is not updated to reflect the new state */
         priv->protection = g_value_get_boolean(value);
         break;
     default:
@@ -172,17 +169,20 @@ hildon_set_password_get_property(GObject * object,
     HildonSetPasswordDialogPrivate *priv;
     const gchar *string;
 
+    /* Access private structure */
     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
     
     switch (prop_id) {
     case PROP_DOMAIN:
         string = gtk_label_get_text(priv->domainLabel);
         g_value_set_string(value, string);
+        /* FIXME: break missing */
     case PROP_PASSWORD:
         string = gtk_entry_get_text(GTK_ENTRY(priv->pwd1stEntry));
         g_value_set_string(value, string);
         break;
     case PROP_HILDON_PASSWORD_DIALOG:
+        /* FIXME: Set the value to itself, i.e. do nothing */
         g_value_set_boolean(value, g_value_get_boolean(value));
         break;
     default:
@@ -202,94 +202,83 @@ hildon_set_password_dialog_constructor(GType type,
     HildonSetPasswordDialogPrivate *priv;
     GtkSizeGroup *group;
 
+    /* Chain to parent constructor */
     parent_class = G_OBJECT_CLASS(g_type_class_peek_parent
                                   (g_type_class_peek(type)));
     dialog = parent_class->constructor(type, n_construct_properties,
                                        construct_properties);
 
     gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-
     priv->checkbox = NULL;
 
+    /* Size group for labels */
     group = GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
 
     gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
 
+    /* Setup and pack domain label */
     priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
-
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                       GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
-
     gtk_widget_show(GTK_WIDGET(priv->domainLabel));
 
 
     if (priv->protection == TRUE) {
-        /* create checkbox */
+        /* Use Change Password Dialog strings */
         priv->pwd1stCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_PASSWORD);
         priv->pwd2ndCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_VERIFY_PASSWORD);
 
+        /* Setup checkbox to enable/disable password protection */
         priv->checkbox = gtk_check_button_new();
-
         gtk_widget_show(priv->checkbox);
-
         priv->checkboxCaption = hildon_caption_new
          (group,
           _(HILDON_SET_MODIFY_PASSWORD_DIALOG_LABEL),
           priv->checkbox,
           NULL, HILDON_CAPTION_OPTIONAL);
        hildon_caption_set_separator(HILDON_CAPTION(priv->checkboxCaption), "");
-
         gtk_signal_connect(GTK_OBJECT(priv->checkbox), "toggled",
                            G_CALLBACK(hildon_checbox_toggled), dialog);
-       
         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                            priv->checkboxCaption, TRUE, TRUE, 0);
         gtk_widget_show(priv->checkboxCaption);
-
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbox),
                                      TRUE);
 
     } else {
+        /* Use Set Password Dialog strings */
         priv->pwd1stCaption_string = _(HILDON_SET_PASSWORD_DIALOG_PASSWORD);
         priv->pwd2ndCaption_string = _(HILDON_SET_PASSWORD_DIALOG_VERIFY_PASSWORD);
     }
 
-
-    /* create tab1 */
+    /* Create the password field */
     priv->pwd1stEntry = gtk_entry_new();
     gtk_widget_show(priv->pwd1stEntry);
-
     priv->pwd1stCaption = hildon_caption_new(group,
                                         priv->pwd1stCaption_string,
                                         priv->pwd1stEntry,
                                         NULL, HILDON_CAPTION_OPTIONAL);
     hildon_caption_set_separator(HILDON_CAPTION(priv->pwd1stCaption), "");
-
     gtk_entry_set_visibility(GTK_ENTRY(priv->pwd1stEntry), FALSE);
-
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                        priv->pwd1stCaption, TRUE, TRUE, 0);
     gtk_widget_show(priv->pwd1stCaption);
 
-    /* create tab2 */
+    /* Create the password verify field */
     priv->pwd2ndEntry = gtk_entry_new();
     gtk_widget_show(priv->pwd2ndEntry);
-
     priv->pwd2ndCaption = hildon_caption_new(group,
                                         priv->pwd2ndCaption_string,
                                         priv->pwd2ndEntry,
                                         NULL, HILDON_CAPTION_OPTIONAL);
     hildon_caption_set_separator(HILDON_CAPTION(priv->pwd2ndCaption), "");
-
     gtk_entry_set_visibility(GTK_ENTRY(priv->pwd2ndEntry), FALSE);
-
     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                        priv->pwd2ndCaption, TRUE, TRUE, 0);
-
     gtk_widget_show(priv->pwd2ndCaption);
 
+    /* Set dialog title */
     gtk_window_set_title(GTK_WINDOW(dialog),
                          _(priv->protection
                            ? HILDON_SET_MODIFY_PASSWORD_DIALOG_TITLE
@@ -313,6 +302,7 @@ hildon_set_password_dialog_constructor(GType type,
     gtk_widget_show(priv->okButton);
     gtk_widget_show(priv->cancelButton);
 
+    /* FIXME: Do not leak size group */
 
     return dialog;
 }
@@ -326,11 +316,12 @@ hildon_set_password_dialog_class_init(HildonSetPasswordDialogClass * class)
 
     parent_class = g_type_class_peek_parent(class);
 
+    /* Override virtual methods */
     object_class->set_property = hildon_set_password_set_property;
     object_class->get_property = hildon_set_password_get_property;
     object_class->constructor = hildon_set_password_dialog_constructor;
 
-
+    /* Install new properties */
     g_object_class_install_property(object_class, 
                     PROP_DOMAIN, 
                     g_param_spec_string ("domain",
@@ -356,11 +347,14 @@ hildon_set_password_dialog_class_init(HildonSetPasswordDialogClass * class)
                                          "DEFAULT",
                                          G_PARAM_READWRITE));
 
+    /* Install private structure */
     g_type_class_add_private(class,
                              sizeof(HildonSetPasswordDialogPrivate));
 }
 
-
+/* FIXME: More code from constructor should be moved here.
+          {get,set}_property currently contain weirdnesses that
+          happen because the needed widgets are not created yet. */
 static void
 hildon_set_password_dialog_init(HildonSetPasswordDialog * dialog)
 {
@@ -371,6 +365,8 @@ hildon_set_password_dialog_init(HildonSetPasswordDialog * dialog)
     priv->protection = FALSE;
 }
 
+/* We come here when response button is clicked and dialog 
+   is used to change existing password. */
 static void
 hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
                                     GtkWindow * parent)
@@ -379,34 +375,38 @@ hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
     GtkEntry *pwd2ndEntry;
     gchar *text1;
     gchar *text2;
-
     HildonNote *note;
     gint i;
-
     HildonSetPasswordDialogPrivate *priv;
 
     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
 
+    /* Password and verification */
     pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
                            (GTK_BIN(priv->pwd1stCaption)));
-
     pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
                            (GTK_BIN(priv->pwd2ndCaption)));
-
     text1 = GTK_ENTRY(pwd1stEntry)->text;
     text2 = GTK_ENTRY(pwd2ndEntry)->text;
+
+    /* User accepted the dialog */
     if (arg1 == GTK_RESPONSE_OK){
+      /* Is the checkbox marked, so password protection is still in use? */  
       if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbox))){
+    /* Yes, Something is given as password as well? */
        if(strcmp(text1, "" ) != 0){
          if(strcmp (text1, text2) == 0){
+           /* Passwords match, so accept change password */
            priv->protection = TRUE;
          } else if(strcmp(text2, "" ) == 0){
+           /* Second field is empty, so show error, but don't clear fields */
            g_signal_stop_emission_by_name(G_OBJECT(dialog),
                                           "response");
            gtk_infoprint (NULL,
                           _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
            gtk_widget_grab_focus(GTK_WIDGET(pwd2ndEntry));
          } else{
+           /* Error: Passwords don't match, so start over */
            g_signal_stop_emission_by_name(G_OBJECT(dialog),
                                           "response");
            gtk_entry_set_text(pwd1stEntry, "");
@@ -416,16 +416,22 @@ hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
            gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
          }
        } else {
+         /* No, the password is empty */
          g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
          if (strcmp(text2, "") == 0) {
+           /* Error: Both fields are empty */
            gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
          } else {
+           /* Error: Second field doesn't match
+              the empty first field, so start over */
            gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
            gtk_entry_set_text(pwd2ndEntry, "");
          }
          gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
        }
       } else{
+       /* No, user wants to remove password protection. 
+       Confirm remove password protection */
        note = HILDON_NOTE(hildon_note_new_confirmation
                           (GTK_WINDOW(dialog),
                            _(HILDON_SET_PASSWORD_DIALOG_REMOVE_PROTECTION
@@ -436,23 +442,29 @@ hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
           _(HILDON_REMOVE_PROTECTION_CONFIRMATION_REMOVE), 
           _(HILDON_REMOVE_PROTECTION_CONFIRMATION_CANCEL));
        
+    /* Display confirmation note */
        i = gtk_dialog_run(GTK_DIALOG(note));
        
        gtk_widget_destroy(GTK_WIDGET(note));
        
        if (i == GTK_RESPONSE_OK)
+         /* Remove password protection */
          priv->protection = FALSE;
        else {
+         /* Remove password protection cancelled */
          priv->protection = TRUE;
          g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
        }
       }
 
     } else {
+      /* Watch out for fading boolean values */
       priv->protection = TRUE;
     }
 }
 
+/* We come here when response button is clicked and dialog 
+   is used to set new password. */
 static void
 hildon_set_password_response_set(GtkDialog * dialog, gint arg1,
                                  GtkWindow * parent)
@@ -466,24 +478,28 @@ hildon_set_password_response_set(GtkDialog * dialog, gint arg1,
 
     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
 
+    /* Password and confirmation */
     pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
                            (GTK_BIN(priv->pwd1stCaption)));
-
     pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
                            (GTK_BIN(priv->pwd2ndCaption)));
-
     text1 = GTK_ENTRY(pwd1stEntry)->text;
     text2 = GTK_ENTRY(pwd2ndEntry)->text;
 
     if (arg1 == GTK_RESPONSE_OK) {
+        /* User provided something for password? */
         if (strcmp (text1, "") != 0) {
             if (strcmp (text1, text2) == 0) {
+               /* Passwords match, so accept set password */
                 priv->protection = TRUE;
             } else if (strcmp (text2, "") == 0) {
+                /* Second field is empty, so show error,
+                   but don't clear the fields */
                 g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
                 gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
                 gtk_widget_grab_focus (GTK_WIDGET (priv->pwd2ndEntry));
             } else {
+                /* Error: Passwords don't match, so start over */
                 g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
                gtk_entry_set_text(pwd1stEntry, "");
                gtk_entry_set_text(pwd2ndEntry, "");
@@ -491,16 +507,21 @@ hildon_set_password_response_set(GtkDialog * dialog, gint arg1,
                 gtk_widget_grab_focus(GTK_WIDGET(priv->pwd1stEntry));
            }
         } else {
-            g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
+          /* First field is empty */
+          g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
          if (strcmp(text2, "") == 0) {
+           /* Error: Both fields are empty */
            gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
          } else {
+           /* Error: Second field doesn't match
+              the empty first field, so start over */
            gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
            gtk_entry_set_text(pwd2ndEntry, "");
          }
          gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
         }
     } else { 
+        /* Watch out for fading boolean values */
         priv->protection = FALSE;
     }            
 }
@@ -513,6 +534,8 @@ static void hildon_checbox_toggled(GtkWidget * widget, gpointer data)
     dialog = HILDON_SET_PASSWORD_DIALOG(data);
     priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
 
+    /* If the user enabled/disabled the password protection feature
+       we enable/disable password entries accordingly */
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd1stEntry), TRUE);
         gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd2ndEntry), TRUE);
@@ -574,6 +597,8 @@ GtkWidget *hildon_set_password_dialog_new(GtkWindow * parent,
         (HILDON_TYPE_SET_PASSWORD_DIALOG, "modify_protection",
          modify_protection, NULL);
 
+    /* Different types of password dialogs use different callbacks */
+    /* FIXME: Why this is done here and not in init/constructor?? */
     if (modify_protection == TRUE) {
         g_signal_connect(G_OBJECT(dialog), "response",
                          G_CALLBACK(hildon_set_password_response_change),
@@ -610,6 +635,8 @@ GtkWidget *hildon_set_password_dialog_new_with_default
 {
     GtkWidget *dialog;
 
+    /* FIXME: Change the simpler generator function to call more
+              complex one, so we can avoid additional g_object_set */
     dialog = hildon_set_password_dialog_new(parent, 
                                            modify_protection);
     if(password != NULL)
@@ -671,6 +698,5 @@ void hildon_set_password_dialog_set_domain(HildonSetPasswordDialog *dialog,
 {
   HildonSetPasswordDialogPrivate *priv =
     HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-  gtk_label_set_text(priv->domainLabel, domain);
-  
+  gtk_label_set_text(priv->domainLabel, domain);  
 }
index 593cfd5..78fa4d1 100644 (file)
@@ -27,7 +27,7 @@
  * 
  * This file contains API for Hildon Sort dialog.
  * @desc: The sort dialog is used to define the order in which item are 
- * shown in a list. Choise lists always display the current value when 
+ * shown in a list. Choice lists always display the current value when 
  * the dialog is opened. 
  *
  */
index b2ab5cb..081abaa 100644 (file)
@@ -63,7 +63,7 @@
 #include <hildon-widgets/hildon-defines.h>
 #include <hildon-widgets/hildon-time-editor.h>
 #include <hildon-widgets/hildon-time-picker.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include ? */
 #include <hildon-widgets/hildon-input-mode-hint.h>
 #include "hildon-composite-widget.h"
 #include "hildon-date-editor.h"
@@ -78,7 +78,7 @@ correctly. (With 12 only one digit would be shown in the entries).
 #define TIME_EDITOR_RBORDER         1
 #define TIME_EDITOR_HEIGHT         28
 #define TIME_EDITOR_CLOCK_BORDER    6
-#define ENTRY_BORDER               2
+#define ENTRY_BORDER                2
 #define ICON_WIDTH                 26
 #define ICON_HEIGHT                26
 #define ICON_PRESSED                4
@@ -90,6 +90,8 @@ correctly. (With 12 only one digit would be shown in the entries).
 #define MIN_DURATION 0
 #define MAX_DURATION (3600 * 99) + (60 * 59) + 59
 
+/* Default values for properties */
+/* FIXME:  _TIME_LOWER/UPPER_VALUEs aren't really used for anything. */
 #define HILDON_TIME_EDITOR_TICKS_VALUE           0
 #define HILDON_TIME_EDITOR_SHOW_SECONDS          TRUE
 #define HILDON_TIME_EDITOR_DURATION_MODE         FALSE
@@ -100,8 +102,8 @@ correctly. (With 12 only one digit would be shown in the entries).
 
 #define HOURS_MAX_24   23
 #define HOURS_MAX_12   12
-#define HOURS_MIN_24   0
-#define HOURS_MIN_12   1
+#define HOURS_MIN_24    0
+#define HOURS_MIN_12    1
 #define MINUTES_MAX 59
 #define SECONDS_MAX 59
 #define MINUTES_MIN 0
@@ -270,7 +272,7 @@ struct _HildonTimeEditorPrivate {
     gboolean ampm_pos_after;    /* is the am/pm shown after others */
     gboolean clock_24h; /* whether to show a 24h clock */
     gboolean am;        /* TRUE == showing am, FALSE == pm */
-    gboolean valid_value; /* If entry has an valid value */
+    gboolean valid_value; /* If entry has an valid value. FIXME: unused */
     
     gboolean validated; /* If the current value has been validated */
 
@@ -407,7 +409,8 @@ hildon_time_editor_class_init(HildonTimeEditorClass * editor_class)
   /**
    * HildonTimeEditor:ticks:
    *
-   * TimeEditor current duration (or time since midnight) value.
+   * If editor is in duration mode, contains the duration seconds.
+   * If not, contains seconds since midnight.
    */
   g_object_class_install_property( object_class, PROP_TICKS,
                                    g_param_spec_uint("ticks",
@@ -420,7 +423,7 @@ hildon_time_editor_class_init(HildonTimeEditorClass * editor_class)
   /**
    * HildonTimeEditor:show_seconds:
    *
-   * TimeEditor show_seconds property.
+   * Controls whether seconds are shown in the editor
    */
   g_object_class_install_property( object_class, PROP_SHOW_SECONDS,
                                    g_param_spec_boolean("show_seconds",
@@ -432,7 +435,7 @@ hildon_time_editor_class_init(HildonTimeEditorClass * editor_class)
   /**
    * HildonTimeEditor:duration_mode:
    *
-   * TimeEditor duration mode indicator.
+   * Controls whether the TimeEditor is in duration mode
    */
   g_object_class_install_property( object_class, PROP_DURATION_MODE,
                                    g_param_spec_boolean("duration_mode",
@@ -444,8 +447,9 @@ hildon_time_editor_class_init(HildonTimeEditorClass * editor_class)
   /**
    * HildonTimeEditor:duration_min:
    *
-   * TimeEditor minimum duration value.
+   * Minimum allowed duration value.
    */
+  /* FIXME: min/max values should be MIN_DURATION/MAX_DURATION */
   g_object_class_install_property( object_class, PROP_DURATION_MIN,
                                    g_param_spec_uint("duration_min",
                                    "Minumum duration value",
@@ -457,7 +461,7 @@ hildon_time_editor_class_init(HildonTimeEditorClass * editor_class)
   /**
    * HildonTimeEditor:duration_max:
    *
-   * TimeEditor maximum duration value.
+   * Maximum allowed duration value.
    */
   g_object_class_install_property( object_class, PROP_DURATION_MAX,
                                    g_param_spec_uint("duration_max",
@@ -477,6 +481,7 @@ void hildon_time_editor_tap_and_hold_setup(GtkWidget * widget,
 {
     HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE(widget);
 
+    /* Forward this tap_and_hold_setup signal to all our child widgets */
     gtk_widget_tap_and_hold_setup(priv->h_entry, menu, func,
                                   GTK_TAP_AND_HOLD_NO_SIGNALS);
     gtk_widget_tap_and_hold_setup(priv->m_entry, menu, func,
@@ -498,6 +503,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
 
     gtk_widget_push_composite_child();
     
+    /* Setup defaults and create widgets */
     priv->ticks = 0;
     priv->show_s = FALSE;
     priv->ampm_pos_after = TRUE;
@@ -526,10 +532,13 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
     gtk_container_add(GTK_CONTAINER(priv->iconbutton), priv->icon);
     gtk_container_add(GTK_CONTAINER(priv->eventbox), priv->ampm);
 
+    /* No frames for entries, so that they all appear to be inside one
+       long entry */
     gtk_entry_set_has_frame(GTK_ENTRY(priv->h_entry), FALSE);
     gtk_entry_set_has_frame(GTK_ENTRY(priv->m_entry), FALSE);
     gtk_entry_set_has_frame(GTK_ENTRY(priv->s_entry), FALSE);
     
+    /* Set H:M:S entries to accept only numeric characters */
     g_object_set (G_OBJECT(priv->h_entry), "input-mode",
                   HILDON_INPUT_MODE_HINT_NUMERIC, NULL);
     g_object_set (G_OBJECT(priv->m_entry), "input-mode", 
@@ -597,6 +606,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
                       G_CALLBACK (hildon_time_editor_entry_changed), 
                       editor);
                       
+    /* Set ourself as the parent of all the widgets we created */
     gtk_widget_set_parent(priv->iconbutton, GTK_WIDGET(editor));
     gtk_widget_set_parent(priv->label, GTK_WIDGET(editor));
 
@@ -606,6 +616,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
     gtk_widget_set_parent(priv->m_entry, GTK_WIDGET(editor));
     gtk_widget_set_parent(priv->h_entry, GTK_WIDGET(editor));
 
+    /* Show created widgets */
     gtk_widget_show(priv->h_entry);
     gtk_widget_show(priv->m_entry);
     gtk_widget_show_all(priv->iconbutton);
@@ -614,13 +625,15 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
     gtk_widget_set_parent(priv->frame, GTK_WIDGET(editor));
     gtk_widget_show_all(priv->frame);
 
-    /* Check if we are in am/pm time locale */
+    /* Update AM/PM settings from locale */
     if (!hildon_time_editor_check_locale(editor)) {
+        /* Using 24h clock */
         priv->clock_24h = FALSE;
         gtk_widget_show_all(priv->eventbox);
     }
 
-    {   /* get current time */
+    /* set the default time to current time. */
+    {
         time_t tm;
         struct tm *stm;
 
@@ -628,6 +641,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
         stm = localtime(&tm);
 
         if (stm) {
+            /* convert current time to ticks */
             ticks = stm->tm_hour * 3600;
             ticks = ticks + stm->tm_min * 60;
             ticks = ticks + stm->tm_sec;
@@ -636,6 +650,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
 
     hildon_time_editor_set_ticks (editor, ticks);
     
+    /* H:M:S fields all take exactly two characters */
     gtk_entry_set_max_length(GTK_ENTRY(priv->h_entry), 2);
     gtk_entry_set_width_chars(GTK_ENTRY(priv->h_entry), 2);
     gtk_entry_set_max_length(GTK_ENTRY(priv->m_entry), 2);
@@ -643,6 +658,7 @@ static void hildon_time_editor_init(HildonTimeEditor * editor)
     gtk_entry_set_max_length(GTK_ENTRY(priv->s_entry), 2);
     gtk_entry_set_width_chars(GTK_ENTRY(priv->s_entry), 2);
 
+    /* Fix appearance */
     hildon_time_editor_add_style();
     gtk_widget_set_name(GTK_WIDGET(priv->iconbutton),
                         "hildon-time-editor-icon");
@@ -721,6 +737,9 @@ hildon_time_editor_mnemonic_activate( GtkWidget *widget,
                                       gboolean group_cycling)
 {
   HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE(widget);
+
+  /* Select hour field when mnemonic is activated
+     FIXME: why? Hildon doesn't even support mnemonics */
   gtk_widget_grab_focus( priv->h_entry );
   gtk_editable_select_region(GTK_EDITABLE(priv->h_entry), 0, 2);
   return TRUE;
@@ -754,6 +773,8 @@ static void hildon_time_editor_finalize(GObject * obj_self)
 
 static void hildon_time_editor_add_style(void)
 {
+    /* We want to make time editor appear like it's inside one GtkEntry
+       field. */
     gtk_rc_parse_string("  style \"hildon-time-editor-icon\" {"
                         "    GtkButton::default_border = { 0, 0, 0, 0 }"
                         "    xthickness = 0"
@@ -768,6 +789,7 @@ static void hildon_time_editor_add_style(void)
                         "    style \"hildon-time-editor-icon\"");
 }
 
+/* Convert ticks to H:M:S. Ticks = seconds since 00:00:00. */
 static void ticks_to_time (guint ticks,
                            guint *hours,
                            guint *minutes,
@@ -813,9 +835,14 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
-    /* Validate the value if it is not already validated */
+    /* Validate the value if it is not already validated.
+       FIXME: We're changing the ticks, it can't have been validated yet!
+       This code is currently validating the previously set ticks, which is
+       wrong. */
     if (!priv->validated) {
         if (priv->duration_mode) {
+            /* Validate duration. If it's too low or too high, set it to
+               min/max value. */
             validation = hildon_time_editor_validate_duration (editor, ticks);
             switch(validation) {
                 case VALIDATION_DURATION_MIN:
@@ -829,10 +856,17 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
                     break;
             }
         } else {
+            /* Check if given time is in valid range. FIXME: Since we're
+               converting to H:M:S from ticks, only hours can be too large.
+               We're also just duplicating the check from validate_time()
+               here, so the call is pretty much useless. */
             ticks_to_time (ticks, &h, &m, &s);
             validation = hildon_time_editor_validate_time (editor, h, m, s, TRUE);
             switch (validation) {
                 case VALIDATION_TIME_HOURS:
+                    /* ticks value was too large. Set hour to maximum allowed.
+                       FIXME: The maximum hour is still 23 here even with 12h
+                       clock. The hour is converted to AM/PM value later. */
                     if (priv->clock_24h) {
                         if (h > HOURS_MAX_24) {
                             h = HOURS_MAX_24;
@@ -849,6 +883,7 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
                     priv->ticks = (3600 * h) + (60 * m) + s;
                     break;
                 case VALIDATION_TIME_MINUTES:
+                    /* FIXME: we never get here */
                     if (m > MINUTES_MAX) {
                         m = MINUTES_MAX;
                     } else if (m < MINUTES_MIN) {
@@ -856,6 +891,7 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
                     }
                     break;
                 case VALIDATION_TIME_SECONDS:
+                    /* FIXME: we never get here */
                     if (s > SECONDS_MAX) {
                         s = SECONDS_MAX;
                     } else if (s < SECONDS_MIN) {
@@ -872,15 +908,19 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
       priv->ticks = ticks;
     }
     
+    /* ticks may have been modified, fix H:M:S variables.
+       FIXME: once is enough.. */
     ticks_to_time (priv->ticks, &h, &m, &s);
     
     ticks_to_time (priv->ticks, &h, &m, &s);
     
     if (!priv->clock_24h && !priv->duration_mode)
       {
+        /* Convert 24h H:M:S values to 12h mode, and update AM/PM state */
         convert_to_12h (&h, &m, &s, &priv->am);
       }
 
+    /* Set H:M:S values to entries */
     g_snprintf(hours,   3, "%02u", h);
     g_snprintf(minutes, 3, "%02u", m);
     g_snprintf(seconds, 3, "%02u", s);
@@ -891,7 +931,7 @@ void hildon_time_editor_set_ticks (HildonTimeEditor * editor,
     priv->valid_value = TRUE;
     priv->validated = FALSE;
 
-    /* set current time (am/pm) */
+    /* Update AM/PM label in case we're in 12h mode */
     gtk_label_set_label(GTK_LABEL(priv->ampm), priv->am ? priv->am_symbol :
                         priv->pm_symbol);
     
@@ -938,6 +978,7 @@ void hildon_time_editor_set_show_seconds (HildonTimeEditor * editor,
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
+    /* show/hide seconds field and its ':' label if the value changed. */
     if (!priv->show_s && show_seconds) {
         priv->show_s = TRUE;
 
@@ -953,6 +994,7 @@ void hildon_time_editor_set_show_seconds (HildonTimeEditor * editor,
     } else
         return;
 
+    /* Our width changed, do a resize. */
     gtk_widget_queue_resize(GTK_WIDGET(editor));
     
     g_object_notify (G_OBJECT (editor), "show_seconds");
@@ -997,29 +1039,33 @@ void hildon_time_editor_set_duration_mode (HildonTimeEditor * editor,
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
-    /* switch to duration editor mode */
     if (duration_mode && !priv->duration_mode) {
+        /* Switch to duration editor mode. */
         priv->duration_mode = duration_mode;
+        /* FIXME: Why do we reset the duration range here? */
         hildon_time_editor_set_duration_range(editor, MIN_DURATION,
                                               MAX_DURATION);
 
+        /* There's no AM/PM label or time picker icon in duration mode.
+           Make sure they're hidden. */
         if (!priv->clock_24h)
             gtk_widget_hide(GTK_WIDGET(priv->ampm));
 
         gtk_widget_hide(GTK_WIDGET(priv->eventbox));
         gtk_widget_hide(GTK_WIDGET(priv->icon));
 
-        /* Show seconds for duration editor */
+        /* Duration mode has seconds by default. */
         hildon_time_editor_set_show_seconds(editor, TRUE);
     }
-    /* switch to time editor mode */
     else if (!duration_mode && priv->duration_mode) {
+        /* Switch to time editor mode. */
         guint ticks;
         time_t tm;
         struct tm *stm;
-            
+
         priv->duration_mode = duration_mode;
 
+        /* Make sure AM/PM label and time picker icons are visible if needed */
         if (!priv->clock_24h)
             gtk_widget_show(GTK_WIDGET(priv->ampm));
 
@@ -1027,13 +1073,15 @@ void hildon_time_editor_set_duration_mode (HildonTimeEditor * editor,
         gtk_widget_show(GTK_WIDGET(priv->icon));
         
 
-        /* Put the ticks to match current time, anything set in the 
-         * duration mode is bound to be invalid or useless in time mode
+       /* Reset the ticks to current time. Anything set in duration mode
+         * is bound to be invalid or useless in time mode.
          */
         
         tm = time(NULL);
         stm = localtime(&tm);
 
+        /* FIXME: stm is practically always non-NULL. Just do
+           guint ticks = 0 above */
         ticks = HILDON_TIME_EDITOR_TIME_LOWER_VALUE;
         
         if (stm) {
@@ -1045,6 +1093,7 @@ void hildon_time_editor_set_duration_mode (HildonTimeEditor * editor,
         hildon_time_editor_set_ticks (editor, ticks);
         
     }
+    /* Our width may have changed, do a resize. */
     gtk_widget_queue_resize(GTK_WIDGET(editor));
     
     g_object_notify (G_OBJECT (editor), "duration_mode");
@@ -1200,8 +1249,8 @@ guint hildon_time_editor_get_duration_max (HildonTimeEditor * editor)
  * @seconds: seconds
  *
  * This function sets the time on an existing time editor. If the
- * time specified by the arguments is invalid, the function returns
- * without doing anything else. The time is assumed to be in 24h format.
+ * time specified by the arguments is invalid, it's fixed.
+ * The time is assumed to be in 24h format.
  *  
  **/
 
@@ -1273,7 +1322,9 @@ void hildon_time_editor_set_duration_range(HildonTimeEditor * editor,
     hildon_time_editor_set_duration_min (editor, min_seconds);
 
     if (priv->duration_mode) {
-        /* Set minimum allowed value for duration editor */
+        /* Set minimum allowed value for duration editor.
+           FIXME: Shouldn't it be changed only if it's not in range?
+           If not, update the API documentation above. */
         hildon_time_editor_set_ticks(editor, min_seconds);
     }
 }
@@ -1309,16 +1360,23 @@ static gboolean hildon_time_editor_check_locale(HildonTimeEditor * editor)
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
+    /* Update AM/PM symbols */
     priv->am_symbol = g_strdup(nl_langinfo(AM_STR));
     priv->pm_symbol = g_strdup(nl_langinfo(PM_STR));
 
     if (!strcmp(priv->am_symbol, ""))
         return TRUE;
     else {
+        /* 12h clock mode. Check if AM/PM should be before or after time.
+           %p is the AM/PM string, so we assume that if the format string
+           begins with %p it's in the beginning, and in any other case it's
+           in the end (although that's not necessarily the case).
+           FIXME: no need to g_strdup() here. */
         t_fm = g_strdup(nl_langinfo(T_FMT_AMPM));
-        /* Check what format am/pm time should be */
         if (!strncmp(t_fm, "%p", 2))
             priv->ampm_pos_after = FALSE;
+
+        /* We want to show AM/PM in lowercase. FIXME: leaks memory. */
         priv->am_symbol =
             g_ascii_strdown((const gchar *) priv->am_symbol, -1);
         priv->pm_symbol =
@@ -1332,6 +1390,14 @@ static gboolean hildon_time_editor_entry_focusin(GtkWidget * widget,
                                                  GdkEventFocus * event, 
                                                  gpointer data)
 {
+    /* If we were trying to move away from a field with invalid value,
+       we get moved back to it. Here we want to select the text in the field.
+       The !button check checks that the entry wasn't focused with a mouse
+       click.
+
+       The selection happens temporarily if we got here with left/right
+       keys, but it gets immediately unselected within same call due to some
+       inner entry/clipboard magic. */
     if (!GTK_ENTRY(widget)->button)
         gtk_editable_select_region(GTK_EDITABLE(widget), 0, 2);
 
@@ -1339,6 +1405,8 @@ static gboolean hildon_time_editor_entry_focusin(GtkWidget * widget,
 }
 
 
+/* Update ticks from current H:M:S entries. If they're invalid, show an
+   infoprint and update the fields unless they're empty. */
 void
 hildon_time_editor_validate (HildonTimeEditor *editor)
 {
@@ -1368,6 +1436,7 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
     /* No empty values thank you */
     if (strlen(GTK_ENTRY(priv->h_entry)->text) == 0)
       {
+        /* Empty hour field */
         if (!priv->duration_mode)
           {
             if (priv->clock_24h)
@@ -1389,11 +1458,13 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                            _("Ckct_ib_set_a_value_within_range"),
                            min_hours, max_hours);
           }
+        /* FIXME: No point in setting the ticks to current value. */
         hildon_time_editor_set_ticks (editor, priv->ticks);
         gtk_widget_grab_focus (priv->h_entry);
       }
     else if (strlen(GTK_ENTRY(priv->m_entry)->text) == 0)
       {
+        /* Empty minute field */
         if (!priv->duration_mode)
           {
             gtk_infoprintf(window,
@@ -1406,11 +1477,13 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                            _("Ckct_ib_set_a_value_within_range"),
                            min_minutes, max_minutes);
           }
+        /* FIXME: No point in setting the ticks to current value. */
         hildon_time_editor_set_ticks (editor, priv->ticks);
         gtk_widget_grab_focus (priv->m_entry);
       }
     else if (strlen(GTK_ENTRY(priv->s_entry)->text) == 0)
       {
+        /* Empty seconds field */
         if (!priv->duration_mode)
           {
             gtk_infoprintf(window,
@@ -1423,10 +1496,10 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                            _("Ckct_ib_set_a_value_within_range"),
                            min_seconds, max_seconds);
           }
+        /* FIXME: No point in setting the ticks to current value. */
         hildon_time_editor_set_ticks (editor, priv->ticks);
         gtk_widget_grab_focus (priv->s_entry);
       }
-    /* Do the validation dance! */
     else 
       {
 
@@ -1436,6 +1509,9 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
       
         if (priv->duration_mode)
           {
+            /* Ensure that duration is in valid range. If it's not, just set
+               it to its min/max value. Too large minute and second values are
+               also just wrapped up. */
             validation = hildon_time_editor_validate_duration (editor,
                                                                h*3600 + m*60 + s);
           
@@ -1460,10 +1536,15 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
           }
         else
           {
+            /* Validate H:M:S values. FIXME: More than one field can be broken,
+               should we update them? Although maybe not needed since focus is
+               moved back to the first broken field, and next validation moves
+               to next field.. */
             validation = hildon_time_editor_validate_time (editor, h, m, s, priv->clock_24h);
             switch (validation)
               {
                 case VALIDATION_TIME_HOURS:
+                  /* At least hour field is too large. */
                   if (priv->clock_24h)
                     {
                       if (h > HOURS_MAX_24)
@@ -1501,6 +1582,7 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                   if (!priv->clock_24h)
                     convert_to_24h (&h, &m, &s, priv->am);
                   hildon_time_editor_set_time (editor, h, m, s);
+                  /* Move focus back to hour field */
                   gtk_widget_grab_focus (priv->h_entry);
                   gtk_editable_select_region(GTK_EDITABLE(priv->h_entry), 0, 2);
                   break;
@@ -1522,6 +1604,7 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                   if (!priv->clock_24h)
                     convert_to_24h (&h, &m, &s, priv->am);
                   hildon_time_editor_set_time (editor, h, m, s);
+                  /* Move focus back to minute field */
                   gtk_widget_grab_focus (priv->m_entry);
                   gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0, 2);
                   break;
@@ -1543,10 +1626,12 @@ hildon_time_editor_validate (HildonTimeEditor *editor)
                   if (!priv->clock_24h)
                     convert_to_24h (&h, &m, &s, priv->am);
                   hildon_time_editor_set_time (editor, h, m, s);
+                  /* Move focus back to second field */
                   gtk_widget_grab_focus (priv->s_entry);
                   gtk_editable_select_region(GTK_EDITABLE(priv->s_entry), 0, 2);
                   break;
                 default:
+                  /* Given time is valid. */
                   if (!priv->clock_24h)
                     {
                       convert_to_24h (&h, &m, &s, priv->am);
@@ -1567,6 +1652,7 @@ static gboolean hildon_time_editor_entry_focusout(GtkWidget * widget,
 
   editor = HILDON_TIME_EDITOR(data);
 
+  /* Validate the given time and update ticks. */
   hildon_time_editor_validate (editor);
 
   return FALSE;
@@ -1586,19 +1672,22 @@ hildon_time_editor_ampm_clicked(GtkWidget * widget,
     editor = HILDON_TIME_EDITOR(data);
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
-    /* validate to set the time and get infoprints
-     * if the user was editing the value
-     */
+    /* First validate the given time and update ticks. */
     hildon_time_editor_validate (editor);
+
+    /* Apply the AM/PM change by moving the current time by 12 hours */
     if (priv->am) {
       if (priv->ticks >= (12*3600))
         {
+          /* FIXME: never reached */
           hildon_time_editor_set_ticks (editor, priv->ticks - 12*3600);
         } else 
         {
+          /* 00:00 .. 11:59 -> 12:00 .. 23:59 */
           hildon_time_editor_set_ticks (editor, priv->ticks + 12*3600);
         }
     } else {
+        /* 12:00 .. 23:59 -> 00:00 .. 11:59 */
         hildon_time_editor_set_ticks (editor, priv->ticks - 12*3600);
     }
     return FALSE;
@@ -1623,6 +1712,7 @@ hildon_time_editor_icon_clicked(GtkWidget * widget, gpointer data)
     if (priv->duration_mode)
         return FALSE;
 
+    /* Launch HildonTimePicker dialog */
     parent = gtk_widget_get_ancestor(GTK_WIDGET(editor), GTK_TYPE_WINDOW);
     picker = hildon_time_picker_new(GTK_WINDOW(parent));
 
@@ -1633,6 +1723,7 @@ hildon_time_editor_icon_clicked(GtkWidget * widget, gpointer data)
     switch (result) {
     case GTK_RESPONSE_OK:
     case GTK_RESPONSE_ACCEPT:
+        /* Use the selected time */
         hildon_time_picker_get_time(HILDON_TIME_PICKER(picker), &h, &m);
         hildon_time_editor_set_time(editor, h, m, 0);
         break;
@@ -1655,7 +1746,10 @@ static gboolean hildon_time_editor_entry_clicked(GtkWidget * widget,
     priv = HILDON_TIME_EDITOR_GET_PRIVATE (editor);
 
     /* If the focus has been grabbed back before the "clicked"
-     * signal gets processed, don't highlight the text
+     * signal gets processed, don't highlight the text.
+     * This happens when input in one H:M:S field is invalid and we're
+     * trying to move to another field. The focus moves back to the invalid
+     * field.
      */
     if (gtk_widget_is_focus (widget))
         gtk_editable_select_region(GTK_EDITABLE(widget), 0, 2);
@@ -1673,11 +1767,16 @@ static void hildon_time_editor_size_request(GtkWidget * widget,
     editor = HILDON_TIME_EDITOR(widget);
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
+    /* Call size_request for each of our child widget. We don't use all of
+       the return values. */
     gtk_widget_size_request(priv->frame, &req);
+    /* FIXME: next line is useless */
     *requisition = req;
 
+    /* Calculate our width. First reserve some space for borders */
     requisition->width = TIME_EDITOR_LBORDER + TIME_EDITOR_RBORDER;
 
+    /* Add each child widget's width */
     gtk_widget_size_request(priv->h_entry, &req);
     requisition->width += req.width;
 
@@ -1690,11 +1789,13 @@ static void hildon_time_editor_size_request(GtkWidget * widget,
     if (priv->iconbutton && GTK_WIDGET_VISIBLE(priv->iconbutton))
     {
         gtk_widget_size_request(priv->iconbutton, &req);
+        /* Hardcoded icon button size.. */
         requisition->width += ICON_WIDTH + ICON_PRESSED + 
                               TIME_EDITOR_CLOCK_BORDER;
     }
 
     if (priv->show_s) {
+        /* Add width for seconds entry + label */
         gtk_widget_size_request(priv->s_entry, &req);
         requisition->width += req.width;
 
@@ -1703,10 +1804,12 @@ static void hildon_time_editor_size_request(GtkWidget * widget,
     }
 
     if (!priv->clock_24h && !priv->duration_mode) {
+        /* Add width for AM/PM label */
         gtk_widget_size_request(priv->eventbox, &req);
         requisition->width += req.width + 4;
     }
 
+    /* Hardcoded height.. */
     requisition->height = TIME_EDITOR_HEIGHT + widget->style->ythickness * 2;
 }
 
@@ -1716,16 +1819,24 @@ static void set_widget_allocation(GtkWidget * widget,
 {
     GtkRequisition child_requisition;
 
+    /* Get this widget's wanted width */
     gtk_widget_get_child_requisition(widget, &child_requisition);
 
+    /* allocation = whole time editor's allocation.
+       alloc = allocation for this one child widget. */
     if (allocation->width + allocation->x >
         alloc->x + child_requisition.width)
+        /* We have enough space */
         alloc->width = child_requisition.width;
     else {
+        /* Not enough space. Give it as much as there's left. If this isn't
+           the rightmost child widget, the rest get zero width. */
         alloc->width = allocation->width - (alloc->x - allocation->x);
         if (alloc->width < 0)
             alloc->width = 0;
     }
+    /* Allocate the widget and update alloc->x to contain the X position
+       for the next child widget. */
     gtk_widget_size_allocate(widget, alloc);
     alloc->x += alloc->width;
 }
@@ -1745,11 +1856,13 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
 
     widget->allocation = *allocation;
 
-    /*Init start values*/
+    /* Set alloc to contain frame's size and position.
+       Leave ythickness pixels of padding at top and bottom */
     alloc.y = widget->allocation.y + widget->style->ythickness;
 
     if (widget->allocation.height > (TIME_EDITOR_HEIGHT +
                                      widget->style->ythickness * 2)) {
+        /* We have more vertical space than needed, move to center */
         alloc.height = TIME_EDITOR_HEIGHT;
         alloc.y +=
             (widget->allocation.height - TIME_EDITOR_HEIGHT) / 2;
@@ -1757,32 +1870,39 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
         alloc.height =
             widget->allocation.height - widget->style->ythickness * 2;
 
+    /* Make sure the height didn't get negative (even padding doesn't fit) */
     if (alloc.height < 0)
         alloc.height = 0;
 
+    /* Get the whole widget's wanted width and set our X position */
     gtk_widget_get_child_requisition(widget, &child_requisition);
     if (allocation->width > child_requisition.width) {
+        /* We have more horizontal space than needed, move to center */
         mod_w = (allocation->width - child_requisition.width) / 2;
         alloc.x = allocation->x + mod_w;
     } else
         alloc.x = allocation->x;
 
 
-    /** frame **/
+    /* FIXME: below check is always true */
     if (priv->frame && GTK_WIDGET_VISIBLE(priv->frame))
     {
+        /* Frame's width is widget's full width minus the space reserved for
+           time picker icon and borders. */
         alloc.width = child_requisition.width -
             TIME_EDITOR_CLOCK_BORDER - ICON_WIDTH - ICON_PRESSED;
         gtk_widget_size_allocate(priv->frame, &alloc);
     }
 
-    /** icon **/
+    /* FIXME: below check is always true (priv->icon may be hidden though) */
     if (priv->iconbutton && GTK_WIDGET_VISIBLE(priv->iconbutton)) {
         gtk_widget_get_child_requisition(priv->iconbutton, 
                 &child_requisition);
 
+        /* Place icon button after time fields and some border */
         child_alloc.x = alloc.x + alloc.width + TIME_EDITOR_CLOCK_BORDER;
 
+        /* Make the icon centered vertically */
         if(alloc.height > ICON_HEIGHT)
             child_alloc.y = alloc.y + (alloc.height - ICON_HEIGHT) / 2 -1;
         else
@@ -1792,24 +1912,33 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
         gtk_widget_size_allocate(priv->iconbutton, &child_alloc);
     }
 
-    /* allocation of child widgets */
+    /* Allocate widgets appearing inside frame.
+       child_alloc.x keeps the position where the next widget should placed.
+       Widget heights start from a constant, but they change a bit:
+
+        - Labels already add ythickness internally, so we give labels that
+          much more height.
+        - For entries we want ENTRY_BORDER amount of padding at top and bottom.
+    */
     child_alloc.x = alloc.x + TIME_EDITOR_LBORDER;
     child_alloc.y = alloc.y;
     child_alloc.height = TIME_EDITOR_HEIGHT;
     child_alloc.width = -1;
 
-    /* am/pm label (when first) */
+    /* Start with AM/PM label when it comes before time */
     if (!priv->duration_mode) {
         if (!priv->clock_24h && !priv->ampm_pos_after)
           {
+            /* FIXME: ythickness modification missing from here */
             set_widget_allocation(priv->eventbox, &child_alloc,
                     &widget->allocation);
           }
     }
 
-    /* hours */
+    /* FIXME: below check is always true */
     if (priv->h_entry && GTK_WIDGET_VISIBLE(priv->h_entry))
       {
+        /* Allocate hours entry. */
         child_alloc.y += ENTRY_BORDER;
         child_alloc.height -= ENTRY_BORDER * 2;
         set_widget_allocation(priv->h_entry, &child_alloc,
@@ -1818,25 +1947,19 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
         child_alloc.height += ENTRY_BORDER * 2;
       }
 
-    /* first separator label */
+    /* FIXME: below check is always true */
     if (priv->label && GTK_WIDGET_VISIBLE(priv->label))
       {
-        /* We'll have to subtract the ythickness from the labels
-         * allocation or it'll be there twice
-         */
+        /* Allocate the label between H:M. */
         child_alloc.y -= widget->style->ythickness;
         set_widget_allocation(priv->label, &child_alloc,
                 &widget->allocation);
         child_alloc.y += widget->style->ythickness;
       }
-    /* minutes */
+    /* FIXME: below check is always true */
     if (priv->m_entry && GTK_WIDGET_VISIBLE(priv->m_entry))
       {
-        /* Entries have a little different allocation requirements
-         * so we'll have to accommodate. This is done per entry
-         * so that the "running" width value of the allocation isn't lost
-         * FIXME: Rearrange this code so it could be done just once
-         */
+        /* Allocate minutes entry. */
         child_alloc.y += ENTRY_BORDER;
         child_alloc.height -= ENTRY_BORDER * 2;
         set_widget_allocation(priv->m_entry, &child_alloc,
@@ -1846,18 +1969,21 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
       }
     
     if (priv->show_s) {
-        /* second separator label */
+        /* Seconds are shown */
+        /* FIXME: below check is always true */
         if (priv->label2)
           {
+            /* Allocate the label between M:S. */
             child_alloc.y -= widget->style->ythickness;
             set_widget_allocation(priv->label2, &child_alloc,
                     &widget->allocation);
             child_alloc.y += widget->style->ythickness;
           }
 
-        /* seconds */
+        /* FIXME: below check is always true */
         if (priv->s_entry)
           {
+            /* Allocate seconds entry. */
             child_alloc.y += ENTRY_BORDER;
             child_alloc.height -= ENTRY_BORDER * 2;
             set_widget_allocation(priv->s_entry, &child_alloc,
@@ -1867,7 +1993,7 @@ static void hildon_time_editor_size_allocate(GtkWidget * widget,
           }
     }
 
-    /* am/pm label (when last) */
+    /* Finish with AM/PM label when it comes after time */
     if (!priv->duration_mode) {
         if (!priv->clock_24h && priv->ampm_pos_after)
           {
@@ -1897,7 +2023,9 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
     pos = gtk_editable_get_position(GTK_EDITABLE(widget));
 
     if (event->keyval == GDK_Return) {
-        /* Check that we have correct values in entries */
+        /* Return key popups up time picker dialog. Visually it looks as if
+           the time picker icon was clicked. Before opening the time picker
+           the fields are first validated and fixed. */
         hildon_time_editor_validate (editor);
         _gtk_button_set_depressed(GTK_BUTTON(priv->iconbutton), TRUE);
         hildon_time_editor_icon_clicked(widget, data);
@@ -1908,7 +2036,10 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
     if  (event->keyval == GDK_KP_Enter)
         return FALSE;
 
-    /* We don't want wrap */
+    /* Left/right keys may move focus to next/previous entry (see below).
+       Here we're disabling wrapping from leftmost entry to rightmost, and
+       vice versa. FIXME: Just delete this code, and the wrapping handling
+       code from below.. */
     if (event->keyval == GDK_KP_Left || event->keyval == GDK_Left) {
         if (pos == 0 && widget == priv->h_entry) {
             return TRUE;
@@ -1926,7 +2057,8 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
         }
     }
 
-    /* numeric key pressed */
+    /* If entry is filled with number hardware key press,
+       validate the entry. */
     if (event->keyval >= GDK_0 && event->keyval <= GDK_9) {
         GtkWidgetClass *c = GTK_WIDGET_GET_CLASS(widget);
 
@@ -2000,6 +2132,8 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
             gtk_widget_grab_focus(priv->s_entry);
             gtk_editable_set_position(GTK_EDITABLE(priv->s_entry), 0);
         } else {
+          /* FIXME: the code is wrapping focus to leftmost entry, but this
+             code path is blocked at the beginning of this function */
             gtk_widget_grab_focus(priv->h_entry);
             gtk_editable_set_position(GTK_EDITABLE(priv->h_entry), 0);
         }
@@ -2009,6 +2143,8 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
     else if (widget == priv->s_entry &&
              (event->keyval == GDK_Right || event->keyval == GDK_KP_Right)
              && pos >= GTK_ENTRY(priv->s_entry)->text_length) {
+      /* FIXME: the code is wrapping focus to leftmost entry, but this
+         code path is blocked at the beginning of this function */
         gtk_widget_grab_focus(priv->h_entry);
         gtk_editable_set_position(GTK_EDITABLE(priv->h_entry), 0);
         return TRUE;
@@ -2017,6 +2153,8 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
     else if (widget == priv->h_entry &&
              (event->keyval == GDK_Left || event->keyval == GDK_KP_Left) &&
              pos <= 0) {
+        /* FIXME: the code is wrapping focus to rightmost entry, but this
+           code path is blocked at the beginning of this function */
         if (priv->show_s) {
             gtk_widget_grab_focus(priv->s_entry);
             gtk_editable_set_position(GTK_EDITABLE(priv->s_entry), -1);
@@ -2043,18 +2181,27 @@ static gboolean hildon_time_editor_entry_keypress(GtkWidget * widget,
         return TRUE;
     }
     /* pass other arrow key presses and backspace and del onwards */
-    else if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left ||
-             event->keyval == GDK_Right || event->keyval == GDK_KP_Right ||
-             event->keyval == GDK_Up || event->keyval == GDK_KP_Up ||
-             event->keyval == GDK_Down || event->keyval == GDK_KP_Down ||
-             event->keyval == GDK_BackSpace || event->keyval == GDK_Delete
-             || event->keyval == GDK_KP_Delete)
+    else if (event->keyval == GDK_Left      ||
+             event->keyval == GDK_KP_Left   ||
+             event->keyval == GDK_Right     ||
+             event->keyval == GDK_KP_Right  ||
+             event->keyval == GDK_Up        ||
+             event->keyval == GDK_KP_Up     ||
+             event->keyval == GDK_Down      ||
+             event->keyval == GDK_KP_Down   ||
+             event->keyval == GDK_BackSpace ||
+             event->keyval == GDK_Delete    ||
+             event->keyval == GDK_KP_Delete)
         return FALSE;   /* pass the keypress on */
 
     /* ingore other keys */
     return TRUE;
 }
 
+
+/* Returns VALIDATION_OK           if ticks is ok,
+           VALIDATION_DURATION_MIN if it's too low,
+           VALIDATION_DURATION_MAX if it's too high. */
 static HildonValidation
 hildon_time_editor_validate_duration (HildonTimeEditor * editor, guint ticks)
 {
@@ -2073,7 +2220,11 @@ hildon_time_editor_validate_duration (HildonTimeEditor * editor, guint ticks)
   return (VALIDATION_OK);
 }
 
-
+/* Returns VALIDATION_OK if given H:M:S values are valid, or
+           VALIDATION_TIME_HOURS,
+           VALIDATION_TIME_MINUTES or
+           VALIDATION_TIME_SECONDS 
+              if some of them contain values out of valid range */
 static HildonValidation
 hildon_time_editor_validate_time (HildonTimeEditor * editor,
                                   guint hours,
@@ -2089,6 +2240,7 @@ hildon_time_editor_validate_time (HildonTimeEditor * editor,
 
   priv->validated = FALSE;
 
+  /* Check that hours are within allowed range (0..12/23) */
   if (mode_24h) {
     if (hours < HOURS_MIN_24 || hours > HOURS_MAX_24)
         return VALIDATION_TIME_HOURS;
@@ -2097,9 +2249,11 @@ hildon_time_editor_validate_time (HildonTimeEditor * editor,
         return VALIDATION_TIME_HOURS;
   }
 
+  /* Check that minutes are within allowed range (0..59) */
   if (minutes < MINUTES_MIN || minutes > MINUTES_MAX)
     return VALIDATION_TIME_MINUTES;
   
+  /* Check that seconds are within allowed range (0..59) */
   if (seconds < SECONDS_MIN || seconds > SECONDS_MAX)
     return VALIDATION_TIME_SECONDS;
 
@@ -2114,6 +2268,9 @@ hildon_time_editor_entry_changed(GtkWidget * widget, gpointer user_data)
 
   editor = HILDON_TIME_EDITOR(user_data);
 
+  /* Do nothing. We can't validate it immediately after each change or
+     eg. changing hour in steps 19->29->22 would give errors in 29 step.
+     FIXME: just remove this function. */
 /*  hildon_time_editor_validate (editor);*/
 }
 
@@ -2135,6 +2292,8 @@ hildon_time_editor_get_max_values(HildonTimeEditor *editor,
 
     priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
 
+    /* Get duration min/max values as H:M:S. These are only used in
+       duration mode. */
     max_hours   = priv->duration_max / 3600;
     max_minutes = (priv->duration_max - (max_hours * 3600)) / 60;
     max_seconds = priv->duration_max - (max_hours * 3600) - (max_minutes * 60);
@@ -2150,6 +2309,9 @@ hildon_time_editor_get_max_values(HildonTimeEditor *editor,
        */
       if (!gtk_widget_is_focus (priv->h_entry))
         {
+          /* Hour field isn't focused, use it for getting min/max mins/seconds.
+             If hour isn't exactly the min/max hour value, the M:S fields
+             are 00:00/59:59 */
           if ((guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->h_entry))) < max_hours)
             {
               max_minutes = 59;
@@ -2163,6 +2325,7 @@ hildon_time_editor_get_max_values(HildonTimeEditor *editor,
         }
       if (!gtk_widget_is_focus (priv->m_entry))
         {
+          /* Minute field isn't focused, use it for getting min/max seconds. */
           if ((guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry))) < max_minutes)
             {
               max_seconds = 59;
@@ -2203,32 +2366,20 @@ hildon_time_editor_get_max_values(HildonTimeEditor *editor,
 static void
 convert_to_12h (guint *h, guint *m, guint *s, gboolean *am)
 {
-  /* 0000 to 0059
-   * add 12 hours
-   */
-  if (*h == 0)
+  if (*h == 0) /* 00:00 to 00:59  add 12 hours */
     {
       *h += 12;
       *am = TRUE;
     }
-  /* 0100 to 1159
-   * straight to am
-   */
-  else if (*h >= 1 && *h < 12)
+  else if (*h >= 1 && *h < 12) /* 01:00 to 11:59  straight to am  */
     {
       *am = TRUE;
     }
-  /* 1200 to 1259
-   * straight to pm
-   */
-  else if (*h >= 12 && *h < 13)
+  else if (*h >= 12 && *h < 13) /* 12:00 to 12:59  straight to pm  */
     {
       *am = FALSE;
     }
-  /* 1300 to 23:59
-   * subtract 12 hours
-   */
-  else if (*h >= 13 && *h < 24 )
+  else if (*h >= 13 && *h < 24 ) /* 13:00 to 23:59  subtract 12 hours */
     {
       *h -= 12;
       *am = FALSE;
@@ -2238,17 +2389,11 @@ convert_to_12h (guint *h, guint *m, guint *s, gboolean *am)
 static void
 convert_to_24h (guint *h, guint *m, guint *s, gboolean am)
 {
-  /* 12 midnight - 12:59 AM
-   * subtract 12 hours
-   */
-  if (*h == 12 && am)
+  if (*h == 12 && am) /* 12 midnight - 12:59 AM  subtract 12 hours  */
     {
       *h -= 12;
     }
-  /* 1:00 PM - 11:59 AM
-   * add 12 hours
-   */
-  else if (!am && *h >= 1 && *h < 12)
+  else if (!am && *h >= 1 && *h < 12)    /* 1:00 PM - 11:59 AM   add 12 hours */
     {
       *h += 12;
     }
index 92a5806..b3ecc46 100644 (file)
@@ -110,7 +110,7 @@ struct _HildonTimePickerPrivate
   gchar *pm_symbol;
 
   guint key_repeat;
-  guint minutes;
+  guint minutes; /* time in minutes since midnight */
   gint mul;
   guint timer_id;
 
@@ -123,7 +123,7 @@ struct _HildonTimePickerPrivate
 enum
 {
   PROP_MINUTES = 1,
-  PROP_AMPM
+  PROP_AMPM /* FIXME: unused */
 };
 
 
@@ -221,12 +221,13 @@ hildon_time_picker_class_init( HildonTimePickerClass *klass )
   /**
    * HildonTimePicker:minutes:
    *
-   * Currently selected minutes.
+   * Currently selected time in minutes since midnight.
    */
   g_object_class_install_property( gobject_class, PROP_MINUTES,
                                    g_param_spec_uint("minutes",
                                      "Current minutes",
-                                     "The selected minutes",
+                                     "The selected time in minutes "
+                                     "since midnight",
                                      0, 1440, 0,
                                      G_PARAM_READABLE | G_PARAM_WRITABLE) );
 
@@ -265,11 +266,14 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
 
   gtk_widget_push_composite_child();
 
+  /* Pack all our internal widgets into a table */
   priv->child[TABLE] = gtk_table_new( 3, 6, FALSE );
   table = GTK_TABLE(priv->child[TABLE]);
 
+  /* Put everything centered into window */
   maintocenter = gtk_alignment_new( 0.5, 0, 0, 0 );
 
+  /* Create our internal widgets */
   for( i = FRAME_HOURS; i <= FRAME_LMINUTES; i++ )
   {
     priv->child[i] = gtk_frame_new( NULL );
@@ -284,13 +288,17 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
 
   for( i = LABEL_HOURS; i <= LABEL_LMINUTES; i++ )
   {
+    /* minute fields are "0" initially */
     priv->child[i] = gtk_label_new( "0" );
+    /* Add 1 pixel of padding on top and bottom of labels */
     gtk_misc_set_padding( GTK_MISC( priv->child[i] ), 0, 1 );
     gtk_widget_set_name( priv->child[i], "osso-LargeFont" );
   }
 
+  /* Hour field defaults to "00" */
   gtk_label_set_text (GTK_LABEL (priv->child[LABEL_HOURS]), "00");
 
+  /* Label between hour and minutes */
   priv->child[LABEL_COLON] = gtk_label_new(_("Ecdg_ti_time_picker_separator"));
   gtk_widget_set_name( priv->child[LABEL_COLON], "osso-LargeFont" );
 
@@ -301,40 +309,34 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
   priv->timer_id = 0;
   priv->button_press = FALSE;
 
-  /* Load locales */
+  /* Get AM/PM strings from locale. If they're set, the time is wanted
+     in 12 hour mode. */
   priv->am_symbol = nl_langinfo(AM_STR);
   priv->pm_symbol = nl_langinfo(PM_STR);
 
   priv->c12h = priv->am_symbol[0] == '\0' ? FALSE : TRUE;
 
+  /* Get current time for initializing fields */
   stamp = time( NULL );
   local = localtime( &stamp );
 
-  gtk_table_attach( table, priv->child[BUTTON_HOURS_UP], 1, 2, 0, 1,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[FRAME_HOURS], 1, 2, 1, 2,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[BUTTON_HOURS_DOWN], 1, 2, 2, 3,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[LABEL_COLON], 2, 3, 1, 2,
-                    GTK_SHRINK, GTK_SHRINK, 6, 0 );
-  gtk_table_attach( table, priv->child[BUTTON_MMINUTES_UP], 3, 4, 0, 1,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[FRAME_MMINUTES], 3, 4, 1, 2,
-                    GTK_FILL, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[BUTTON_MMINUTES_DOWN], 3, 4, 2, 3,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-
-  gtk_table_attach( table, priv->child[BUTTON_LMINUTES_UP], 4, 5, 0, 1,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[FRAME_LMINUTES], 4, 5, 1, 2,
-                    GTK_FILL, GTK_SHRINK, 0, 0 );
-  gtk_table_attach( table, priv->child[BUTTON_LMINUTES_DOWN], 4, 5, 2, 3,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  /* Pack widgets into table */
+  gtk_table_attach( table, priv->child[BUTTON_HOURS_UP],      1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[FRAME_HOURS],          1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[BUTTON_HOURS_DOWN],    1, 2, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[LABEL_COLON],          2, 3, 1, 2, GTK_SHRINK, GTK_SHRINK, 6, 0 );
+  gtk_table_attach( table, priv->child[BUTTON_MMINUTES_UP],   3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[FRAME_MMINUTES],       3, 4, 1, 2, GTK_FILL,   GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[BUTTON_MMINUTES_DOWN], 3, 4, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[BUTTON_LMINUTES_UP],   4, 5, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[FRAME_LMINUTES],       4, 5, 1, 2, GTK_FILL,   GTK_SHRINK, 0, 0 );
+  gtk_table_attach( table, priv->child[BUTTON_LMINUTES_DOWN], 4, 5, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
 
   gtk_table_set_row_spacing( table, 0, 6 );
   gtk_table_set_row_spacing( table, 1, 6 );
 
+  /* Put minute labels and buttons into same size group, so they each have
+     the exact same horizontal width. */
   size_group = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );
   gtk_size_group_add_widget( size_group, priv->child[BUTTON_MMINUTES_UP] );
   gtk_size_group_add_widget( size_group, priv->child[FRAME_MMINUTES] );
@@ -348,12 +350,20 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
   {
     GtkWidget *ampmtotop = NULL;
     guint placement = 0;
+
+    /* 12h clock mode. Check if AM/PM should be before or after time.
+       %p is the AM/PM string, so we assume that if the format string
+       begins with %p it's in the beginning, and in any other case it's
+       in the end (although that's not necessarily the case). */
     priv->ampm_pos = strncmp(nl_langinfo(T_FMT_AMPM), "%p", 2) ? TRUE : FALSE;
+    /* Show the AM/PM label centered vertically */
     ampmtotop = gtk_alignment_new( 0, 0.5, 0, 0 );
     priv->child[FRAME_AMPM] = gtk_frame_new( NULL );
     priv->child[EBOX_AMPM] = gtk_event_box_new();
     priv->child[LABEL_AMPM] = gtk_label_new( priv->pm_symbol );
 
+    /* Pack AM/PM widgets. If AM/PM is before time, pack them into table
+       position 0..1. If it's after time, pack to 5..6 */
     placement = priv->ampm_pos * 5;
 
     gtk_container_add( GTK_CONTAINER(ampmtotop), priv->child[FRAME_AMPM] );
@@ -365,6 +375,7 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
                       GTK_SHRINK, GTK_SHRINK, 0, 0 );
     gtk_table_set_col_spacing( table, placement - 1, 6 );
 
+    /* Connect AM/PM signal handlers */
     g_signal_connect( G_OBJECT(priv->child[EBOX_AMPM]), "button-release-event",
                       (GCallback)hildon_time_picker_ampm_release, picker );
     g_signal_connect( G_OBJECT(priv->child[EBOX_AMPM]), "focus-out-event",
@@ -379,6 +390,7 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
                       (GCallback)hildon_time_picker_event_box_key_press,
                       picker );
 
+    /* Set AM/PM evenbox focusable */
     g_object_set( G_OBJECT(priv->child[EBOX_AMPM]), "can-focus", TRUE, NULL );
     gtk_widget_set_events( priv->child[EBOX_AMPM],
                            GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK );
@@ -389,11 +401,14 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
 
   gtk_widget_pop_composite_child();
 
+  /* Set default time to current time */
   hildon_time_picker_set_time( picker, local->tm_hour, local->tm_min );
 
+  /* Get button press repeater timeout from settings (in milliseconds) */
   settings = gtk_settings_get_default();
   g_object_get( settings, "gtk-update-timeout", &priv->key_repeat, NULL );
 
+  /* Handle hour and minute fields */
   for( i = 0; i < 3; i++ )
   {
     gtk_container_add( GTK_CONTAINER(priv->child[FRAME_HOURS + i]),
@@ -424,6 +439,7 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
                          "hildon-time-picker-down" );
   }
 
+  /* Handle hour/minute up/down buttons */
   for( i = BUTTON_HOURS_UP; i <= BUTTON_LMINUTES_DOWN; i++ )
   {
     g_object_set( G_OBJECT(priv->child[i]), "can-focus", FALSE, NULL );
@@ -435,6 +451,7 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
                       (GCallback)hildon_time_picker_arrow_release, picker );
   }
 
+  /* Handle hour/minute eventboxes */
   for( i = EBOX_HOURS; i <= EBOX_LMINUTES; i++ )
   {
     g_object_set( G_OBJECT(priv->child[i]), "can-focus", TRUE, NULL );
@@ -444,7 +461,9 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
                            GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK );
   }
 
+  /* This dialog isn't modal */
   gtk_window_set_modal( GTK_WINDOW(dialog), FALSE );
+  /* And final dialog packing */
   gtk_dialog_set_has_separator( dialog, FALSE );
   gtk_dialog_add_button( dialog, _("ecdg_bd_time_picker_close"),
                          GTK_RESPONSE_OK );
@@ -452,6 +471,7 @@ static void hildon_time_picker_init( HildonTimePicker *picker )
   gtk_container_add( GTK_CONTAINER(maintocenter), priv->child[TABLE] );
   gtk_box_pack_start( GTK_BOX(dialog->vbox), maintocenter, TRUE, FALSE, 0 );
 
+  /* FIXME: no point in setting the time to its current value */
   hildon_time_picker_change_time (picker, priv->minutes);
 
   gtk_widget_show_all( maintocenter );
@@ -500,8 +520,10 @@ hildon_time_picker_map( GtkWidget *widget )
   gint i;
   HildonTimePickerPrivate *priv = HILDON_TIME_PICKER(widget)->priv;
 
+  /* Widget is now mapped. Set border for the dialog. */
   gdk_window_set_decorations( widget->window, GDK_DECOR_BORDER );
 
+  /* Update hour/minute up/down buttons sizes from style properties */
   gtk_widget_style_get( widget,
                         "arrow-width", &width,
                         "arrow-height", &height, NULL );
@@ -516,6 +538,7 @@ static gboolean
 hildon_time_picker_event_box_press( GtkWidget *widget,  GdkEventKey *event,
                                     gpointer data )
 {
+  /* Clicked hour/minute field. Move focus to it. */
   gtk_widget_grab_focus( widget );
   return FALSE;
 }
@@ -524,6 +547,7 @@ static gboolean
 hildon_time_picker_ampm_release( GtkWidget *widget, GdkEvent *event,
                                  HildonTimePicker *picker )
 {
+  /* Clicked AM/PM label. Move focus to it and move the time by 12 hours. */
   gtk_widget_grab_focus( widget );
   hildon_time_picker_change_time( picker, picker->priv->minutes > 720 ?
                                   picker->priv->minutes - 720 :
@@ -538,11 +562,15 @@ hildon_time_picker_arrow_press( GtkWidget *widget, GdkEvent *event,
   HildonTimePickerPrivate *priv = picker->priv;
   gint newval = 0;
 
+  /* Make sure we don't add repeat timer twice. Normally it shouldn't
+     happen but WM can cause button release to be lost. */
   if( priv->button_press )
     return FALSE;
 
   priv->start_key_repeat = priv->button_press = TRUE;
 
+  /* Move the focus to field whose arrow was clicked, and get the minute
+     change multiplier. */
   if( widget == priv->child[BUTTON_HOURS_UP] )
   {
     priv->mul = 60;
@@ -574,11 +602,14 @@ hildon_time_picker_arrow_press( GtkWidget *widget, GdkEvent *event,
     gtk_widget_grab_focus( priv->child[EBOX_LMINUTES] );
   }
 
+  /* Change the time now, wrapping if needed. */
   newval = priv->minutes + priv->mul;
   if( newval < 0 )
     newval += 1440;
 
   hildon_time_picker_change_time( picker, newval );
+  /* Keep changing the time as long as button is being pressed.
+     The first repeat takes 3 times longer to start than the rest. */
   priv->timer_id = g_timeout_add( priv->key_repeat * 3, hildon_time_picker_timeout, picker );
   return FALSE;
 }
@@ -590,6 +621,7 @@ hildon_time_picker_arrow_release( GtkWidget *widget, GdkEvent *event,
   HildonTimePickerPrivate *priv = picker->priv;
   if( priv->timer_id )
   {
+    /* Stop repeat timer */
     g_source_remove( priv->timer_id );
     priv->timer_id = 0;
   }
@@ -601,6 +633,7 @@ static gboolean
 hildon_time_picker_event_box_focus_in( GtkWidget *widget, GdkEvent *event,
                                        gpointer data )
 {
+  /* Draw the widget in selected state so focus shows clearly. */
   gtk_widget_set_state( widget, GTK_STATE_SELECTED );
   return FALSE;
 }
@@ -609,6 +642,7 @@ static gboolean
 hildon_time_picker_event_box_focus_out( GtkWidget *widget, GdkEvent *event,
                                         gpointer data )
 {
+  /* Draw the widget in normal state */
   gtk_widget_set_state( widget, GTK_STATE_NORMAL );
   return FALSE;
 }
@@ -619,20 +653,24 @@ hildon_time_picker_event_box_key_press( GtkWidget *widget, GdkEventKey *event,
 {
   HildonTimePickerPrivate *priv = picker->priv;
 
+  /* If mouse button is already being pressed, ignore this keypress */
   if( priv->timer_id )
     return TRUE;
 
+  /* Handle keypresses in hour/minute/AMPM fields */
   switch( event->keyval )
   {
     case GDK_Up:
       if( widget == priv->child[EBOX_HOURS] )
       {
+        /* Fake a hour button up press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_HOURS_UP], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_HOURS_UP], GTK_STATE_SELECTED );
       }
       else if( widget == priv->child[EBOX_MMINUTES] )
       {
+        /* Fake a 10-minute button up press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_MMINUTES_UP], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_MMINUTES_UP],
@@ -640,18 +678,21 @@ hildon_time_picker_event_box_key_press( GtkWidget *widget, GdkEventKey *event,
       }
       else if( widget == priv->child[EBOX_LMINUTES] )
       {
+        /* Fake a minute button up press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_LMINUTES_UP], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_LMINUTES_UP],
                               GTK_STATE_SELECTED );
       }
       else
+        /* Fake a AM/PM button release */
         hildon_time_picker_ampm_release( priv->child[EBOX_AMPM], NULL, picker );
       return TRUE;
 
     case GDK_Down:
       if( widget == priv->child[EBOX_HOURS] )
       {
+        /* Fake a hour button down press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_HOURS_DOWN], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_HOURS_DOWN],
@@ -659,6 +700,7 @@ hildon_time_picker_event_box_key_press( GtkWidget *widget, GdkEventKey *event,
       }
       else if( widget == priv->child[EBOX_MMINUTES] )
       {
+        /* Fake a 10-minute button down press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_MMINUTES_DOWN], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_MMINUTES_DOWN],
@@ -666,16 +708,20 @@ hildon_time_picker_event_box_key_press( GtkWidget *widget, GdkEventKey *event,
       }
       else if( widget == priv->child[EBOX_LMINUTES] )
       {
+        /* Fake a minute button down press */
         hildon_time_picker_arrow_press( priv->child[BUTTON_LMINUTES_DOWN], NULL,
                                         picker );
         gtk_widget_set_state( priv->child[BUTTON_LMINUTES_DOWN],
                               GTK_STATE_SELECTED );
       }
       else
+        /* Fake a AM/PM button release */
         hildon_time_picker_ampm_release( priv->child[EBOX_AMPM], NULL, picker );
       return TRUE;
 
     case GDK_Left:
+      /* If we're in leftmost field, stop this keypress signal.
+         Otherwise let the default key handler move focus to field in left. */
       if( priv->c12h )
       {
         if( !priv->ampm_pos )
@@ -692,6 +738,8 @@ hildon_time_picker_event_box_key_press( GtkWidget *widget, GdkEventKey *event,
     break;
 
     case GDK_Right:
+      /* If we're in rightmost field, stop this keypress signal.
+         Otherwise let the default key handler move focus to field in right. */
       if( priv->c12h )
       {
         if( priv->ampm_pos )
@@ -724,6 +772,7 @@ hildon_time_picker_event_box_key_release( GtkWidget *widget, GdkEventKey *event,
 {
   gint i;
 
+  /* Fake a button release if in key-press handler we faked a button press. */
   switch( event->keyval )
   {
     case GDK_Up:
@@ -741,30 +790,37 @@ hildon_time_picker_event_box_key_release( GtkWidget *widget, GdkEventKey *event,
   return FALSE;
 }
 
+/* Button up/down is being pressed. Update the time. */
 static gboolean
-hildon_time_picker_timeout( gpointer data )
+hildon_time_picker_timeout( gpointer data )/* FIXME: use meaningful name */
 {
   HildonTimePicker *picker = NULL;
   HildonTimePickerPrivate *priv = NULL;
   gint newval = 0;
 
+  /* FIXME: the following condition never occurs */
+  /* luc: function should check its parameters. Otherwise document the use of the function "parameter must not be NULL". */
   if( !data )
     return FALSE;
 
   picker = HILDON_TIME_PICKER(data);
   priv = picker->priv;
 
+  /* FIXME: the following condition never occurs */
   if( !picker->priv->timer_id )
     return FALSE;
 
+  /* Change the time, wrapping if needed */
   newval = priv->minutes + priv->mul;
   if( newval < 0 )
-    newval += 1440;
+    newval += 1440;/*FIXME: document, or use 24*60 if this is the case */
 
   hildon_time_picker_change_time( picker, newval );
 
   if( priv->start_key_repeat )
   {
+    /* This is the first repeat. Shorten the timeout to key_repeat
+       (instead of the first time's 3*key_repeat) */
     priv->timer_id = g_timeout_add( priv->key_repeat, hildon_time_picker_timeout, picker );
     priv->start_key_repeat = FALSE;
     return FALSE;
@@ -783,24 +839,31 @@ hildon_time_picker_change_time( HildonTimePicker *picker, guint minutes )
   guint hours = 0;
   gboolean ampm = TRUE;
 
+  /* If the minutes isn't in valid range, wrap them. */
   minutes %= 1440;
 
   if( priv->minutes == minutes )
     return;
 
+  /* Minutes changed. Update widgets to show the new time. */
   priv->minutes = minutes;
 
   if( priv->c12h )
   {
+    /* am < 12:00 (720 minutes) <= pm */
     ampm = !((guint)(minutes / 720));
+    /* 12:00 - 23:59 -> 00:00 - 11:59 */
     minutes %= 720;
     if( minutes < 60 )
+      /* 00:mm is always shown as 12:mm */
       minutes += 720;
 
+    /* Update the AM/PM label */
     gtk_label_set_text( GTK_LABEL(priv->child[LABEL_AMPM]),
                         ampm ? priv->am_symbol : priv->pm_symbol );
   }
 
+  /* Update hour and minute fields */
   hours = minutes / 60;
   minutes %= 60;
 
index dd02eb1..b804996 100644 (file)
@@ -33,11 +33,12 @@ typedef struct _HildonVolumebarPrivate HildonVolumebarPrivate;
 struct _HildonVolumebarPrivate {
   HildonVolumebarRange *volumebar;
 
-  GtkOrientation orientation;
-  GtkOrientation ownorientation;
+  GtkOrientation orientation;   /* Orientation of range *//* FIXME: XXX This isn't needed */
+  GtkOrientation ownorientation;/* Orientation of widget *//* FIXME: XXX This isn't needed */
+
   GtkToggleButton *tbutton;
 
-  gboolean is_toolbar;
+  gboolean is_toolbar;/* Is inside toolbar (for horizontal volumebar) */
 };
 
 #endif /* __HILDON_VOLUMEBAR_PRIVATE__ */
index c4f3ad4..97ec6e3 100644 (file)
@@ -31,7 +31,7 @@
  *
  * Purpose of this widget is to act as an "container" for GtkScale
  * widget. #HildonVolumebarRange changes some event parameters so
- * that #HildonVolumebar can meet it's specifications.
+ * that #HildonVolumebar can meet its specifications.
  *
  * Currently #HildonVolumebarRange models range of [0..100].
  * 
@@ -139,7 +139,7 @@ hildon_volumebar_range_class_init(HildonVolumebarRangeClass *
 static void 
 hildon_volumebar_range_init(HildonVolumebarRange * volumerange)
 {
-   
+  /* stepper_a = "less", stepper_d = "more" */
   GTK_RANGE(volumerange)->has_stepper_a = TRUE;
   GTK_RANGE(volumerange)->has_stepper_d = TRUE;
   
@@ -186,6 +186,7 @@ static
 gboolean hildon_volumebar_range_keypress(GtkWidget * widget,
                                          GdkEventKey * event)
 {
+    /* Accept arrow keys only if they match the orientation of the widget */
     if (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL)
       {
         if (event->keyval == GDK_Up || event->keyval == GDK_Down) {
@@ -219,7 +220,7 @@ hildon_volumebar_range_new(GtkOrientation orientation)
 
     GTK_RANGE(self)->orientation = orientation;
 
-    /* invert vertical range */
+    /* Default vertical range is upside down for purposes of this widget */
     gtk_range_set_inverted(GTK_RANGE(self),
                            (orientation == GTK_ORIENTATION_VERTICAL));
 
@@ -264,7 +265,8 @@ hildon_volumebar_range_button_press_event(GtkWidget * widget,
 {
     gboolean result = FALSE;
 
-    event->button = event->button == 1 ? 2 : event->button;
+    /* FIXME: Ugly hack to trick GtkRange event handler */
+    event->button = (event->button == 1) ? 2 : event->button;
     if (GTK_WIDGET_CLASS(parent_class)->button_press_event) {
         result =
             GTK_WIDGET_CLASS(parent_class)->button_press_event(widget,
@@ -280,6 +282,7 @@ hildon_volumebar_range_button_release_event(GtkWidget * widget,
 {
     gboolean result = FALSE;
 
+    /* FIXME: Ugly hack to trick GtkRange event handler */
     event->button = event->button == 1 ? 2 : event->button;
     if (GTK_WIDGET_CLASS(parent_class)->button_release_event) {
         result =
index 526cd65..1c03a5a 100644 (file)
@@ -205,7 +205,8 @@ hildon_volumebar_init(HildonVolumebar * volumebar)
        GtkContainer */
     GTK_WIDGET_SET_FLAGS(GTK_WIDGET(volumebar), GTK_NO_WINDOW);
     GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(volumebar), GTK_CAN_FOCUS);
-    
+
+    /* Initialize mute button */
     priv->tbutton = GTK_TOGGLE_BUTTON(gtk_toggle_button_new());
     g_object_set (G_OBJECT (priv->tbutton), "can-focus", FALSE, NULL);
 }
@@ -223,9 +224,11 @@ hildon_child_forall(GtkContainer * container,
 
     g_return_if_fail(callback != NULL);
 
+    /* No external children */
     if (!include_internals)
         return;
 
+    /* Execute callback for both internals */
     (*callback) (GTK_WIDGET(priv->tbutton), callback_data);
     (*callback) (GTK_WIDGET(priv->volumebar), callback_data);
 }
@@ -263,6 +266,7 @@ hildon_volumebar_set_property(GObject * object,
 
     switch (prop_id) {
     case PROP_HILDON_HAS_MUTE:
+        /* Mute button always exists, but might be hidden */
         if (g_value_get_boolean(value))
             gtk_widget_show(GTK_WIDGET(priv->tbutton));
         else
@@ -344,9 +348,6 @@ hildon_volumebar_set_level(HildonVolumebar * self, gdouble level)
 
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(self);
    
-    /* No need to clamp the level to legal values here as volumebarrange
-     * will do it anyway. And here we don't know the correct values anyway.
-     */
     hildon_volumebar_range_set_level(priv->volumebar, level);
 }
 
@@ -356,7 +357,7 @@ hildon_volumebar_set_level(HildonVolumebar * self, gdouble level)
  *
  * Gets the volumelevel of this #HildonVolumebar.
  *
- * Return value: Volume level.
+ * Return value: Volume level or -1 on error.
  **/
 gdouble 
 hildon_volumebar_get_level(HildonVolumebar * self)
@@ -387,13 +388,15 @@ hildon_volumebar_set_mute(HildonVolumebar * self, gboolean mute)
     g_return_if_fail(self);
 
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(self);
+
+    /* Slider should be insensitive when mute is on */
     gtk_widget_set_sensitive(GTK_WIDGET(priv->volumebar), !mute);
     
     focusable = GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (priv->volumebar));
     
     if (mute){   
         if (focusable){
-
+           /* Make mute button focusable since the slider isn't anymore */
             g_object_set (G_OBJECT (priv->tbutton), "can-focus", TRUE, NULL);
             gtk_widget_grab_focus (GTK_WIDGET(priv->tbutton));
         }
@@ -402,16 +405,19 @@ hildon_volumebar_set_mute(HildonVolumebar * self, gboolean mute)
     {
         g_object_set (G_OBJECT (priv->tbutton), "can-focus", FALSE, NULL);
         
+       /* Mute off grabs focus */
         if (focusable){
             gtk_widget_grab_focus (GTK_WIDGET (self));
         }
         else{
+           /* If volumebar is not focusable, focus the parent window instead */
             GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (self), 
                                                       GTK_TYPE_WINDOW);
             gtk_window_set_focus (GTK_WINDOW (win), NULL);
         }
     }
 
+    /* Update mute button state and redraw */
     gtk_toggle_button_set_active(priv->tbutton, mute);
 
     gtk_widget_queue_draw (GTK_WIDGET (self));
@@ -466,7 +472,6 @@ hildon_volumebar_get_adjustment (HildonVolumebar * self)
 static void
 mute_toggled (HildonVolumebar *self)
 {
-  /* only call hildon_volumebar_set_mute. everything is done there */
   hildon_volumebar_set_mute (self, hildon_volumebar_get_mute(self));
 }
 
@@ -480,7 +485,8 @@ hildon_volumebar_key_press (GtkWidget * widget,
     g_return_val_if_fail(event, FALSE);
 
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(widget);
-    
+
+    /* Enter key toggles mute button (unless it is hidden) */
     if (event->keyval == GDK_Return && GTK_WIDGET_VISIBLE(priv->tbutton)) {
         gtk_toggle_button_set_active(priv->tbutton, 
                 !hildon_volumebar_get_mute(HILDON_VOLUMEBAR(widget)));
index a65b12e..2be073d 100644 (file)
 #include "hildon-volumebar-range.h"
 #include "hildon-volumebar-private.h"
 
+/* Volume bar */
 #define DEFAULT_BAR_WIDTH               58
 #define MINIMUM_BAR_HEIGHT             165
+/* Toggle button */
 #define DEFAULT_VERTICAL_TBUTTON_WIDTH  26
 #define DEFAULT_VERTICAL_TBUTTON_HEIGHT 26
 #define DEFAULT_ENDING_SIZE             20
+/* Gap to leave for mute button */
 #define HORIZONTAL_MUTE_GAP             16
 #define VERTICAL_MUTE_GAP                6
 
@@ -121,7 +124,6 @@ static void vvolumebar_init(HildonVVolumebar * vvolumebar)
                              vvolumebar);
     g_signal_connect(G_OBJECT(priv->tbutton), "toggled",
                      G_CALLBACK(hildon_vvolumebar_mute), vvolumebar);
-    /* end here */
 
     gtk_widget_show(GTK_WIDGET(priv->volumebar));
 }
@@ -145,6 +147,7 @@ static gboolean hildon_vvolumebar_expose(GtkWidget * widget,
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
     
     if (GTK_WIDGET_DRAWABLE(widget)) {
+        /* Paint background */
         gtk_paint_box(widget->style, widget->window,
                       GTK_WIDGET_STATE(priv->volumebar), GTK_SHADOW_OUT,
                       NULL, widget, "background",
@@ -153,6 +156,7 @@ static gboolean hildon_vvolumebar_expose(GtkWidget * widget,
                       widget->allocation.width,
                       widget->allocation.height);
 
+       /* The contents of the widget can paint themselves */
         (*GTK_WIDGET_CLASS(parent_class)->expose_event) (widget, event);
     }
 
@@ -179,6 +183,7 @@ hildon_vvolumebar_size_allocate(GtkWidget * widget,
     vbar = HILDON_VOLUMEBAR(widget);
     priv = HILDON_VOLUMEBAR_GET_PRIVATE(vbar);
 
+    /* Center the widget horizontally */
     if (allocation->width > DEFAULT_BAR_WIDTH) {
         allocation->x +=
          (allocation->width - DEFAULT_BAR_WIDTH) / 2;
@@ -188,6 +193,7 @@ hildon_vvolumebar_size_allocate(GtkWidget * widget,
     widget->allocation = *allocation;
 
     if (priv->volumebar && GTK_WIDGET_VISIBLE(priv->volumebar)) {
+        /* Allocate space for the slider */
         range_allocation.x = allocation->x;
         range_allocation.y = allocation->y + DEFAULT_ENDING_SIZE;
 
@@ -195,6 +201,7 @@ hildon_vvolumebar_size_allocate(GtkWidget * widget,
         
         if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton))
         {
+           /* Leave room for the mute button */
             range_allocation.height = MAX(0,
                                           allocation->height
                                           - 2 * DEFAULT_ENDING_SIZE
@@ -214,6 +221,7 @@ hildon_vvolumebar_size_allocate(GtkWidget * widget,
     }
     
     if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton)) {
+        /* Allocate space for the mute button */
         button_allocation.x = allocation->x + HORIZONTAL_MUTE_GAP;
         button_allocation.y = allocation->y + allocation->height -
                               VERTICAL_MUTE_GAP - 2 * DEFAULT_ENDING_SIZE;
index a5d5023..9e32ca1 100644 (file)
  *
  */
 
-/*
- * TODO:
- * - Must check if graphics should be added to widgets weekday
- *   buttons
- *
- */
-
-/* HILDON DOC
- * @shortdesc: Weekday Picker is a widget for selecting weekdays
- * @longdesc: Weekday Picker is a widget for selecting weekdays. 
- * It shows seven toggle buttons that can have state on or off.
- *
- * @seealso: #HildonTimePicker
- */
-
  /* GDate numbers days from 1 to 7 and G_DATE_MONDAY is 1st day. However
     according to locale settings first day is sunday. To get around this
     problem, we addjust GDate days numbering to be same as locale
@@ -73,30 +58,23 @@ typedef struct _HildonWeekdayPickerPrivate HildonWeekdayPickerPrivate;
 
 static void
 hildon_weekday_picker_class_init(HildonWeekdayPickerClass * picker_class);
-
 static void 
 hildon_weekday_picker_init(HildonWeekdayPicker * picker);
-
 static void
 hildon_weekday_picker_size_allocate(GtkWidget * widget,
                                     GtkAllocation * allocation);
-
 static void
 hildon_weekday_picker_size_request(GtkWidget * widget,
                                    GtkRequisition * requisition);
-
 static void
 hildon_weekday_picker_forall(GtkContainer * container,
                              gboolean include_internals,
                              GtkCallback callback, gpointer callback_data);
-
 static void
 hildon_weekday_picker_destroy(GtkObject * self);
-
 static gboolean
 hildon_weekday_picker_mnemonic_activate(GtkWidget *widget,
                                         gboolean group_cycling);
-
 static void
 button_toggle(GtkToggleButton * togglebutton, gpointer data);
 
@@ -149,6 +127,7 @@ hildon_weekday_picker_class_init(HildonWeekdayPickerClass * picker_class)
     g_type_class_add_private(picker_class,
                              sizeof(HildonWeekdayPickerPrivate));
 
+    /* Override virtual methods */
     widget_class->mnemonic_activate = hildon_weekday_picker_mnemonic_activate;
     widget_class->size_request = hildon_weekday_picker_size_request;
     widget_class->size_allocate = hildon_weekday_picker_size_allocate;
@@ -157,6 +136,7 @@ hildon_weekday_picker_class_init(HildonWeekdayPickerClass * picker_class)
     GTK_OBJECT_CLASS(picker_class)->destroy =
         hildon_weekday_picker_destroy;
 
+    /* Create a signal for reporting user actions */
     signals[SELECTION_CHANGED_SIGNAL] = g_signal_new("selection_changed",
                                                 G_OBJECT_CLASS_TYPE
                                                 (object_class),
@@ -187,6 +167,7 @@ hildon_weekday_picker_init(HildonWeekdayPicker * picker)
     /* Check our first weekday */
     day = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
 
+    /* Use localized short names for weekdays */
     wdays[1] = nl_langinfo(ABDAY_1);
     wdays[2] = nl_langinfo(ABDAY_2);
     wdays[3] = nl_langinfo(ABDAY_3);
@@ -197,6 +178,7 @@ hildon_weekday_picker_init(HildonWeekdayPicker * picker)
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* Initialize and pack day buttons */
     for (i = 1; i <= 7; i++) {
         priv->buttons[i] = gtk_toggle_button_new_with_label(wdays[day]);
         priv->dayorder[i] = day++;
@@ -215,6 +197,8 @@ hildon_weekday_picker_init(HildonWeekdayPicker * picker)
     }
 
     GTK_WIDGET_SET_FLAGS(picker, GTK_NO_WINDOW);
+
+    /* FIXME: Do not leak sizegroup */
 }
 
 /**
@@ -229,6 +213,7 @@ GtkWidget *hildon_weekday_picker_new(void)
     return g_object_new(HILDON_WEEKDAY_PICKER_TYPE, NULL);
 }
 
+/* FIXME: mnemonic actionvation is no longer used by hildon libraries */
 static gboolean
 hildon_weekday_picker_mnemonic_activate(GtkWidget *widget,
                                         gboolean group_cycling)
@@ -253,9 +238,11 @@ hildon_weekday_picker_forall(GtkContainer * container,
     picker = HILDON_WEEKDAY_PICKER(container);
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* We only have internal children */
     if (!include_internals)
         return;
 
+    /* Activate callback for each day button */
     for (i = 1; i <= 7; ++i) {
         (*callback) (priv->buttons[i], callback_data);
     }
@@ -270,6 +257,7 @@ hildon_weekday_picker_destroy(GtkObject * self)
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(self);
 
+    /* Destroy internal children... */
     for (i = 1; i <= 7; ++i) {
       if (priv->buttons[i])
       {
@@ -278,6 +266,7 @@ hildon_weekday_picker_destroy(GtkObject * self)
       }
     }
 
+    /* ... and chain to parent. */
     if (GTK_OBJECT_CLASS(parent_class)->destroy)
         GTK_OBJECT_CLASS(parent_class)->destroy(self);
 
@@ -297,6 +286,8 @@ hildon_weekday_picker_size_request(GtkWidget * widget,
     requisition->width = 0;
     requisition->height = 0;
 
+    /* Request an area that is as wide as all of the buttons
+       together and tall enough to hold heightest button */
     for (i = 1; i <= 7; ++i) {
         gtk_widget_size_request(priv->buttons[i], &req);
         requisition->width += req.width;
@@ -334,6 +325,8 @@ hildon_weekday_picker_size_allocate(GtkWidget * widget,
         sval = 1;
     else
         sval = 7;
+
+    /* Allocate day buttons side by side honouring the text direction */
     for (i = 1; i <= 7; ++i) {
         gtk_widget_get_child_requisition(priv->buttons[sval],
                                          &child_requisition);
@@ -351,6 +344,7 @@ hildon_weekday_picker_size_allocate(GtkWidget * widget,
     }
 }
 
+/* FIXME: rewrite this */
 static void
 button_toggle(GtkToggleButton * button, gpointer data)
 {
@@ -365,6 +359,7 @@ button_toggle(GtkToggleButton * button, gpointer data)
     picker = HILDON_WEEKDAY_PICKER(data);
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* FIXME: this is just copy paste from several other places */
     for (i = 1; i <= 7; ++i) {
         if (GTK_WIDGET(button) == priv->buttons[i]) {
             priv->days ^= wdays[i];
@@ -378,9 +373,9 @@ button_toggle(GtkToggleButton * button, gpointer data)
 /**
  * hildon_weekday_picker_set_day:
  * @picker: the @HildonWeekdayPicker widget
- * @day: Day to be set
+ * @day: Day to be set active
  *
- * Select specified weekday.
+ * Set specified weekday active.
  */
 void 
 hildon_weekday_picker_set_day(HildonWeekdayPicker * picker,
@@ -395,11 +390,15 @@ hildon_weekday_picker_set_day(HildonWeekdayPicker * picker,
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* Adjust between GDate and locale (shift one day),
+       FIXME: would be more elegant to use GDate as internal representation */
     if (day == G_DATE_SUNDAY)
         day = G_DATE_MONDAY;
     else
         day++;
 
+    /* FIXME: this is just copy paste from several other places
+              the above also! */
     for (i = 1; i <= 7; i++) {
         if (priv->dayorder[i] == day) {
             if (!(priv->days & wdays[i]))
@@ -412,9 +411,9 @@ hildon_weekday_picker_set_day(HildonWeekdayPicker * picker,
 /**
  * hildon_weekday_picker_unset_day:
  * @picker: the @HildonWeekdayPicker widget
- * @day: Day to be unset
+ * @day: Day to be set inactive 
  *
- * Unselect specified weekday.
+ * Set specified weekday inactive.
  */
 void 
 hildon_weekday_picker_unset_day(HildonWeekdayPicker * picker,
@@ -429,11 +428,15 @@ hildon_weekday_picker_unset_day(HildonWeekdayPicker * picker,
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* Adjust between GDate and locale (shift one day),
+       FIXME: would be more elegant to use GDate as internal representation */
     if (day == G_DATE_SUNDAY)
         day = G_DATE_MONDAY;
     else
         day++;
 
+    /* FIXME: this is just copy paste from several other places
+              the above also! */
     for (i = 1; i <= 7; i++) {
         if (priv->dayorder[i] == day) {
             if (priv->days & wdays[i])
@@ -463,11 +466,15 @@ hildon_weekday_picker_toggle_day(HildonWeekdayPicker * picker,
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* Adjust between GDate and locale (shift one day),
+       FIXME: would be more elegant to use GDate as internal representation */
     if (day == G_DATE_SUNDAY)
         day = G_DATE_MONDAY;
     else
         day++;
 
+    /* FIXME: this is just copy paste from several other places
+              the above also! */
     for (i = 1; i <= 7; i++) {
         if (priv->dayorder[i] == day) {
             is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
@@ -483,7 +490,7 @@ hildon_weekday_picker_toggle_day(HildonWeekdayPicker * picker,
  * hildon_weekday_picker_set_all:
  * @picker: the @HildonWeekdayPicker widget
  *
- * Set all weekdays.
+ * Set all weekdays active.
  */
 void 
 hildon_weekday_picker_set_all(HildonWeekdayPicker * picker)
@@ -496,6 +503,7 @@ hildon_weekday_picker_set_all(HildonWeekdayPicker * picker)
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* FIXME: this is just copy paste from several other places */
     for (i = 1; i <= 7; i++) {
         if (!(priv->days & wdays[i]))
             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
@@ -507,7 +515,7 @@ hildon_weekday_picker_set_all(HildonWeekdayPicker * picker)
  * hildon_weekday_picker_unset_all:
  * @picker: the @HildonWeekdayPicker widget
  *
- * Unset all weekdays.
+ * Set all weekdays inactive.
  */
 void 
 hildon_weekday_picker_unset_all(HildonWeekdayPicker * picker)
@@ -520,6 +528,7 @@ hildon_weekday_picker_unset_all(HildonWeekdayPicker * picker)
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* FIXME: this is just copy paste from several other places */
     for (i = 1; i <= 7; i++) {
         if (priv->days & wdays[i])
             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
@@ -528,13 +537,13 @@ hildon_weekday_picker_unset_all(HildonWeekdayPicker * picker)
 }
 
 /**
- * hildon_weekday_picker_set_all:
+ * hildon_weekday_picker_isset_day:
  * @picker: the @HildonWeekdayPicker widget
  * @day: Day to be checked.
  *
- * Check if the specified weekday is set.
+ * Check if the specified weekday is set active.
  *
- * Return value: TRUE if the day is set. 
+ * Return value: TRUE if the day is set, FALSE is day is not set.
  */
 gboolean 
 hildon_weekday_picker_isset_day(HildonWeekdayPicker * picker,
@@ -548,11 +557,15 @@ hildon_weekday_picker_isset_day(HildonWeekdayPicker * picker,
 
     priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
 
+    /* Adjust between GDate and locale (shift one day),
+       FIXME: would be more elegant to use GDate as internal representation */
     if (day == G_DATE_SUNDAY)
         day = G_DATE_MONDAY;
     else
         day++;
 
+    /* FIXME: this is just copy paste from several other places
+              the above also! */
     for (i = 1; i <= 7; i++) {
         if ( priv->dayorder[i] == day && 
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
index 2685854..0190080 100644 (file)
@@ -112,21 +112,32 @@ hildon_wizard_dialog_class_init(HildonWizardDialogClass *
     g_type_class_add_private(wizard_dialog_class,
                              sizeof(HildonWizardDialogPrivate));
 
+    /* Override virtual methods */
     object_class->set_property = hildon_wizard_dialog_set_property;
     object_class->get_property = hildon_wizard_dialog_get_property;
     object_class->finalize = hildon_wizard_dialog_finalize;
 
+    /**
+     * HildonWizardDialog:wizard-name:
+     *
+     * The name of the wizard.
+     */
     g_object_class_install_property(object_class, PROP_WIZARD_NAME,
         g_param_spec_string("wizard-name",
                             "Wizard Name",
-                            "Set the HildonWizardDialog name",
+                            "The name of the HildonWizardDialog",
                             NULL,
                             G_PARAM_READWRITE));
 
+    /**
+     * HildonWizardDialog:wizard-notebook:
+     *
+     * The notebook object, which is used by the HildonWizardDialog.
+     */
     g_object_class_install_property(object_class, PROP_WIZARD_NOTEBOOK,
         g_param_spec_object("wizard-notebook",
                             "Wizard Notebook",
-                            "Set the GtkNotebook to be used in the "
+                            "GtkNotebook object to be used in the "
                               "HildonWizardDialog",
                             GTK_TYPE_NOTEBOOK, G_PARAM_READWRITE));
 }
@@ -140,49 +151,56 @@ static void hildon_wizard_dialog_finalize(GObject * object)
 
 static void hildon_wizard_dialog_init(HildonWizardDialog * wizard_dialog)
 {
+    /* Initialize private structure for faster member access */
     HildonWizardDialogPrivate *priv =
         G_TYPE_INSTANCE_GET_PRIVATE(wizard_dialog,
                                     HILDON_TYPE_WIZARD_DIALOG,
                                     HildonWizardDialogPrivate);
     GtkDialog *dialog = GTK_DIALOG(wizard_dialog);
+
+    /* Init internal widgets */
     GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
-    
     gtk_dialog_set_has_separator(dialog, FALSE);
-
     wizard_dialog->priv = priv;
     priv->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
     priv->image = gtk_image_new_from_icon_name("qgn_widg_wizard",
                                               HILDON_ICON_SIZE_WIDG_WIZARD);
+
+    /* Default values for user provided properties */
     priv->notebook = NULL;
     priv->wizard_name = NULL;
 
+    /* Build wizard layout */
     gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox),
                                 GTK_WIDGET(priv->box));
     gtk_box_pack_start_defaults(GTK_BOX(priv->box), GTK_WIDGET(vbox));
     gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(priv->image), FALSE, FALSE, 0);
 
+    /* Initialize cancel button */
     gtk_dialog_add_button(dialog, _("Ecdg_bd_wizard_cancel"),
                           HILDON_WIZARD_DIALOG_CANCEL);
 
+    /* Initialize previous button */
     priv->previous_button =
         gtk_button_new_with_label(_("Ecdg_bd_wizard_previous"));
     gtk_box_pack_start(GTK_BOX(dialog->action_area),
                        priv->previous_button, FALSE, TRUE, 0);
-
     g_signal_connect(priv->previous_button, "clicked",
                      G_CALLBACK(direction_button_clicked), wizard_dialog);
 
+    /* Initialize next button */
     priv->next_button =
         gtk_button_new_with_label(_("Ecdg_bd_wizard_next"));
     gtk_box_pack_start(GTK_BOX(dialog->action_area),
                        priv->next_button, FALSE, TRUE, 0);
-
     g_signal_connect(priv->next_button, "clicked",
                      G_CALLBACK(direction_button_clicked), wizard_dialog);
 
+    /* Initialize finish button */
     gtk_dialog_add_button(dialog, _("Ecdg_bd_wizard_finish"),
                           HILDON_WIZARD_DIALOG_FINISH);
 
+    /* Set initial button states */
     gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard_dialog),
                                       HILDON_WIZARD_DIALOG_FINISH,
                                       FALSE);
@@ -200,20 +218,29 @@ hildon_wizard_dialog_set_property(GObject * object, guint property_id,
 
     switch (property_id) {
     case PROP_WIZARD_NAME:
+
+        /* Set new wizard name. This name will appear in titlebar */
         if (priv->wizard_name)
             g_free(priv->wizard_name);
         priv->wizard_name = g_strdup((gchar *) g_value_get_string(value));
+
+        /* We need notebook in order to create title, since page information
+           is used in title generation */
         if (priv->notebook)
             hildon_wizard_dialog_create_title(HILDON_WIZARD_DIALOG
                                               (object));
         break;
     case PROP_WIZARD_NOTEBOOK:
         priv->notebook = GTK_NOTEBOOK(g_value_get_object(value));
+
+        /* Set the default properties for the notebook (disable tabs,
+         * and remove borders) to make it look like a nice wizard widget */
         gtk_notebook_set_show_tabs(priv->notebook, FALSE);
         gtk_notebook_set_show_border(priv->notebook, FALSE);
         gtk_box_pack_start_defaults(GTK_BOX(priv->box),
                                     GTK_WIDGET(priv->notebook));
-        
+
+        /* Update dialog title to reflact current page stats etc */        
         if (priv->wizard_name)
             hildon_wizard_dialog_create_title(HILDON_WIZARD_DIALOG
                                               (object));
@@ -252,22 +279,24 @@ hildon_wizard_dialog_create_title(HildonWizardDialog * wizard_dialog)
     gchar *str = NULL;
     HildonWizardDialogPrivate *priv = wizard_dialog->priv;
     GtkNotebook *notebook = priv->notebook;
-    /*
-    const gchar *step = _("step");
-    const gchar *welcome = _("Welcome");
-    const gchar *wizard_completed = _("Wizard completed");
-    */
+
     if (!notebook)
         return;
+
+    /* Get page information, we'll need that when creating title */
     pages = gtk_notebook_get_n_pages(notebook);
     current = gtk_notebook_get_current_page(priv->notebook);
     if (current < 0)
         current = 0;
 
+    /* the welcome title on the initial page */
     if (current == 0) {
         str = g_strdup_printf(_("Ecdg_ti_wizard_welcome"), 
                               priv->wizard_name, pages);
     } else if (current + 1 == pages) {
+
+        /* Other pages contain step information. 
+           FIXME: why the follwing two blocks are identical */
         gchar *steps = (gchar *) gtk_notebook_get_tab_label_text(notebook,
             gtk_notebook_get_nth_page(notebook, current));
         str = g_strdup_printf(_("Ecdg_ti_wizard_step"), 
@@ -278,25 +307,19 @@ hildon_wizard_dialog_create_title(HildonWizardDialog * wizard_dialog)
         str = g_strdup_printf(_("Ecdg_ti_wizard_step"), 
                               priv->wizard_name, current + 1, pages, steps);
     }
-    /*
-    if (current == 0)
-        str = g_strdup_printf("%s %s %d/%d %s", priv->wizard_name, step,
-                              current + 1, pages, welcome);
-    else if (current + 1 == pages)
-        str = g_strdup_printf("%s %s %d/%d %s",
-                              priv->wizard_name, step, current + 1, pages,
-                              wizard_completed);
-    else {
-        gchar *steps = (gchar *) gtk_notebook_get_tab_label_text(notebook,
-            gtk_notebook_get_nth_page(notebook, current));
-        str = g_strdup_printf("%s %s %d/%d: %s", priv->wizard_name, step,
-                              current + 1, pages, steps);
-    }
-    */
+
+    /* Update the dialog to display the generated title */
     gtk_window_set_title(GTK_WINDOW(wizard_dialog), str);
     g_free(str);
 }
 
+/* This function is called when next/previous buttons are clicked.
+   We dim buttons based on our new page.
+
+   FIXME: Why on earth these buttons are not response buttos like
+          other buttons in action area?? Now they cannot be conveniently
+          dimmed.
+*/
 static void direction_button_clicked(GtkWidget *widget,
                                      HildonWizardDialog *wizard_dialog)
 {
@@ -305,10 +328,13 @@ static void direction_button_clicked(GtkWidget *widget,
     gint current = 0;
     gint last = gtk_notebook_get_n_pages(notebook) - 1;
 
+    /* Previous button clicked, we probably are on the first page now */
     if (widget == priv->previous_button)
     {
         gtk_notebook_prev_page(notebook);
         current = gtk_notebook_get_current_page(notebook);
+
+        /* If we are on the first page, we disable previous button. */
         if (current == 0)
         {
             gtk_widget_set_sensitive(priv->previous_button, FALSE);
@@ -317,13 +343,21 @@ static void direction_button_clicked(GtkWidget *widget,
                  HILDON_WIZARD_DIALOG_FINISH,
                  FALSE);
         }
+
+        /* We want next button to be enabled, unless this is also
+           our last (and only) page. */
         if (current != last)
             gtk_widget_set_sensitive(priv->next_button, TRUE);
     }
-    else /* Next button */
+    else /* handle the "Next" button */
     {
+        /* Move forward */
         gtk_notebook_next_page(notebook);
         current = gtk_notebook_get_current_page(notebook);
+
+        /* If we actually moved somewhere else than to the first page,
+           we allow user to go backwards and also finish the dialog.
+           FIXME: Is this the desired behaviour? */
         if (gtk_notebook_get_current_page(notebook) != 0)
         {
             gtk_widget_set_sensitive(priv->previous_button, TRUE);
@@ -332,14 +366,19 @@ static void direction_button_clicked(GtkWidget *widget,
                  HILDON_WIZARD_DIALOG_FINISH,
                  TRUE);
         }
+
+        /* If we ended up to the last page, going forward must be disabled */
         if (current == last)
             gtk_widget_set_sensitive(priv->next_button, FALSE);
     }
 
+    /* We show the default image on first and last pages */
     if (current == last || current == 0)
         gtk_widget_show(GTK_WIDGET(priv->image));
     else
         gtk_widget_hide(GTK_WIDGET(priv->image));
+
+    /* New page number may appear in the title, update it */
     hildon_wizard_dialog_create_title(wizard_dialog);
 }
 
@@ -361,6 +400,7 @@ GtkWidget *hildon_wizard_dialog_new(GtkWindow * parent,
     GtkWidget *widget;
 
     g_return_val_if_fail(GTK_IS_NOTEBOOK(notebook), NULL);
+
     widget = GTK_WIDGET(g_object_new(HILDON_TYPE_WIZARD_DIALOG,
                                      "wizard-name", wizard_name,
                                      "wizard-notebook", notebook, NULL));