diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-04-18 13:18:09 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-18 13:18:09 -0700 |
commit | 75765be14cc90886d7f46ec02097b7efeb3d8234 (patch) | |
tree | 8029786e6399bc0a1298005263afc74c37452add /divelist-gtk.c | |
parent | 1a15462073d854674e4d745c6af0249a1d48452e (diff) | |
download | subsurface-75765be14cc90886d7f46ec02097b7efeb3d8234.tar.gz |
Move creation of dive and dive trip date string into helper functions
This allows this code to easily be shared by Gtk and Qt UI.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist-gtk.c')
-rw-r--r-- | divelist-gtk.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/divelist-gtk.c b/divelist-gtk.c index 5420f9e1a..189b75ba1 100644 --- a/divelist-gtk.c +++ b/divelist-gtk.c @@ -261,31 +261,19 @@ static void date_data_func(GtkTreeViewColumn *col, struct tm tm; timestamp_t when; /* this should be enought for most languages. if not increase the value. */ - char buffer[256]; + char *buffer; gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &when, -1); nr = gtk_tree_model_iter_n_children(model, iter); utc_mkdate(when, &tm); if (idx < 0) { - snprintf(buffer, sizeof(buffer), - /*++GETTEXT 60 char buffer weekday, monthname, day of month, year, nr dives */ - ngettext("Trip %1$s, %2$s %3$d, %4$d (%5$d dive)", - "Trip %1$s, %2$s %3$d, %4$d (%5$d dives)", nr), - weekday(tm.tm_wday), - monthname(tm.tm_mon), - tm.tm_mday, tm.tm_year + 1900, - nr); + buffer = get_trip_date_string(&tm, nr); } else { - snprintf(buffer, sizeof(buffer), - /*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */ - _("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"), - weekday(tm.tm_wday), - monthname(tm.tm_mon), - tm.tm_mday, tm.tm_year + 1900, - tm.tm_hour, tm.tm_min); + buffer = get_dive_date_string(&tm); } g_object_set(renderer, "text", buffer, NULL); + free(buffer); } static void depth_data_func(GtkTreeViewColumn *col, |