Mercurial > pidgin
diff src/gtkconv.c @ 12737:a1e241dd50b6
[gaim-migrate @ 15082]
Conversation and Logging Message Timestamp Formatting...
The idea here is that we should honor the user's locale for message timestamps in the conversation window and in the logs.
I've added a signal and created a plugin that allows one to override this. The plugin is named "Message Timestamp Formats". Enabling that will by default change the timestamps back to the format we had before this commit. (That is to say, it forces the old format and ignores the locale.) The plugin also has options to show dates in the timestamps "Always", "In Chats", or "For Delayed Messages" (the default behavior).
This addresses all requests for 12 hour timestamps, allows people to continue with the 24 hour timestamps we have, even if their locale says differently, enables plugin authors to override the message timestamp formats in any way they choose, and addresses requests for complete dates in logs.
To recap, if you don't like the format string your locale has, enabled the "Message Timestamp Formats" plugin.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 05 Jan 2006 20:17:36 +0000 |
parents | d6fa227827a1 |
children | ca1144227826 |
line wrap: on
line diff
--- a/src/gtkconv.c Thu Jan 05 19:50:12 2006 +0000 +++ b/src/gtkconv.c Thu Jan 05 20:17:36 2006 +0000 @@ -4453,7 +4453,7 @@ "/gaim/gtk/conversations/scrollback_lines"); int line_count; char buf2[BUF_LONG]; - char mdate[64]; + char *mdate; char color[10]; char *str; char *with_font_tag; @@ -4462,6 +4462,7 @@ GaimConversationType type; char *displaying; gboolean plugin_return; + struct tm tm = *(localtime(&mtime)); gtkconv = GAIM_GTK_CONVERSATION(conv); @@ -4513,10 +4514,20 @@ if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); - if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ - strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); - else - strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); + mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), + "conversation-timestamp", + conv, &tm); + if (mdate == NULL) + { + char buf[64]; + + if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ + strftime(buf, sizeof(buf), "%x %X", &tm); + else + strftime(buf, sizeof(buf), "%X", &tm); + + mdate = g_strdup(buf); + } if(gc) sml_attrib = g_strdup_printf("sml=\"%s\"", @@ -4733,8 +4744,8 @@ g_free(new_message); } - if(sml_attrib) - g_free(sml_attrib); + g_free(mdate); + g_free(sml_attrib); gaim_signal_emit(gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), @@ -6178,6 +6189,13 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONV_WINDOW)); + gaim_signal_register(handle, "conversation-timestamp", + gaim_marshal_POINTER__POINTER_POINTER, + gaim_value_new(GAIM_TYPE_POINTER), 2, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_CONVERSATION), + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "displaying-im-msg", gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, gaim_value_new(GAIM_TYPE_BOOLEAN), 4,