gint creation_day;
gint creation_month;
gint creation_year; /* date at creation time */
-
- gchar *monthname[12];
};
static void hildon_date_selector_finalize (GObject * object);
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);
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);
{
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);
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);
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);
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;
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 */
#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 */
{
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);
{
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);
{
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);
}