comparison 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
comparison
equal deleted inserted replaced
12736:f49d49444c68 12737:a1e241dd50b6
4451 int gtk_font_options_all = 0; 4451 int gtk_font_options_all = 0;
4452 int max_scrollback_lines = gaim_prefs_get_int( 4452 int max_scrollback_lines = gaim_prefs_get_int(
4453 "/gaim/gtk/conversations/scrollback_lines"); 4453 "/gaim/gtk/conversations/scrollback_lines");
4454 int line_count; 4454 int line_count;
4455 char buf2[BUF_LONG]; 4455 char buf2[BUF_LONG];
4456 char mdate[64]; 4456 char *mdate;
4457 char color[10]; 4457 char color[10];
4458 char *str; 4458 char *str;
4459 char *with_font_tag; 4459 char *with_font_tag;
4460 char *sml_attrib = NULL; 4460 char *sml_attrib = NULL;
4461 size_t length; 4461 size_t length;
4462 GaimConversationType type; 4462 GaimConversationType type;
4463 char *displaying; 4463 char *displaying;
4464 gboolean plugin_return; 4464 gboolean plugin_return;
4465 struct tm tm = *(localtime(&mtime));
4465 4466
4466 gtkconv = GAIM_GTK_CONVERSATION(conv); 4467 gtkconv = GAIM_GTK_CONVERSATION(conv);
4467 4468
4468 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) 4469 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling"))
4469 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; 4470 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING;
4511 } 4512 }
4512 4513
4513 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) 4514 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml))))
4514 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); 4515 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all);
4515 4516
4516 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ 4517 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(),
4517 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); 4518 "conversation-timestamp",
4518 else 4519 conv, &tm);
4519 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); 4520 if (mdate == NULL)
4521 {
4522 char buf[64];
4523
4524 if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */
4525 strftime(buf, sizeof(buf), "%x %X", &tm);
4526 else
4527 strftime(buf, sizeof(buf), "%X", &tm);
4528
4529 mdate = g_strdup(buf);
4530 }
4520 4531
4521 if(gc) 4532 if(gc)
4522 sml_attrib = g_strdup_printf("sml=\"%s\"", 4533 sml_attrib = g_strdup_printf("sml=\"%s\"",
4523 gaim_account_get_protocol_name(conv->account)); 4534 gaim_account_get_protocol_name(conv->account));
4524 4535
4731 4742
4732 g_free(with_font_tag); 4743 g_free(with_font_tag);
4733 g_free(new_message); 4744 g_free(new_message);
4734 } 4745 }
4735 4746
4736 if(sml_attrib) 4747 g_free(mdate);
4737 g_free(sml_attrib); 4748 g_free(sml_attrib);
4738 4749
4739 gaim_signal_emit(gaim_gtk_conversations_get_handle(), 4750 gaim_signal_emit(gaim_gtk_conversations_get_handle(),
4740 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), 4751 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"),
4741 account, conv, message, flags); 4752 account, conv, message, flags);
4742 g_free(displaying); 4753 g_free(displaying);
6175 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, 6186 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
6176 gaim_value_new(GAIM_TYPE_SUBTYPE, 6187 gaim_value_new(GAIM_TYPE_SUBTYPE,
6177 GAIM_SUBTYPE_CONV_WINDOW), 6188 GAIM_SUBTYPE_CONV_WINDOW),
6178 gaim_value_new(GAIM_TYPE_SUBTYPE, 6189 gaim_value_new(GAIM_TYPE_SUBTYPE,
6179 GAIM_SUBTYPE_CONV_WINDOW)); 6190 GAIM_SUBTYPE_CONV_WINDOW));
6191
6192 gaim_signal_register(handle, "conversation-timestamp",
6193 gaim_marshal_POINTER__POINTER_POINTER,
6194 gaim_value_new(GAIM_TYPE_POINTER), 2,
6195 gaim_value_new(GAIM_TYPE_SUBTYPE,
6196 GAIM_SUBTYPE_CONVERSATION),
6197 gaim_value_new(GAIM_TYPE_POINTER));
6180 6198
6181 gaim_signal_register(handle, "displaying-im-msg", 6199 gaim_signal_register(handle, "displaying-im-msg",
6182 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, 6200 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT,
6183 gaim_value_new(GAIM_TYPE_BOOLEAN), 4, 6201 gaim_value_new(GAIM_TYPE_BOOLEAN), 4,
6184 gaim_value_new(GAIM_TYPE_SUBTYPE, 6202 gaim_value_new(GAIM_TYPE_SUBTYPE,