Mercurial > pidgin
comparison src/gtknotify.c @ 10774:d83f745c997b
[gaim-migrate @ 12383]
Some escaping stuff, all over the place.
Various escaping fixes in the IRC prpl.
The core and plugins only need to escape text if it's going to be shown in
a gtkimhtml or equivalent - such as writing to a conversation window, or
gaim_notify_{formatted,userinfo}
The primary and secondary text for all notify and request API functions
do NOT need to be escaped by the core or plugins, because whether html-like
markup is required for these is UI dependent. Now we always escape these
in the Gtk UI request & notify ops.
Should I backport any of the above to oldstatus?
I also removed gaim_chat_get_display_name() - it was almost a duplicate of
gaim_chat_get_name(), and it leaked.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 02 Apr 2005 17:18:43 +0000 |
parents | d5a00882d118 |
children | a118e50116df |
comparison
equal
deleted
inserted
replaced
10773:888d4c328be5 | 10774:d83f745c997b |
---|---|
126 GtkWidget *hbox; | 126 GtkWidget *hbox; |
127 GtkWidget *label; | 127 GtkWidget *label; |
128 GtkWidget *img = NULL; | 128 GtkWidget *img = NULL; |
129 char label_text[2048]; | 129 char label_text[2048]; |
130 const char *icon_name = NULL; | 130 const char *icon_name = NULL; |
131 char *primary_esc, *secondary_esc; | |
131 | 132 |
132 switch (type) | 133 switch (type) |
133 { | 134 { |
134 case GAIM_NOTIFY_MSG_ERROR: | 135 case GAIM_NOTIFY_MSG_ERROR: |
135 icon_name = GAIM_STOCK_DIALOG_ERROR; | 136 icon_name = GAIM_STOCK_DIALOG_ERROR; |
173 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | 174 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
174 | 175 |
175 if (img != NULL) | 176 if (img != NULL) |
176 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 177 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
177 | 178 |
179 primary_esc = g_markup_escape_text(primary, -1); | |
180 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
178 g_snprintf(label_text, sizeof(label_text), | 181 g_snprintf(label_text, sizeof(label_text), |
179 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | 182 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", |
180 primary, (secondary ? secondary : "")); | 183 primary_esc, (secondary ? secondary_esc : "")); |
184 g_free(primary_esc); | |
185 g_free(secondary_esc); | |
181 | 186 |
182 label = gtk_label_new(NULL); | 187 label = gtk_label_new(NULL); |
183 | 188 |
184 gtk_label_set_markup(GTK_LABEL(label), label_text); | 189 gtk_label_set_markup(GTK_LABEL(label), label_text); |
185 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 190 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
348 GtkWidget *button; | 353 GtkWidget *button; |
349 GtkWidget *imhtml; | 354 GtkWidget *imhtml; |
350 GtkWidget *frame; | 355 GtkWidget *frame; |
351 int options = 0; | 356 int options = 0; |
352 char label_text[2048]; | 357 char label_text[2048]; |
353 char *linked_text; | 358 char *linked_text, *primary_esc, *secondary_esc; |
354 | 359 |
355 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 360 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
356 gtk_window_set_title(GTK_WINDOW(window), title); | 361 gtk_window_set_title(GTK_WINDOW(window), title); |
357 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | 362 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); |
358 gtk_container_set_border_width(GTK_CONTAINER(window), 12); | 363 gtk_container_set_border_width(GTK_CONTAINER(window), 12); |
364 vbox = gtk_vbox_new(FALSE, 12); | 369 vbox = gtk_vbox_new(FALSE, 12); |
365 gtk_container_add(GTK_CONTAINER(window), vbox); | 370 gtk_container_add(GTK_CONTAINER(window), vbox); |
366 gtk_widget_show(vbox); | 371 gtk_widget_show(vbox); |
367 | 372 |
368 /* Setup the descriptive label */ | 373 /* Setup the descriptive label */ |
374 primary_esc = g_markup_escape_text(primary, -1); | |
375 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
369 g_snprintf(label_text, sizeof(label_text), | 376 g_snprintf(label_text, sizeof(label_text), |
370 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", | 377 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
371 primary, | 378 primary_esc, |
372 (secondary ? "\n" : ""), | 379 (secondary ? "\n" : ""), |
373 (secondary ? secondary : "")); | 380 (secondary ? secondary_esc : "")); |
381 g_free(primary_esc); | |
382 g_free(secondary_esc); | |
374 | 383 |
375 label = gtk_label_new(NULL); | 384 label = gtk_label_new(NULL); |
376 | 385 |
377 gtk_label_set_markup(GTK_LABEL(label), label_text); | 386 gtk_label_set_markup(GTK_LABEL(label), label_text); |
378 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 387 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
436 GtkListStore *model; | 445 GtkListStore *model; |
437 GtkCellRenderer *renderer; | 446 GtkCellRenderer *renderer; |
438 GtkTreeIter iter; | 447 GtkTreeIter iter; |
439 int i; | 448 int i; |
440 char *label_text; | 449 char *label_text; |
450 char *primary_esc, *secondary_esc; | |
441 | 451 |
442 data = g_malloc(sizeof(GaimNotifySearchResultsData)); | 452 data = g_malloc(sizeof(GaimNotifySearchResultsData)); |
443 | 453 |
444 /* Create the window */ | 454 /* Create the window */ |
445 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 455 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
454 vbox = gtk_vbox_new(FALSE, 12); | 464 vbox = gtk_vbox_new(FALSE, 12); |
455 gtk_container_add(GTK_CONTAINER(window), vbox); | 465 gtk_container_add(GTK_CONTAINER(window), vbox); |
456 gtk_widget_show(vbox); | 466 gtk_widget_show(vbox); |
457 | 467 |
458 /* Setup the descriptive label */ | 468 /* Setup the descriptive label */ |
469 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; | |
470 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
459 label_text = g_strdup_printf( | 471 label_text = g_strdup_printf( |
460 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", | 472 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
461 (primary ? primary : ""), | 473 (primary ? primary_esc : ""), |
462 (primary && secondary ? "\n" : ""), | 474 (primary && secondary ? "\n" : ""), |
463 (secondary ? secondary : "")); | 475 (secondary ? secondary_esc : "")); |
476 g_free(primary_esc); | |
477 g_free(secondary_esc); | |
464 label = gtk_label_new(NULL); | 478 label = gtk_label_new(NULL); |
465 gtk_label_set_markup(GTK_LABEL(label), label_text); | 479 gtk_label_set_markup(GTK_LABEL(label), label_text); |
466 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 480 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
467 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 481 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
468 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | 482 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
526 icon = create_prpl_icon(gc->account); | 540 icon = create_prpl_icon(gc->account); |
527 scaled = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); | 541 scaled = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR); |
528 | 542 |
529 for (i = 0; results[i] != NULL; i++) | 543 for (i = 0; results[i] != NULL; i++) |
530 { | 544 { |
545 char *escaped = g_markup_escape_text(results[i], -1); | |
531 gtk_list_store_append(model, &iter); | 546 gtk_list_store_append(model, &iter); |
532 gtk_list_store_set(model, &iter, | 547 gtk_list_store_set(model, &iter, |
533 COLUMN_ICON, scaled, | 548 COLUMN_ICON, scaled, |
534 COLUMN_SCREENNAME, results[i], | 549 COLUMN_SCREENNAME, escaped, |
535 -1); | 550 -1); |
551 g_free(escaped); | |
536 } | 552 } |
537 | 553 |
538 data->account = gc->account; | 554 data->account = gc->account; |
539 data->model = model; | 555 data->model = model; |
540 data->treeview = treeview; | 556 data->treeview = treeview; |