pidgin/gtkimhtml.c

branch
release-2.x.y
changeset 40926
d10bb378f560
parent 40777
dd0328cdc8eb
child 41326
0079467afee4
equal deleted inserted replaced
40925:a4a68d315090 40926:d10bb378f560
352 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); 352 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
353 t->children [index] = g_new0 (GtkSmileyTree, 1); 353 t->children [index] = g_new0 (GtkSmileyTree, 1);
354 } else 354 } else
355 index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); 355 index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str);
356 356
357 t = t->children [index]; 357 if(t->children != NULL) {
358 t = t->children [index];
359 }
358 360
359 x++; 361 x++;
360 } while (*x); 362 } while (*x);
361 363
362 t->image = smiley; 364 t->image = smiley;
542 GtkIMHtml *imhtml = data; 544 GtkIMHtml *imhtml = data;
543 PangoFontMetrics *font_metrics; 545 PangoFontMetrics *font_metrics;
544 PangoLayout *layout; 546 PangoLayout *layout;
545 PangoFont *font; 547 PangoFont *font;
546 548
547 gint gap, x, y, h, w, scr_w, baseline_skip; 549 gint x, y, h, w, scr_w, baseline_skip;
548 550
549 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); 551 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
550 552
551 if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { 553 if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) {
552 imhtml->tip_timer = 0; 554 imhtml->tip_timer = 0;
596 } 598 }
597 599
598 font_metrics = pango_font_get_metrics(font, NULL); 600 font_metrics = pango_font_get_metrics(font, NULL);
599 601
600 pango_layout_get_pixel_size(layout, &scr_w, NULL); 602 pango_layout_get_pixel_size(layout, &scr_w, NULL);
601 gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + 603
602 pango_font_metrics_get_descent(font_metrics))/ 4);
603
604 if (gap < 2)
605 gap = 2;
606 baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + 604 baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) +
607 pango_font_metrics_get_descent(font_metrics)); 605 pango_font_metrics_get_descent(font_metrics));
608 w = 8 + scr_w; 606 w = 8 + scr_w;
609 h = 8 + baseline_skip; 607 h = 8 + baseline_skip;
610 608
2733 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2731 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2734 2732
2735 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) 2733 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD))
2736 gtk_imhtml_toggle_bold(imhtml); 2734 gtk_imhtml_toggle_bold(imhtml);
2737 bold++; 2735 bold++;
2738 ws[0] = '\0'; wpos = 0; 2736 ws[0] = '\0';
2737 wpos = 0;
2739 } 2738 }
2740 break; 2739 break;
2741 case 3: /* /B */ 2740 case 3: /* /B */
2742 case 4: /* /BOLD */ 2741 case 4: /* /BOLD */
2743 case 55: /* /STRONG */ 2742 case 55: /* /STRONG */
2744 if (!(options & GTK_IMHTML_NO_FORMATTING)) { 2743 if (!(options & GTK_IMHTML_NO_FORMATTING)) {
2745 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2744 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2746 ws[0] = '\0'; wpos = 0; 2745 ws[0] = '\0';
2746 wpos = 0;
2747 2747
2748 if (bold) { 2748 if (bold) {
2749 bold--; 2749 bold--;
2750 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) 2750 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo)
2751 gtk_imhtml_toggle_bold(imhtml); 2751 gtk_imhtml_toggle_bold(imhtml);
2755 case 5: /* I */ 2755 case 5: /* I */
2756 case 6: /* ITALIC */ 2756 case 6: /* ITALIC */
2757 case 52: /* EM */ 2757 case 52: /* EM */
2758 if (!(options & GTK_IMHTML_NO_FORMATTING)) { 2758 if (!(options & GTK_IMHTML_NO_FORMATTING)) {
2759 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2759 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2760 ws[0] = '\0'; wpos = 0; 2760 ws[0] = '\0';
2761 wpos = 0;
2761 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) 2762 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC))
2762 gtk_imhtml_toggle_italic(imhtml); 2763 gtk_imhtml_toggle_italic(imhtml);
2763 italics++; 2764 italics++;
2764 } 2765 }
2765 break; 2766 break;
2766 case 7: /* /I */ 2767 case 7: /* /I */
2767 case 8: /* /ITALIC */ 2768 case 8: /* /ITALIC */
2768 case 53: /* /EM */ 2769 case 53: /* /EM */
2769 if (!(options & GTK_IMHTML_NO_FORMATTING)) { 2770 if (!(options & GTK_IMHTML_NO_FORMATTING)) {
2770 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2771 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2771 ws[0] = '\0'; wpos = 0; 2772 ws[0] = '\0';
2773 wpos = 0;
2772 if (italics) { 2774 if (italics) {
2773 italics--; 2775 italics--;
2774 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) 2776 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo)
2775 gtk_imhtml_toggle_italic(imhtml); 2777 gtk_imhtml_toggle_italic(imhtml);
2776 } 2778 }
2778 break; 2780 break;
2779 case 9: /* U */ 2781 case 9: /* U */
2780 case 10: /* UNDERLINE */ 2782 case 10: /* UNDERLINE */
2781 if (!(options & GTK_IMHTML_NO_FORMATTING)) { 2783 if (!(options & GTK_IMHTML_NO_FORMATTING)) {
2782 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2784 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2783 ws[0] = '\0'; wpos = 0; 2785 ws[0] = '\0';
2786 wpos = 0;
2784 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) 2787 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE))
2785 gtk_imhtml_toggle_underline(imhtml); 2788 gtk_imhtml_toggle_underline(imhtml);
2786 underline++; 2789 underline++;
2787 } 2790 }
2788 break; 2791 break;
2789 case 11: /* /U */ 2792 case 11: /* /U */
2790 case 12: /* /UNDERLINE */ 2793 case 12: /* /UNDERLINE */
2791 if (!(options & GTK_IMHTML_NO_FORMATTING)) { 2794 if (!(options & GTK_IMHTML_NO_FORMATTING)) {
2792 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2795 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2793 ws[0] = '\0'; wpos = 0; 2796 ws[0] = '\0';
2797 wpos = 0;
2794 if (underline) { 2798 if (underline) {
2795 underline--; 2799 underline--;
2796 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) 2800 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo)
2797 gtk_imhtml_toggle_underline(imhtml); 2801 gtk_imhtml_toggle_underline(imhtml);
2798 } 2802 }
2799 } 2803 }
2800 break; 2804 break;
2801 case 13: /* S */ 2805 case 13: /* S */
2802 case 14: /* STRIKE */ 2806 case 14: /* STRIKE */
2803 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2807 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2804 ws[0] = '\0'; wpos = 0; 2808 ws[0] = '\0';
2809 wpos = 0;
2805 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) 2810 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE))
2806 gtk_imhtml_toggle_strike(imhtml); 2811 gtk_imhtml_toggle_strike(imhtml);
2807 strike++; 2812 strike++;
2808 break; 2813 break;
2809 case 15: /* /S */ 2814 case 15: /* /S */
2810 case 16: /* /STRIKE */ 2815 case 16: /* /STRIKE */
2811 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2816 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2812 ws[0] = '\0'; wpos = 0; 2817 ws[0] = '\0';
2818 wpos = 0;
2813 if (strike) 2819 if (strike)
2814 strike--; 2820 strike--;
2815 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) 2821 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo)
2816 gtk_imhtml_toggle_strike(imhtml); 2822 gtk_imhtml_toggle_strike(imhtml);
2817 break; 2823 break;
2885 scalable->add_to(scalable, imhtml, iter); 2891 scalable->add_to(scalable, imhtml, iter);
2886 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + 2892 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) +
2887 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); 2893 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml));
2888 scalable->scale(scalable, rect.width - minus, rect.height); 2894 scalable->scale(scalable, rect.width - minus, rect.height);
2889 imhtml->scalables = g_list_append(imhtml->scalables, sd); 2895 imhtml->scalables = g_list_append(imhtml->scalables, sd);
2890 ws[0] = '\0'; wpos = 0; 2896 ws[0] = '\0';
2897 wpos = 0;
2891 ws[wpos++] = '\n'; 2898 ws[wpos++] = '\n';
2892 2899
2893 break; 2900 break;
2894 } 2901 }
2895 case 27: /* /FONT */ 2902 case 27: /* /FONT */
2896 if (fonts && !imhtml->wbfo) { 2903 if (fonts && !imhtml->wbfo) {
2897 GtkIMHtmlFontDetail *font = fonts->data; 2904 GtkIMHtmlFontDetail *font = fonts->data;
2898 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2905 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2899 ws[0] = '\0'; wpos = 0; 2906 ws[0] = '\0';
2907 wpos = 0;
2900 /* NEW_BIT (NEW_TEXT_BIT); */ 2908 /* NEW_BIT (NEW_TEXT_BIT); */
2901 2909
2902 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { 2910 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) {
2903 gtk_imhtml_toggle_fontface(imhtml, NULL); 2911 gtk_imhtml_toggle_fontface(imhtml, NULL);
2904 } 2912 }
2934 } 2942 }
2935 break; 2943 break;
2936 case 28: /* /A */ 2944 case 28: /* /A */
2937 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2945 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2938 gtk_imhtml_toggle_link(imhtml, NULL); 2946 gtk_imhtml_toggle_link(imhtml, NULL);
2939 ws[0] = '\0'; wpos = 0; 2947 ws[0] = '\0';
2948 wpos = 0;
2940 break; 2949 break;
2941 2950
2942 case 30: /* /P */ 2951 case 30: /* /P */
2943 case 31: /* H3 */ 2952 case 31: /* H3 */
2944 case 32: /* /H3 */ 2953 case 32: /* /H3 */
2946 case 34: /* /HTML */ 2955 case 34: /* /HTML */
2947 case 35: /* BODY */ 2956 case 35: /* BODY */
2948 break; 2957 break;
2949 case 36: /* /BODY */ 2958 case 36: /* /BODY */
2950 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2959 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2951 ws[0] = '\0'; wpos = 0; 2960 ws[0] = '\0';
2961 wpos = 0;
2952 gtk_imhtml_toggle_background(imhtml, NULL); 2962 gtk_imhtml_toggle_background(imhtml, NULL);
2953 break; 2963 break;
2954 case 37: /* FONT */ 2964 case 37: /* FONT */
2955 case 38: /* HEAD */ 2965 case 38: /* HEAD */
2956 case 39: /* /HEAD */ 2966 case 39: /* /HEAD */
2968 sml = gtk_imhtml_get_html_opt (tag, "SML="); 2978 sml = gtk_imhtml_get_html_opt (tag, "SML=");
2969 if (!(color || back || face || size || sml)) 2979 if (!(color || back || face || size || sml))
2970 break; 2980 break;
2971 2981
2972 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 2982 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
2973 ws[0] = '\0'; wpos = 0; 2983 ws[0] = '\0';
2984 wpos = 0;
2974 2985
2975 font = g_new0 (GtkIMHtmlFontDetail, 1); 2986 font = g_new0 (GtkIMHtmlFontDetail, 1);
2976 if (fonts) 2987 if (fonts)
2977 oldfont = fonts->data; 2988 oldfont = fonts->data;
2978 2989
3027 case 44: /* BODY (opt) */ 3038 case 44: /* BODY (opt) */
3028 if (!(options & GTK_IMHTML_NO_COLOURS)) { 3039 if (!(options & GTK_IMHTML_NO_COLOURS)) {
3029 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); 3040 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
3030 if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { 3041 if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) {
3031 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3042 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3032 ws[0] = '\0'; wpos = 0; 3043 ws[0] = '\0';
3044 wpos = 0;
3033 /* NEW_BIT(NEW_TEXT_BIT); */ 3045 /* NEW_BIT(NEW_TEXT_BIT); */
3034 g_free(bg); 3046 g_free(bg);
3035 bg = bgcolor; 3047 bg = bgcolor;
3036 gtk_imhtml_toggle_background(imhtml, bg); 3048 gtk_imhtml_toggle_background(imhtml, bg);
3037 } else 3049 } else
3041 case 45: /* A (opt) */ 3053 case 45: /* A (opt) */
3042 { 3054 {
3043 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); 3055 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
3044 if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { 3056 if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) {
3045 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3057 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3046 ws[0] = '\0'; wpos = 0; 3058 ws[0] = '\0';
3059 wpos = 0;
3047 gtk_imhtml_toggle_link(imhtml, href); 3060 gtk_imhtml_toggle_link(imhtml, href);
3048 } 3061 }
3049 g_free(href); 3062 g_free(href);
3050 } 3063 }
3051 break; 3064 break;
3053 case 59: /* IMG */ 3066 case 59: /* IMG */
3054 { 3067 {
3055 char *id; 3068 char *id;
3056 3069
3057 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3070 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3058 ws[0] = '\0'; wpos = 0; 3071 ws[0] = '\0';
3072 wpos = 0;
3059 3073
3060 if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) 3074 if (!(imhtml->format_functions & GTK_IMHTML_IMAGE))
3061 break; 3075 break;
3062 3076
3063 id = gtk_imhtml_get_html_opt(tag, "ID="); 3077 id = gtk_imhtml_get_html_opt(tag, "ID=");
3122 break; 3136 break;
3123 } 3137 }
3124 3138
3125 3139
3126 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3140 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3127 ws[0] = '\0'; wpos = 0; 3141 ws[0] = '\0';
3142 wpos = 0;
3128 /* NEW_BIT (NEW_TEXT_BIT); */ 3143 /* NEW_BIT (NEW_TEXT_BIT); */
3129 3144
3130 /* Bi-Directional text support */ 3145 /* Bi-Directional text support */
3131 if (direction && (!g_ascii_strncasecmp(direction, "RTL", 3))) { 3146 if (direction && (!g_ascii_strncasecmp(direction, "RTL", 3))) {
3132 rtl_direction = TRUE; 3147 rtl_direction = TRUE;
3134 ws[wpos++] = 0xE2; 3149 ws[wpos++] = 0xE2;
3135 ws[wpos++] = 0x80; 3150 ws[wpos++] = 0x80;
3136 ws[wpos++] = 0xAB; 3151 ws[wpos++] = 0xAB;
3137 ws[wpos] = '\0'; 3152 ws[wpos] = '\0';
3138 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3153 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3139 ws[0] = '\0'; wpos = 0; 3154 ws[0] = '\0';
3155 wpos = 0;
3140 } 3156 }
3141 g_free(direction); 3157 g_free(direction);
3142 3158
3143 if (alignment && (!g_ascii_strncasecmp(alignment, "RIGHT", 5))) { 3159 if (alignment && (!g_ascii_strncasecmp(alignment, "RIGHT", 5))) {
3144 align_right = TRUE; 3160 align_right = TRUE;
3283 /* Inline CSS Support - Douglas Thrift */ 3299 /* Inline CSS Support - Douglas Thrift */
3284 if (fonts && !imhtml->wbfo) { 3300 if (fonts && !imhtml->wbfo) {
3285 GtkIMHtmlFontDetail *oldfont = NULL; 3301 GtkIMHtmlFontDetail *oldfont = NULL;
3286 GtkIMHtmlFontDetail *font = fonts->data; 3302 GtkIMHtmlFontDetail *font = fonts->data;
3287 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3303 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3288 ws[0] = '\0'; wpos = 0; 3304 ws[0] = '\0';
3305 wpos = 0;
3289 /* NEW_BIT (NEW_TEXT_BIT); */ 3306 /* NEW_BIT (NEW_TEXT_BIT); */
3290 fonts = g_slist_remove (fonts, font); 3307 fonts = g_slist_remove (fonts, font);
3291 if (fonts) 3308 if (fonts)
3292 oldfont = fonts->data; 3309 oldfont = fonts->data;
3293 3310
3354 if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { 3371 if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) {
3355 wpos = g_snprintf (ws, len, "%s", tag); 3372 wpos = g_snprintf (ws, len, "%s", tag);
3356 gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); 3373 gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL);
3357 } 3374 }
3358 #endif 3375 #endif
3359 ws[0] = '\0'; wpos = 0; 3376 ws[0] = '\0';
3377 wpos = 0;
3360 3378
3361 /* NEW_BIT (NEW_COMMENT_BIT); */ 3379 /* NEW_BIT (NEW_COMMENT_BIT); */
3362 break; 3380 break;
3363 default: 3381 default:
3364 break; 3382 break;
3380 } 3398 }
3381 if (!sml) 3399 if (!sml)
3382 sml = imhtml->protocol_name; 3400 sml = imhtml->protocol_name;
3383 3401
3384 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3402 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3385 wpos = g_snprintf (ws, smilelen + 1, "%s", c); 3403 g_snprintf (ws, smilelen + 1, "%s", c);
3386 3404
3387 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); 3405 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter);
3388 3406
3389 c += smilelen; 3407 c += smilelen;
3390 pos += smilelen; 3408 pos += smilelen;
3400 } else if (*c == '\n') { 3418 } else if (*c == '\n') {
3401 if (!(options & GTK_IMHTML_NO_NEWLINE)) { 3419 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
3402 ws[wpos] = '\n'; 3420 ws[wpos] = '\n';
3403 wpos++; 3421 wpos++;
3404 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3422 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3405 ws[0] = '\0'; wpos = 0; 3423 ws[0] = '\0';
3424 wpos = 0;
3406 /* NEW_BIT (NEW_TEXT_BIT); */ 3425 /* NEW_BIT (NEW_TEXT_BIT); */
3407 } else if (!br) { /* Don't insert a space immediately after an HTML break */ 3426 } else if (!br) { /* Don't insert a space immediately after an HTML break */
3408 /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. 3427 /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary.
3409 * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine 3428 * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine
3410 * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert 3429 * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert
3411 * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? 3430 * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand?
3412 * Bu-wahaha! */ 3431 * Bu-wahaha! */
3413 ws[wpos] = ' '; 3432 ws[wpos] = ' ';
3414 wpos++; 3433 wpos++;
3415 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3434 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3416 ws[0] = '\0'; wpos = 0; 3435 ws[0] = '\0';
3436 wpos = 0;
3417 } 3437 }
3418 c++; 3438 c++;
3419 pos++; 3439 pos++;
3420 } else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) && 3440 } else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) &&
3421 (len_protocol = gtk_imhtml_is_protocol(c)) > 0 && 3441 (len_protocol = gtk_imhtml_is_protocol(c)) > 0 &&
3422 c[len_protocol] && !isspace(c[len_protocol]) && 3442 c[len_protocol] && !isspace(c[len_protocol]) &&
3423 (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { 3443 (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) {
3424 br = FALSE; 3444 br = FALSE;
3425 if (wpos > 0) { 3445 if (wpos > 0) {
3426 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3446 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3427 ws[0] = '\0'; wpos = 0; 3447 ws[0] = '\0';
3448 wpos = 0;
3428 } 3449 }
3429 while (len_protocol--) { 3450 while (len_protocol--) {
3430 /* Skip the next len_protocol characters, but 3451 /* Skip the next len_protocol characters, but
3431 * make sure they're copied into the ws array. 3452 * make sure they're copied into the ws array.
3432 */ 3453 */
3447 } 3468 }
3448 } 3469 }
3449 ws[wpos] = '\0'; 3470 ws[wpos] = '\0';
3450 gtk_imhtml_toggle_link(imhtml, ws); 3471 gtk_imhtml_toggle_link(imhtml, ws);
3451 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3472 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3452 ws[0] = '\0'; wpos = 0; 3473 ws[0] = '\0';
3474 wpos = 0;
3453 gtk_imhtml_toggle_link(imhtml, NULL); 3475 gtk_imhtml_toggle_link(imhtml, NULL);
3454 } 3476 }
3455 } else if (*c) { 3477 } else if (*c) {
3456 br = FALSE; 3478 br = FALSE;
3457 ws [wpos++] = *c++; 3479 ws [wpos++] = *c++;
3459 } else { 3481 } else {
3460 break; 3482 break;
3461 } 3483 }
3462 } 3484 }
3463 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); 3485 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
3464 ws[0] = '\0'; wpos = 0; 3486 ws[0] = '\0';
3487 wpos = 0;
3465 3488
3466 /* NEW_BIT(NEW_TEXT_BIT); */ 3489 /* NEW_BIT(NEW_TEXT_BIT); */
3467 3490
3468 if(align_right) { 3491 if(align_right) {
3469 /* insert RLM+LRM at beginning of the line to set alignment */ 3492 /* insert RLM+LRM at beginning of the line to set alignment */
3485 } 3508 }
3486 3509
3487 ws[wpos] = '\0'; 3510 ws[wpos] = '\0';
3488 gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos); 3511 gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos);
3489 gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter); 3512 gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter);
3490 ws[0] = '\0'; wpos = 0; 3513 ws[0] = '\0';
3491 } 3514 }
3492 3515
3493 while (fonts) { 3516 while (fonts) {
3494 GtkIMHtmlFontDetail *font = fonts->data; 3517 GtkIMHtmlFontDetail *font = fonts->data;
3495 fonts = g_slist_remove (fonts, font); 3518 fonts = g_slist_remove (fonts, font);

mercurial