From: Darko Koruga Date: Thu, 26 Apr 2001 09:36:01 +0000 (+0000) Subject: Check for strftime() in configure and use it to display date X-Git-Tag: local-account~3 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=bed75555aa5c1eb2c34608c41743d930cac3ca86 Check for strftime() in configure and use it to display date in summary pane. --- diff --git a/ChangeLog.claws b/ChangeLog.claws index f9b6df398..f40778edd 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,12 @@ +2001-04-26 + + * configure.in: check for availability of strftime() + [darko] + * src/prefs_common.[ch], src/procheader.c: use + strftime() for displaying date in summary pane if it + is available + + 2001-04-25 * more .cvsignore cleanups [alfons] diff --git a/configure.in b/configure.in index 7e81637b9..a09effdbc 100644 --- a/configure.in +++ b/configure.in @@ -195,7 +195,7 @@ AC_CHECK_FUNCS(gethostname mkdir mktime socket strstr \ wcsstr wcswcs iswalnum iswspace towlower \ wcslen wcscpy wcsncpy \ uname flock lockf inet_aton inet_addr \ - fchmod mkstemp) + fchmod mkstemp strftime) AC_OUTPUT([ Makefile diff --git a/src/prefs_common.c b/src/prefs_common.c index 4b058c74f..8b62c8151 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -104,6 +104,10 @@ static struct Display { GtkWidget *chkbtn_transhdr; GtkWidget *chkbtn_swapfrom; GtkWidget *chkbtn_hscrollbar; +#ifdef HAVE_STRFTIME + GtkWidget *entry_dateformat; + GtkTooltips tooltips_dateformat +#endif } display; static struct Message { @@ -284,6 +288,13 @@ static PrefParam param[] = { &display.chkbtn_hscrollbar, prefs_set_data_from_toggle, prefs_set_toggle}, +#ifdef HAVE_STRFTIME + {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format, + P_STRING, &display.entry_dateformat, + prefs_set_data_from_entry, prefs_set_entry}, +#endif + + {"enable_thread", "TRUE", &prefs_common.enable_thread, P_BOOL, NULL, NULL, NULL}, {"toolbar_style", "3", &prefs_common.toolbar_style, P_ENUM, @@ -1086,6 +1097,13 @@ static void prefs_display_create(void) GtkWidget *hbox1; GtkWidget *button_dispitem; +#ifdef HAVE_STRFTIME + GtkWidget *hbox_dateformat; + GtkWidget *label_dateformat; + GtkWidget *entry_dateformat; + GtkTooltips *tooltips_dateformat; +#endif + vbox1 = gtk_vbox_new (FALSE, VSPACING); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); @@ -1155,6 +1173,54 @@ static void prefs_display_create(void) GTK_SIGNAL_FUNC (prefs_summary_display_item_set), NULL); + /* ---- Date format ---- */ + +#ifdef HAVE_STRFTIME + hbox1 = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox1); + gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0); + + hbox_dateformat = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox1); + gtk_box_pack_start (GTK_BOX (hbox1), hbox_dateformat, FALSE, TRUE, 0); + + label_dateformat = gtk_label_new (_("Date format")); + gtk_widget_show (label_dateformat); + gtk_box_pack_start (GTK_BOX (hbox_dateformat), label_dateformat, + FALSE, FALSE, 0); + entry_dateformat = gtk_entry_new (); + gtk_widget_show (entry_dateformat); + gtk_box_pack_start (GTK_BOX (hbox1), entry_dateformat, TRUE, TRUE, 0); + + tooltips_dateformat = gtk_tooltips_new(); + gtk_tooltips_set_tip(tooltips_dateformat, entry_dateformat, + _("Ordinary characters placed in the format string are copied " + "without conversion. Conversion specifiers are introduced by " + "a % character, and are replaced as follows:\n" + "%a the abbreviated weekday name\n" + "%A the full weekday name\n" + "%b the abbreviated month name\n" + "%B the full month name\n" + "%c the preferred date and time for the current locale\n" + "%C the century number (year/100)\n" + "%d the day of the month as a decimal number\n" + "%H the hour as a decimal number using a 24-hour clock\n" + "%I the hour as a decimal number using a 12-hour clock\n" + "%j the day of the year as a decimal number\n" + "%m the month as a decimal number\n" + "%M the minute as a decimal number\n" + "%p either AM or PM\n" + "%S the second as a decimal number\n" + "%w the day of the week as a decimal number\n" + "%x the preferred date for the current locale\n" + "%y the last two digits of a year\n" + "%Y the year as a decimal number\n" + "%Z the time zone or name or abbreviation" + ), + NULL); +#endif + + display.entry_textfont = entry_textfont; display.button_textfont = button_textfont; @@ -1163,6 +1229,10 @@ static void prefs_display_create(void) display.chkbtn_transhdr = chkbtn_transhdr; display.chkbtn_swapfrom = chkbtn_swapfrom; display.chkbtn_hscrollbar = chkbtn_hscrollbar; + +#ifdef HAVE_STRFTIME + display.entry_dateformat = entry_dateformat; +#endif } static void prefs_message_create(void) diff --git a/src/prefs_common.h b/src/prefs_common.h index 315c4ee52..b217a28e7 100644 --- a/src/prefs_common.h +++ b/src/prefs_common.h @@ -69,6 +69,9 @@ struct _PrefsCommon gboolean enable_thread; gboolean enable_hscrollbar; gboolean swap_from; +#ifdef HAVE_STRFTIME + gchar *date_format; +#endif /* Filtering */ GSList *fltlist; diff --git a/src/procheader.c b/src/procheader.c index 79b840187..0f7e8c0a5 100644 --- a/src/procheader.c +++ b/src/procheader.c @@ -32,6 +32,7 @@ #include "procmsg.h" #include "codeconv.h" #include "utils.h" +#include "prefs_common.h" #define BUFFSIZE 8192 @@ -523,6 +524,16 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len) void procheader_date_get_localtime(gchar *dest, gint len, const time_t timer) { +#ifdef HAVE_STRFTIME + struct tm *lt; + + lt = localtime(&timer); + + if (prefs_common.date_format) + strftime(dest, len, prefs_common.date_format, lt); + else + *dest = '\0'; +#else static gchar *wdaystr = N_("SunMonTueWedThuFriSat"); static gchar *tr_wday = NULL; struct tm *lt; @@ -543,4 +554,5 @@ void procheader_date_get_localtime(gchar *dest, gint len, const time_t timer) g_snprintf(dest, len, "%02d/%d/%d(%s) %02d:%02d", lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday, wday, lt->tm_hour, lt->tm_min); +#endif }