Italian translation update.
[rox-filer.git] / ROX-Filer / src / display.c
blobb80c07696390ea551080f393f3bdd42e200710f1
1 /*
2 * ROX-Filer, filer for the ROX desktop project
3 * Copyright (C) 2006, Thomas Leonard and others (see changelog for details).
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
20 /* display.c - code for arranging and displaying file items */
22 #include "config.h"
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <math.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <sys/param.h>
30 #include <unistd.h>
31 #include <time.h>
32 #include <ctype.h>
34 #include <gtk/gtk.h>
35 #include <gdk/gdkx.h>
36 #include <gdk/gdkkeysyms.h>
38 #include "global.h"
40 #include "main.h"
41 #include "filer.h"
42 #include "display.h"
43 #include "support.h"
44 #include "gui_support.h"
45 #include "pixmaps.h"
46 #include "menu.h"
47 #include "dnd.h"
48 #include "run.h"
49 #include "mount.h"
50 #include "type.h"
51 #include "options.h"
52 #include "action.h"
53 #include "minibuffer.h"
54 #include "dir.h"
55 #include "diritem.h"
56 #include "fscache.h"
57 #include "view_iface.h"
58 #include "xtypes.h"
60 #define HUGE_WRAP (1.5 * o_large_width.int_value)
62 /* Options bits */
63 static Option o_display_caps_first;
64 static Option o_display_dirs_first;
65 Option o_display_size;
66 Option o_display_details;
67 Option o_display_sort_by;
68 static Option o_large_width;
69 Option o_small_width;
70 Option o_display_show_hidden;
71 Option o_display_show_thumbs;
72 Option o_display_show_headers;
73 Option o_display_show_full_type;
74 Option o_display_inherit_options;
75 static Option o_filer_change_size_num;
76 Option o_vertical_order_small, o_vertical_order_large;
77 Option o_xattr_show;
79 /* Static prototypes */
80 static void display_details_set(FilerWindow *filer_window, DetailsType details);
81 static void display_style_set(FilerWindow *filer_window, DisplayStyle style);
82 static void options_changed(void);
83 static char *details(FilerWindow *filer_window, DirItem *item);
84 static void display_set_actual_size_real(FilerWindow *filer_window);
86 /****************************************************************
87 * EXTERNAL INTERFACE *
88 ****************************************************************/
90 void display_init()
92 option_add_int(&o_display_caps_first, "display_caps_first", FALSE);
93 option_add_int(&o_display_dirs_first, "display_dirs_first", FALSE);
94 option_add_int(&o_display_size, "display_icon_size", AUTO_SIZE_ICONS);
95 option_add_int(&o_display_details, "display_details", DETAILS_NONE);
96 option_add_int(&o_display_sort_by, "display_sort_by", SORT_NAME);
97 option_add_int(&o_large_width, "display_large_width", 155);
98 option_add_int(&o_small_width, "display_small_width", 250);
99 option_add_int(&o_display_show_hidden, "display_show_hidden", FALSE);
100 option_add_int(&o_display_show_thumbs, "display_show_thumbs", FALSE);
101 option_add_int(&o_display_show_headers, "display_show_headers", TRUE);
102 option_add_int(&o_display_show_full_type, "display_show_full_type", FALSE);
103 option_add_int(&o_display_inherit_options,
104 "display_inherit_options", FALSE);
105 option_add_int(&o_filer_change_size_num, "filer_change_size_num", 30);
106 option_add_int(&o_vertical_order_small, "vertical_order_small", FALSE);
107 option_add_int(&o_vertical_order_large, "vertical_order_large", FALSE);
108 option_add_int(&o_xattr_show, "xattr_show", TRUE);
110 option_add_notify(options_changed);
113 static void draw_emblem_on_icon(GdkWindow *window, MaskedPixmap *image,
114 int *x, int y)
116 gdk_pixbuf_render_to_drawable_alpha(image->pixbuf,
117 window,
118 0, 0, /* src */
119 *x, y, /* dest */
120 -1, -1,
121 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
122 GDK_RGB_DITHER_NORMAL, 0, 0);
124 *x+=image->width+1;
127 /* Draw this icon (including any symlink or mount symbol) inside the
128 * given rectangle.
130 void draw_huge_icon(GdkWindow *window, GdkRectangle *area,
131 DirItem *item, MaskedPixmap *image, gboolean selected,
132 GdkColor *color)
134 int width, height;
135 int image_x;
136 int image_y;
137 GdkPixbuf *pixbuf;
139 if (!image)
140 return;
142 width = image->huge_width;
143 height = image->huge_height;
144 image_x = area->x + ((area->width - width) >> 1);
145 image_y = MAX(0, area->height - height - 6);
147 pixbuf = selected
148 ? create_spotlight_pixbuf(image->huge_pixbuf, color)
149 : image->huge_pixbuf;
151 gdk_pixbuf_render_to_drawable_alpha(
152 pixbuf,
153 window,
154 0, 0, /* src */
155 image_x, area->y + image_y, /* dest */
156 width, height,
157 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
158 GDK_RGB_DITHER_NORMAL, 0, 0);
160 if (selected)
161 g_object_unref(pixbuf);
163 if (item->flags & ITEM_FLAG_MOUNT_POINT)
165 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
166 ? im_mounted
167 : im_unmounted;
168 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
170 if (item->flags & ITEM_FLAG_SYMLINK)
172 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 2);
174 if ((item->flags & ITEM_FLAG_HAS_XATTR) && o_xattr_show.int_value)
176 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 2);
180 /* Draw this icon (including any symlink or mount symbol) inside the
181 * given rectangle.
183 void draw_large_icon(GdkWindow *window,
184 GdkRectangle *area,
185 DirItem *item,
186 MaskedPixmap *image,
187 gboolean selected,
188 GdkColor *color)
190 int width;
191 int height;
192 int image_x;
193 int image_y;
194 GdkPixbuf *pixbuf;
196 if (!image)
197 return;
199 width = MIN(image->width, ICON_WIDTH);
200 height = MIN(image->height, ICON_HEIGHT);
201 image_x = area->x + ((area->width - width) >> 1);
202 image_y = MAX(0, area->height - height - 6);
204 pixbuf = selected
205 ? create_spotlight_pixbuf(image->pixbuf, color)
206 : image->pixbuf;
208 gdk_pixbuf_render_to_drawable_alpha(
209 pixbuf,
210 window,
211 0, 0, /* src */
212 image_x, area->y + image_y, /* dest */
213 width, height,
214 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
215 GDK_RGB_DITHER_NORMAL, 0, 0);
217 if (selected)
218 g_object_unref(pixbuf);
220 if (item->flags & ITEM_FLAG_MOUNT_POINT)
222 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
223 ? im_mounted
224 : im_unmounted;
225 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
227 if (item->flags & ITEM_FLAG_SYMLINK)
229 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 2);
231 if ((item->flags & ITEM_FLAG_HAS_XATTR) && o_xattr_show.int_value)
233 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 2);
237 void draw_small_icon(GdkWindow *window, GdkRectangle *area,
238 DirItem *item, MaskedPixmap *image, gboolean selected,
239 GdkColor *color)
241 int width, height, image_x, image_y;
242 GdkPixbuf *pixbuf;
244 if (!image)
245 return;
247 if (!image->sm_pixbuf)
248 pixmap_make_small(image);
250 width = MIN(image->sm_width, SMALL_WIDTH);
251 height = MIN(image->sm_height, SMALL_HEIGHT);
252 image_x = area->x + ((area->width - width) >> 1);
253 image_y = MAX(0, SMALL_HEIGHT - image->sm_height);
255 pixbuf = selected
256 ? create_spotlight_pixbuf(image->sm_pixbuf, color)
257 : image->sm_pixbuf;
259 gdk_pixbuf_render_to_drawable_alpha(
260 pixbuf,
261 window,
262 0, 0, /* src */
263 image_x, area->y + image_y, /* dest */
264 width, height,
265 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
266 GDK_RGB_DITHER_NORMAL, 0, 0);
268 if (selected)
269 g_object_unref(pixbuf);
271 if (item->flags & ITEM_FLAG_MOUNT_POINT)
273 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
274 ? im_mounted
275 : im_unmounted;
276 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
278 if (item->flags & ITEM_FLAG_SYMLINK)
280 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 8);
282 if ((item->flags & ITEM_FLAG_HAS_XATTR) && o_xattr_show.int_value)
284 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 8);
288 /* The sort functions aren't called from outside, but they are
289 * passed as arguments to display_set_sort_fn().
292 #define IS_A_DIR(item) (item->base_type == TYPE_DIRECTORY && \
293 !(item->flags & ITEM_FLAG_APPDIR))
295 #define SORT_DIRS \
296 if (o_display_dirs_first.int_value) { \
297 gboolean id1 = IS_A_DIR(i1); \
298 gboolean id2 = IS_A_DIR(i2); \
299 if (id1 && !id2) return -1; \
300 if (id2 && !id1) return 1; \
303 int sort_by_name(const void *item1, const void *item2)
305 const DirItem *i1 = (DirItem *) item1;
306 const DirItem *i2 = (DirItem *) item2;
307 CollateKey *n1 = i1->leafname_collate;
308 CollateKey *n2 = i2->leafname_collate;
309 int retval;
311 SORT_DIRS;
313 retval = collate_key_cmp(n1, n2, o_display_caps_first.int_value);
315 return retval ? retval : strcmp(i1->leafname, i2->leafname);
318 int sort_by_type(const void *item1, const void *item2)
320 const DirItem *i1 = (DirItem *) item1;
321 const DirItem *i2 = (DirItem *) item2;
322 MIME_type *m1, *m2;
324 int diff = i1->base_type - i2->base_type;
326 if (!diff)
327 diff = (i1->flags & ITEM_FLAG_APPDIR)
328 - (i2->flags & ITEM_FLAG_APPDIR);
329 if (diff)
330 return diff > 0 ? 1 : -1;
332 m1 = i1->mime_type;
333 m2 = i2->mime_type;
335 if (m1 && m2)
337 diff = strcmp(m1->media_type, m2->media_type);
338 if (!diff)
339 diff = strcmp(m1->subtype, m2->subtype);
341 else if (m1 || m2)
342 diff = m1 ? 1 : -1;
343 else
344 diff = 0;
346 if (diff)
347 return diff > 0 ? 1 : -1;
349 return sort_by_name(item1, item2);
352 int sort_by_owner(const void *item1, const void *item2)
354 const DirItem *i1 = (DirItem *) item1;
355 const DirItem *i2 = (DirItem *) item2;
356 const gchar *name1;
357 const gchar *name2;
359 if(i1->uid==i2->uid)
360 return sort_by_name(item1, item2);
362 name1=user_name(i1->uid);
363 name2=user_name(i2->uid);
365 return strcmp(name1, name2);
368 int sort_by_group(const void *item1, const void *item2)
370 const DirItem *i1 = (DirItem *) item1;
371 const DirItem *i2 = (DirItem *) item2;
372 const gchar *name1;
373 const gchar *name2;
375 if(i1->gid==i2->gid)
376 return sort_by_name(item1, item2);
378 name1=group_name(i1->gid);
379 name2=group_name(i2->gid);
381 return strcmp(name1, name2);
384 int sort_by_date(const void *item1, const void *item2)
386 const DirItem *i1 = (DirItem *) item1;
387 const DirItem *i2 = (DirItem *) item2;
389 /* SORT_DIRS; -- too confusing! */
391 return i1->mtime < i2->mtime ? -1 :
392 i1->mtime > i2->mtime ? 1 :
393 sort_by_name(item1, item2);
396 int sort_by_size(const void *item1, const void *item2)
398 const DirItem *i1 = (DirItem *) item1;
399 const DirItem *i2 = (DirItem *) item2;
401 SORT_DIRS;
403 return i1->size < i2->size ? -1 :
404 i1->size > i2->size ? 1 :
405 sort_by_name(item1, item2);
408 void display_set_sort_type(FilerWindow *filer_window, SortType sort_type,
409 GtkSortType order)
411 if (filer_window->sort_type == sort_type &&
412 filer_window->sort_order == order)
413 return;
415 filer_window->sort_type = sort_type;
416 filer_window->sort_order = order;
418 view_sort(filer_window->view);
421 /* Change the icon size and style.
422 * force_resize should only be TRUE for new windows.
424 void display_set_layout(FilerWindow *filer_window,
425 DisplayStyle style,
426 DetailsType details,
427 gboolean force_resize)
429 gboolean style_changed = FALSE;
431 g_return_if_fail(filer_window != NULL);
433 if (filer_window->display_style_wanted != style
434 || filer_window->details_type != details)
436 style_changed = TRUE;
439 display_style_set(filer_window, style);
440 display_details_set(filer_window, details);
442 /* Recreate layouts because wrapping may have changed */
443 view_style_changed(filer_window->view, VIEW_UPDATE_NAME);
445 if (force_resize || o_filer_auto_resize.int_value == RESIZE_ALWAYS
446 || (o_filer_auto_resize.int_value == RESIZE_STYLE && style_changed))
448 view_autosize(filer_window->view);
452 /* Set the 'Show Thumbnails' flag for this window */
453 void display_set_thumbs(FilerWindow *filer_window, gboolean thumbs)
455 if (filer_window->show_thumbs == thumbs)
456 return;
458 filer_window->show_thumbs = thumbs;
460 view_style_changed(filer_window->view, VIEW_UPDATE_VIEWDATA);
462 if (!thumbs)
463 filer_cancel_thumbnails(filer_window);
465 filer_set_title(filer_window);
467 filer_create_thumbs(filer_window);
470 void display_update_hidden(FilerWindow *filer_window)
472 filer_detach_rescan(filer_window); /* (updates titlebar) */
474 display_set_actual_size(filer_window, FALSE);
477 /* Set the 'Show Hidden' flag for this window */
478 void display_set_hidden(FilerWindow *filer_window, gboolean hidden)
480 if (filer_window->show_hidden == hidden)
481 return;
484 filer_window->show_hidden = hidden;
486 filer_set_hidden(filer_window, hidden);
488 display_update_hidden(filer_window);
491 /* Set the 'Filter Directories' flag for this window */
492 void display_set_filter_directories(FilerWindow *filer_window, gboolean filter_directories)
494 if (filer_window->filter_directories == filter_directories)
495 return;
498 filer_window->show_hidden = hidden;
500 filer_set_filter_directories(filer_window, filter_directories);
502 display_update_hidden(filer_window);
505 void display_set_filter(FilerWindow *filer_window, FilterType type,
506 const gchar *filter_string)
508 if (filer_set_filter(filer_window, type, filter_string))
509 display_update_hidden(filer_window);
513 /* Highlight (wink or cursor) this item in the filer window. If the item
514 * isn't already there but we're scanning then highlight it if it
515 * appears later.
517 void display_set_autoselect(FilerWindow *filer_window, const gchar *leaf)
519 gchar *new;
521 g_return_if_fail(filer_window != NULL);
522 g_return_if_fail(leaf != NULL);
524 new = g_strdup(leaf); /* leaf == old value sometimes */
526 null_g_free(&filer_window->auto_select);
528 if (view_autoselect(filer_window->view, new))
529 g_free(new);
530 else
531 filer_window->auto_select = new;
534 /* Change the icon size (wraps) */
535 void display_change_size(FilerWindow *filer_window, gboolean bigger)
537 DisplayStyle new;
539 g_return_if_fail(filer_window != NULL);
541 switch (filer_window->display_style)
543 case LARGE_ICONS:
544 new = bigger ? HUGE_ICONS : SMALL_ICONS;
545 break;
546 case HUGE_ICONS:
547 if (bigger)
548 return;
549 new = LARGE_ICONS;
550 break;
551 default:
552 if (!bigger)
553 return;
554 new = LARGE_ICONS;
555 break;
558 display_set_layout(filer_window, new, filer_window->details_type,
559 FALSE);
562 ViewData *display_create_viewdata(FilerWindow *filer_window, DirItem *item)
564 ViewData *view;
566 view = g_new(ViewData, 1);
568 view->layout = NULL;
569 view->details = NULL;
570 view->image = NULL;
572 display_update_view(filer_window, item, view, TRUE);
574 return view;
577 /* Set the display style to the desired style. If the desired style
578 * is AUTO_SIZE_ICONS, choose an appropriate size. Also resizes filer
579 * window, if requested.
581 void display_set_actual_size(FilerWindow *filer_window, gboolean force_resize)
583 display_set_layout(filer_window, filer_window->display_style_wanted,
584 filer_window->details_type, force_resize);
588 /****************************************************************
589 * INTERNAL FUNCTIONS *
590 ****************************************************************/
592 static void options_changed(void)
594 GList *next;
596 for (next = all_filer_windows; next; next = next->next)
598 FilerWindow *filer_window = (FilerWindow *) next->data;
599 int flags = 0;
601 if (o_display_dirs_first.has_changed ||
602 o_display_caps_first.has_changed)
603 view_sort(VIEW(filer_window->view));
605 if (o_display_show_headers.has_changed)
606 flags |= VIEW_UPDATE_HEADERS;
608 if (o_large_width.has_changed || o_small_width.has_changed)
609 flags |= VIEW_UPDATE_NAME; /* Recreate PangoLayout */
611 view_style_changed(filer_window->view, flags);
615 /* Return a new string giving details of this item, or NULL if details
616 * are not being displayed. If details are not yet available, return
617 * a string of the right length.
619 static char *details(FilerWindow *filer_window, DirItem *item)
621 mode_t m = item->mode;
622 guchar *buf = NULL;
623 gboolean scanned = item->base_type != TYPE_UNKNOWN;
625 if (filer_window->details_type == DETAILS_NONE)
626 return NULL;
628 if (scanned && item->lstat_errno)
629 buf = g_strdup_printf(_("lstat(2) failed: %s"),
630 g_strerror(item->lstat_errno));
631 else if (filer_window->details_type == DETAILS_TYPE)
633 MIME_type *type = item->mime_type;
635 if (!scanned)
636 return g_strdup("application/octet-stream");
638 buf = g_strdup_printf("%s/%s",
639 type->media_type, type->subtype);
641 else if (filer_window->details_type == DETAILS_TIMES)
643 guchar *ctime, *mtime, *atime;
645 ctime = pretty_time(&item->ctime);
646 mtime = pretty_time(&item->mtime);
647 atime = pretty_time(&item->atime);
649 buf = g_strdup_printf("a[%s] c[%s] m[%s]", atime, ctime, mtime);
650 g_free(ctime);
651 g_free(mtime);
652 g_free(atime);
654 else if (filer_window->details_type == DETAILS_PERMISSIONS)
656 if (!scanned)
657 return g_strdup("---,---,---/--"
658 #ifdef S_ISVTX
660 #endif
661 " 12345678 12345678");
663 buf = g_strdup_printf("%s %-8.8s %-8.8s",
664 pretty_permissions(m),
665 user_name(item->uid),
666 group_name(item->gid));
668 else
670 if (!scanned)
672 if (filer_window->display_style == SMALL_ICONS)
673 return g_strdup("1234M");
674 else
675 return g_strdup("1234 bytes");
678 if (item->base_type != TYPE_DIRECTORY)
680 if (filer_window->display_style == SMALL_ICONS)
681 buf = g_strdup(format_size_aligned(item->size));
682 else
683 buf = g_strdup(format_size(item->size));
685 else
686 buf = g_strdup("-");
689 return buf;
692 /* Note: Call style_changed after this */
693 static void display_details_set(FilerWindow *filer_window, DetailsType details)
695 filer_window->details_type = details;
698 /* Note: Call style_changed after this */
699 static void display_style_set(FilerWindow *filer_window, DisplayStyle style)
701 filer_window->display_style_wanted = style;
702 display_set_actual_size_real(filer_window);
705 /* Each displayed item has a ViewData structure with some cached information
706 * to help quickly draw the item (eg, the PangoLayout). This function updates
707 * this information.
709 void display_update_view(FilerWindow *filer_window,
710 DirItem *item,
711 ViewData *view,
712 gboolean update_name_layout)
714 DisplayStyle style = filer_window->display_style;
715 int w, h;
716 int wrap_width = -1;
717 char *str;
718 static PangoFontDescription *monospace = NULL;
719 PangoAttrList *list = NULL;
721 if (!monospace)
722 monospace = pango_font_description_from_string("monospace");
724 if (view->details)
726 g_object_unref(G_OBJECT(view->details));
727 view->details = NULL;
730 str = details(filer_window, item);
731 if (str)
733 PangoAttrList *details_list;
734 int perm_offset = -1;
736 view->details = gtk_widget_create_pango_layout(
737 filer_window->window, str);
738 g_free(str);
740 pango_layout_set_font_description(view->details, monospace);
741 pango_layout_get_size(view->details, &w, &h);
742 view->details_width = w / PANGO_SCALE;
743 view->details_height = h / PANGO_SCALE;
745 if (filer_window->details_type == DETAILS_PERMISSIONS)
746 perm_offset = 0;
747 if (perm_offset > -1)
749 PangoAttribute *attr;
751 attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
753 perm_offset += 4 * applicable(item->uid, item->gid);
754 attr->start_index = perm_offset;
755 attr->end_index = perm_offset + 3;
757 details_list = pango_attr_list_new();
758 pango_attr_list_insert(details_list, attr);
759 pango_layout_set_attributes(view->details,
760 details_list);
764 if (view->image)
766 g_object_unref(view->image);
767 view->image = NULL;
770 if (filer_window->show_thumbs && item->base_type == TYPE_FILE /*&&
771 strcmp(item->mime_type->media_type, "image") == 0*/)
773 const guchar *path;
775 path = make_path(filer_window->real_path, item->leafname);
777 view->image = g_fscache_lookup_full(pixmap_cache, path,
778 FSCACHE_LOOKUP_ONLY_NEW, NULL);
781 if (!view->image)
783 view->image = di_image(item);
784 if (view->image)
785 g_object_ref(view->image);
788 if (view->layout && update_name_layout)
790 g_object_unref(G_OBJECT(view->layout));
791 view->layout = NULL;
794 if (view->layout)
796 /* Do nothing */
798 else if (g_utf8_validate(item->leafname, -1, NULL))
800 view->layout = gtk_widget_create_pango_layout(
801 filer_window->window, item->leafname);
802 pango_layout_set_auto_dir(view->layout, FALSE);
804 else
806 PangoAttribute *attr;
807 gchar *utf8;
809 utf8 = to_utf8(item->leafname);
810 view->layout = gtk_widget_create_pango_layout(
811 filer_window->window, utf8);
812 g_free(utf8);
814 attr = pango_attr_foreground_new(0xffff, 0, 0);
815 attr->start_index = 0;
816 attr->end_index = -1;
817 if (!list)
818 list = pango_attr_list_new();
819 pango_attr_list_insert(list, attr);
822 if (item->flags & ITEM_FLAG_RECENT)
824 PangoAttribute *attr;
826 attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
827 attr->start_index = 0;
828 attr->end_index = -1;
829 if (!list)
830 list = pango_attr_list_new();
831 pango_attr_list_insert(list, attr);
834 if (list)
835 pango_layout_set_attributes(view->layout, list);
837 if (filer_window->details_type == DETAILS_NONE)
839 if (style == HUGE_ICONS)
840 wrap_width = HUGE_WRAP * PANGO_SCALE;
841 else if (style == LARGE_ICONS)
842 wrap_width = o_large_width.int_value * PANGO_SCALE;
845 #ifdef USE_PANGO_WRAP_WORD_CHAR
846 pango_layout_set_wrap(view->layout, PANGO_WRAP_WORD_CHAR);
847 #endif
848 if (wrap_width != -1)
849 pango_layout_set_width(view->layout, wrap_width);
851 pango_layout_get_size(view->layout, &w, &h);
852 view->name_width = w / PANGO_SCALE;
853 view->name_height = h / PANGO_SCALE;
856 /* Sets display_style from display_style_wanted.
857 * See also display_set_actual_size().
859 static void display_set_actual_size_real(FilerWindow *filer_window)
861 DisplayStyle size = filer_window->display_style_wanted;
862 int n;
864 g_return_if_fail(filer_window != NULL);
866 if (size == AUTO_SIZE_ICONS)
868 n = view_count_items(filer_window->view);
870 if (n >= o_filer_change_size_num.int_value)
871 size = SMALL_ICONS;
872 else
873 size = LARGE_ICONS;
876 filer_window->display_style = size;