Mercurial > pidgin
comparison src/gtkimhtml.c @ 1476:721cd9b73704
[gaim-migrate @ 1486]
fix solaris stupidity (on my part). thanks tKirin
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 07 Feb 2001 20:06:29 +0000 |
parents | 38e8391aa563 |
children | 68d44466c0b0 |
comparison
equal
deleted
inserted
replaced
1475:a15d5aaca94a | 1476:721cd9b73704 |
---|---|
52 #define MIN_HEIGHT 20 | 52 #define MIN_HEIGHT 20 |
53 #define HR_HEIGHT 2 | 53 #define HR_HEIGHT 2 |
54 | 54 |
55 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) | 55 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) |
56 #define COLOR_MOD 0x8000 | 56 #define COLOR_MOD 0x8000 |
57 #define COLOR_DIFF (COLOR_MOD >> 8) | 57 #define COLOR_DIFF 0x80 |
58 | 58 |
59 #define TYPE_TEXT 0 | 59 #define TYPE_TEXT 0 |
60 #define TYPE_SMILEY 1 | 60 #define TYPE_SMILEY 1 |
61 #define TYPE_IMG 2 | 61 #define TYPE_IMG 2 |
62 #define TYPE_SEP 3 | 62 #define TYPE_SEP 3 |
203 | 203 |
204 if (GTK_WIDGET_CLASS (parent_class)->realize) | 204 if (GTK_WIDGET_CLASS (parent_class)->realize) |
205 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); | 205 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); |
206 | 206 |
207 widget->style = gtk_style_attach (widget->style, widget->window); | 207 widget->style = gtk_style_attach (widget->style, widget->window); |
208 gdk_window_set_events (imhtml->layout.bin_window, | 208 gdk_window_set_events (GTK_LAYOUT (imhtml)->bin_window, |
209 (gdk_window_get_events (imhtml->layout.bin_window) | 209 (gdk_window_get_events (GTK_LAYOUT (imhtml)->bin_window) |
210 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 210 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
211 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK)); | 211 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK)); |
212 | 212 |
213 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); | 213 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); |
214 | 214 |
215 gdk_color_alloc (widget->style->colormap, imhtml->default_bg_color); | 215 gdk_color_alloc (gtk_widget_get_colormap (widget), imhtml->default_bg_color); |
216 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, imhtml->default_bg_color); | 216 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, imhtml->default_bg_color); |
217 } | 217 } |
218 | 218 |
219 static gboolean | 219 static gboolean |
220 similar_colors (GdkColor bg, | 220 similar_colors (GdkColor *bg, |
221 GdkColor *fg) | 221 GdkColor *fg) |
222 { | 222 { |
223 bg.red = bg.pixel >> 16; fg->red = fg->pixel >> 16; | 223 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) && |
224 bg.green = (bg.pixel >> 8) & 0xff; fg->green = (fg->pixel >> 8) & 0xff; | 224 (DIFF (bg->green, fg->green) < COLOR_DIFF) && |
225 bg.blue = bg.pixel & 0xff; fg->blue = fg->pixel & 0xff; | 225 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) { |
226 if ((DIFF (bg.red, fg->red) < COLOR_DIFF) && | 226 fg->red = (0xff00 - COLOR_MOD > bg->red) ? |
227 (DIFF (bg.green, fg->green) < COLOR_DIFF) && | 227 bg->red + COLOR_MOD : bg->red - COLOR_MOD; |
228 (DIFF (bg.blue, fg->blue) < COLOR_DIFF)) { | 228 fg->green = (0xff00 - COLOR_MOD > bg->green) ? |
229 fg->red = (0xff00 - COLOR_MOD > bg.red) ? | 229 bg->green + COLOR_MOD : bg->green - COLOR_MOD; |
230 bg.red + COLOR_MOD : bg.red - COLOR_MOD; | 230 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ? |
231 fg->green = (0xff00 - COLOR_MOD > bg.green) ? | 231 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD; |
232 bg.green + COLOR_MOD : bg.green - COLOR_MOD; | |
233 fg->blue = (0xff00 - COLOR_MOD > bg.blue) ? | |
234 bg.blue + COLOR_MOD : bg.blue - COLOR_MOD; | |
235 return TRUE; | 232 return TRUE; |
236 } | 233 } |
237 return FALSE; | 234 return FALSE; |
238 } | 235 } |
239 | 236 |
244 GtkIMHtmlBit *bit; | 241 GtkIMHtmlBit *bit; |
245 GdkGC *gc; | 242 GdkGC *gc; |
246 GdkColormap *cmap; | 243 GdkColormap *cmap; |
247 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; | 244 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; |
248 gfloat xoff, yoff; | 245 gfloat xoff, yoff; |
249 GdkGCValues bgv, fgv; | 246 GdkColor *bg, *fg; |
250 | 247 |
251 bit = line->bit; | 248 bit = line->bit; |
252 gc = gdk_gc_new (window); | 249 gc = gdk_gc_new (window); |
253 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE); | 250 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
254 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; | 251 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; |
255 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; | 252 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; |
253 | |
254 if (bit->bg != NULL) { | |
255 gdk_color_alloc (cmap, bit->bg); | |
256 gdk_gc_set_foreground (gc, bit->bg); | |
257 bg = bit->bg; | |
258 } else { | |
259 gdk_color_alloc (cmap, imhtml->default_bg_color); | |
260 gdk_gc_set_foreground (gc, imhtml->default_bg_color); | |
261 bg = imhtml->default_bg_color; | |
262 } | |
263 | |
264 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, line->width, line->height); | |
265 | |
266 if (!line->text) { | |
267 gdk_gc_unref (gc); | |
268 return; | |
269 } | |
270 | |
271 if (bit->back != NULL) { | |
272 gdk_color_alloc (cmap, bit->back); | |
273 gdk_gc_set_foreground (gc, bit->back); | |
274 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, | |
275 gdk_string_width (bit->font, line->text), line->height); | |
276 bg = bit->back; | |
277 } | |
278 | |
279 bg = gdk_color_copy (bg); | |
280 | |
281 if (line->selected) { | |
282 gint width, x; | |
283 gchar *start, *end; | |
284 GdkColor col; | |
285 | |
286 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) { | |
287 start = line->sel_end; | |
288 end = line->sel_start; | |
289 } else { | |
290 start = line->sel_start; | |
291 end = line->sel_end; | |
292 } | |
293 | |
294 if (start == NULL) | |
295 x = 0; | |
296 else | |
297 x = gdk_text_width (bit->font, line->text, start - line->text); | |
298 | |
299 if (end == NULL) | |
300 width = gdk_string_width (bit->font, line->text) - x; | |
301 else | |
302 width = gdk_text_width (bit->font, line->text, end - line->text) - x; | |
303 | |
304 col.red = col.green = col.blue = 0xc000; | |
305 gdk_color_alloc (cmap, &col); | |
306 gdk_gc_set_foreground (gc, &col); | |
307 | |
308 gdk_draw_rectangle (window, gc, TRUE, x + line->x - xoff, line->y - yoff, | |
309 width, line->height); | |
310 } | |
311 | |
312 if (bit->url) { | |
313 GdkColor *tc = gtk_imhtml_get_color ("#0000a0"); | |
314 gdk_color_alloc (cmap, tc); | |
315 gdk_gc_set_foreground (gc, tc); | |
316 fg = gdk_color_copy (tc); | |
317 gdk_color_free (tc); | |
318 } else if (bit->fore) { | |
319 gdk_color_alloc (cmap, bit->fore); | |
320 gdk_gc_set_foreground (gc, bit->fore); | |
321 fg = gdk_color_copy (bit->fore); | |
322 } else { | |
323 gdk_color_alloc (cmap, imhtml->default_fg_color); | |
324 gdk_gc_set_foreground (gc, imhtml->default_fg_color); | |
325 fg = gdk_color_copy (imhtml->default_fg_color); | |
326 } | |
327 | |
328 if (similar_colors (bg, fg)) { | |
329 gdk_color_alloc (cmap, fg); | |
330 gdk_gc_set_foreground (gc, fg); | |
331 } | |
332 gdk_color_free (bg); | |
333 gdk_color_free (fg); | |
334 | |
335 gdk_draw_string (window, bit->font, gc, line->x - xoff, | |
336 line->y - yoff + line->ascent, line->text); | |
337 | |
338 if (bit->underline || bit->url) | |
339 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff + line->ascent + 1, | |
340 gdk_string_width (bit->font, line->text), 1); | |
341 if (bit->strike) | |
342 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, | |
343 line->y - yoff + line->ascent - (bit->font->ascent / 2), | |
344 gdk_string_width (bit->font, line->text), 1); | |
345 | |
346 gdk_gc_unref (gc); | |
347 } | |
348 | |
349 static gint | |
350 draw_img (GtkIMHtml *imhtml, | |
351 struct line_info *line) | |
352 { | |
353 GtkIMHtmlBit *bit; | |
354 GdkGC *gc; | |
355 GdkColormap *cmap; | |
356 gint width, height, hoff; | |
357 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; | |
358 gfloat xoff, yoff; | |
359 | |
360 bit = line->bit; | |
361 gdk_window_get_size (bit->pm, &width, &height); | |
362 hoff = (line->height - height) / 2; | |
363 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; | |
364 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; | |
365 gc = gdk_gc_new (window); | |
366 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); | |
256 | 367 |
257 if (bit->bg != NULL) { | 368 if (bit->bg != NULL) { |
258 gdk_color_alloc (cmap, bit->bg); | 369 gdk_color_alloc (cmap, bit->bg); |
259 gdk_gc_set_foreground (gc, bit->bg); | 370 gdk_gc_set_foreground (gc, bit->bg); |
260 } else { | 371 } else { |
262 gdk_gc_set_foreground (gc, imhtml->default_bg_color); | 373 gdk_gc_set_foreground (gc, imhtml->default_bg_color); |
263 } | 374 } |
264 | 375 |
265 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, line->width, line->height); | 376 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, line->width, line->height); |
266 | 377 |
267 if (!line->text) { | |
268 gdk_colormap_unref (cmap); | |
269 gdk_gc_unref (gc); | |
270 return; | |
271 } | |
272 | |
273 if (bit->back != NULL) { | |
274 gdk_color_alloc (cmap, bit->back); | |
275 gdk_gc_set_foreground (gc, bit->back); | |
276 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, | |
277 gdk_string_width (bit->font, line->text), line->height); | |
278 } | |
279 | |
280 gdk_gc_get_values (gc, &bgv); | |
281 | |
282 if (line->selected) { | |
283 gint width, x; | |
284 gchar *start, *end; | |
285 GdkColor col; | |
286 | |
287 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) { | |
288 start = line->sel_end; | |
289 end = line->sel_start; | |
290 } else { | |
291 start = line->sel_start; | |
292 end = line->sel_end; | |
293 } | |
294 | |
295 if (start == NULL) | |
296 x = 0; | |
297 else | |
298 x = gdk_text_width (bit->font, line->text, start - line->text); | |
299 | |
300 if (end == NULL) | |
301 width = gdk_string_width (bit->font, line->text) - x; | |
302 else | |
303 width = gdk_text_width (bit->font, line->text, end - line->text) - x; | |
304 | |
305 col.red = col.green = col.blue = 0xc000; | |
306 gdk_color_alloc (cmap, &col); | |
307 gdk_gc_set_foreground (gc, &col); | |
308 | |
309 gdk_draw_rectangle (window, gc, TRUE, x + line->x - xoff, line->y - yoff, | |
310 width, line->height); | |
311 } | |
312 | |
313 if (bit->url) { | |
314 GdkColor *tc = gtk_imhtml_get_color ("#0000a0"); | |
315 gdk_color_alloc (cmap, tc); | |
316 gdk_gc_set_foreground (gc, tc); | |
317 gdk_color_free (tc); | |
318 } else if (bit->fore) { | |
319 gdk_color_alloc (cmap, bit->fore); | |
320 gdk_gc_set_foreground (gc, bit->fore); | |
321 } else { | |
322 gdk_color_alloc (cmap, imhtml->default_fg_color); | |
323 gdk_gc_set_foreground (gc, imhtml->default_fg_color); | |
324 } | |
325 | |
326 gdk_gc_get_values (gc, &fgv); | |
327 if (similar_colors (bgv.foreground, &fgv.foreground)) { | |
328 gdk_color_alloc (cmap, &fgv.foreground); | |
329 gdk_gc_set_foreground (gc, &fgv.foreground); | |
330 } | |
331 | |
332 gdk_draw_string (window, bit->font, gc, line->x - xoff, | |
333 line->y - yoff + line->ascent, line->text); | |
334 | |
335 if (bit->underline || bit->url) | |
336 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff + line->ascent + 1, | |
337 gdk_string_width (bit->font, line->text), 1); | |
338 if (bit->strike) | |
339 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, | |
340 line->y - yoff + line->ascent - (bit->font->ascent >> 1), | |
341 gdk_string_width (bit->font, line->text), 1); | |
342 | |
343 gdk_colormap_unref (cmap); | |
344 gdk_gc_unref (gc); | |
345 } | |
346 | |
347 static gint | |
348 draw_img (GtkIMHtml *imhtml, | |
349 struct line_info *line) | |
350 { | |
351 GtkIMHtmlBit *bit; | |
352 GdkGC *gc; | |
353 GdkColormap *cmap; | |
354 gint width, height, hoff; | |
355 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; | |
356 gfloat xoff, yoff; | |
357 | |
358 bit = line->bit; | |
359 gdk_window_get_size (bit->pm, &width, &height); | |
360 hoff = (line->height - height) / 2; | |
361 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; | |
362 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; | |
363 gc = gdk_gc_new (window); | |
364 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE); | |
365 | |
366 if (bit->bg != NULL) { | |
367 gdk_color_alloc (cmap, bit->bg); | |
368 gdk_gc_set_foreground (gc, bit->bg); | |
369 } else { | |
370 gdk_color_alloc (cmap, imhtml->default_bg_color); | |
371 gdk_gc_set_foreground (gc, imhtml->default_bg_color); | |
372 } | |
373 | |
374 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, line->width, line->height); | |
375 | |
376 if (bit->back != NULL) { | 378 if (bit->back != NULL) { |
377 gdk_color_alloc (cmap, bit->back); | 379 gdk_color_alloc (cmap, bit->back); |
378 gdk_gc_set_foreground (gc, bit->back); | 380 gdk_gc_set_foreground (gc, bit->back); |
379 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, | 381 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, |
380 width, line->height); | 382 width, line->height); |
381 } | 383 } |
382 | 384 |
383 gdk_draw_pixmap (window, gc, bit->pm, 0, 0, line->x - xoff, line->y - yoff + hoff, -1, -1); | 385 gdk_draw_pixmap (window, gc, bit->pm, 0, 0, line->x - xoff, line->y - yoff + hoff, -1, -1); |
384 | 386 |
385 gdk_colormap_unref (cmap); | |
386 gdk_gc_unref (gc); | 387 gdk_gc_unref (gc); |
387 | 388 |
388 return TRUE; | 389 return TRUE; |
389 } | 390 } |
390 | 391 |
401 | 402 |
402 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; | 403 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; |
403 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; | 404 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; |
404 bit = line->bit; | 405 bit = line->bit; |
405 drawable = GTK_LAYOUT (imhtml)->bin_window; | 406 drawable = GTK_LAYOUT (imhtml)->bin_window; |
406 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE); | 407 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
407 gc = gdk_gc_new (drawable); | 408 gc = gdk_gc_new (drawable); |
408 | 409 |
409 if (bit->bg != NULL) { | 410 if (bit->bg != NULL) { |
410 gdk_color_alloc (cmap, bit->bg); | 411 gdk_color_alloc (cmap, bit->bg); |
411 gdk_gc_set_foreground (gc, bit->bg); | 412 gdk_gc_set_foreground (gc, bit->bg); |
420 line_height = line->height / 2; | 421 line_height = line->height / 2; |
421 | 422 |
422 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff + line_height / 2, | 423 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff + line_height / 2, |
423 line->width, line_height); | 424 line->width, line_height); |
424 | 425 |
425 gdk_colormap_unref (cmap); | |
426 gdk_gc_unref (gc); | 426 gdk_gc_unref (gc); |
427 | 427 |
428 return TRUE; | 428 return TRUE; |
429 } | 429 } |
430 | 430 |
688 return text; | 688 return text; |
689 | 689 |
690 for (pos = text; *pos != '\0'; pos++) { | 690 for (pos = text; *pos != '\0'; pos++) { |
691 gint char_width = gdk_text_width (chunk->bit->font, pos, 1); | 691 gint char_width = gdk_text_width (chunk->bit->font, pos, 1); |
692 if ((width > total) && (width <= total + char_width)) { | 692 if ((width > total) && (width <= total + char_width)) { |
693 if (width < total + (char_width >> 1)) | 693 if (width < total + (char_width / 2)) |
694 return pos; | 694 return pos; |
695 else | 695 else |
696 return ++pos; | 696 return ++pos; |
697 } | 697 } |
698 total += char_width; | 698 total += char_width; |
908 gint x, y; | 908 gint x, y; |
909 GdkModifierType mask; | 909 GdkModifierType mask; |
910 | 910 |
911 imhtml->scroll_timer = 0; | 911 imhtml->scroll_timer = 0; |
912 | 912 |
913 gdk_window_get_pointer (imhtml->layout.bin_window, &x, &y, &mask); | 913 gdk_window_get_pointer (GTK_LAYOUT (imhtml)->bin_window, &x, &y, &mask); |
914 | 914 |
915 if (mask & GDK_BUTTON1_MASK) { | 915 if (mask & GDK_BUTTON1_MASK) { |
916 event.is_hint = 0; | 916 event.is_hint = 0; |
917 event.x = x; | 917 event.x = x; |
918 event.y = y; | 918 event.y = y; |
951 (imhtml->scroll_timer == 0) && | 951 (imhtml->scroll_timer == 0) && |
952 (vadj->upper > vadj->page_size)) { | 952 (vadj->upper > vadj->page_size)) { |
953 imhtml->scroll_timer = gtk_timeout_add (100, | 953 imhtml->scroll_timer = gtk_timeout_add (100, |
954 (GtkFunction) scroll_timeout, | 954 (GtkFunction) scroll_timeout, |
955 imhtml); | 955 imhtml); |
956 diff = (yy < 0) ? (yy >> 1) : ((yy - height) >> 1); | 956 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2); |
957 gtk_adjustment_set_value (vadj, | 957 gtk_adjustment_set_value (vadj, |
958 MIN (vadj->value + diff, vadj->upper - height + 20)); | 958 MIN (vadj->value + diff, vadj->upper - height + 20)); |
959 } | 959 } |
960 | 960 |
961 if (imhtml->selection) { | 961 if (imhtml->selection) { |
969 | 969 |
970 while (urls) { | 970 while (urls) { |
971 uw = (struct url_widget *) urls->data; | 971 uw = (struct url_widget *) urls->data; |
972 if ((x > uw->x) && (x < uw->x + uw->width) && | 972 if ((x > uw->x) && (x < uw->x + uw->width) && |
973 (y > uw->y) && (y < uw->y + uw->height)) { | 973 (y > uw->y) && (y < uw->y + uw->height)) { |
974 gdk_window_set_cursor (imhtml->layout.bin_window, imhtml->hand_cursor); | 974 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, |
975 imhtml->hand_cursor); | |
975 return TRUE; | 976 return TRUE; |
976 } | 977 } |
977 urls = g_list_next (urls); | 978 urls = g_list_next (urls); |
978 } | 979 } |
979 } | 980 } |
980 | 981 |
981 gdk_window_set_cursor (imhtml->layout.bin_window, imhtml->arrow_cursor); | 982 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor); |
982 | 983 |
983 return TRUE; | 984 return TRUE; |
984 } | 985 } |
985 | 986 |
986 static gint | 987 static gint |
1453 while (last) { | 1454 while (last) { |
1454 gint diff; | 1455 gint diff; |
1455 li = last->data; | 1456 li = last->data; |
1456 diff = MIN_HEIGHT - li->height; | 1457 diff = MIN_HEIGHT - li->height; |
1457 li->height = MIN_HEIGHT; | 1458 li->height = MIN_HEIGHT; |
1458 li->ascent += diff >> 1; | 1459 li->ascent += diff / 2; |
1459 last = g_list_next (last); | 1460 last = g_list_next (last); |
1460 } | 1461 } |
1461 imhtml->llheight = MIN_HEIGHT; | 1462 imhtml->llheight = MIN_HEIGHT; |
1462 } | 1463 } |
1463 } | 1464 } |
1490 li = ls->data; | 1491 li = ls->data; |
1491 li->height += diff; | 1492 li->height += diff; |
1492 if (ascent) | 1493 if (ascent) |
1493 li->ascent = ascent; | 1494 li->ascent = ascent; |
1494 else | 1495 else |
1495 li->ascent += diff >> 1; | 1496 li->ascent += diff / 2; |
1496 ls = g_list_next (ls); | 1497 ls = g_list_next (ls); |
1497 } | 1498 } |
1498 | 1499 |
1499 ls = imhtml->urls; | 1500 ls = imhtml->urls; |
1500 while (ls) { | 1501 while (ls) { |
1506 | 1507 |
1507 imhtml->llheight = height; | 1508 imhtml->llheight = height; |
1508 if (ascent) | 1509 if (ascent) |
1509 imhtml->llascent = ascent; | 1510 imhtml->llascent = ascent; |
1510 else | 1511 else |
1511 imhtml->llascent += diff >> 1; | 1512 imhtml->llascent += diff / 2; |
1512 } | 1513 } |
1513 } | 1514 } |
1514 | 1515 |
1515 static void | 1516 static void |
1516 add_text_renderer (GtkIMHtml *imhtml, | 1517 add_text_renderer (GtkIMHtml *imhtml, |
1858 | 1859 |
1859 #define UPDATE_BG_COLORS \ | 1860 #define UPDATE_BG_COLORS \ |
1860 { \ | 1861 { \ |
1861 GdkColormap *cmap; \ | 1862 GdkColormap *cmap; \ |
1862 GList *rev; \ | 1863 GList *rev; \ |
1863 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE); \ | 1864 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \ |
1864 rev = g_list_last (newbits); \ | 1865 rev = g_list_last (newbits); \ |
1865 while (rev) { \ | 1866 while (rev) { \ |
1866 GtkIMHtmlBit *bit = rev->data; \ | 1867 GtkIMHtmlBit *bit = rev->data; \ |
1867 if (bit->type == TYPE_BR) \ | 1868 if (bit->type == TYPE_BR) \ |
1868 break; \ | 1869 break; \ |
1881 gdk_color_free (bit->bg); \ | 1882 gdk_color_free (bit->bg); \ |
1882 bit->bg = gdk_color_copy (bg); \ | 1883 bit->bg = gdk_color_copy (bg); \ |
1883 gdk_color_alloc (cmap, bit->bg); \ | 1884 gdk_color_alloc (cmap, bit->bg); \ |
1884 rev = g_list_previous (rev); \ | 1885 rev = g_list_previous (rev); \ |
1885 } \ | 1886 } \ |
1886 gdk_colormap_unref (cmap); \ | |
1887 } \ | 1887 } \ |
1888 } | 1888 } |
1889 | 1889 |
1890 static gboolean | 1890 static gboolean |
1891 is_amp_escape (const gchar *string, | 1891 is_amp_escape (const gchar *string, |