Mercurial > pidgin
comparison src/gtkconv.c @ 11485:16b0da1f376f
[gaim-migrate @ 13727]
Fix the /nick weirdness bug I introduced.
Also, patch 1283539, from Peter Lawler (two changes)
1. When in a chat where Gaim can tell which users are buddies (i.e. non-Jabber chats), only the names of buddies are bolded. I'm not sure if I'll like this, but I'm committing it so we can all try it out.
2. "remove bold, underline, and italics when we're ignoring formatting, as well"
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 09 Sep 2005 20:14:32 +0000 |
parents | e9251afae7b8 |
children | 3ca08210da50 |
comparison
equal
deleted
inserted
replaced
11484:4539174a88bd | 11485:16b0da1f376f |
---|---|
5217 time_t mtime) | 5217 time_t mtime) |
5218 { | 5218 { |
5219 GaimGtkConversation *gtkconv; | 5219 GaimGtkConversation *gtkconv; |
5220 GaimConvWindow *win; | 5220 GaimConvWindow *win; |
5221 GaimConnection *gc; | 5221 GaimConnection *gc; |
5222 GaimAccount *account; | |
5223 GaimPluginProtocolInfo *prpl_info; | |
5222 int gtk_font_options = 0; | 5224 int gtk_font_options = 0; |
5223 int max_scrollback_lines = gaim_prefs_get_int( | 5225 int max_scrollback_lines = gaim_prefs_get_int( |
5224 "/gaim/gtk/conversations/scrollback_lines"); | 5226 "/gaim/gtk/conversations/scrollback_lines"); |
5225 int line_count; | 5227 int line_count; |
5226 char buf2[BUF_LONG]; | 5228 char buf2[BUF_LONG]; |
5232 size_t length = strlen(message) + 1; | 5234 size_t length = strlen(message) + 1; |
5233 | 5235 |
5234 gtkconv = GAIM_GTK_CONVERSATION(conv); | 5236 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5235 gtkconv->active_conv = conv; | 5237 gtkconv->active_conv = conv; |
5236 gc = gaim_conversation_get_gc(conv); | 5238 gc = gaim_conversation_get_gc(conv); |
5237 | 5239 account = gaim_conversation_get_account(conv); |
5238 win = gaim_conversation_get_window(conv); | 5240 win = gaim_conversation_get_window(conv); |
5241 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5239 | 5242 |
5240 line_count = gtk_text_buffer_get_line_count( | 5243 line_count = gtk_text_buffer_get_line_count( |
5241 gtk_text_view_get_buffer(GTK_TEXT_VIEW( | 5244 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
5242 gtkconv->imhtml))); | 5245 gtkconv->imhtml))); |
5243 | 5246 |
5268 gaim_account_get_protocol_name(conv->account)); | 5271 gaim_account_get_protocol_name(conv->account)); |
5269 | 5272 |
5270 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; | 5273 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
5271 | 5274 |
5272 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) | 5275 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
5273 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; | 5276 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
5274 | 5277 |
5275 /* this is gonna crash one day, I can feel it. */ | 5278 /* this is gonna crash one day, I can feel it. */ |
5276 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | 5279 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & |
5277 OPT_PROTO_USE_POINTSIZE) { | 5280 OPT_PROTO_USE_POINTSIZE) { |
5278 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; | 5281 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5373 } | 5376 } |
5374 } | 5377 } |
5375 | 5378 |
5376 if(alias_escaped) | 5379 if(alias_escaped) |
5377 g_free(alias_escaped); | 5380 g_free(alias_escaped); |
5378 g_snprintf(buf2, BUF_LONG, | 5381 |
5379 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" | 5382 /* Are we in a chat where we can tell which users are buddies? */ |
5380 "<B>%s</B></FONT> ", | 5383 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
5381 color, sml_attrib ? sml_attrib : "", mdate, str); | 5384 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
5385 | |
5386 /* Bold buddies to make them stand out from non-buddies. */ | |
5387 if (gaim_find_buddy(account, name) != NULL) { | |
5388 g_snprintf(buf2, BUF_LONG, | |
5389 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" | |
5390 "<B>%s</B></FONT> ", | |
5391 color, sml_attrib ? sml_attrib : "", mdate, str); | |
5392 } else { | |
5393 g_snprintf(buf2, BUF_LONG, | |
5394 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" | |
5395 "%s</FONT> ", | |
5396 color, sml_attrib ? sml_attrib : "", mdate, str); | |
5397 | |
5398 } | |
5399 } else { | |
5400 /* Bold everyone's name to make the name stand out from the message. */ | |
5401 g_snprintf(buf2, BUF_LONG, | |
5402 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" | |
5403 "<B>%s</B></FONT> ", | |
5404 color, sml_attrib ? sml_attrib : "", mdate, str); | |
5405 } | |
5382 | 5406 |
5383 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); | 5407 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
5384 | 5408 |
5385 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && | 5409 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
5386 !(flags & GAIM_MESSAGE_SEND)) { | 5410 !(flags & GAIM_MESSAGE_SEND)) { |
5469 } | 5493 } |
5470 } | 5494 } |
5471 | 5495 |
5472 static void | 5496 static void |
5473 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, | 5497 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
5474 const char *new_name) | 5498 const char *new_name, const char *new_alias) |
5475 { | 5499 { |
5476 GaimConvChat *chat; | 5500 GaimConvChat *chat; |
5477 GaimGtkConversation *gtkconv; | 5501 GaimGtkConversation *gtkconv; |
5478 GaimGtkChatPane *gtkchat; | 5502 GaimGtkChatPane *gtkchat; |
5479 GtkTreeIter iter; | 5503 GtkTreeIter iter; |
5480 GtkTreeModel *model; | 5504 GtkTreeModel *model; |
5481 int f = 1; | 5505 int f = 1; |
5482 char *alias = NULL; | |
5483 | 5506 |
5484 chat = GAIM_CONV_CHAT(conv); | 5507 chat = GAIM_CONV_CHAT(conv); |
5485 gtkconv = GAIM_GTK_CONVERSATION(conv); | 5508 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5486 gtkchat = gtkconv->u.chat; | 5509 gtkchat = gtkconv->u.chat; |
5487 | 5510 |
5494 char *val; | 5517 char *val; |
5495 | 5518 |
5496 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | 5519 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); |
5497 | 5520 |
5498 if (!gaim_utf8_strcasecmp(old_name, val)) { | 5521 if (!gaim_utf8_strcasecmp(old_name, val)) { |
5499 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); | |
5500 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 5522 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5501 g_free(val); | 5523 g_free(val); |
5502 break; | 5524 break; |
5503 } | 5525 } |
5504 | 5526 |
5508 } | 5530 } |
5509 | 5531 |
5510 if (!gaim_conv_chat_find_user(chat, old_name)) | 5532 if (!gaim_conv_chat_find_user(chat, old_name)) |
5511 return; | 5533 return; |
5512 | 5534 |
5513 g_return_if_fail(alias != NULL); | 5535 g_return_if_fail(new_alias != NULL); |
5514 | 5536 |
5515 add_chat_buddy_common(conv, new_name, alias); | 5537 add_chat_buddy_common(conv, new_name, new_alias); |
5516 g_free(alias); | |
5517 } | 5538 } |
5518 | 5539 |
5519 static void | 5540 static void |
5520 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) | 5541 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
5521 { | 5542 { |