From: Alejandro PiƱeiro Date: Thu, 4 Sep 2008 13:51:36 +0000 (+0000) Subject: 2008-09-04 Alejandro Pinheiro X-Git-Tag: 2.1.66-1~535 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=f44bcd99fcfd07bbc770b94ce71e83f240089121;p=hildon 2008-09-04 Alejandro Pinheiro * src/hildon-time-selector.c Define gettext auxiliar macro N_ (_create_minutes_model) (_create_hours_model) (_create_ampm_model): use of strftime in order to fill the model * src/hildon-date-selector.c (hildon_date_selector_finalize): (_locales_init): remove the logic related to get the name of the months using nl_langinfo, as it is not required anymore (_create_day_model) (_create_year_model) (_create_month_model) (_update_day_model): use of strftime in order to fill the model properly --- diff --git a/ChangeLog b/ChangeLog index b146c4b..ba6a102 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-09-04 Alejandro Pinheiro + + * src/hildon-time-selector.c + Define gettext auxiliar macro N_ + (_create_minutes_model) + (_create_hours_model) + (_create_ampm_model): use of strftime in order to fill the model + * src/hildon-date-selector.c + (hildon_date_selector_finalize): + (_locales_init): remove the logic related to get the name of the months + using nl_langinfo, as it is not required anymore + (_create_day_model) + (_create_year_model) + (_create_month_model) + (_update_day_model): use of strftime in order to fill the model properly + + 2008-09-04 Alberto Garcia * src/hildon-button.h diff --git a/src/hildon-date-selector.c b/src/hildon-date-selector.c index f0acfb9..05b9c84 100644 --- a/src/hildon-date-selector.c +++ b/src/hildon-date-selector.c @@ -87,8 +87,6 @@ struct _HildonDateSelectorPrivate gint creation_day; gint creation_month; gint creation_year; /* date at creation time */ - - gchar *monthname[12]; }; static void hildon_date_selector_finalize (GObject * object); @@ -273,14 +271,9 @@ static void hildon_date_selector_finalize (GObject * object) { HildonDateSelector *selector = NULL; - gint i = 0; selector = HILDON_DATE_SELECTOR (object); - for (i = 0; i < 12; i++) { - g_free (selector->priv->monthname[i]); - } - g_slist_free (selector->priv->column_order); g_free (selector->priv); @@ -329,31 +322,6 @@ _locales_init (HildonDateSelectorPrivate * priv) l = newlocale (LC_TIME_MASK, setlocale (LC_MESSAGES, NULL), NULL); - priv->monthname[0] = g_locale_to_utf8 (nl_langinfo_l (MON_1, l), - -1, NULL, NULL, NULL); - priv->monthname[1] = g_locale_to_utf8 (nl_langinfo_l (MON_2, l), - -1, NULL, NULL, NULL); - priv->monthname[2] = g_locale_to_utf8 (nl_langinfo_l (MON_3, l), - -1, NULL, NULL, NULL); - priv->monthname[3] = g_locale_to_utf8 (nl_langinfo_l (MON_4, l), - -1, NULL, NULL, NULL); - priv->monthname[4] = g_locale_to_utf8 (nl_langinfo_l (MON_5, l), - -1, NULL, NULL, NULL); - priv->monthname[5] = g_locale_to_utf8 (nl_langinfo_l (MON_6, l), - -1, NULL, NULL, NULL); - priv->monthname[6] = g_locale_to_utf8 (nl_langinfo_l (MON_7, l), - -1, NULL, NULL, NULL); - priv->monthname[7] = g_locale_to_utf8 (nl_langinfo_l (MON_8, l), - -1, NULL, NULL, NULL); - priv->monthname[8] = g_locale_to_utf8 (nl_langinfo_l (MON_9, l), - -1, NULL, NULL, NULL); - priv->monthname[9] = g_locale_to_utf8 (nl_langinfo_l (MON_10, l), - -1, NULL, NULL, NULL); - priv->monthname[10] = g_locale_to_utf8 (nl_langinfo_l (MON_11, l), - -1, NULL, NULL, NULL); - priv->monthname[11] = g_locale_to_utf8 (nl_langinfo_l (MON_12, l), - -1, NULL, NULL, NULL); - priv->format = g_locale_to_utf8 (nl_langinfo_l (D_FMT, l), -1, NULL, NULL, NULL); @@ -438,17 +406,18 @@ _create_day_model (HildonDateSelector * selector) { GtkListStore *store_days = NULL; gint i = 0; - gchar *label = NULL; + gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; GtkTreeIter iter; store_days = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for (i = 1; i < 32; i++) { - label = g_strdup_printf ("%d", i); + tm.tm_mday = i; + strftime (label, 255, _("wdgt_va_day_numeric"), &tm); gtk_list_store_append (store_days, &iter); gtk_list_store_set (store_days, &iter, COLUMN_STRING, label, COLUMN_INT, i, -1); - g_free (label); } return GTK_TREE_MODEL (store_days); @@ -460,19 +429,20 @@ _create_year_model (HildonDateSelector * selector) GtkListStore *store_years = NULL; gint real_year = 0; gint i = 0; - gchar *label = NULL; + static gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; GtkTreeIter iter; real_year = selector->priv->creation_year; store_years = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for (i = real_year - INIT_YEAR; i < real_year + LAST_YEAR; i++) { - label = g_strdup_printf ("%d", i); + tm.tm_year = i - 1900; + strftime (label, 255, _("wdgt_va_year"), &tm); gtk_list_store_append (store_years, &iter); gtk_list_store_set (store_years, &iter, COLUMN_STRING, label, COLUMN_INT, i, -1); - g_free (label); } return GTK_TREE_MODEL (store_years); @@ -484,17 +454,18 @@ _create_month_model (HildonDateSelector * selector) GtkTreeIter iter; gint i = 0; GtkListStore *store_months = NULL; - gchar *label = NULL; + static gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; store_months = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for (i = 0; i < 12; i++) { - label = g_strdup_printf ("%s", selector->priv->monthname[i]); + tm.tm_mon = i; + strftime (label, 255, _("wdgt_va_month"), &tm); gtk_list_store_append (store_months, &iter); - gtk_list_store_set (store_months, &iter, COLUMN_STRING, label, /* the label with the month */ - COLUMN_INT, i, /* the month number */ + gtk_list_store_set (store_months, &iter, COLUMN_STRING, label, + COLUMN_INT, i, -1); - g_free (label); } return GTK_TREE_MODEL (store_months); @@ -506,7 +477,8 @@ _update_day_model (HildonDateSelector * selector) GtkListStore *store_days = NULL; gint i = 0; GtkTreeIter iter; - gchar *label = NULL; + static gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; guint current_day = 0; guint current_year = 0; guint current_month = 0; @@ -530,12 +502,12 @@ _update_day_model (HildonDateSelector * selector) gtk_list_store_clear (store_days); for (i = 1; i <= num_days; i++) { - label = g_strdup_printf ("%d", i); + tm.tm_mday = i; + strftime (label, 255, _("wdgt_va_day_numeric"), &tm); gtk_list_store_append (store_days, &iter); gtk_list_store_set (store_days, &iter, COLUMN_STRING, label, COLUMN_INT, i, -1); - g_free (label); } /* now we select a day */ diff --git a/src/hildon-time-selector.c b/src/hildon-time-selector.c index 7fa6404..bc5a485 100644 --- a/src/hildon-time-selector.c +++ b/src/hildon-time-selector.c @@ -53,8 +53,7 @@ G_DEFINE_TYPE (HildonTimeSelector, hildon_time_selector, HILDON_TYPE_TOUCH_SELEC #define LAST_YEAR 50 /* since current year */ #define _(String) dgettext("hildon-libs", String) - -/* #define _(String) "%I:%M %p" debug purposes */ +#define N_(String) String /* FIXME: we should get this two props from the clock ui headers */ @@ -220,17 +219,18 @@ _create_minutes_model (HildonTimeSelector * selector) { GtkListStore *store_minutes = NULL; gint i = 0; - gchar *label = NULL; + static gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; GtkTreeIter iter; store_minutes = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for (i = 0; i <= 59; i++) { - label = g_strdup_printf ("%02d", i); + tm.tm_min = i; + strftime (label, 255, _("wdgt_va_minutes"), &tm); gtk_list_store_append (store_minutes, &iter); gtk_list_store_set (store_minutes, &iter, COLUMN_STRING, label, COLUMN_INT, i, -1); - g_free (label); } return GTK_TREE_MODEL (store_minutes); @@ -241,30 +241,34 @@ _create_hours_model (HildonTimeSelector * selector) { GtkListStore *store_hours = NULL; gint i = 0; - gchar *label = NULL; GtkTreeIter iter; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + static gchar label[255]; static gint range_12h[12] = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11}; static gint range_24h[24] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, 12,13,14,15,16,17,18,19,20,21,22,23}; gint *range = NULL; gint num_elements = 0; + gchar *format_string = NULL; if (selector->priv->ampm_format) { range = range_12h; num_elements = 12; + format_string = N_("wdgt_va_12h_hours"); } else { range = range_24h; num_elements = 24; + format_string = N_("wdgt_va_24h_hours"); } store_hours = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for (i = 0; i < num_elements; i++) { - label = g_strdup_printf ("%02d", range[i]); + tm.tm_hour = range[i]; + strftime (label, 255, _(format_string), &tm); gtk_list_store_append (store_hours, &iter); gtk_list_store_set (store_hours, &iter, COLUMN_STRING, label, COLUMN_INT, range[i], -1); - g_free (label); } return GTK_TREE_MODEL (store_hours); @@ -275,16 +279,26 @@ _create_ampm_model (HildonTimeSelector * selector) { GtkListStore *store_ampm = NULL; GtkTreeIter iter; + static gchar label[255]; + struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; store_ampm = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); + tm.tm_hour = 0; + strftime (label, 255, _("wdgt_va_am_pm"), &tm); + gtk_list_store_append (store_ampm, &iter); - gtk_list_store_set (store_ampm, &iter, COLUMN_STRING, "am", /* FIXME: use nl_langinfo am/pm strings */ + gtk_list_store_set (store_ampm, &iter, + COLUMN_STRING, label, COLUMN_INT, 0, -1); + tm.tm_hour = 12; + strftime (label, 255, _("wdgt_va_am_pm"), &tm); + gtk_list_store_append (store_ampm, &iter); gtk_list_store_set (store_ampm, &iter, - COLUMN_STRING, "pm", COLUMN_INT, 1, -1); + COLUMN_STRING, label, + COLUMN_INT, 1, -1); return GTK_TREE_MODEL (store_ampm); }