pidgin/gtkblist-theme.c

branch
soc.2013.gobjectification
changeset 35060
195dbb3b6432
parent 35058
506740af931c
child 35075
3a3c90a0ec07
equal deleted inserted replaced
35059:5fd94b14cc49 35060:195dbb3b6432
344 344
345 parent_class->finalize (obj); 345 parent_class->finalize (obj);
346 } 346 }
347 347
348 static void 348 static void
349 pidgin_blist_theme_init(PidginBlistTheme *theme)
350 {
351 PIDGIN_BLIST_THEME_GET_PRIVATE(theme)->opacity = 1.0;
352 }
353
354 static void
349 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass) 355 pidgin_blist_theme_class_init(PidginBlistThemeClass *klass)
350 { 356 {
351 GObjectClass *obj_class = G_OBJECT_CLASS(klass); 357 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
352 GParamSpec *pspec; 358 GParamSpec *pspec;
353 359
360 obj_class->finalize = pidgin_blist_theme_finalize; 366 obj_class->finalize = pidgin_blist_theme_finalize;
361 367
362 /* Buddy List */ 368 /* Buddy List */
363 pspec = g_param_spec_boxed("background-color", "Background Color", 369 pspec = g_param_spec_boxed("background-color", "Background Color",
364 "The background color for the buddy list", 370 "The background color for the buddy list",
365 GDK_TYPE_COLOR, G_PARAM_READWRITE); 371 GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
366 g_object_class_install_property(obj_class, PROP_BACKGROUND_COLOR, pspec); 372 g_object_class_install_property(obj_class, PROP_BACKGROUND_COLOR, pspec);
373
374 pspec = g_param_spec_double("opacity", "Opacity",
375 "The opacity of the buddy list",
376 0.0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
377 g_object_class_install_property(obj_class, PROP_OPACITY, pspec);
367 378
368 pspec = g_param_spec_pointer("layout", "Layout", 379 pspec = g_param_spec_pointer("layout", "Layout",
369 "The layout of icons, name, and status of the buddy list", 380 "The layout of icons, name, and status of the buddy list",
370 G_PARAM_READWRITE); 381 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
371 382
372 g_object_class_install_property(obj_class, PROP_LAYOUT, pspec); 383 g_object_class_install_property(obj_class, PROP_LAYOUT, pspec);
373 384
374 /* Group */ 385 /* Group */
375 /* Note to translators: These two strings refer to the background color
376 of a buddy list group when in its expanded state */
377 pspec = g_param_spec_boxed("expanded-color", "Expanded Background Color", 386 pspec = g_param_spec_boxed("expanded-color", "Expanded Background Color",
378 "The background color of an expanded group", 387 "The background color of an expanded group",
379 GDK_TYPE_COLOR, G_PARAM_READWRITE); 388 GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
380 g_object_class_install_property(obj_class, PROP_EXPANDED_COLOR, pspec); 389 g_object_class_install_property(obj_class, PROP_EXPANDED_COLOR, pspec);
381 390
382 /* Note to translators: These two strings refer to the font and color
383 of a buddy list group when in its expanded state */
384 pspec = g_param_spec_pointer("expanded-text", "Expanded Text", 391 pspec = g_param_spec_pointer("expanded-text", "Expanded Text",
385 "The text information for when a group is expanded", 392 "The text information for when a group is expanded",
386 G_PARAM_READWRITE); 393 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
387 g_object_class_install_property(obj_class, PROP_EXPANDED_TEXT, pspec); 394 g_object_class_install_property(obj_class, PROP_EXPANDED_TEXT, pspec);
388 395
389 /* Note to translators: These two strings refer to the background color
390 of a buddy list group when in its collapsed state */
391 pspec = g_param_spec_boxed("collapsed-color", "Collapsed Background Color", 396 pspec = g_param_spec_boxed("collapsed-color", "Collapsed Background Color",
392 "The background color of a collapsed group", 397 "The background color of a collapsed group",
393 GDK_TYPE_COLOR, G_PARAM_READWRITE); 398 GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
394 g_object_class_install_property(obj_class, PROP_COLLAPSED_COLOR, pspec); 399 g_object_class_install_property(obj_class, PROP_COLLAPSED_COLOR, pspec);
395 400
396 /* Note to translators: These two strings refer to the font and color
397 of a buddy list group when in its collapsed state */
398 pspec = g_param_spec_pointer("collapsed-text", "Collapsed Text", 401 pspec = g_param_spec_pointer("collapsed-text", "Collapsed Text",
399 "The text information for when a group is collapsed", 402 "The text information for when a group is collapsed",
400 G_PARAM_READWRITE); 403 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
401 g_object_class_install_property(obj_class, PROP_COLLAPSED_TEXT, pspec); 404 g_object_class_install_property(obj_class, PROP_COLLAPSED_TEXT, pspec);
402 405
403 /* Buddy */ 406 /* Buddy */
404 /* Note to translators: These two strings refer to the background color
405 of a buddy list contact or chat room */
406 pspec = g_param_spec_boxed("contact-color", "Contact/Chat Background Color", 407 pspec = g_param_spec_boxed("contact-color", "Contact/Chat Background Color",
407 "The background color of a contact or chat", 408 "The background color of a contact or chat",
408 GDK_TYPE_COLOR, G_PARAM_READWRITE); 409 GDK_TYPE_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
409 g_object_class_install_property(obj_class, PROP_CONTACT_COLOR, pspec); 410 g_object_class_install_property(obj_class, PROP_CONTACT_COLOR, pspec);
410 411
411 /* Note to translators: These two strings refer to the font and color
412 of a buddy list contact when in its expanded state */
413 pspec = g_param_spec_pointer("contact", "Contact Text", 412 pspec = g_param_spec_pointer("contact", "Contact Text",
414 "The text information for when a contact is expanded", 413 "The text information for when a contact is expanded",
415 G_PARAM_READWRITE); 414 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
416 g_object_class_install_property(obj_class, PROP_CONTACT, pspec); 415 g_object_class_install_property(obj_class, PROP_CONTACT, pspec);
417 416
418 /* Note to translators: These two strings refer to the font and color
419 of a buddy list buddy when it is online */
420 pspec = g_param_spec_pointer("online", "Online Text", 417 pspec = g_param_spec_pointer("online", "Online Text",
421 "The text information for when a buddy is online", 418 "The text information for when a buddy is online",
422 G_PARAM_READWRITE); 419 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
423 g_object_class_install_property(obj_class, PROP_ONLINE, pspec); 420 g_object_class_install_property(obj_class, PROP_ONLINE, pspec);
424 421
425 /* Note to translators: These two strings refer to the font and color
426 of a buddy list buddy when it is away */
427 pspec = g_param_spec_pointer("away", "Away Text", 422 pspec = g_param_spec_pointer("away", "Away Text",
428 "The text information for when a buddy is away", 423 "The text information for when a buddy is away",
429 G_PARAM_READWRITE); 424 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
430 g_object_class_install_property(obj_class, PROP_AWAY, pspec); 425 g_object_class_install_property(obj_class, PROP_AWAY, pspec);
431 426
432 /* Note to translators: These two strings refer to the font and color
433 of a buddy list buddy when it is offline */
434 pspec = g_param_spec_pointer("offline", "Offline Text", 427 pspec = g_param_spec_pointer("offline", "Offline Text",
435 "The text information for when a buddy is offline", 428 "The text information for when a buddy is offline",
436 G_PARAM_READWRITE); 429 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
437 g_object_class_install_property(obj_class, PROP_OFFLINE, pspec); 430 g_object_class_install_property(obj_class, PROP_OFFLINE, pspec);
438 431
439 /* Note to translators: These two strings refer to the font and color
440 of a buddy list buddy when it is idle */
441 pspec = g_param_spec_pointer("idle", "Idle Text", 432 pspec = g_param_spec_pointer("idle", "Idle Text",
442 "The text information for when a buddy is idle", 433 "The text information for when a buddy is idle",
443 G_PARAM_READWRITE); 434 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
444 g_object_class_install_property(obj_class, PROP_IDLE, pspec); 435 g_object_class_install_property(obj_class, PROP_IDLE, pspec);
445 436
446 /* Note to translators: These two strings refer to the font and color
447 of a buddy list buddy when they have sent you a new message */
448 pspec = g_param_spec_pointer("message", "Message Text", 437 pspec = g_param_spec_pointer("message", "Message Text",
449 "The text information for when a buddy has an unread message", 438 "The text information for when a buddy has an unread message",
450 G_PARAM_READWRITE); 439 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
451 g_object_class_install_property(obj_class, PROP_MESSAGE, pspec); 440 g_object_class_install_property(obj_class, PROP_MESSAGE, pspec);
452 441
453 /* Note to translators: These two strings refer to the font and color 442 pspec = g_param_spec_pointer("message-nick-said", "Message (Nick Said) Text",
454 of a buddy list buddy when they have sent you a new message */
455 pspec = g_param_spec_pointer("message_nick_said", "Message (Nick Said) Text",
456 "The text information for when a chat has an unread message that mentions your nickname", 443 "The text information for when a chat has an unread message that mentions your nickname",
457 G_PARAM_READWRITE); 444 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
458 g_object_class_install_property(obj_class, PROP_MESSAGE_NICK_SAID, pspec); 445 g_object_class_install_property(obj_class, PROP_MESSAGE_NICK_SAID, pspec);
459 446
460 pspec = g_param_spec_pointer("status", "Status Text", 447 pspec = g_param_spec_pointer("status", "Status Text",
461 "The text information for a buddy's status", 448 "The text information for a buddy's status",
462 G_PARAM_READWRITE); 449 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
463 g_object_class_install_property(obj_class, PROP_STATUS, pspec); 450 g_object_class_install_property(obj_class, PROP_STATUS, pspec);
464 } 451 }
465 452
466 GType 453 GType
467 pidgin_blist_theme_get_type (void) 454 pidgin_blist_theme_get_type (void)
475 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */ 462 (GClassInitFunc)pidgin_blist_theme_class_init, /* class_init */
476 NULL, /* class_finalize */ 463 NULL, /* class_finalize */
477 NULL, /* class_data */ 464 NULL, /* class_data */
478 sizeof(PidginBlistTheme), 465 sizeof(PidginBlistTheme),
479 0, /* n_preallocs */ 466 0, /* n_preallocs */
480 NULL, /* instance_init */ 467 (GInstanceInitFunc)pidgin_blist_theme_init, /* instance_init */
481 NULL, /* value table */ 468 NULL, /* value table */
482 }; 469 };
483 type = g_type_register_static (PURPLE_TYPE_THEME, 470 type = g_type_register_static (PURPLE_TYPE_THEME,
484 "PidginBlistTheme", &info, 0); 471 "PidginBlistTheme", &info, 0);
485 } 472 }
696 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 683 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
697 684
698 if (priv->bgcolor) 685 if (priv->bgcolor)
699 gdk_color_free(priv->bgcolor); 686 gdk_color_free(priv->bgcolor);
700 priv->bgcolor = color ? gdk_color_copy(color) : NULL; 687 priv->bgcolor = color ? gdk_color_copy(color) : NULL;
688
689 g_object_notify(G_OBJECT(theme), "background-color");
701 } 690 }
702 691
703 void 692 void
704 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity) 693 pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity)
705 { 694 {
708 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme) || opacity < 0.0 || opacity > 1.0); 697 g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme) || opacity < 0.0 || opacity > 1.0);
709 698
710 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 699 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
711 700
712 priv->opacity = opacity; 701 priv->opacity = opacity;
702
703 g_object_notify(G_OBJECT(theme), "opacity");
713 } 704 }
714 705
715 void 706 void
716 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout) 707 pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout)
717 { 708 {
721 712
722 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 713 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
723 714
724 g_free(priv->layout); 715 g_free(priv->layout);
725 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout)); 716 priv->layout = g_memdup(layout, sizeof(PidginBlistLayout));
717
718 g_object_notify(G_OBJECT(theme), "layout");
726 } 719 }
727 720
728 void 721 void
729 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkColor *color) 722 pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkColor *color)
730 { 723 {
735 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 728 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
736 729
737 if (priv->expanded_color) 730 if (priv->expanded_color)
738 gdk_color_free(priv->expanded_color); 731 gdk_color_free(priv->expanded_color);
739 priv->expanded_color = color ? gdk_color_copy(color) : NULL; 732 priv->expanded_color = color ? gdk_color_copy(color) : NULL;
733
734 g_object_notify(G_OBJECT(theme), "expanded-color");
740 } 735 }
741 736
742 void 737 void
743 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 738 pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
744 { 739 {
748 743
749 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 744 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
750 745
751 pidgin_theme_font_free(priv->expanded); 746 pidgin_theme_font_free(priv->expanded);
752 priv->expanded = copy_font_and_color(pair); 747 priv->expanded = copy_font_and_color(pair);
748
749 g_object_notify(G_OBJECT(theme), "expanded-text");
753 } 750 }
754 751
755 void 752 void
756 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkColor *color) 753 pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkColor *color)
757 { 754 {
762 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 759 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
763 760
764 if (priv->collapsed_color) 761 if (priv->collapsed_color)
765 gdk_color_free(priv->collapsed_color); 762 gdk_color_free(priv->collapsed_color);
766 priv->collapsed_color = color ? gdk_color_copy(color) : NULL; 763 priv->collapsed_color = color ? gdk_color_copy(color) : NULL;
764
765 g_object_notify(G_OBJECT(theme), "collapsed-color");
767 } 766 }
768 767
769 void 768 void
770 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 769 pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
771 { 770 {
775 774
776 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 775 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
777 776
778 pidgin_theme_font_free(priv->collapsed); 777 pidgin_theme_font_free(priv->collapsed);
779 priv->collapsed = copy_font_and_color(pair); 778 priv->collapsed = copy_font_and_color(pair);
779
780 g_object_notify(G_OBJECT(theme), "collapsed-text");
780 } 781 }
781 782
782 void 783 void
783 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkColor *color) 784 pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkColor *color)
784 { 785 {
789 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 790 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
790 791
791 if (priv->contact_color) 792 if (priv->contact_color)
792 gdk_color_free(priv->contact_color); 793 gdk_color_free(priv->contact_color);
793 priv->contact_color = color ? gdk_color_copy(color) : NULL; 794 priv->contact_color = color ? gdk_color_copy(color) : NULL;
795
796 g_object_notify(G_OBJECT(theme), "contact-color");
794 } 797 }
795 798
796 void 799 void
797 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 800 pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
798 { 801 {
802 805
803 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 806 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
804 807
805 pidgin_theme_font_free(priv->contact); 808 pidgin_theme_font_free(priv->contact);
806 priv->contact = copy_font_and_color(pair); 809 priv->contact = copy_font_and_color(pair);
810
811 g_object_notify(G_OBJECT(theme), "contact");
807 } 812 }
808 813
809 void 814 void
810 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 815 pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
811 { 816 {
815 820
816 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 821 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
817 822
818 pidgin_theme_font_free(priv->online); 823 pidgin_theme_font_free(priv->online);
819 priv->online = copy_font_and_color(pair); 824 priv->online = copy_font_and_color(pair);
825
826 g_object_notify(G_OBJECT(theme), "online");
820 } 827 }
821 828
822 void 829 void
823 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 830 pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
824 { 831 {
828 835
829 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 836 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
830 837
831 pidgin_theme_font_free(priv->away); 838 pidgin_theme_font_free(priv->away);
832 priv->away = copy_font_and_color(pair); 839 priv->away = copy_font_and_color(pair);
840
841 g_object_notify(G_OBJECT(theme), "away");
833 } 842 }
834 843
835 void 844 void
836 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 845 pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
837 { 846 {
841 850
842 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 851 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
843 852
844 pidgin_theme_font_free(priv->offline); 853 pidgin_theme_font_free(priv->offline);
845 priv->offline = copy_font_and_color(pair); 854 priv->offline = copy_font_and_color(pair);
855
856 g_object_notify(G_OBJECT(theme), "offline");
846 } 857 }
847 858
848 void 859 void
849 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 860 pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
850 { 861 {
854 865
855 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 866 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
856 867
857 pidgin_theme_font_free(priv->idle); 868 pidgin_theme_font_free(priv->idle);
858 priv->idle = copy_font_and_color(pair); 869 priv->idle = copy_font_and_color(pair);
870
871 g_object_notify(G_OBJECT(theme), "idle");
859 } 872 }
860 873
861 void 874 void
862 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 875 pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
863 { 876 {
867 880
868 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 881 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
869 882
870 pidgin_theme_font_free(priv->message); 883 pidgin_theme_font_free(priv->message);
871 priv->message = copy_font_and_color(pair); 884 priv->message = copy_font_and_color(pair);
885
886 g_object_notify(G_OBJECT(theme), "message");
872 } 887 }
873 888
874 void 889 void
875 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 890 pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
876 { 891 {
880 895
881 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 896 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
882 897
883 pidgin_theme_font_free(priv->message_nick_said); 898 pidgin_theme_font_free(priv->message_nick_said);
884 priv->message_nick_said = copy_font_and_color(pair); 899 priv->message_nick_said = copy_font_and_color(pair);
900
901 g_object_notify(G_OBJECT(theme), "message-nick-said");
885 } 902 }
886 903
887 void 904 void
888 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) 905 pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair)
889 { 906 {
893 910
894 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme); 911 priv = PIDGIN_BLIST_THEME_GET_PRIVATE(theme);
895 912
896 pidgin_theme_font_free(priv->status); 913 pidgin_theme_font_free(priv->status);
897 priv->status = copy_font_and_color(pair); 914 priv->status = copy_font_and_color(pair);
898 } 915
916 g_object_notify(G_OBJECT(theme), "status");
917 }

mercurial