Mercurial > pidgin.yaz
changeset 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 | 4539174a88bd |
children | 3ca08210da50 |
files | plugins/ChangeLog.API src/conversation.c src/conversation.h src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h |
diffstat | 6 files changed, 106 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Fri Sep 09 20:06:13 2005 +0000 +++ b/plugins/ChangeLog.API Fri Sep 09 20:14:32 2005 +0000 @@ -93,6 +93,7 @@ same behavior as before) * Changed: chat_add_users in GaimConversationUiOps, added aliases list * Removed: chat_add_user from GaimConversationUiOps + * Changed: chat_rename_user in GaimConversationUiOps, added new_alias * Changed: GaimConversation.log became GList * GaimConversation.logs, so that a conversation can have multiple logs at once * Changed: gaim_conv_chat_add_user, added extra_msgs list
--- a/src/conversation.c Fri Sep 09 20:06:13 2005 +0000 +++ b/src/conversation.c Fri Sep 09 20:14:32 2005 +0000 @@ -2051,10 +2051,13 @@ { GaimConversation *conv; GaimConversationUiOps *ops; + GaimConnection *gc; + GaimPluginProtocolInfo *prpl_info; GaimConvChatBuddy *cb; GaimConvChatBuddyFlags flags; + const char *new_alias = new_user; char tmp[BUF_LONG]; - gboolean its_me = FALSE; + gboolean is_me = FALSE; g_return_if_fail(chat != NULL); g_return_if_fail(old_user != NULL); @@ -2063,13 +2066,25 @@ conv = gaim_conv_chat_get_conversation(chat); ops = gaim_conversation_get_ui_ops(conv); + gc = gaim_conversation_get_gc(conv); + g_return_if_fail(gc != NULL); + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); + g_return_if_fail(prpl_info != NULL); + flags = gaim_conv_chat_user_get_flags(chat, old_user); cb = gaim_conv_chat_cb_new(new_user, flags); gaim_conv_chat_set_users(chat, g_list_prepend(gaim_conv_chat_get_users(chat), cb)); + if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { + GaimBuddy *buddy; + + if ((buddy = gaim_find_buddy(gc->account, new_user)) != NULL) + new_alias = gaim_buddy_get_contact_alias(buddy); + } + if (ops != NULL && ops->chat_rename_user != NULL) - ops->chat_rename_user(conv, old_user, new_user); + ops->chat_rename_user(conv, old_user, new_user, new_alias); cb = gaim_conv_chat_cb_find(chat, old_user); @@ -2086,25 +2101,21 @@ else if (gaim_conv_chat_is_user_ignored(chat, new_user)) gaim_conv_chat_unignore(chat, new_user); + /* This should use gaim_normalize on the two values and strcmp them. */ if(!g_utf8_collate(old_user, chat->nick)) { gaim_conv_chat_set_nick(chat, new_user); - its_me = TRUE; + is_me = TRUE; } if (gaim_prefs_get_bool("/core/conversations/chat/show_nick_change") && !gaim_conv_chat_is_user_ignored(chat, new_user)) { - if(its_me) { + if(is_me) { g_snprintf(tmp, sizeof(tmp), _("You are now known as %s"), new_user); } else { - GaimConnection *gc = gaim_conversation_get_gc(conv); - GaimPluginProtocolInfo *prpl_info; const char *old_alias = old_user; const char *new_alias = new_user; - - if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) - return; if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { GaimBuddy *buddy;
--- a/src/conversation.h Fri Sep 09 20:06:13 2005 +0000 +++ b/src/conversation.h Fri Sep 09 20:14:32 2005 +0000 @@ -189,8 +189,8 @@ time_t mtime); void (*chat_add_users)(GaimConversation *conv, GList *users, GList *aliases); - void (*chat_rename_user)(GaimConversation *conv, - const char *old_name, const char *new_name); + void (*chat_rename_user)(GaimConversation *conv, const char *old_name, + const char *new_name, const char *new_alias); void (*chat_remove_user)(GaimConversation *conv, const char *user); void (*chat_remove_users)(GaimConversation *conv, GList *users); void (*chat_update_user)(GaimConversation *conv, const char *user);
--- a/src/gtkconv.c Fri Sep 09 20:06:13 2005 +0000 +++ b/src/gtkconv.c Fri Sep 09 20:14:32 2005 +0000 @@ -5219,6 +5219,8 @@ GaimGtkConversation *gtkconv; GaimConvWindow *win; GaimConnection *gc; + GaimAccount *account; + GaimPluginProtocolInfo *prpl_info; int gtk_font_options = 0; int max_scrollback_lines = gaim_prefs_get_int( "/gaim/gtk/conversations/scrollback_lines"); @@ -5234,8 +5236,9 @@ gtkconv = GAIM_GTK_CONVERSATION(conv); gtkconv->active_conv = conv; gc = gaim_conversation_get_gc(conv); - + account = gaim_conversation_get_account(conv); win = gaim_conversation_get_window(conv); + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); line_count = gtk_text_buffer_get_line_count( gtk_text_view_get_buffer(GTK_TEXT_VIEW( @@ -5270,7 +5273,7 @@ gtk_font_options |= GTK_IMHTML_NO_COMMENTS; if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) - gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; + gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; /* this is gonna crash one day, I can feel it. */ if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & @@ -5375,10 +5378,31 @@ if(alias_escaped) g_free(alias_escaped); - g_snprintf(buf2, BUF_LONG, - "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" - "<B>%s</B></FONT> ", - color, sml_attrib ? sml_attrib : "", mdate, str); + + /* Are we in a chat where we can tell which users are buddies? */ + if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && + gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { + + /* Bold buddies to make them stand out from non-buddies. */ + if (gaim_find_buddy(account, name) != NULL) { + g_snprintf(buf2, BUF_LONG, + "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" + "<B>%s</B></FONT> ", + color, sml_attrib ? sml_attrib : "", mdate, str); + } else { + g_snprintf(buf2, BUF_LONG, + "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" + "%s</FONT> ", + color, sml_attrib ? sml_attrib : "", mdate, str); + + } + } else { + /* Bold everyone's name to make the name stand out from the message. */ + g_snprintf(buf2, BUF_LONG, + "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" + "<B>%s</B></FONT> ", + color, sml_attrib ? sml_attrib : "", mdate, str); + } gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); @@ -5471,7 +5495,7 @@ static void gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, - const char *new_name) + const char *new_name, const char *new_alias) { GaimConvChat *chat; GaimGtkConversation *gtkconv; @@ -5479,7 +5503,6 @@ GtkTreeIter iter; GtkTreeModel *model; int f = 1; - char *alias = NULL; chat = GAIM_CONV_CHAT(conv); gtkconv = GAIM_GTK_CONVERSATION(conv); @@ -5496,7 +5519,6 @@ gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); if (!gaim_utf8_strcasecmp(old_name, val)) { - gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); gtk_list_store_remove(GTK_LIST_STORE(model), &iter); g_free(val); break; @@ -5510,10 +5532,9 @@ if (!gaim_conv_chat_find_user(chat, old_name)) return; - g_return_if_fail(alias != NULL); - - add_chat_buddy_common(conv, new_name, alias); - g_free(alias); + g_return_if_fail(new_alias != NULL); + + add_chat_buddy_common(conv, new_name, new_alias); } static void
--- a/src/gtkimhtml.c Fri Sep 09 20:06:13 2005 +0000 +++ b/src/gtkimhtml.c Fri Sep 09 20:14:32 2005 +0000 @@ -2367,60 +2367,71 @@ case 1: /* B */ case 2: /* BOLD */ case 54: /* STRONG */ - - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - - if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) - gtk_imhtml_toggle_bold(imhtml); - bold++; - ws[0] = '\0'; wpos = 0; + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + + if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) + gtk_imhtml_toggle_bold(imhtml); + bold++; + ws[0] = '\0'; wpos = 0; + } break; case 3: /* /B */ case 4: /* /BOLD */ case 55: /* /STRONG */ - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - ws[0] = '\0'; wpos = 0; - - if (bold) - bold--; - if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) - gtk_imhtml_toggle_bold(imhtml); + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + ws[0] = '\0'; wpos = 0; + + if (bold) + bold--; + if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) + gtk_imhtml_toggle_bold(imhtml); + } break; case 5: /* I */ case 6: /* ITALIC */ case 52: /* EM */ - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - ws[0] = '\0'; wpos = 0; - if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) - gtk_imhtml_toggle_italic(imhtml); - italics++; + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + ws[0] = '\0'; wpos = 0; + if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) + gtk_imhtml_toggle_italic(imhtml); + italics++; + } break; case 7: /* /I */ case 8: /* /ITALIC */ case 53: /* /EM */ - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - ws[0] = '\0'; wpos = 0; - if (italics) - italics--; - if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) - gtk_imhtml_toggle_italic(imhtml); + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + ws[0] = '\0'; wpos = 0; + if (italics) + italics--; + if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) + gtk_imhtml_toggle_italic(imhtml); + } break; case 9: /* U */ case 10: /* UNDERLINE */ - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - ws[0] = '\0'; wpos = 0; - if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) - gtk_imhtml_toggle_underline(imhtml); - underline++; + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + ws[0] = '\0'; wpos = 0; + if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) + gtk_imhtml_toggle_underline(imhtml); + underline++; + } break; case 11: /* /U */ case 12: /* /UNDERLINE */ - gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); - ws[0] = '\0'; wpos = 0; - if (underline) - underline--; - if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) - gtk_imhtml_toggle_underline(imhtml); + if (!(options & GTK_IMHTML_NO_FORMATTING)) { + gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); + ws[0] = '\0'; wpos = 0; + if (underline) + underline--; + if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) + gtk_imhtml_toggle_underline(imhtml); + } break; case 13: /* S */ case 14: /* STRIKE */
--- a/src/gtkimhtml.h Fri Sep 09 20:06:13 2005 +0000 +++ b/src/gtkimhtml.h Fri Sep 09 20:14:32 2005 +0000 @@ -189,7 +189,8 @@ GTK_IMHTML_NO_SIZES = 1 << 5, GTK_IMHTML_NO_SCROLL = 1 << 6, GTK_IMHTML_RETURN_LOG = 1 << 7, - GTK_IMHTML_USE_POINTSIZE = 1 << 8 + GTK_IMHTML_USE_POINTSIZE = 1 << 8, + GTK_IMHTML_NO_FORMATTING = 1 << 9 } GtkIMHtmlOptions; enum {