2005-08-17 Tommi Komulainen <tommi.komulainen@nokia.com>
authorTommi Komulainen <tommi.komulainen@nokia.com>
Wed, 17 Aug 2005 15:18:33 +0000 (15:18 +0000)
committerTommi Komulainen <tommi.komulainen@nokia.com>
Wed, 17 Aug 2005 15:18:33 +0000 (15:18 +0000)
* hildon-widgets/hildon-calendar-popup.c (MAX_YEAR, MIN_YEAR):
* hildon-widgets/hildon-note.c (ELLIPSATION_STRING, BOX_SPAXING):
* hildon-widgets/hildon-volumebar-range.c (CHANGE_THRESHOLD):
Use defines rather than magic numbers in the code.

ChangeLog
hildon-widgets/hildon-calendar-popup.c
hildon-widgets/hildon-note.c
hildon-widgets/hildon-volumebar-range.c

index 5ad4b0a..95b92b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2005-08-17  Tommi Komulainen  <tommi.komulainen@nokia.com>
 
+       * hildon-widgets/hildon-calendar-popup.c (MAX_YEAR, MIN_YEAR):
+       * hildon-widgets/hildon-note.c (ELLIPSATION_STRING, BOX_SPAXING):
+       * hildon-widgets/hildon-volumebar-range.c (CHANGE_THRESHOLD):
+       Use defines rather than magic numbers in the code.
+
+2005-08-17  Tommi Komulainen  <tommi.komulainen@nokia.com>
+
        Update to new l10n packaging style.  po-files (inside this package)
        are not used for now, the message catalogs come from separate packages
        and including them here would conflict.
index 0021dcf..1ce04b1 100644 (file)
@@ -47,6 +47,9 @@
 #include <hildon-widgets/hildon-calendar-popup.h>
 #include <hildon-widgets/gtk-infoprint.h>
 
+#define MAX_YEAR 2100
+#define MIN_YEAR 1980
+
 #define _(String) dgettext(PACKAGE, String)
 
 #define HILDON_CALENDAR_POPUP_GET_PRIVATE(obj) \
@@ -309,14 +312,14 @@ init_dmy(guint year, guint month, guint day, guint * d, guint * m,
 {
     GDate date;
 
-    if (year > 2100) {
+    if (year > MAX_YEAR) {
         *d = 31;
         *m = 12;
-        *y = 2100;
-    } else if (year < 1980) {
+        *y = MAX_YEAR;
+    } else if (year < MIN_YEAR) {
         *d = 1;
         *m = 1;
-        *y = 1980;
+        *y = MIN_YEAR;
     } else if (!g_date_valid_dmy(day, month, year)) {
         g_date_clear(&date, 1);
         g_date_set_time(&date, time(NULL));
index 7b3e4e7..e9fd2c3 100644 (file)
@@ -70,6 +70,9 @@
 #define HILDON_NOTE_CONFIRMATION_ICON        "qgn_note_confirm"
 #define HILDON_NOTE_INFORMATION_ICON         "qgn_note_info"
 
+#define ELLIPSATION_STRING "\342\200\246"
+#define BOX_SPACING 10
+
 /* Not exactly sure what this actually _should_ be, because there is
    practically no documentation for the ESD... */
 
@@ -207,7 +210,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
                 line = pango_layout_get_line(layout, 0);
                 templine = g_strndup(lines[last_line], line->length);
                 g_free(lines[last_line]);
-                lines[last_line] = g_strconcat(templine, "\342\200\246", NULL);
+                lines[last_line] = g_strconcat(templine, ELLIPSATION_STRING, NULL);
                 g_free(templine);
             }
 
@@ -218,7 +221,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
                 gchar *tempresult;
                 PangoLayout *ellipsis = pango_layout_new(context);
 
-                pango_layout_set_text(ellipsis, "\342\200\246", -1);
+                pango_layout_set_text(ellipsis, ELLIPSATION_STRING, -1);
                 pango_layout_get_size(ellipsis, &ellipsiswidth, NULL);
                 pango_layout_xy_to_index(layout,
                                          max_width * PANGO_SCALE -
@@ -227,7 +230,7 @@ hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
                 g_object_unref(G_OBJECT(ellipsis));
                 tempresult = g_strndup(lines[last_line], index);
                 lines[last_line] = g_strconcat(tempresult,
-                                               "\342\200\246",
+                                               ELLIPSATION_STRING,
                                                NULL);
                 g_free(tempresult);
             }
@@ -291,7 +294,7 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
         line = pango_layout_get_line(layout, 0);
         templine = g_strndup(str, line->length);
         g_free(str);
-        str = g_strconcat(templine, "\342\200\246", NULL);
+        str = g_strconcat(templine, ELLIPSATION_STRING, NULL);
         g_free(templine);
     }
 
@@ -302,7 +305,7 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
         gchar *tempresult;
         PangoLayout *ellipsis = pango_layout_new(context);
 
-        pango_layout_set_text(ellipsis, "\342\200\246", -1);
+        pango_layout_set_text(ellipsis, ELLIPSATION_STRING, -1);
         pango_layout_get_size(ellipsis, &ellipsiswidth, NULL);
         pango_layout_xy_to_index(layout,
                                  max_width * PANGO_SCALE -
@@ -311,7 +314,7 @@ hildon_note_one_line_truncate(const HildonNote * note, const gchar * text)
         g_object_unref(G_OBJECT(ellipsis));
         tempresult = g_strndup(str, index);
         str = g_strconcat(tempresult,
-                          "\342\200\246",
+                          ELLIPSATION_STRING,
                           NULL);
         g_free(tempresult);
     }
@@ -685,7 +688,7 @@ hildon_note_create_form(GtkDialog * dialog, GtkWidget * item,
     }
 
     if (IsHorizontal) {
-        priv->box = gtk_hbox_new(FALSE, 10);
+        priv->box = gtk_hbox_new(FALSE, BOX_SPACING);
         gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
 
         if (item) {
@@ -697,7 +700,7 @@ hildon_note_create_form(GtkDialog * dialog, GtkWidget * item,
         gtk_box_pack_start(GTK_BOX(priv->box), priv->label, FALSE, FALSE, 0);
 
     } else {
-        priv->box = gtk_vbox_new(FALSE, 10);
+        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);
 
index 5183798..c4f3ad4 100644 (file)
@@ -52,6 +52,8 @@
 #define VOLUMEBAR_RANGE_PAGE_INCREMENT_VALUE 5.0
 #define VOLUMEBAR_RANGE_PAGE_SIZE_VALUE 0.0
 
+#define CHANGE_THRESHOLD 0.001
+
 static GtkScaleClass *parent_class;
 
 static void hildon_volumebar_range_class_init(HildonVolumebarRangeClass *  
@@ -246,7 +248,7 @@ hildon_volumebar_range_set_level(HildonVolumebarRange * self,
 
     /* Check that value is actually changed. Note that it's not safe to
      * just compare if floats are equivalent or not */
-    if (ABS(GTK_RANGE (self)->adjustment->value - newlevel) > 0.001) {
+    if (ABS(GTK_RANGE (self)->adjustment->value - newlevel) > CHANGE_THRESHOLD) {
         /* This might be a bit faster because this skips
         * gtkadjustment's own clamping and check if value has
         * indeed changed. */