comparison src/buddy.c @ 4815:3efe860c40c7

[gaim-migrate @ 5139] non-utf8 messages that come from the prpls for status messages and tooltips will no longer wreak havoc. yay. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 18 Mar 2003 01:46:06 +0000
parents f9cc606607dc
children cd60c41e6e4a
comparison
equal deleted inserted replaced
4814:043f7c059034 4815:3efe860c40c7
576 struct prpl* prpl = find_prpl(b->account->protocol); 576 struct prpl* prpl = find_prpl(b->account->protocol);
577 char *statustext = NULL; 577 char *statustext = NULL;
578 char *warning = NULL, *idletime = NULL; 578 char *warning = NULL, *idletime = NULL;
579 579
580 if (prpl->tooltip_text) { 580 if (prpl->tooltip_text) {
581 const char *end;
581 statustext = prpl->tooltip_text(b); 582 statustext = prpl->tooltip_text(b);
583
584 if(statustext && !g_utf8_validate(statustext, -1, &end)) {
585 char *new = g_strndup(statustext,
586 g_utf8_pointer_to_offset(statustext, end));
587 g_free(statustext);
588 statustext = new;
589 }
582 } 590 }
583 591
584 if (b->idle) { 592 if (b->idle) {
585 int ihrs, imin; 593 int ihrs, imin;
586 time_t t; 594 time_t t;
818 ihrs = (t - b->idle) / 3600; 826 ihrs = (t - b->idle) / 3600;
819 imin = ((t - b->idle) / 60) % 60; 827 imin = ((t - b->idle) / 60) % 60;
820 828
821 if (prpl->status_text) { 829 if (prpl->status_text) {
822 char *tmp = prpl->status_text(b); 830 char *tmp = prpl->status_text(b);
831 const char *end;
832
833 if(tmp && !g_utf8_validate(tmp, -1, &end)) {
834 char *new = g_strndup(tmp,
835 g_utf8_pointer_to_offset(tmp, end));
836 g_free(tmp);
837 tmp = new;
838 }
823 839
824 if(tmp) { 840 if(tmp) {
825 g_strdelimit(tmp, "\n", ' '); 841 g_strdelimit(tmp, "\n", ' ');
826 if(strlen(tmp) > 20) 842 if(strlen(tmp) > 20)
827 statustext = g_strdup_printf("%.20s... ", tmp); 843 statustext = g_strdup_printf("%.20s... ", tmp);
940 956
941 /****************************** GtkTreeView **********************************/ 957 /****************************** GtkTreeView **********************************/
942 sw = gtk_scrolled_window_new(NULL,NULL); 958 sw = gtk_scrolled_window_new(NULL,NULL);
943 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); 959 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
944 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 960 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
945 gtk_widget_set_size_request(sw, 200, 200);
946 961
947 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, 962 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
948 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); 963 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
949 964
950 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel)); 965 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel));