Commit f9526023 authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Add helper for getting max. number of layout lines, which does not use the

2008-08-21  Christian Neumair  <cneumair@gnome.org>

	* libnautilus-private/nautilus-icon-canvas-item.c
	(layout_get_full_size), (draw_or_measure_label_text):
	* libnautilus-private/nautilus-icon-container.c
	(nautilus_icon_container_constructor),
	(nautilus_icon_container_get_max_layout_lines_for_pango),
	(nautilus_icon_container_get_max_layout_lines):
	* libnautilus-private/nautilus-icon-container.h:
	Add helper for getting max. number of layout lines, which does not use
	the negative PangoLayout height convention. Use it in
	layout_get_full_size() instead of hardcoding three lines.
	Only connect GConf text ellipsis preferences container callbacks while
	the containers are alive.

svn path=/trunk/; revision=14510
parent 67d22e8b
2008-08-21 Christian Neumair <cneumair@gnome.org>
* libnautilus-private/nautilus-icon-canvas-item.c
(layout_get_full_size), (draw_or_measure_label_text):
* libnautilus-private/nautilus-icon-container.c
(nautilus_icon_container_constructor),
(nautilus_icon_container_get_max_layout_lines_for_pango),
(nautilus_icon_container_get_max_layout_lines):
* libnautilus-private/nautilus-icon-container.h:
Add helper for getting max. number of layout lines, which does not use
the negative PangoLayout height convention. Use it in
layout_get_full_size() instead of hardcoding three lines.
Only connect GConf text ellipsis preferences container callbacks while
the containers are alive.
2008-08-21 Cosimo Cecchi <cosimoc@gnome.org>
* src/file-manager/fm-properties-window.c:
......
......@@ -976,9 +976,10 @@ draw_frame (NautilusIconCanvasItem *item,
*/
static void
layout_get_full_size (PangoLayout *layout,
int max_layout_line_count,
int *width,
int *height,
int *height_for_for_layout,
int *height_for_layout,
int *dx)
{
PangoLayoutIter *iter;
......@@ -991,24 +992,24 @@ layout_get_full_size (PangoLayout *layout,
*dx = total_width - *width;
*height = (logical_rect.height + PANGO_SCALE / 2) / PANGO_SCALE;
if (height_for_for_layout != NULL) {
if (height_for_layout != NULL) {
/* only use the first three lines for the gridded auto layout */
if (pango_layout_get_line_count (layout) <= 3) {
*height_for_for_layout = *height;
if (pango_layout_get_line_count (layout) <= max_layout_line_count) {
*height_for_layout = *height;
} else {
*height_for_for_layout = 0;
*height_for_layout = 0;
iter = pango_layout_get_iter (layout);
/* VOODOO-TODO, determine number of lines based on the icon size for text besides icon.
* cf. compute_text_rectangle() */
for (i = 0; i < 3; i++) {
for (i = 0; i < max_layout_line_count; i++) {
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
*height_for_for_layout += (logical_rect.height + PANGO_SCALE / 2) / PANGO_SCALE;
*height_for_layout += (logical_rect.height + PANGO_SCALE / 2) / PANGO_SCALE;
if (!pango_layout_iter_next_line (iter)) {
break;
}
*height_for_for_layout += pango_layout_get_spacing (layout);
*height_for_layout += pango_layout_get_spacing (layout);
}
pango_layout_iter_free (iter);
}
......@@ -1115,14 +1116,18 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
pango_layout_set_height (editable_layout, G_MININT);
} else {
pango_layout_set_height (editable_layout,
nautilus_icon_container_get_layout_height (container));
nautilus_icon_container_get_max_layout_lines_for_pango (container));
}
layout_get_full_size (editable_layout, &editable_width, &editable_height, &editable_for_layout_height, &editable_dx);
layout_get_full_size (editable_layout,
nautilus_icon_container_get_max_layout_lines (container),
&editable_width, &editable_height, &editable_for_layout_height, &editable_dx);
}
if (have_additional) {
additional_layout = get_label_layout (&details->additional_text_layout, item, details->additional_text);
layout_get_full_size (additional_layout, &additional_width, &additional_height, NULL, &additional_dx);
layout_get_full_size (additional_layout,
nautilus_icon_container_get_max_layout_lines (container),
&additional_width, &additional_height, NULL, &additional_dx);
}
if (editable_width > additional_width) {
......
......@@ -5127,13 +5127,13 @@ nautilus_icon_container_constructor (GType type,
container = NAUTILUS_ICON_CONTAINER (object);
if (nautilus_icon_container_get_is_desktop (container)) {
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
text_ellipsis_limit_changed_container_callback,
container);
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
text_ellipsis_limit_changed_container_callback,
container, G_OBJECT (container));
} else {
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
text_ellipsis_limit_changed_container_callback,
container);
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
text_ellipsis_limit_changed_container_callback,
container, G_OBJECT (container));
}
return object;
......@@ -5767,7 +5767,7 @@ nautilus_icon_container_instance_init (NautilusIconContainer *container)
nautilus_icon_container_theme_changed (container);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
nautilus_icon_container_theme_changed,
container);
container);
if (!setup_prefs) {
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
......@@ -8976,7 +8976,7 @@ nautilus_icon_container_is_layout_vertical (NautilusIconContainer *container)
}
int
nautilus_icon_container_get_layout_height (NautilusIconContainer *container)
nautilus_icon_container_get_max_layout_lines_for_pango (NautilusIconContainer *container)
{
int limit;
......@@ -8993,5 +8993,23 @@ nautilus_icon_container_get_layout_height (NautilusIconContainer *container)
return -limit;
}
int
nautilus_icon_container_get_max_layout_lines (NautilusIconContainer *container)
{
int limit;
if (nautilus_icon_container_get_is_desktop (container)) {
limit = desktop_text_ellipsis_limit;
} else {
limit = text_ellipsis_limits[container->details->zoom_level];
}
if (limit <= 0) {
return G_MAXINT;
}
return limit;
}
#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
......@@ -252,7 +252,8 @@ void nautilus_icon_container_set_label_position (Nautilu
void nautilus_icon_container_sort (NautilusIconContainer *container);
void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container);
int nautilus_icon_container_get_layout_height (NautilusIconContainer *container);
int nautilus_icon_container_get_max_layout_lines (NautilusIconContainer *container);
int nautilus_icon_container_get_max_layout_lines_for_pango (NautilusIconContainer *container);
/* operations on all icons */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment