Mercurial > pidgin.yaz
comparison pidgin/gtkconv-theme.c @ 32827:4a34689eeb33 default tip
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 19 Nov 2011 14:42:54 +0900 |
parents | 910475e626be |
children |
comparison
equal
deleted
inserted
replaced
32692:0f94ec89f0bc | 32827:4a34689eeb33 |
---|---|
81 /****************************************************************************** | 81 /****************************************************************************** |
82 * Globals | 82 * Globals |
83 *****************************************************************************/ | 83 *****************************************************************************/ |
84 | 84 |
85 static GObjectClass *parent_class = NULL; | 85 static GObjectClass *parent_class = NULL; |
86 #if GLIB_CHECK_VERSION(2,26,0) | |
86 static GParamSpec *properties[PROP_LAST]; | 87 static GParamSpec *properties[PROP_LAST]; |
88 #endif | |
87 | 89 |
88 /****************************************************************************** | 90 /****************************************************************************** |
89 * Helper Functions | 91 * Helper Functions |
90 *****************************************************************************/ | 92 *****************************************************************************/ |
91 | 93 |
107 } | 109 } |
108 | 110 |
109 return val; | 111 return val; |
110 } | 112 } |
111 | 113 |
114 /* The template path can either come from the theme, or can | |
115 * be stock Template.html that comes with Pidgin */ | |
116 static char * | |
117 get_template_path(const char *dir) | |
118 { | |
119 char *file; | |
120 | |
121 file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); | |
122 | |
123 if (!g_file_test(file, G_FILE_TEST_EXISTS)) { | |
124 g_free(file); | |
125 file = g_build_filename(DATADIR, "pidgin", "theme", "conversation", "Template.html", NULL); | |
126 } | |
127 | |
128 return file; | |
129 } | |
130 | |
112 static const char * | 131 static const char * |
113 get_template_html(PidginConvThemePrivate *priv, const char *dir) | 132 get_template_html(PidginConvThemePrivate *priv, const char *dir) |
114 { | 133 { |
115 char *file; | 134 char *file; |
116 | 135 |
117 if (priv->template_html) | 136 if (priv->template_html) |
118 return priv->template_html; | 137 return priv->template_html; |
119 | 138 |
120 /* The template path can either come from the theme, or can | 139 file = get_template_path(dir); |
121 * be stock Template.html that comes with the plugin */ | |
122 file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); | |
123 | |
124 if (!g_file_test(file, G_FILE_TEST_EXISTS)) { | |
125 g_free(file); | |
126 file = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL); | |
127 } | |
128 | 140 |
129 if (!g_file_get_contents(file, &priv->template_html, NULL, NULL)) { | 141 if (!g_file_get_contents(file, &priv->template_html, NULL, NULL)) { |
130 purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", file); | 142 purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", file); |
131 priv->template_html = g_strdup(""); | 143 priv->template_html = g_strdup(""); |
132 } | 144 } |
367 | 379 |
368 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "NextContext.html", NULL); | 380 file = g_build_filename(dir, "Contents", "Resources", "Outgoing", "NextContext.html", NULL); |
369 if (!g_file_get_contents(file, &priv->outgoing_next_context_html, NULL, NULL)) { | 381 if (!g_file_get_contents(file, &priv->outgoing_next_context_html, NULL, NULL)) { |
370 priv->outgoing_next_context_html = g_strdup(get_outgoing_context_html(priv, dir)); | 382 priv->outgoing_next_context_html = g_strdup(get_outgoing_context_html(priv, dir)); |
371 } | 383 } |
384 g_free(file); | |
372 | 385 |
373 return priv->outgoing_next_context_html; | 386 return priv->outgoing_next_context_html; |
374 } | 387 } |
375 | 388 |
376 static void | 389 static void |
505 pspec = g_param_spec_boxed("info", "Info", | 518 pspec = g_param_spec_boxed("info", "Info", |
506 "The information about this theme", | 519 "The information about this theme", |
507 G_TYPE_HASH_TABLE, | 520 G_TYPE_HASH_TABLE, |
508 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | 521 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); |
509 g_object_class_install_property(obj_class, PROP_INFO, pspec); | 522 g_object_class_install_property(obj_class, PROP_INFO, pspec); |
523 #if GLIB_CHECK_VERSION(2,26,0) | |
510 properties[PROP_INFO] = pspec; | 524 properties[PROP_INFO] = pspec; |
525 #endif | |
511 | 526 |
512 /* VARIANT */ | 527 /* VARIANT */ |
513 pspec = g_param_spec_string("variant", "Variant", | 528 pspec = g_param_spec_string("variant", "Variant", |
514 "The current variant for this theme", | 529 "The current variant for this theme", |
515 NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); | 530 NULL, G_PARAM_READWRITE); |
516 g_object_class_install_property(obj_class, PROP_VARIANT, pspec); | 531 g_object_class_install_property(obj_class, PROP_VARIANT, pspec); |
532 #if GLIB_CHECK_VERSION(2,26,0) | |
517 properties[PROP_VARIANT] = pspec; | 533 properties[PROP_VARIANT] = pspec; |
518 | 534 #endif |
519 } | 535 } |
520 | 536 |
521 GType | 537 GType |
522 pidgin_conversation_theme_get_type(void) | 538 pidgin_conversation_theme_get_type(void) |
523 { | 539 { |
678 | 694 |
679 void | 695 void |
680 pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant) | 696 pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant) |
681 { | 697 { |
682 _set_variant(theme, variant); | 698 _set_variant(theme, variant); |
699 #if GLIB_CHECK_VERSION(2,26,0) | |
683 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_VARIANT]); | 700 g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_VARIANT]); |
701 #else | |
702 g_object_notify(G_OBJECT(theme), "variant"); | |
703 #endif | |
684 } | 704 } |
685 | 705 |
686 const GList * | 706 const GList * |
687 pidgin_conversation_theme_get_variants(PidginConvTheme *theme) | 707 pidgin_conversation_theme_get_variants(PidginConvTheme *theme) |
688 { | 708 { |
697 | 717 |
698 char * | 718 char * |
699 pidgin_conversation_theme_get_template_path(PidginConvTheme *theme) | 719 pidgin_conversation_theme_get_template_path(PidginConvTheme *theme) |
700 { | 720 { |
701 const char *dir; | 721 const char *dir; |
702 char *filename; | |
703 | 722 |
704 g_return_val_if_fail(theme != NULL, NULL); | 723 g_return_val_if_fail(theme != NULL, NULL); |
705 | 724 |
706 dir = purple_theme_get_dir(PURPLE_THEME(theme)); | 725 dir = purple_theme_get_dir(PURPLE_THEME(theme)); |
707 filename = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); | 726 |
708 | 727 return get_template_path(dir); |
709 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
710 g_free(filename); | |
711 filename = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL); | |
712 } | |
713 | |
714 return filename; | |
715 } | 728 } |
716 | 729 |
717 char * | 730 char * |
718 pidgin_conversation_theme_get_css_path(PidginConvTheme *theme) | 731 pidgin_conversation_theme_get_css_path(PidginConvTheme *theme) |
719 { | 732 { |