GNOME Bugzilla – Bug 324052
Tooltip on tabs can get too big
Last modified: 2007-08-15 21:40:56 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.
Confirming.
Mass changing target 2.16 -> 2.18
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... :/
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.
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 :).
char short_tip[6*TOOLTIP_MAX_LENGTH + 4]; g_utf8_strncpy (short_tip, title, TOOLTIP_MAX_LENGTH); /* now add the "..." to it */
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.
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.
Yes, but still needs the force_window thing.
Created attachment 77369 [details] [review] Updated patch
You don't need this anymore: +#define TOOLTIP_SUFFIX "…" (No need to attach a new patch, just commit once you get your cvs access.)
Committed.
At this point, I don't see any tooltips on tab titles at all, but I do see them on tab close buttons.
The missing tooltips on the tab labels is bug 457642.