comparison src/buddy.c @ 4722:534eaa4ead94

[gaim-migrate @ 5034] Provided a generic way for prpls to put text in the second line of the Big List and removed a hideous Yahoo! buddy menu hack in the process committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 12 Mar 2003 06:37:40 +0000
parents 91ef4fae4a49
children b9e7ccf21f9c
comparison
equal deleted inserted replaced
4721:91ef4fae4a49 4722:534eaa4ead94
543 543
544 static gchar *gaim_gtk_blist_get_name_markup(struct buddy *b) 544 static gchar *gaim_gtk_blist_get_name_markup(struct buddy *b)
545 { 545 {
546 char *name = gaim_get_buddy_alias(b); 546 char *name = gaim_get_buddy_alias(b);
547 char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL; 547 char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL;
548 struct prpl* prpl = find_prpl(b->account->protocol);
549
548 /* XXX Clean up this crap */ 550 /* XXX Clean up this crap */
549 551
550 int ihrs, imin; 552 int ihrs, imin;
551 char *idletime = ""; 553 char *idletime = NULL, *warning = NULL;
552 char *warning = idletime; 554 const char *statustext = NULL;
553 time_t t; 555 time_t t;
554 556
555 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) { 557 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) {
556 if (b->idle > 0 && blist_options & OPT_BLIST_GREY_IDLERS) { 558 if (b->idle > 0 && blist_options & OPT_BLIST_GREY_IDLERS) {
557 text = g_strdup_printf("<span color='dim grey'>%s</span>", 559 text = g_strdup_printf("<span color='dim grey'>%s</span>",
558 esc); 560 esc);
565 567
566 time(&t); 568 time(&t);
567 ihrs = (t - b->idle) / 3600; 569 ihrs = (t - b->idle) / 3600;
568 imin = ((t - b->idle) / 60) % 60; 570 imin = ((t - b->idle) / 60) % 60;
569 571
572 if (prpl->status_text) {
573 char *tmp = prpl->status_text(b);
574 if (tmp)
575 statustext = g_markup_escape_text(tmp, strlen(tmp));
576 }
577
570 if (b->idle) { 578 if (b->idle) {
571 if (ihrs) 579 if (ihrs)
572 idletime = g_strdup_printf(_("Idle (%dh%02dm)"), ihrs, imin); 580 idletime = g_strdup_printf(_("Idle (%dh%02dm)"), ihrs, imin);
573 else 581 else
574 idletime = g_strdup_printf(_("Idle (%dm)"), imin); 582 idletime = g_strdup_printf(_("Idle (%dm)"), imin);
575 } 583 }
576 584
577 if (b->evil > 0) 585 if (b->evil > 0)
578 warning = g_strdup_printf(_("Warned (%d%%)"), b->evil); 586 warning = g_strdup_printf(_("Warned (%d%%)"), b->evil);
579 587
580 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS) 588 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS)
581 text = g_strdup_printf("<span color='dim grey'>%s</span>\n<span color='dim grey' size='smaller'>%s %s</span>", 589 text = g_strdup_printf("<span color='dim grey'>%s</span>\n<span color='dim grey' size='smaller'>%s %s %s</span>",
582 esc, 590 esc,
583 idletime, warning); 591 statustext != NULL ? statustext : "",
592 idletime != NULL ? idletime : "",
593 warning != NULL ? warning : "");
584 else 594 else
585 text = g_strdup_printf("%s\n<span color='dim grey' size='smaller'>%s %s</span>", esc, idletime, warning); 595 text = g_strdup_printf("%s\n<span color='dim grey' size='smaller'>%s %s %s</span>", esc,
586 596 statustext != NULL ? statustext : "",
587 if (idletime[0]) 597 idletime != NULL ? idletime : "",
598 warning != NULL ? warning : "");
599 if (idletime)
588 g_free(idletime); 600 g_free(idletime);
589 if (warning[0]) 601 if (warning)
590 g_free(warning); 602 g_free(warning);
603 if (statustext)
604 g_free(statustext);
591 605
592 return text; 606 return text;
593 } 607 }
594 608
595 /********************************************************************************** 609 /**********************************************************************************