libpurple/notify.c

branch
next.minor
changeset 25888
d0fdd378a635
parent 24569
5dbd0617a27d
child 30537
9f833935ecd7
equal deleted inserted replaced
25887:6eac2f6c32e2 25888:d0fdd378a635
442 442
443 PurpleNotifyUserInfoEntry * 443 PurpleNotifyUserInfoEntry *
444 purple_notify_user_info_entry_new(const char *label, const char *value) 444 purple_notify_user_info_entry_new(const char *label, const char *value)
445 { 445 {
446 PurpleNotifyUserInfoEntry *user_info_entry; 446 PurpleNotifyUserInfoEntry *user_info_entry;
447 447
448 user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1); 448 user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1);
449 PURPLE_DBUS_REGISTER_POINTER(user_info_entry, PurpleNotifyUserInfoEntry); 449 PURPLE_DBUS_REGISTER_POINTER(user_info_entry, PurpleNotifyUserInfoEntry);
450 user_info_entry->label = g_strdup(label); 450 user_info_entry->label = g_strdup(label);
451 user_info_entry->value = g_strdup(value); 451 user_info_entry->value = g_strdup(value);
452 user_info_entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR; 452 user_info_entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR;
456 456
457 static void 457 static void
458 purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry) 458 purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry)
459 { 459 {
460 g_return_if_fail(user_info_entry != NULL); 460 g_return_if_fail(user_info_entry != NULL);
461 461
462 g_free(user_info_entry->label); 462 g_free(user_info_entry->label);
463 g_free(user_info_entry->value); 463 g_free(user_info_entry->value);
464 PURPLE_DBUS_UNREGISTER_POINTER(user_info_entry); 464 PURPLE_DBUS_UNREGISTER_POINTER(user_info_entry);
465 g_free(user_info_entry); 465 g_free(user_info_entry);
466 } 466 }
467 467
468 PurpleNotifyUserInfo * 468 PurpleNotifyUserInfo *
469 purple_notify_user_info_new() 469 purple_notify_user_info_new()
470 { 470 {
471 PurpleNotifyUserInfo *user_info; 471 PurpleNotifyUserInfo *user_info;
472 472
473 user_info = g_new0(PurpleNotifyUserInfo, 1); 473 user_info = g_new0(PurpleNotifyUserInfo, 1);
474 PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo); 474 PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo);
475 user_info->user_info_entries = NULL; 475 user_info->user_info_entries = NULL;
476 476
477 return user_info; 477 return user_info;
478 } 478 }
479 479
480 void 480 void
481 purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info) 481 purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info)
482 { 482 {
483 GList *l; 483 GList *l;
484 484
485 for (l = user_info->user_info_entries; l != NULL; l = l->next) { 485 for (l = user_info->user_info_entries; l != NULL; l = l->next) {
486 PurpleNotifyUserInfoEntry *user_info_entry = l->data; 486 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
487 487
488 purple_notify_user_info_entry_destroy(user_info_entry); 488 purple_notify_user_info_entry_destroy(user_info_entry);
489 } 489 }
490 490
491 g_list_free(user_info->user_info_entries); 491 g_list_free(user_info->user_info_entries);
492 PURPLE_DBUS_UNREGISTER_POINTER(user_info); 492 PURPLE_DBUS_UNREGISTER_POINTER(user_info);
493 g_free(user_info); 493 g_free(user_info);
494 } 494 }
495 495
504 char * 504 char *
505 purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, const char *newline) 505 purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, const char *newline)
506 { 506 {
507 GList *l; 507 GList *l;
508 GString *text; 508 GString *text;
509 509
510 text = g_string_new(""); 510 text = g_string_new("");
511 511
512 for (l = user_info->user_info_entries; l != NULL; l = l->next) { 512 for (l = user_info->user_info_entries; l != NULL; l = l->next) {
513 PurpleNotifyUserInfoEntry *user_info_entry = l->data; 513 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
514 /* Add a newline before a section header */ 514 /* Add a newline before a section header */
530 530
531 /* Don't insert a new line before or after a section break; <HR> does that for us */ 531 /* Don't insert a new line before or after a section break; <HR> does that for us */
532 if ((user_info_entry->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) && 532 if ((user_info_entry->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) &&
533 (l->next && ((((PurpleNotifyUserInfoEntry *)(l->next->data))->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)))) 533 (l->next && ((((PurpleNotifyUserInfoEntry *)(l->next->data))->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK))))
534 g_string_append(text, newline); 534 g_string_append(text, newline);
535 535
536 /* Add an extra newline after a section header */ 536 /* Add an extra newline after a section header */
537 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) 537 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
538 g_string_append(text, newline); 538 g_string_append(text, newline);
539 } 539 }
540 540
561 561
562 const gchar * 562 const gchar *
563 purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry) 563 purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry)
564 { 564 {
565 g_return_val_if_fail(user_info_entry != NULL, NULL); 565 g_return_val_if_fail(user_info_entry != NULL, NULL);
566 566
567 return user_info_entry->value; 567 return user_info_entry->value;
568 } 568 }
569 569
570 void 570 void
571 purple_notify_user_info_entry_set_value(PurpleNotifyUserInfoEntry *user_info_entry, const char *value) 571 purple_notify_user_info_entry_set_value(PurpleNotifyUserInfoEntry *user_info_entry, const char *value)
594 594
595 void 595 void
596 purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value) 596 purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
597 { 597 {
598 PurpleNotifyUserInfoEntry *entry; 598 PurpleNotifyUserInfoEntry *entry;
599 599
600 entry = purple_notify_user_info_entry_new(label, value); 600 entry = purple_notify_user_info_entry_new(label, value);
601 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); 601 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
602 } 602 }
603 603
604 void 604 void
621 621
622 void 622 void
623 purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label) 623 purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label)
624 { 624 {
625 PurpleNotifyUserInfoEntry *entry; 625 PurpleNotifyUserInfoEntry *entry;
626 626
627 entry = purple_notify_user_info_entry_new(label, NULL); 627 entry = purple_notify_user_info_entry_new(label, NULL);
628 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER; 628 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
629 629
630 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); 630 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
631 } 631 }
632 632
633 void 633 void
634 purple_notify_user_info_prepend_section_header(PurpleNotifyUserInfo *user_info, const char *label) 634 purple_notify_user_info_prepend_section_header(PurpleNotifyUserInfo *user_info, const char *label)
635 { 635 {
636 PurpleNotifyUserInfoEntry *entry; 636 PurpleNotifyUserInfoEntry *entry;
637 637
638 entry = purple_notify_user_info_entry_new(label, NULL); 638 entry = purple_notify_user_info_entry_new(label, NULL);
639 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER; 639 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
640 640
641 user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry); 641 user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
642 } 642 }
643 643
644 void 644 void
645 purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info) 645 purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info)
646 { 646 {
647 PurpleNotifyUserInfoEntry *entry; 647 PurpleNotifyUserInfoEntry *entry;
648 648
649 entry = purple_notify_user_info_entry_new(NULL, NULL); 649 entry = purple_notify_user_info_entry_new(NULL, NULL);
650 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK; 650 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
651 651
652 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); 652 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
653 } 653 }
654 654
655 void 655 void
656 purple_notify_user_info_prepend_section_break(PurpleNotifyUserInfo *user_info) 656 purple_notify_user_info_prepend_section_break(PurpleNotifyUserInfo *user_info)
657 { 657 {
658 PurpleNotifyUserInfoEntry *entry; 658 PurpleNotifyUserInfoEntry *entry;
659 659
660 entry = purple_notify_user_info_entry_new(NULL, NULL); 660 entry = purple_notify_user_info_entry_new(NULL, NULL);
661 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK; 661 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
662 662
663 user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry); 663 user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
664 } 664 }
665 665
666 void 666 void
667 purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info) 667 purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info)

mercurial