comparison src/buddy.c @ 1068:ed28707debdc

[gaim-migrate @ 1078] tooltips for one connection. need to figure out how to do it for multiple connections. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 04 Nov 2000 22:35:05 +0000
parents d6c70d58a4b2
children 5d4926907b21
comparison
equal deleted inserted replaced
1067:649199f4730e 1068:ed28707debdc
1418 } 1418 }
1419 b->log_timer = -1; 1419 b->log_timer = -1;
1420 return FALSE; 1420 return FALSE;
1421 } 1421 }
1422 1422
1423 static char *caps_string(gushort caps)
1424 {
1425 static char buf[256], *tmp;
1426 int count = 0, i = 0;
1427 gushort bit = 1;
1428 while (bit <= 0x20) {
1429 if (bit & caps) {
1430 switch (bit) {
1431 case 0x1:
1432 tmp = _("Buddy Icon");
1433 break;
1434 case 0x2:
1435 tmp = _("Voice");
1436 break;
1437 case 0x4:
1438 tmp = _("IM Image");
1439 break;
1440 case 0x8:
1441 tmp = _("Chat");
1442 break;
1443 case 0x10:
1444 tmp = _("Get File");
1445 break;
1446 case 0x20:
1447 tmp = _("Send File");
1448 break;
1449 default:
1450 tmp = NULL;
1451 break;
1452 }
1453 if (tmp)
1454 i += g_snprintf(buf+i, sizeof(buf)-i, "%s%s", (count ? ", " : ""), tmp);
1455 count++;
1456 }
1457 bit <<= 1;
1458 }
1459 return buf;
1460 }
1461
1423 static void update_idle_time(struct buddy_show *bs) { 1462 static void update_idle_time(struct buddy_show *bs) {
1424 char idlet[16]; 1463 char idlet[16];
1425 time_t t; 1464 time_t t;
1426 int ihrs, imin; 1465 int ihrs, imin;
1427 struct buddy *b; 1466 struct buddy *b;
1428 GSList *c; 1467 GSList *c;
1468
1469 char infotip[256];
1470 char warn[256];
1471 char caps[256];
1472 char *sotime, *itime;
1429 1473
1430 time(&t); 1474 time(&t);
1431 if (g_slist_length(bs->connlist) == 1) { 1475 if (g_slist_length(bs->connlist) == 1) {
1432 b = find_buddy(bs->connlist->data, bs->name); 1476 b = find_buddy(bs->connlist->data, bs->name);
1433 if (!b) return; 1477 if (!b) return;
1443 gtk_label_set(GTK_LABEL(bs->idle), idlet); 1487 gtk_label_set(GTK_LABEL(bs->idle), idlet);
1444 else 1488 else
1445 gtk_label_set(GTK_LABEL(bs->idle), ""); 1489 gtk_label_set(GTK_LABEL(bs->idle), "");
1446 if (display_options & OPT_DISP_SHOW_IDLETIME) 1490 if (display_options & OPT_DISP_SHOW_IDLETIME)
1447 gtk_widget_show(bs->idle); 1491 gtk_widget_show(bs->idle);
1492
1493 /* now we do the tooltip */
1494 sotime = sec_to_text(t - b->signon +
1495 ((struct gaim_connection *)bs->connlist->data)->correction_time);
1496
1497 if (b->idle)
1498 itime = sec_to_text(t - b->idle);
1499 else {
1500 itime = g_malloc(1); itime[0] = 0;
1501 }
1502
1503 if (b->evil)
1504 g_snprintf(warn, sizeof warn, _("Warnings: %d%%\n"), b->evil);
1505 else
1506 warn[0] = '\0';
1507
1508 if (b->caps)
1509 g_snprintf(caps, sizeof caps, _("Capabilities: %s\n"), caps_string(b->caps));
1510 else
1511 caps[0] = '\0';
1512
1513 g_snprintf(infotip, sizeof infotip, _("Alias: %s \nScreen Name: %s\n"
1514 "Logged in: %s\n%s%s%s%s%s"),
1515 b->show, b->name, sotime, warn,
1516 (b->idle ? _("Idle: ") : ""), itime,
1517 (b->idle ? "\n" : ""), caps);
1518
1519 gtk_tooltips_set_tip(tips, GTK_WIDGET(bs->item), infotip, "");
1520
1521 g_free(sotime);
1522 g_free(itime);
1448 } else { 1523 } else {
1449 /* FIXME */ 1524 /* FIXME */
1450 } 1525 }
1451 } 1526 }
1452 1527