| 22 |
22 |
| 23 #include "internal.h" |
23 #include "internal.h" |
| 24 #include "gtkblist-theme.h" |
24 #include "gtkblist-theme.h" |
| 25 |
25 |
| 26 #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \ |
26 #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \ |
| 27 ((PidginBlistThemePrivate *) ((PIDGIN_BLIST_THEME(Gobject))->priv)) |
27 (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_BLIST_THEME, PidginBlistThemePrivate)) |
| 28 |
28 |
| 29 /****************************************************************************** |
29 /****************************************************************************** |
| 30 * Structs |
30 * Structs |
| 31 *****************************************************************************/ |
31 *****************************************************************************/ |
| 32 |
32 |
| 187 /****************************************************************************** |
187 /****************************************************************************** |
| 188 * GObject Stuff |
188 * GObject Stuff |
| 189 *****************************************************************************/ |
189 *****************************************************************************/ |
| 190 |
190 |
| 191 static void |
191 static void |
| 192 pidgin_blist_theme_init(GTypeInstance *instance, |
|
| 193 gpointer klass) |
|
| 194 { |
|
| 195 (PIDGIN_BLIST_THEME(instance))->priv = g_new0(PidginBlistThemePrivate, 1); |
|
| 196 } |
|
| 197 |
|
| 198 static void |
|
| 199 pidgin_blist_theme_get_property(GObject *obj, guint param_id, GValue *value, |
192 pidgin_blist_theme_get_property(GObject *obj, guint param_id, GValue *value, |
| 200 GParamSpec *psec) |
193 GParamSpec *psec) |
| 201 { |
194 { |
| 202 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj); |
195 PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj); |
| 203 |
196 |
| 347 pidgin_theme_font_free(priv->idle); |
340 pidgin_theme_font_free(priv->idle); |
| 348 pidgin_theme_font_free(priv->message); |
341 pidgin_theme_font_free(priv->message); |
| 349 pidgin_theme_font_free(priv->message_nick_said); |
342 pidgin_theme_font_free(priv->message_nick_said); |
| 350 pidgin_theme_font_free(priv->status); |
343 pidgin_theme_font_free(priv->status); |
| 351 |
344 |
| 352 g_free(priv); |
|
| 353 |
|
| 354 parent_class->finalize (obj); |
345 parent_class->finalize (obj); |
| 355 } |
346 } |
| 356 |
347 |
| 357 static void |
348 static void |
| 358 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass) |
349 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass) |
| 359 { |
350 { |
| 360 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
351 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
| 361 GParamSpec *pspec; |
352 GParamSpec *pspec; |
| 362 |
353 |
| 363 parent_class = g_type_class_peek_parent (klass); |
354 parent_class = g_type_class_peek_parent (klass); |
| |
355 |
| |
356 g_type_class_add_private(klass, sizeof(PidginBlistThemePrivate)); |
| 364 |
357 |
| 365 obj_class->get_property = pidgin_blist_theme_get_property; |
358 obj_class->get_property = pidgin_blist_theme_get_property; |
| 366 obj_class->set_property = pidgin_blist_theme_set_property; |
359 obj_class->set_property = pidgin_blist_theme_set_property; |
| 367 obj_class->finalize = pidgin_blist_theme_finalize; |
360 obj_class->finalize = pidgin_blist_theme_finalize; |
| 368 |
361 |
| 482 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */ |
475 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */ |
| 483 NULL, /* class_finalize */ |
476 NULL, /* class_finalize */ |
| 484 NULL, /* class_data */ |
477 NULL, /* class_data */ |
| 485 sizeof(PidginBlistTheme), |
478 sizeof(PidginBlistTheme), |
| 486 0, /* n_preallocs */ |
479 0, /* n_preallocs */ |
| 487 pidgin_blist_theme_init, /* instance_init */ |
480 NULL, /* instance_init */ |
| 488 NULL, /* value table */ |
481 NULL, /* value table */ |
| 489 }; |
482 }; |
| 490 type = g_type_register_static (PURPLE_TYPE_THEME, |
483 type = g_type_register_static (PURPLE_TYPE_THEME, |
| 491 "PidginBlistTheme", &info, 0); |
484 "PidginBlistTheme", &info, 0); |
| 492 } |
485 } |
| 698 { |
691 { |
| 699 PidginBlistThemePrivate *priv; |
692 PidginBlistThemePrivate *priv; |
| 700 |
693 |
| 701 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
694 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 702 |
695 |
| 703 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
696 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 704 |
697 |
| 705 if (priv->bgcolor) |
698 if (priv->bgcolor) |
| 706 gdk_color_free(priv->bgcolor); |
699 gdk_color_free(priv->bgcolor); |
| 707 priv->bgcolor = color ? gdk_color_copy(color) : NULL; |
700 priv->bgcolor = color ? gdk_color_copy(color) : NULL; |
| 708 } |
701 } |
| 724 { |
717 { |
| 725 PidginBlistThemePrivate *priv; |
718 PidginBlistThemePrivate *priv; |
| 726 |
719 |
| 727 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
720 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 728 |
721 |
| 729 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
722 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 730 |
723 |
| 731 g_free(priv->layout); |
724 g_free(priv->layout); |
| 732 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout)); |
725 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout)); |
| 733 } |
726 } |
| 734 |
727 |
| 737 { |
730 { |
| 738 PidginBlistThemePrivate *priv; |
731 PidginBlistThemePrivate *priv; |
| 739 |
732 |
| 740 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
733 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 741 |
734 |
| 742 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
735 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 743 |
736 |
| 744 if (priv->expanded_color) |
737 if (priv->expanded_color) |
| 745 gdk_color_free(priv->expanded_color); |
738 gdk_color_free(priv->expanded_color); |
| 746 priv->expanded_color = color ? gdk_color_copy(color) : NULL; |
739 priv->expanded_color = color ? gdk_color_copy(color) : NULL; |
| 747 } |
740 } |
| 751 { |
744 { |
| 752 PidginBlistThemePrivate *priv; |
745 PidginBlistThemePrivate *priv; |
| 753 |
746 |
| 754 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
747 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 755 |
748 |
| 756 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
749 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 757 |
750 |
| 758 pidgin_theme_font_free(priv->expanded); |
751 pidgin_theme_font_free(priv->expanded); |
| 759 priv->expanded = copy_font_and_color(pair); |
752 priv->expanded = copy_font_and_color(pair); |
| 760 } |
753 } |
| 761 |
754 |
| 764 { |
757 { |
| 765 PidginBlistThemePrivate *priv; |
758 PidginBlistThemePrivate *priv; |
| 766 |
759 |
| 767 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
760 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 768 |
761 |
| 769 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
762 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 770 |
763 |
| 771 if (priv->collapsed_color) |
764 if (priv->collapsed_color) |
| 772 gdk_color_free(priv->collapsed_color); |
765 gdk_color_free(priv->collapsed_color); |
| 773 priv->collapsed_color = color ? gdk_color_copy(color) : NULL; |
766 priv->collapsed_color = color ? gdk_color_copy(color) : NULL; |
| 774 } |
767 } |
| 778 { |
771 { |
| 779 PidginBlistThemePrivate *priv; |
772 PidginBlistThemePrivate *priv; |
| 780 |
773 |
| 781 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
774 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 782 |
775 |
| 783 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
776 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 784 |
777 |
| 785 pidgin_theme_font_free(priv->collapsed); |
778 pidgin_theme_font_free(priv->collapsed); |
| 786 priv->collapsed = copy_font_and_color(pair); |
779 priv->collapsed = copy_font_and_color(pair); |
| 787 } |
780 } |
| 788 |
781 |
| 791 { |
784 { |
| 792 PidginBlistThemePrivate *priv; |
785 PidginBlistThemePrivate *priv; |
| 793 |
786 |
| 794 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
787 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 795 |
788 |
| 796 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
789 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 797 |
790 |
| 798 if (priv->contact_color) |
791 if (priv->contact_color) |
| 799 gdk_color_free(priv->contact_color); |
792 gdk_color_free(priv->contact_color); |
| 800 priv->contact_color = color ? gdk_color_copy(color) : NULL; |
793 priv->contact_color = color ? gdk_color_copy(color) : NULL; |
| 801 } |
794 } |
| 805 { |
798 { |
| 806 PidginBlistThemePrivate *priv; |
799 PidginBlistThemePrivate *priv; |
| 807 |
800 |
| 808 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
801 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 809 |
802 |
| 810 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
803 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 811 |
804 |
| 812 pidgin_theme_font_free(priv->contact); |
805 pidgin_theme_font_free(priv->contact); |
| 813 priv->contact = copy_font_and_color(pair); |
806 priv->contact = copy_font_and_color(pair); |
| 814 } |
807 } |
| 815 |
808 |
| 818 { |
811 { |
| 819 PidginBlistThemePrivate *priv; |
812 PidginBlistThemePrivate *priv; |
| 820 |
813 |
| 821 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
814 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 822 |
815 |
| 823 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
816 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 824 |
817 |
| 825 pidgin_theme_font_free(priv->online); |
818 pidgin_theme_font_free(priv->online); |
| 826 priv->online = copy_font_and_color(pair); |
819 priv->online = copy_font_and_color(pair); |
| 827 } |
820 } |
| 828 |
821 |
| 831 { |
824 { |
| 832 PidginBlistThemePrivate *priv; |
825 PidginBlistThemePrivate *priv; |
| 833 |
826 |
| 834 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
827 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 835 |
828 |
| 836 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
829 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 837 |
830 |
| 838 pidgin_theme_font_free(priv->away); |
831 pidgin_theme_font_free(priv->away); |
| 839 priv->away = copy_font_and_color(pair); |
832 priv->away = copy_font_and_color(pair); |
| 840 } |
833 } |
| 841 |
834 |
| 844 { |
837 { |
| 845 PidginBlistThemePrivate *priv; |
838 PidginBlistThemePrivate *priv; |
| 846 |
839 |
| 847 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
840 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 848 |
841 |
| 849 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
842 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 850 |
843 |
| 851 pidgin_theme_font_free(priv->offline); |
844 pidgin_theme_font_free(priv->offline); |
| 852 priv->offline = copy_font_and_color(pair); |
845 priv->offline = copy_font_and_color(pair); |
| 853 } |
846 } |
| 854 |
847 |
| 857 { |
850 { |
| 858 PidginBlistThemePrivate *priv; |
851 PidginBlistThemePrivate *priv; |
| 859 |
852 |
| 860 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
853 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 861 |
854 |
| 862 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
855 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 863 |
856 |
| 864 pidgin_theme_font_free(priv->idle); |
857 pidgin_theme_font_free(priv->idle); |
| 865 priv->idle = copy_font_and_color(pair); |
858 priv->idle = copy_font_and_color(pair); |
| 866 } |
859 } |
| 867 |
860 |
| 870 { |
863 { |
| 871 PidginBlistThemePrivate *priv; |
864 PidginBlistThemePrivate *priv; |
| 872 |
865 |
| 873 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
866 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 874 |
867 |
| 875 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
868 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 876 |
869 |
| 877 pidgin_theme_font_free(priv->message); |
870 pidgin_theme_font_free(priv->message); |
| 878 priv->message = copy_font_and_color(pair); |
871 priv->message = copy_font_and_color(pair); |
| 879 } |
872 } |
| 880 |
873 |
| 883 { |
876 { |
| 884 PidginBlistThemePrivate *priv; |
877 PidginBlistThemePrivate *priv; |
| 885 |
878 |
| 886 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
879 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 887 |
880 |
| 888 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
881 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 889 |
882 |
| 890 pidgin_theme_font_free(priv->message_nick_said); |
883 pidgin_theme_font_free(priv->message_nick_said); |
| 891 priv->message_nick_said = copy_font_and_color(pair); |
884 priv->message_nick_said = copy_font_and_color(pair); |
| 892 } |
885 } |
| 893 |
886 |
| 896 { |
889 { |
| 897 PidginBlistThemePrivate *priv; |
890 PidginBlistThemePrivate *priv; |
| 898 |
891 |
| 899 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
892 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme)); |
| 900 |
893 |
| 901 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); |
894 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); |
| 902 |
895 |
| 903 pidgin_theme_font_free(priv->status); |
896 pidgin_theme_font_free(priv->status); |
| 904 priv->status = copy_font_and_color(pair); |
897 priv->status = copy_font_and_color(pair); |
| 905 } |
898 } |