After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 324052 - Tooltip on tabs can get too big
Tooltip on tabs can get too big
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Tabs
1.9.x
Other Linux
: Normal minor
: 2.18.x
Assigned To: Epiphany Maintainers
Marco Pesenti Gritti
Depends on:
Blocks:
 
 
Reported: 2005-12-14 10:48 UTC by Reinout van Schouwen
Modified: 2007-08-15 21:40 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Truncates tooltips to N characters, leaves titles untouched (1.44 KB, patch)
2006-11-11 08:30 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review
White magic version (1.19 KB, patch)
2006-11-29 19:04 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
Updated patch (1.33 KB, patch)
2006-11-29 19:51 UTC, Diego Escalante Urrelo (not reading bugmail)
accepted-commit_now Details | Review

Description Reinout van Schouwen 2005-12-14 10:48:30 UTC
Open http://www.goodfeeling.nl/default.htm in a new tab.
Hover mouse over the tab title.

The tooltip displayed is very big. It should be limited to a certain maximum
width x height.
Comment 1 spark 2006-01-11 15:12:41 UTC
Confirming.
Comment 2 Christian Persch 2006-08-17 14:04:53 UTC
Mass changing target 2.16 -> 2.18
Comment 3 Diego Escalante Urrelo (not reading bugmail) 2006-11-11 08:30:34 UTC
Created attachment 76373 [details] [review]
Truncates tooltips to N characters, leaves titles untouched

This adds 2 defines:
#define TOOLTIP_MAX_LENGTH 50
#define TOOLTIP_SUFFIX "..."

Both of them are obvious, the idea is that this patch will only truncate the text that is given to the tooltip of each _notebook page_, it WONT touch the title of the _tab_, that means that you can still get big titles in your title bar or in the tooltip of your Window List.

This can also truncate the title if we only forget about using short_title and use title directly instead.

PS: I think that my short_title var memleaks since I never free it, I guess I can't free it because it has to be shown on the tooltips... Hmmm... :/
Comment 4 Christian Persch 2006-11-11 13:52:44 UTC
Thanks for the patch!

+#define TOOLTIP_MAX_LENGTH 50
IMHO 50 is way to short... maybe ~200 ?

+#define TOOLTIP_SUFFIX "..."
Use the ellipsis character (U+2026)

+        short_title = g_strdup (title);
 
 	if (title)
 	{
 		gtk_label_set_text (GTK_LABEL (label), title);
-		gtk_tooltips_set_tip (tips, ebox, title, NULL);
+		if (g_utf8_strlen (short_title, -1) > TOOLTIP_MAX_LENGTH)
+		{
+			strcpy (g_utf8_offset_to_pointer (short_title, 
+					(TOOLTIP_MAX_LENGTH - strlen (TOOLTIP_SUFFIX))),
+				TOOLTIP_SUFFIX);
+		}

I think we can do without a malloc here, something like this:
char short_tip[6*TOOLTIP_MAX_LENGTH + 4]; (4 = 3 [==strlen ellipsis] + 1)

g_utf8_strncpy (short_tip, title, TOOLTIP_MAX_LENGTH);

and then add the ellipsis in the buffer. That will also fix the mem leak.
Comment 5 Diego Escalante Urrelo (not reading bugmail) 2006-11-29 08:30:55 UTC
chpe, I really don't understand ANYTHING starting from "I think we can do without a malloc here...".

If you tell me something more C-newbie enabled I can update the patch :).
Comment 6 Christian Persch 2006-11-29 13:02:13 UTC
char short_tip[6*TOOLTIP_MAX_LENGTH + 4];
g_utf8_strncpy (short_tip, title, TOOLTIP_MAX_LENGTH);
/* now add the "..." to it */
Comment 7 Diego Escalante Urrelo (not reading bugmail) 2006-11-29 19:04:46 UTC
Created attachment 77364 [details] [review]
White magic version

This should be enough, however the title of the window will still be unlimited and things like the panel will show a very big tooltip.
Comment 8 Christian Persch 2006-11-29 19:24:15 UTC
Does it also work if you move this code

+		gtk_tooltips_force_window (tips);
+		gtk_label_set_max_width_chars (GTK_LABEL (tips->tip_label), TOOLTIP_MAX_LENGTH);
+		gtk_label_set_ellipsize (GTK_LABEL (tips->tip_label), PANGO_ELLIPSIZE_END);

to just after gtk_tooltips_new in ephy_notebook_init ? If so, I'd prefer that version.
Comment 9 Diego Escalante Urrelo (not reading bugmail) 2006-11-29 19:50:56 UTC
Yes, but still needs the force_window thing.
Comment 10 Diego Escalante Urrelo (not reading bugmail) 2006-11-29 19:51:36 UTC
Created attachment 77369 [details] [review]
Updated patch
Comment 11 Christian Persch 2006-11-29 20:12:10 UTC
You don't need this anymore:
+#define TOOLTIP_SUFFIX "…"

(No need to attach a new patch, just commit once you get your cvs access.)
Comment 12 Christian Persch 2006-12-17 19:12:37 UTC
Committed.
Comment 13 Reinout van Schouwen 2007-08-12 10:53:39 UTC
At this point, I don't see any tooltips on tab titles at all, but I do see them on tab close buttons.
Comment 14 Christian Persch 2007-08-15 21:40:56 UTC
The missing tooltips on the tab labels is bug 457642.