Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 23008:d3aace801919
merge of '7fd8869cd12ef6b1c4626baf0eb69f81b9564cea'
and 'ccdabeaac8ea742c2a9f7d57d2d3b867ce37cb90'
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Mon, 19 May 2008 22:11:41 +0000 |
parents | f11fc3fb5b8c |
children | 25161f5ea347 |
comparison
equal
deleted
inserted
replaced
22940:9809516e0032 | 23008:d3aace801919 |
---|---|
389 | 389 |
390 /* Don't scroll here if we're in the middle of a smooth scroll */ | 390 /* Don't scroll here if we're in the middle of a smooth scroll */ |
391 if (scroll && imhtml->scroll_time == NULL && | 391 if (scroll && imhtml->scroll_time == NULL && |
392 GTK_WIDGET_REALIZED(imhtml)) | 392 GTK_WIDGET_REALIZED(imhtml)) |
393 gtk_imhtml_scroll_to_end(imhtml, FALSE); | 393 gtk_imhtml_scroll_to_end(imhtml, FALSE); |
394 } | |
395 | |
396 #define DEFAULT_SEND_COLOR "#204a87" | |
397 #define DEFAULT_RECV_COLOR "#cc0000" | |
398 #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00" | |
399 #define DEFAULT_ACTION_COLOR "#062585" | |
400 #define DEFAULT_WHISPER_ACTION_COLOR "#6C2585" | |
401 #define DEFAULT_WHISPER_COLOR "#00FF00" | |
402 | |
403 static void (*parent_style_set)(GtkWidget *widget, GtkStyle *prev_style); | |
404 | |
405 static void | |
406 gtk_imhtml_style_set(GtkWidget *widget, GtkStyle *prev_style) | |
407 { | |
408 int i; | |
409 struct { | |
410 const char *tag; | |
411 const char *color; | |
412 const char *def; | |
413 } styles[] = { | |
414 {"send-name", "send-name-color", DEFAULT_SEND_COLOR}, | |
415 {"receive-name", "receive-name-color", DEFAULT_RECV_COLOR}, | |
416 {"highlight-name", "highlight-name-color", DEFAULT_HIGHLIGHT_COLOR}, | |
417 {"action-name", "action-name-color", DEFAULT_ACTION_COLOR}, | |
418 {"whisper-action-name", "whisper-action-name-color", DEFAULT_WHISPER_ACTION_COLOR}, | |
419 {"whisper-name", "whisper-name-color", DEFAULT_WHISPER_COLOR}, | |
420 {NULL, NULL, NULL} | |
421 }; | |
422 GtkIMHtml *imhtml = GTK_IMHTML(widget); | |
423 GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); | |
424 | |
425 for (i = 0; styles[i].tag; i++) { | |
426 GdkColor *color = NULL; | |
427 GtkTextTag *tag = gtk_text_tag_table_lookup(table, styles[i].tag); | |
428 if (!tag) { | |
429 purple_debug_warning("gtkimhtml", "Cannot find tag '%s'. This should never happen. Please file a bug.\n", styles[i].tag); | |
430 continue; | |
431 } | |
432 gtk_widget_style_get(widget, styles[i].color, &color, NULL); | |
433 if (color) { | |
434 g_object_set(tag, "foreground-gdk", color, NULL); | |
435 gdk_color_free(color); | |
436 } else { | |
437 GdkColor defcolor; | |
438 gdk_color_parse(styles[i].def, &defcolor); | |
439 g_object_set(tag, "foreground-gdk", &defcolor, NULL); | |
440 } | |
441 } | |
442 parent_style_set(widget, prev_style); | |
394 } | 443 } |
395 | 444 |
396 static gint | 445 static gint |
397 gtk_imhtml_tip_paint (GtkIMHtml *imhtml) | 446 gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
398 { | 447 { |
1423 gobject_class->finalize = gtk_imhtml_finalize; | 1472 gobject_class->finalize = gtk_imhtml_finalize; |
1424 widget_class->drag_motion = gtk_text_view_drag_motion; | 1473 widget_class->drag_motion = gtk_text_view_drag_motion; |
1425 widget_class->expose_event = gtk_imhtml_expose_event; | 1474 widget_class->expose_event = gtk_imhtml_expose_event; |
1426 parent_size_allocate = widget_class->size_allocate; | 1475 parent_size_allocate = widget_class->size_allocate; |
1427 widget_class->size_allocate = gtk_imhtml_size_allocate; | 1476 widget_class->size_allocate = gtk_imhtml_size_allocate; |
1477 parent_style_set = widget_class->style_set; | |
1478 widget_class->style_set = gtk_imhtml_style_set; | |
1428 | 1479 |
1429 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", | 1480 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
1430 _("Hyperlink color"), | 1481 _("Hyperlink color"), |
1431 _("Color to draw hyperlinks."), | 1482 _("Color to draw hyperlinks."), |
1432 GDK_TYPE_COLOR, G_PARAM_READABLE)); | 1483 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
1448 GDK_TYPE_COLOR, G_PARAM_READABLE)); | 1499 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
1449 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("action-name-color", | 1500 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("action-name-color", |
1450 _("Action Message Name Color"), | 1501 _("Action Message Name Color"), |
1451 _("Color to draw the name of an action message."), | 1502 _("Color to draw the name of an action message."), |
1452 GDK_TYPE_COLOR, G_PARAM_READABLE)); | 1503 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
1504 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-action-name-color", | |
1505 _("Action Message Name Color for Whispered Message"), | |
1506 _("Color to draw the name of an action message."), | |
1507 GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
1508 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-name-color", | |
1509 _("Whisper Message Name Color"), | |
1510 _("Color to draw the name of an action message."), | |
1511 GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
1453 | 1512 |
1454 /* Customizable typing notification ... sort of. Example: | 1513 /* Customizable typing notification ... sort of. Example: |
1455 * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" | 1514 * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" |
1456 * GtkIMHtml::typing-notification-color = "#ff0000" | 1515 * GtkIMHtml::typing-notification-color = "#ff0000" |
1457 * GtkIMHtml::typing-notification-enable = 1 | 1516 * GtkIMHtml::typing-notification-enable = 1 |
1512 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | 1571 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); |
1513 gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); | 1572 gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); |
1514 #if FALSE && GTK_CHECK_VERSION(2,10,10) | 1573 #if FALSE && GTK_CHECK_VERSION(2,10,10) |
1515 gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "invisible", FALSE, NULL); | 1574 gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "invisible", FALSE, NULL); |
1516 #endif | 1575 #endif |
1576 | |
1577 gtk_text_buffer_create_tag(imhtml->text_buffer, "send-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1578 gtk_text_buffer_create_tag(imhtml->text_buffer, "receive-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1579 gtk_text_buffer_create_tag(imhtml->text_buffer, "highlight-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1580 gtk_text_buffer_create_tag(imhtml->text_buffer, "action-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1581 gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-action-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1582 gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); | |
1517 | 1583 |
1518 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ | 1584 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
1519 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | 1585 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); |
1520 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | 1586 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
1521 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); | 1587 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |