Mercurial > pidgin
diff pidgin/plugins/timestamp_format.c @ 15518:b15cc37605c4
In Pidgin, display a full date on the timestamp of the first message to
cross the boundary into a new day. Sean and various users want this. I
think I'm finally going to admit it's a decent idea.
I've also refactored plenty of code related to the conversation-timestamp
and log-timestamp signals. This breaks API compatibility, but I'm pretty
sure the only plugin that uses those signals is the Message Timestamps
plugin that we ship. The changes eliminate duplicated code between the
core/UI and the plugin.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 03 Feb 2007 20:28:41 +0000 |
parents | d75099d2567e |
children | 45d3dd67fa13 |
line wrap: on
line diff
--- a/pidgin/plugins/timestamp_format.c Sat Feb 03 18:46:49 2007 +0000 +++ b/pidgin/plugins/timestamp_format.c Sat Feb 03 20:28:41 2007 +0000 @@ -53,18 +53,18 @@ static char *timestamp_cb_common(GaimConversation *conv, time_t t, + gboolean show_date, gboolean force, const char *dates) { - struct tm *tm = localtime(&t); g_return_val_if_fail(conv != NULL, NULL); g_return_val_if_fail(dates != NULL, NULL); - if (!strcmp(dates, "always") || - (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && - !strcmp(dates, "chats")) || - (time(NULL) > (mktime(tm) + 20*60))) + if (show_date || + !strcmp(dates, "always") || + (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) { + struct tm *tm = localtime(&t); if (force) return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); else @@ -72,13 +72,16 @@ } if (force) + { + struct tm *tm = localtime(&t); return g_strdup(gaim_utf8_strftime("%H:%M:%S", tm)); + } return NULL; } static char *conversation_timestamp_cb(GaimConversation *conv, - time_t t, gpointer data) + time_t t, gboolean show_date, gpointer data) { gboolean force = gaim_prefs_get_bool( "/plugins/gtk/timestamp_format/force_24hr"); @@ -87,10 +90,10 @@ g_return_val_if_fail(conv != NULL, NULL); - return timestamp_cb_common(conv, t, force, dates); + return timestamp_cb_common(conv, t, show_date, force, dates); } -static char *log_timestamp_cb(GaimLog *log, time_t t, gpointer data) +static char *log_timestamp_cb(GaimLog *log, time_t t, gboolean show_date, gpointer data) { gboolean force = gaim_prefs_get_bool( "/plugins/gtk/timestamp_format/force_24hr"); @@ -99,17 +102,7 @@ g_return_val_if_fail(log != NULL, NULL); - if (log->type == GAIM_LOG_SYSTEM) - { - if (force) { - struct tm *tm = localtime(&t); - return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); - } else { - return NULL; - } - } - - return timestamp_cb_common(log->conv, t, force, dates); + return timestamp_cb_common(log->conv, t, show_date, force, dates); } static gboolean @@ -140,7 +133,7 @@ GAIM_MAJOR_VERSION, GAIM_MINOR_VERSION, GAIM_PLUGIN_STANDARD, /**< type */ - PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ + PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ 0, /**< flags */ NULL, /**< dependencies */ GAIM_PRIORITY_DEFAULT, /**< priority */