pidgin: e5b7004b: Do not show tooltips for <HR> or <IMG>s ...
sadrul at pidgin.im
sadrul at pidgin.im
Sun Apr 13 13:41:06 EDT 2008
-----------------------------------------------------------------
Revision: e5b7004bba36a7abe811e62429b887d62fa9247e
Ancestor: e4e260929f8770bfdb406208fc5a6c943bf37c4e
Author: sadrul at pidgin.im
Date: 2008-04-13T16:28:57
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e5b7004bba36a7abe811e62429b887d62fa9247e
Modified files:
pidgin/gtkimhtml.c
ChangeLog:
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
There are a bunch of white-space fixes in there as well.
-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c 2fabced73e99ea02011d86594e0fc2c3ec6db69b
+++ pidgin/gtkimhtml.c 959ec2b53eced31caf52d9381afcdbf0065bf3a9
@@ -359,17 +359,17 @@ static void gtk_imhtml_size_allocate(Gtk
GtkTextIter iter;
gboolean scroll = TRUE;
- gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
+ gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect);
- gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
+ gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
- if(((y + height) - (rect.y + rect.height)) > height
- && gtk_text_buffer_get_char_count(imhtml->text_buffer)){
- scroll = FALSE;
- }
+ if (((y + height) - (rect.y + rect.height)) > height &&
+ gtk_text_buffer_get_char_count(imhtml->text_buffer)) {
+ scroll = FALSE;
+ }
- if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height){
+ if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height) {
GList *iter = GTK_IMHTML(widget)->scalables;
xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) +
@@ -386,11 +386,11 @@ static void gtk_imhtml_size_allocate(Gtk
imhtml->old_rect = rect;
parent_size_allocate(widget, alloc);
-
+
/* Don't scroll here if we're in the middle of a smooth scroll */
if (scroll && imhtml->scroll_time == NULL &&
- GTK_WIDGET_REALIZED(imhtml))
- gtk_imhtml_scroll_to_end(imhtml, FALSE);
+ GTK_WIDGET_REALIZED(imhtml))
+ gtk_imhtml_scroll_to_end(imhtml, FALSE);
}
static gint
@@ -576,11 +576,11 @@ gtk_motion_event_notify(GtkWidget *imhtm
/* If we don't have a tip from a URL, let's see if we have a tip from a smiley */
anchor = gtk_text_iter_get_child_anchor(&iter);
if (anchor) {
- tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext");
+ tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_tiptext");
hand = FALSE;
}
- if (tip){
+ if (tip && *tip) {
if (!GTK_IMHTML(imhtml)->editable && hand)
gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor);
GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT,
@@ -2268,8 +2268,7 @@ void gtk_imhtml_append_text_with_images
GSList *unused)
{
GtkTextIter iter, ins, sel;
- GdkRectangle rect;
- int y, height, ins_offset = 0, sel_offset = 0;
+ int ins_offset = 0, sel_offset = 0;
gboolean fixins = FALSE, fixsel = FALSE;
g_return_if_fail (imhtml != NULL);
@@ -2290,13 +2289,17 @@ void gtk_imhtml_append_text_with_images
sel_offset = gtk_text_iter_get_offset(&sel);
}
- gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
- gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
+ if (!(options & GTK_IMHTML_NO_SCROLL)) {
+ GdkRectangle rect;
+ int y, height;
+ gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
+ gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
- if(((y + height) - (rect.y + rect.height)) > height
- && gtk_text_buffer_get_char_count(imhtml->text_buffer)){
- options |= GTK_IMHTML_NO_SCROLL;
+ if (((y + height) - (rect.y + rect.height)) > height &&
+ gtk_text_buffer_get_char_count(imhtml->text_buffer)) {
+ options |= GTK_IMHTML_NO_SCROLL;
+ }
}
gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter);
@@ -4713,8 +4716,11 @@ void gtk_imhtml_insert_smiley_at_iter(Gt
}
if (icon) {
+ char *text = g_strdup(unescaped); /* Do not g_free 'text'.
+ It will be destroyed when 'anchor' is destroyed. */
anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
- g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free);
+ g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free);
+ g_object_set_data(G_OBJECT(anchor), "gtkimhtml_tiptext", text);
g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free);
/* This catches the expose events generated by animated
@@ -4732,9 +4738,11 @@ void gtk_imhtml_insert_smiley_at_iter(Gt
imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, anchor);
if (ebox) {
GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU);
+ char *text = g_strdup(unescaped);
gtk_container_add(GTK_CONTAINER(ebox), img);
gtk_widget_show(img);
- g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free);
+ g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free);
+ g_object_set_data(G_OBJECT(anchor), "gtkimhtml_tiptext", text);
gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox, anchor);
}
} else {
More information about the Commits
mailing list