Mercurial > pidgin
comparison src/gtkimhtml.c @ 10799:6f67d4088da0
[gaim-migrate @ 12442]
added some things to the change log
added mouse-over hyperlink colorage
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sat, 09 Apr 2005 01:24:28 +0000 |
parents | 08981462ebbb |
children | 364a2ef907ae |
comparison
equal
deleted
inserted
replaced
10798:08981462ebbb | 10799:6f67d4088da0 |
---|---|
418 GtkTextIter iter; | 418 GtkTextIter iter; |
419 GdkWindow *win = event->window; | 419 GdkWindow *win = event->window; |
420 int x, y; | 420 int x, y; |
421 char *tip = NULL; | 421 char *tip = NULL; |
422 GSList *tags = NULL, *templist = NULL; | 422 GSList *tags = NULL, *templist = NULL; |
423 GdkColor *norm, *pre; | |
424 GtkTextTag *tag = NULL, *oldprelit_tag; | |
425 | |
426 oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
427 | |
423 gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); | 428 gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
424 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, | 429 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
425 event->x, event->y, &x, &y); | 430 event->x, event->y, &x, &y); |
426 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | 431 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); |
427 tags = gtk_text_iter_get_tags(&iter); | 432 tags = gtk_text_iter_get_tags(&iter); |
428 | 433 |
429 templist = tags; | 434 templist = tags; |
430 while (templist) { | 435 while (templist) { |
431 GtkTextTag *tag = templist->data; | 436 tag = templist->data; |
432 tip = g_object_get_data(G_OBJECT(tag), "link_url"); | 437 tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
433 if (tip) | 438 if (tip) |
434 break; | 439 break; |
435 templist = templist->next; | 440 templist = templist->next; |
441 } | |
442 | |
443 if (tip) { | |
444 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL); | |
445 GTK_IMHTML(imhtml)->prelit_tag = tag; | |
446 if (tag != oldprelit_tag) { | |
447 if (pre) | |
448 g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL); | |
449 else | |
450 g_object_set(G_OBJECT(tag), "foreground", "light blue", NULL); | |
451 } | |
452 } else { | |
453 GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
454 } | |
455 | |
456 if (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag) { | |
457 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL); | |
458 if (norm) | |
459 g_object_set(G_OBJECT(oldprelit_tag), "foreground-gdk", norm, NULL); | |
460 else | |
461 g_object_set(G_OBJECT(oldprelit_tag), "foreground", "blue", NULL); | |
436 } | 462 } |
437 | 463 |
438 if (GTK_IMHTML(imhtml)->tip) { | 464 if (GTK_IMHTML(imhtml)->tip) { |
439 if ((tip == GTK_IMHTML(imhtml)->tip)) { | 465 if ((tip == GTK_IMHTML(imhtml)->tip)) { |
440 return FALSE; | 466 return FALSE; |
451 if (GTK_IMHTML(imhtml)->tip_timer) | 477 if (GTK_IMHTML(imhtml)->tip_timer) |
452 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | 478 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
453 GTK_IMHTML(imhtml)->tip_timer = 0; | 479 GTK_IMHTML(imhtml)->tip_timer = 0; |
454 } | 480 } |
455 | 481 |
456 if(tip){ | 482 if (tip){ |
457 if (!GTK_IMHTML(imhtml)->editable) | 483 if (!GTK_IMHTML(imhtml)->editable) |
458 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); | 484 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); |
459 GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, | 485 GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, |
460 gtk_imhtml_tip, imhtml); | 486 gtk_imhtml_tip, imhtml); |
461 } | 487 } |
466 } | 492 } |
467 | 493 |
468 gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) | 494 gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
469 { | 495 { |
470 /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ | 496 /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
497 if (GTK_IMHTML(imhtml)->prelit_tag) { | |
498 GdkColor *norm; | |
499 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL); | |
500 if (norm) | |
501 g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground-gdk", norm, NULL); | |
502 else | |
503 g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground", "blue", NULL); | |
504 GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
505 } | |
506 | |
471 if (GTK_IMHTML(imhtml)->tip_window) { | 507 if (GTK_IMHTML(imhtml)->tip_window) { |
472 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | 508 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
473 GTK_IMHTML(imhtml)->tip_window = NULL; | 509 GTK_IMHTML(imhtml)->tip_window = NULL; |
474 } | 510 } |
475 if (GTK_IMHTML(imhtml)->tip_timer) { | 511 if (GTK_IMHTML(imhtml)->tip_timer) { |
1172 widget_class->drag_motion = gtk_text_view_drag_motion; | 1208 widget_class->drag_motion = gtk_text_view_drag_motion; |
1173 widget_class->expose_event = gtk_imhtml_expose_event; | 1209 widget_class->expose_event = gtk_imhtml_expose_event; |
1174 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", | 1210 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
1175 _("Hyperlink color"), | 1211 _("Hyperlink color"), |
1176 _("Color to draw hyperlinks."), | 1212 _("Color to draw hyperlinks."), |
1213 GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
1214 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", | |
1215 _("Hyperlink prelight color"), | |
1216 _("Color to draw hyperlinks when mouse is over them."), | |
1177 GDK_TYPE_COLOR, G_PARAM_READABLE)); | 1217 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
1178 | 1218 |
1179 binding_set = gtk_binding_set_by_class (parent_class); | 1219 binding_set = gtk_binding_set_by_class (parent_class); |
1180 gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); | 1220 gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
1181 gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); | 1221 gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |