| 84 |
81 |
| 85 /****************************************************************************** |
82 /****************************************************************************** |
| 86 * Globals |
83 * Globals |
| 87 *****************************************************************************/ |
84 *****************************************************************************/ |
| 88 |
85 |
| 89 static GObjectClass *parent_class = NULL; |
|
| 90 static GParamSpec *properties[PROP_LAST]; |
86 static GParamSpec *properties[PROP_LAST]; |
| |
87 |
| |
88 G_DEFINE_TYPE_WITH_PRIVATE(PidginConvTheme, pidgin_conversation_theme, |
| |
89 PURPLE_TYPE_THEME); |
| 91 |
90 |
| 92 /****************************************************************************** |
91 /****************************************************************************** |
| 93 * Helper Functions |
92 * Helper Functions |
| 94 *****************************************************************************/ |
93 *****************************************************************************/ |
| 95 |
94 |
| 434 break; |
433 break; |
| 435 } |
434 } |
| 436 } |
435 } |
| 437 |
436 |
| 438 static void |
437 static void |
| 439 pidgin_conv_theme_init(GTypeInstance *instance, |
438 pidgin_conversation_theme_init(PidginConvTheme *theme) |
| 440 gpointer klass) |
|
| 441 { |
439 { |
| 442 #if 0 |
440 #if 0 |
| 443 PidginConvThemePrivate *priv; |
441 PidginConvThemePrivate *priv; |
| 444 |
442 |
| 445 priv = PIDGIN_CONV_THEME_GET_PRIVATE(instance); |
443 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 446 #endif |
444 #endif |
| 447 } |
445 } |
| 448 |
446 |
| 449 static void |
447 static void |
| 450 pidgin_conv_theme_finalize(GObject *obj) |
448 pidgin_conv_theme_finalize(GObject *obj) |
| 451 { |
449 { |
| 452 PidginConvThemePrivate *priv; |
450 PidginConvThemePrivate *priv; |
| 453 GList *list; |
451 GList *list; |
| 454 |
452 |
| 455 priv = PIDGIN_CONV_THEME_GET_PRIVATE(obj); |
453 priv = pidgin_conversation_theme_get_instance_private( |
| |
454 PIDGIN_CONV_THEME(obj)); |
| 456 |
455 |
| 457 g_free(priv->template_html); |
456 g_free(priv->template_html); |
| 458 g_free(priv->header_html); |
457 g_free(priv->header_html); |
| 459 g_free(priv->footer_html); |
458 g_free(priv->footer_html); |
| 460 g_free(priv->topic_html); |
459 g_free(priv->topic_html); |
| 481 g_free(priv->variant); |
480 g_free(priv->variant); |
| 482 |
481 |
| 483 if (priv->nick_colors) |
482 if (priv->nick_colors) |
| 484 g_array_unref(priv->nick_colors); |
483 g_array_unref(priv->nick_colors); |
| 485 |
484 |
| 486 parent_class->finalize(obj); |
485 G_OBJECT_CLASS(pidgin_conversation_theme_parent_class)->finalize(obj); |
| 487 } |
486 } |
| 488 |
487 |
| 489 static void |
488 static void |
| 490 pidgin_conv_theme_class_init(PidginConvThemeClass *klass) |
489 pidgin_conversation_theme_class_init(PidginConvThemeClass *klass) |
| 491 { |
490 { |
| 492 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
491 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
| 493 |
|
| 494 parent_class = g_type_class_peek_parent(klass); |
|
| 495 |
|
| 496 g_type_class_add_private(klass, sizeof(PidginConvThemePrivate)); |
|
| 497 |
492 |
| 498 obj_class->get_property = pidgin_conv_theme_get_property; |
493 obj_class->get_property = pidgin_conv_theme_get_property; |
| 499 obj_class->set_property = pidgin_conv_theme_set_property; |
494 obj_class->set_property = pidgin_conv_theme_set_property; |
| 500 obj_class->finalize = pidgin_conv_theme_finalize; |
495 obj_class->finalize = pidgin_conv_theme_finalize; |
| 501 |
496 |
| 511 NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
506 NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
| 512 |
507 |
| 513 g_object_class_install_properties(obj_class, PROP_LAST, properties); |
508 g_object_class_install_properties(obj_class, PROP_LAST, properties); |
| 514 } |
509 } |
| 515 |
510 |
| 516 GType |
|
| 517 pidgin_conversation_theme_get_type(void) |
|
| 518 { |
|
| 519 static GType type = 0; |
|
| 520 if (type == 0) { |
|
| 521 static const GTypeInfo info = { |
|
| 522 sizeof(PidginConvThemeClass), |
|
| 523 NULL, /* base_init */ |
|
| 524 NULL, /* base_finalize */ |
|
| 525 (GClassInitFunc)pidgin_conv_theme_class_init, /* class_init */ |
|
| 526 NULL, /* class_finalize */ |
|
| 527 NULL, /* class_data */ |
|
| 528 sizeof(PidginConvTheme), |
|
| 529 0, /* n_preallocs */ |
|
| 530 pidgin_conv_theme_init, /* instance_init */ |
|
| 531 NULL, /* value table */ |
|
| 532 }; |
|
| 533 type = g_type_register_static(PURPLE_TYPE_THEME, |
|
| 534 "PidginConvTheme", &info, 0); |
|
| 535 } |
|
| 536 return type; |
|
| 537 } |
|
| 538 |
|
| 539 /***************************************************************************** |
511 /***************************************************************************** |
| 540 * Public API functions |
512 * Public API functions |
| 541 *****************************************************************************/ |
513 *****************************************************************************/ |
| 542 |
514 |
| 543 const GHashTable * |
515 const GHashTable * |
| 544 pidgin_conversation_theme_get_info(const PidginConvTheme *theme) |
516 pidgin_conversation_theme_get_info(PidginConvTheme *theme) |
| 545 { |
517 { |
| 546 PidginConvThemePrivate *priv; |
518 PidginConvThemePrivate *priv; |
| 547 |
519 |
| 548 g_return_val_if_fail(theme != NULL, NULL); |
520 g_return_val_if_fail(theme != NULL, NULL); |
| 549 |
521 |
| 550 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
522 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 551 return priv->info; |
523 return priv->info; |
| 552 } |
524 } |
| 553 |
525 |
| 554 void |
526 void |
| 555 pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info) |
527 pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info) |
| 556 { |
528 { |
| 557 PidginConvThemePrivate *priv; |
529 PidginConvThemePrivate *priv; |
| 558 |
530 |
| 559 g_return_if_fail(theme != NULL); |
531 g_return_if_fail(theme != NULL); |
| 560 |
532 |
| 561 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
533 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 562 |
534 |
| 563 if (priv->info) |
535 if (priv->info) |
| 564 g_hash_table_destroy(priv->info); |
536 g_hash_table_destroy(priv->info); |
| 565 |
537 |
| 566 priv->info = info; |
538 priv->info = info; |
| 587 const char *dir; |
559 const char *dir; |
| 588 const char *html; |
560 const char *html; |
| 589 |
561 |
| 590 g_return_val_if_fail(theme != NULL, NULL); |
562 g_return_val_if_fail(theme != NULL, NULL); |
| 591 |
563 |
| 592 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
564 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 593 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
565 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
| 594 |
566 |
| 595 switch (type) { |
567 switch (type) { |
| 596 case PIDGIN_CONVERSATION_THEME_TEMPLATE_MAIN: |
568 case PIDGIN_CONVERSATION_THEME_TEMPLATE_MAIN: |
| 597 html = get_template_html(priv, dir); |
569 html = get_template_html(priv, dir); |
| 654 PidginConvThemePrivate *priv; |
626 PidginConvThemePrivate *priv; |
| 655 |
627 |
| 656 g_return_if_fail(theme != NULL); |
628 g_return_if_fail(theme != NULL); |
| 657 g_return_if_fail(variant != NULL); |
629 g_return_if_fail(variant != NULL); |
| 658 |
630 |
| 659 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
631 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 660 |
632 |
| 661 priv->variants = g_list_prepend(priv->variants, variant); |
633 priv->variants = g_list_prepend(priv->variants, variant); |
| 662 } |
634 } |
| 663 |
635 |
| 664 const char * |
636 const char * |
| 681 char *prefname; |
653 char *prefname; |
| 682 |
654 |
| 683 g_return_if_fail(theme != NULL); |
655 g_return_if_fail(theme != NULL); |
| 684 g_return_if_fail(variant != NULL); |
656 g_return_if_fail(variant != NULL); |
| 685 |
657 |
| 686 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
658 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 687 |
659 |
| 688 g_free(priv->variant); |
660 g_free(priv->variant); |
| 689 priv->variant = g_strdup(variant); |
661 priv->variant = g_strdup(variant); |
| 690 |
662 |
| 691 val = get_key(priv, "CFBundleIdentifier", FALSE); |
663 val = get_key(priv, "CFBundleIdentifier", FALSE); |
| 727 PidginConvThemePrivate *priv; |
699 PidginConvThemePrivate *priv; |
| 728 const char *dir; |
700 const char *dir; |
| 729 |
701 |
| 730 g_return_val_if_fail(theme != NULL, NULL); |
702 g_return_val_if_fail(theme != NULL, NULL); |
| 731 |
703 |
| 732 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
704 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 733 |
705 |
| 734 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
706 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
| 735 if (!priv->variant) { |
707 if (!priv->variant) { |
| 736 return g_build_filename(dir, "Contents", "Resources", "main.css", NULL); |
708 return g_build_filename(dir, "Contents", "Resources", "main.css", NULL); |
| 737 } else { |
709 } else { |
| 748 PidginConvThemePrivate *priv; |
720 PidginConvThemePrivate *priv; |
| 749 const char *dir; |
721 const char *dir; |
| 750 |
722 |
| 751 g_return_val_if_fail(theme != NULL, NULL); |
723 g_return_val_if_fail(theme != NULL, NULL); |
| 752 |
724 |
| 753 priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme); |
725 priv = pidgin_conversation_theme_get_instance_private(theme); |
| 754 |
726 |
| 755 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
727 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
| 756 if (NULL == priv->nick_colors) |
728 if (NULL == priv->nick_colors) |
| 757 { |
729 { |
| 758 char *file = g_build_filename(dir, "Contents", "Resources", "Incoming", "SenderColors.txt", NULL); |
730 char *file = g_build_filename(dir, "Contents", "Resources", "Incoming", "SenderColors.txt", NULL); |