comparison pidgin/gtkconv.c @ 22435:5c72a6c071db

Escape conversation title for use in infopane so that ampersands don't generate invalid markup
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 09 Mar 2008 16:43:33 +0000
parents 361b2e61a219
children 8802eddbfedc
comparison
equal deleted inserted replaced
22434:48d09d62912e 22435:5c72a6c071db
6492 } else { 6492 } else {
6493 markup = title; 6493 markup = title;
6494 } 6494 }
6495 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 6495 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
6496 const char *topic = gtkconv->u.chat->topic_text ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) : NULL; 6496 const char *topic = gtkconv->u.chat->topic_text ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) : NULL;
6497 char *esc = NULL; 6497 char *esc = NULL, *tmp;
6498 #if GTK_CHECK_VERSION(2,6,0) 6498 #if GTK_CHECK_VERSION(2,6,0)
6499 esc = topic ? g_markup_escape_text(topic, -1) : NULL; 6499 esc = topic ? g_markup_escape_text(topic, -1) : NULL;
6500 #else 6500 #else
6501 /* GTK < 2.6 doesn't have auto ellipsization, so we do a crude 6501 /* GTK < 2.6 doesn't have auto ellipsization, so we do a crude
6502 * trucation to prevent forcing the window to be as wide as the topic */ 6502 * trucation to prevent forcing the window to be as wide as the topic */
6503 int len = 0; 6503 int len = 0;
6504 char *c, *tmp = g_strdup(topic); 6504 char *c;
6505
6506 tmp = g_strdup(topic);
6505 c = tmp; 6507 c = tmp;
6506 while(*c && len < 72) { 6508 while(*c && len < 72) {
6507 c = g_utf8_next_char(c); 6509 c = g_utf8_next_char(c);
6508 len++; 6510 len++;
6509 } 6511 }
6514 tmp = c; 6516 tmp = c;
6515 } 6517 }
6516 esc = tmp ? g_markup_escape_text(tmp, -1) : NULL; 6518 esc = tmp ? g_markup_escape_text(tmp, -1) : NULL;
6517 g_free(tmp); 6519 g_free(tmp);
6518 #endif 6520 #endif
6521 tmp = g_markup_escape_text(purple_conversation_get_title(conv), -1);
6519 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>", 6522 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>",
6520 purple_conversation_get_title(conv), 6523 tmp, esc && *esc ? "\n" : "",
6521 esc && *esc ? "\n" : "",
6522 pidgin_get_dim_grey_string(gtkconv->infopane), 6524 pidgin_get_dim_grey_string(gtkconv->infopane),
6523 esc ? esc : ""); 6525 esc ? esc : "");
6526 g_free(tmp);
6524 g_free(esc); 6527 g_free(esc);
6525 } 6528 }
6526 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), 6529 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter),
6527 CONV_TEXT_COLUMN, markup, -1); 6530 CONV_TEXT_COLUMN, markup, -1);
6528 /* XXX seanegan Why do I have to do this? */ 6531 /* XXX seanegan Why do I have to do this? */