Mercurial > pidgin.yaz
comparison pidgin/gtkblist-theme.c @ 26648:8c3b1a059ecc
merge of '8952794c1397b9cba4b98accf0639bb5499387d4'
and 'a0102873e8bacb2e83f697a4f7b7ba500ea806bd'
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 12 Apr 2009 23:57:27 +0000 |
parents | b6534ef99dc8 |
children | 1365dbb97c7d |
comparison
equal
deleted
inserted
replaced
26645:75b473f216f2 | 26648:8c3b1a059ecc |
---|---|
94 | 94 |
95 void | 95 void |
96 free_font_and_color(FontColorPair *pair) | 96 free_font_and_color(FontColorPair *pair) |
97 { | 97 { |
98 if (pair != NULL) { | 98 if (pair != NULL) { |
99 if (pair->font) | 99 g_free((gchar *)pair->font); |
100 g_free(pair->font); | 100 g_free((gchar *)pair->color); |
101 if (pair->color) | |
102 g_free(pair->color); | |
103 g_free(pair); | 101 g_free(pair); |
104 } | 102 } |
103 } | |
104 | |
105 static FontColorPair * | |
106 copy_font_and_color(const FontColorPair *pair) | |
107 { | |
108 FontColorPair *copy = g_new0(FontColorPair, 1); | |
109 copy->font = g_strdup(pair->font); | |
110 copy->color = g_strdup(pair->color); | |
111 return copy; | |
105 } | 112 } |
106 | 113 |
107 /****************************************************************************** | 114 /****************************************************************************** |
108 * GObject Stuff | 115 * GObject Stuff |
109 *****************************************************************************/ | 116 *****************************************************************************/ |
243 PidginBlistThemePrivate *priv; | 250 PidginBlistThemePrivate *priv; |
244 | 251 |
245 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(obj); | 252 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(obj); |
246 | 253 |
247 /* Buddy List */ | 254 /* Buddy List */ |
248 g_free(priv->bgcolor); | 255 gdk_color_free(priv->bgcolor); |
249 g_free(priv->layout); | 256 g_free(priv->layout); |
250 | 257 |
251 /* Group */ | 258 /* Group */ |
252 g_free(priv->expanded_color); | 259 gdk_color_free(priv->expanded_color); |
253 free_font_and_color(priv->expanded); | 260 free_font_and_color(priv->expanded); |
254 g_free(priv->collapsed_color); | 261 gdk_color_free(priv->collapsed_color); |
255 free_font_and_color(priv->collapsed); | 262 free_font_and_color(priv->collapsed); |
256 | 263 |
257 /* Buddy */ | 264 /* Buddy */ |
258 g_free(priv->contact_color); | 265 gdk_color_free(priv->contact_color); |
259 free_font_and_color(priv->contact); | 266 free_font_and_color(priv->contact); |
260 free_font_and_color(priv->online); | 267 free_font_and_color(priv->online); |
261 free_font_and_color(priv->away); | 268 free_font_and_color(priv->away); |
262 free_font_and_color(priv->offline); | 269 free_font_and_color(priv->offline); |
263 free_font_and_color(priv->idle); | 270 free_font_and_color(priv->idle); |
584 return priv->status; | 591 return priv->status; |
585 } | 592 } |
586 | 593 |
587 /* Set Methods */ | 594 /* Set Methods */ |
588 void | 595 void |
589 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, GdkColor *color) | 596 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, const GdkColor *color) |
590 { | 597 { |
591 PidginBlistThemePrivate *priv; | 598 PidginBlistThemePrivate *priv; |
592 | 599 |
593 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 600 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
594 | 601 |
595 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 602 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
596 | 603 |
597 g_free(priv->bgcolor); | 604 gdk_color_free(priv->bgcolor); |
598 priv->bgcolor = color; | 605 priv->bgcolor = gdk_color_copy(color); |
599 } | 606 } |
600 | 607 |
601 void | 608 void |
602 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity) | 609 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity) |
603 { | 610 { |
609 | 616 |
610 priv->opacity = opacity; | 617 priv->opacity = opacity; |
611 } | 618 } |
612 | 619 |
613 void | 620 void |
614 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, PidginBlistLayout *layout) | 621 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout) |
615 { | 622 { |
616 PidginBlistThemePrivate *priv; | 623 PidginBlistThemePrivate *priv; |
617 | 624 |
618 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 625 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
619 | 626 |
620 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 627 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
621 | 628 |
622 g_free(priv->layout); | 629 g_free(priv->layout); |
623 priv->layout = layout; | 630 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout)); |
624 } | 631 } |
625 | 632 |
626 void | 633 void |
627 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, GdkColor *color) | 634 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkColor *color) |
628 { | 635 { |
629 PidginBlistThemePrivate *priv; | 636 PidginBlistThemePrivate *priv; |
630 | 637 |
631 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 638 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
632 | 639 |
633 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 640 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
634 | 641 |
635 g_free(priv->expanded_color); | 642 gdk_color_free(priv->expanded_color); |
636 priv->expanded_color = color; | 643 priv->expanded_color = gdk_color_copy(color); |
637 } | 644 } |
638 | 645 |
639 void | 646 void |
640 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 647 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
641 { | 648 { |
642 PidginBlistThemePrivate *priv; | 649 PidginBlistThemePrivate *priv; |
643 | 650 |
644 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 651 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
645 | 652 |
646 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 653 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
647 | 654 |
648 free_font_and_color(priv->expanded); | 655 free_font_and_color(priv->expanded); |
649 priv->expanded = pair; | 656 priv->expanded = copy_font_and_color(pair); |
650 } | 657 } |
651 | 658 |
652 void | 659 void |
653 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, GdkColor *color) | 660 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkColor *color) |
654 { | 661 { |
655 PidginBlistThemePrivate *priv; | 662 PidginBlistThemePrivate *priv; |
656 | 663 |
657 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 664 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
658 | 665 |
659 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 666 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
660 | 667 |
661 g_free(priv->collapsed_color); | 668 gdk_color_free(priv->collapsed_color); |
662 priv->collapsed_color = color; | 669 priv->collapsed_color = gdk_color_copy(color); |
663 } | 670 } |
664 | 671 |
665 void | 672 void |
666 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 673 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
667 { | 674 { |
668 PidginBlistThemePrivate *priv; | 675 PidginBlistThemePrivate *priv; |
669 | 676 |
670 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 677 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
671 | 678 |
672 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 679 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
673 | 680 |
674 free_font_and_color(priv->collapsed); | 681 free_font_and_color(priv->collapsed); |
675 priv->collapsed = pair; | 682 priv->collapsed = copy_font_and_color(pair); |
676 } | 683 } |
677 | 684 |
678 void | 685 void |
679 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, GdkColor *color) | 686 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkColor *color) |
680 { | 687 { |
681 PidginBlistThemePrivate *priv; | 688 PidginBlistThemePrivate *priv; |
682 | 689 |
683 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 690 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
684 | 691 |
685 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 692 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
686 | 693 |
687 g_free(priv->contact_color); | 694 gdk_color_free(priv->contact_color); |
688 priv->contact_color = color; | 695 priv->contact_color = gdk_color_copy(color); |
689 } | 696 } |
690 | 697 |
691 void | 698 void |
692 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 699 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
693 { | 700 { |
694 PidginBlistThemePrivate *priv; | 701 PidginBlistThemePrivate *priv; |
695 | 702 |
696 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 703 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
697 | 704 |
698 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 705 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
699 | 706 |
700 free_font_and_color(priv->contact); | 707 free_font_and_color(priv->contact); |
701 priv->contact = pair; | 708 priv->contact = copy_font_and_color(pair); |
702 } | 709 } |
703 | 710 |
704 void | 711 void |
705 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 712 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
706 { | 713 { |
707 PidginBlistThemePrivate *priv; | 714 PidginBlistThemePrivate *priv; |
708 | 715 |
709 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 716 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
710 | 717 |
711 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 718 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
712 | 719 |
713 free_font_and_color(priv->online); | 720 free_font_and_color(priv->online); |
714 priv->online = pair; | 721 priv->online = copy_font_and_color(pair); |
715 } | 722 } |
716 | 723 |
717 void | 724 void |
718 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 725 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
719 { | 726 { |
720 PidginBlistThemePrivate *priv; | 727 PidginBlistThemePrivate *priv; |
721 | 728 |
722 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 729 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
723 | 730 |
724 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 731 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
725 | 732 |
726 free_font_and_color(priv->away); | 733 free_font_and_color(priv->away); |
727 priv->away = pair; | 734 priv->away = copy_font_and_color(pair); |
728 } | 735 } |
729 | 736 |
730 void | 737 void |
731 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 738 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
732 { | 739 { |
733 PidginBlistThemePrivate *priv; | 740 PidginBlistThemePrivate *priv; |
734 | 741 |
735 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 742 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
736 | 743 |
737 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 744 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
738 | 745 |
739 free_font_and_color(priv->offline); | 746 free_font_and_color(priv->offline); |
740 priv->offline = pair; | 747 priv->offline = copy_font_and_color(pair); |
741 } | 748 } |
742 | 749 |
743 void | 750 void |
744 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 751 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
745 { | 752 { |
746 PidginBlistThemePrivate *priv; | 753 PidginBlistThemePrivate *priv; |
747 | 754 |
748 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 755 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
749 | 756 |
750 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 757 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
751 | 758 |
752 free_font_and_color(priv->idle); | 759 free_font_and_color(priv->idle); |
753 priv->idle = pair; | 760 priv->idle = copy_font_and_color(pair); |
754 } | 761 } |
755 | 762 |
756 void | 763 void |
757 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 764 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
758 { | 765 { |
759 PidginBlistThemePrivate *priv; | 766 PidginBlistThemePrivate *priv; |
760 | 767 |
761 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 768 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
762 | 769 |
763 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 770 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
764 | 771 |
765 free_font_and_color(priv->message); | 772 free_font_and_color(priv->message); |
766 priv->message = pair; | 773 priv->message = copy_font_and_color(pair); |
767 } | 774 } |
768 | 775 |
769 void | 776 void |
770 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 777 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
771 { | 778 { |
772 PidginBlistThemePrivate *priv; | 779 PidginBlistThemePrivate *priv; |
773 | 780 |
774 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 781 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
775 | 782 |
776 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 783 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
777 | 784 |
778 free_font_and_color(priv->message_nick_said); | 785 free_font_and_color(priv->message_nick_said); |
779 priv->message_nick_said = pair; | 786 priv->message_nick_said = copy_font_and_color(pair); |
780 } | 787 } |
781 | 788 |
782 void | 789 void |
783 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, FontColorPair *pair) | 790 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const FontColorPair *pair) |
784 { | 791 { |
785 PidginBlistThemePrivate *priv; | 792 PidginBlistThemePrivate *priv; |
786 | 793 |
787 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); | 794 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
788 | 795 |
789 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); | 796 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
790 | 797 |
791 free_font_and_color(priv->status); | 798 free_font_and_color(priv->status); |
792 priv->status = pair; | 799 priv->status = copy_font_and_color(pair); |
793 } | 800 } |